EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHTpcTrackerUtil.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHTpcTrackerUtil.cc
1 
7 #include "PHTpcTrackerUtil.h"
8 
10 #include <trackbase/TrkrClusterContainer.h> // for TrkrClusterContainer
12 #include <trackbase/TrkrHitSet.h>
13 #include <trackbase/TrkrDefs.h>
14 
15 #include <phool/PHLog.h>
16 
17 #include <cstdint> // for uint64_t
18 #include <cstring>
19 #include <map> // for _Rb_tree_const_iterator
20 #include <utility> // for pair
21 
22 namespace PHTpcTrackerUtil
23 {
24  std::vector<std::vector<double> > convert_clusters_to_hits(TrkrClusterContainer* cluster_map, TrkrHitSetContainer* hitsets )
25  {
26  //***** convert clusters to kdhits
27  std::vector<std::vector<double> > kdhits;
28  if (!cluster_map)
29  {
30  LOG_WARN("tracking.PHTpcTrackerUtil.convert_clusters_to_hits") << "cluster map is not provided";
31  return kdhits;
32  }
33  auto hitsetrange = hitsets->getHitSets(TrkrDefs::TrkrId::tpcId);
34  for (auto hitsetitr = hitsetrange.first;
35  hitsetitr != hitsetrange.second;
36  ++hitsetitr){
37  std::string separator = "";
38  auto range = cluster_map->getClusters(hitsetitr->first);
39  for( auto it = range.first; it != range.second; ++it )
40  {
41  // TrkrDefs::cluskey cluskey = it->first;
42  TrkrCluster* cluster = it->second;
43  if ((std::pow((double) cluster->getPosition(0), 2) +
44  std::pow((double) cluster->getPosition(1), 2) +
45  std::pow((double) cluster->getPosition(2), 2)) > (25.0 * 25.0))
46  {
47  std::vector<double> kdhit(4);
48  kdhit[0] = cluster->getPosition(0);
49  kdhit[1] = cluster->getPosition(1);
50  kdhit[2] = cluster->getPosition(2);
51  uint64_t key = cluster->getClusKey();
52  std::memcpy(&kdhit[3], &key, sizeof(key));
53 
54  // HINT: way to get original uint64_t value from double:
55  //
56  // LOG_DEBUG("tracking.PHTpcTrackerUtil.convert_clusters_to_hits")
57  // << "orig: " << cluster->getClusKey() << ", readback: " << (*((int64_t*)&kdhit[3]));
58 
59  kdhits.push_back(kdhit);
60  }
61  }
62  }
63  return kdhits;
64  }
65 
66 } // namespace PHTpcTrackerUtil