Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrClusterIsMatcher.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrClusterIsMatcher.cc
1 #include "TrkrClusterIsMatcher.h"
2 #include "g4evalfn.h"
3 
10 #include <trackbase/TrkrCluster.h>
11 
12 #include <phool/getClass.h>
13 #include <phool/PHObject.h> // for PHObject
14 #include <phool/phool.h> // for PHWHERE
15 #include <phool/PHCompositeNode.h>
16 #include <phool/PHNode.h> // for PHNode
17 #include <phool/PHNodeIterator.h>
19 
21  PHCompositeNode* topNode,
22  const std::string& name_phg4_clusters,
23  const std::string& name_reco_clusters)
24 {
25  // ------ MVTX data ------
26  PHG4CylinderGeomContainer* geom_container_mvtx
27  = findNode::getClass<PHG4CylinderGeomContainer>(topNode, "CYLINDERGEOM_MVTX");
28  if (!geom_container_mvtx) {
29  std::cout << PHWHERE << " Could not locate CYLINDERGEOM_MVTX " << std::endl;
31  }
32  for (int i=0; i<3; ++i) {
33  auto layergeom = dynamic_cast<CylinderGeom_Mvtx *>
34  (geom_container_mvtx->GetLayerGeom(i));
35  pitch_phi[i] = layergeom->get_pixel_x();
36  if (i == 0) pitch_z_MVTX = layergeom->get_pixel_z();
37  }
38 
39  // ------ INTT data ------
40  PHG4CylinderGeomContainer* geom_container_intt
41  = findNode::getClass<PHG4CylinderGeomContainer>(topNode, "CYLINDERGEOM_INTT");
42  if (!geom_container_intt) {
43  std::cout << PHWHERE << " Could not locate CYLINDERGEOM_INTT " << std::endl;
45  }
46  // get phi and Z steps for intt
47  for (int i=3; i<7; ++i) {
48  CylinderGeomIntt* geom =
49  dynamic_cast<CylinderGeomIntt*>(geom_container_intt->GetLayerGeom(i));
50  pitch_phi[i] = geom->get_strip_y_spacing();
51  }
52 
53  // ------ TPC data ------
54  auto geom_tpc =
55  findNode::getClass<PHG4TpcCylinderGeomContainer>(topNode, "CYLINDERCELLGEOM_SVTX");
56  if (!geom_tpc)
57  {
58  std::cout << PHWHERE << " Could not locate CYLINDERCELLGEOM_SVTX node " << std::endl;
60  }
61  for (int i=7; i<55; ++i) {
62  PHG4TpcCylinderGeom *layergeom = geom_tpc->GetLayerCellGeom(i);
63  if (i==7) step_t_TPC = layergeom->get_zstep();
64  pitch_phi[i] = layergeom->get_phistep() * layergeom->get_radius();
65  }
66 
68  findNode::getClass<TrkrClusterContainer>(topNode, name_phg4_clusters.c_str());
69  if (!m_TruthClusters)
70  {
71  std::cout << PHWHERE << " Could not locate " << name_phg4_clusters << " node" << std::endl;
73  }
74 
76  findNode::getClass<TrkrClusterContainer>(topNode, name_reco_clusters.c_str());
77  if (!m_TruthClusters)
78  {
79  std::cout << PHWHERE << " Could not locate " << name_reco_clusters << " node" << std::endl;
81  }
82 
83  m_ActsGeometry = findNode::getClass<ActsGeometry>(topNode, "ActsGeometry");
84  if (!m_ActsGeometry)
85  {
86  std::cout << PHWHERE << " Could not locate ActsGeometry node" << std::endl;
88  }
89 
92 
94 
97 
99 }
100 
102  tol_phi_MVTX = _val;
103  for (int i=0; i<3; ++i) {
105  }
106 }
107 
109  tol_z_MVTX = _val;
111 }
112 
113 
115  tol_phi_INTT = _val;
116  for (int i=3; i<7; ++i) {
118  }
119 }
120 
122  tol_phi_TPC = _val;
123  for (int i=7; i<55; ++i) {
125  }
126 }
127 
129  tol_t_TPC = _val;
131 }
132 
133  bool TrkrClusterIsMatcher::operator()
135 {
136  // note: can use returned values, or just pull from these values
137  layer = TrkrDefs::getLayer(key_T);
138  if (layer > 55) {
139  std::cout << " Error! Trying to compar cluster in layer > 55, "
140  << "which is not programmed yet!" << std::endl;
141  return false;
142  }
143 
144  clus_T = m_TruthClusters ->findCluster(key_T);
145  clus_R = m_RecoClusters ->findCluster(key_R);
146 
147  det_0123 = g4evalfn::trklayer_det(layer);
148  dphi = g4evalfn::abs_dphi(clus_T->getPosition(0),clus_R->getPosition(0));
149  switch (det_0123) {
150  case g4evalfn::DET::MVTX : {
151  if (single_pixel_phi_MVTX) {
152  if (dphi > tol_pitch_phi[layer]) return false;
153  } else {
154  if (dphi > tol_pitch_phi[layer]*std::max(clus_T->getPhiSize(),clus_R->getPhiSize())) return false;
155  }
156  const float delta_z = fabs(clus_T->getPosition(1)-clus_R->getPosition(1));
157  if (single_pixel_z_MVTX) {
158  if (delta_z > tol_pitch_z_MVTX) return false;
159  } else {
160  if (delta_z > tol_pitch_z_MVTX*std::max(clus_T->getZSize(), clus_R->getZSize())) return false;
161  }
162  return true;
163  } break;
164 
165  case g4evalfn::DET::INTT: {
166  if (single_pixel_phi_INTT) {
167  if (dphi > tol_pitch_phi[layer]) return false;
168  } else {
169  if (dphi > tol_pitch_phi[layer] * std::max(clus_T->getPhiSize(), clus_R->getPhiSize())) return false;
170  }
171  return true;
172  } break;
173 
174  case g4evalfn::DET::TPC: {
175  if (single_bin_phi_TPC) {
176  if (dphi > tol_pitch_phi[layer]) return false;
177  } else {
178  if (dphi > tol_pitch_phi[layer] * std::max(clus_T->getPhiSize(), clus_R->getPhiSize())) return false;
179  }
180  const float delta_t = fabs(clus_T->getPosition(1)-clus_R->getPosition(1));
181  if (single_bin_t_TPC) {
182  if (delta_t > tol_step_t_TPC) return false;
183  } else {
184  if (delta_t > tol_step_t_TPC * std::max(clus_T->getZSize(), clus_R->getZSize())) return false;
185  }
186  return true;
187  } break;
188 
189  case g4evalfn::DET::TPOT: { // TPOT
190  return false; // no info for matching TPOT at this time
191  } break;
192  }
193  return false; // code shouldn't arrive here; just for completeness for compiler
194 }
195