Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
g4evalfn.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file g4evalfn.cc
2 
3 #include "g4evalfn.h"
4 #include "TrkrClusLoc.h"
5 #include "TrkrClusterIsMatcher.h"
8 
9 #include <algorithm>
10 #include <set>
11 
12 
13 namespace g4evalfn {
14 
15  int trklayer_det(int layer) {
16  if (layer < 3) return DET::MVTX;
17  if (layer < 7) return DET::INTT;
18  if (layer < 55) return DET::TPC;
19  return DET::TPOT;
20  }
21 
23  return trklayer_det(TrkrDefs::getLayer(key));
24  }
25 
27  return trklayer_det(TrkrDefs::getLayer(key));
28  }
29 
30 
31  std::vector<int> unmatchedSvtxTrkIds(EmbRecoMatchContainer* matches, SvtxTrackMap* m_SvtxTrackMap) {
32  std::set<unsigned int> ids_matched{};
33  for (auto trkid : matches->ids_RecoMatched()) {
34  ids_matched.insert(trkid);
35  }
36 
37  std::set<int> ids_unmatched;
38  for (auto reco = m_SvtxTrackMap->begin(); reco != m_SvtxTrackMap->end(); ++reco) {
39  auto trkid = reco->first;
40  if (ids_matched.count(trkid)==0) ids_unmatched.insert(trkid);
41  }
42  std::vector<int> ids_vec;
43  for (auto id : ids_unmatched) ids_vec.push_back((int)id);
44  std::sort(ids_vec.begin(), ids_vec.end());
45  return ids_vec;
46  }
47 
49  {
50  auto cluster = ismatcher->m_TruthClusters->findCluster(key);
51  Eigen::Vector3d gloc = ismatcher->m_ActsGeometry->getGlobalPosition(key, cluster);
52  return {TrkrDefs::getLayer(key), gloc,
53  cluster->getPosition(0), cluster->getPhiSize(), cluster->getPosition(1), cluster->getZSize(), key};
54  }
55 
57  {
58  auto cluster = ismatcher->m_RecoClusters->findCluster(key);
59  Eigen::Vector3d gloc = ismatcher->m_ActsGeometry->getGlobalPosition(key, cluster);
60  return {TrkrDefs::getLayer(key), gloc,
61  cluster->getPosition(0), cluster->getPhiSize(), cluster->getPosition(1), cluster->getZSize(), key};
62  }
63 
65  int layer = TrkrDefs::getLayer(key_A);
66  auto det_0123 = trklayer_det(layer);
67  auto clus_T = ismatcher->m_TruthClusters ->findCluster(key_A);
68  auto clus_R = ismatcher->m_RecoClusters ->findCluster(key_B);
69  auto dphi = abs_dphi(clus_T->getPosition(0),clus_R->getPosition(0));
70 
71  float stat = 0.;
72  switch (det_0123) {
73  case 0: { // MVTX
74  if (ismatcher->single_pixel_phi_MVTX) {
75  stat += dphi / ismatcher->tol_pitch_phi[layer];
76  } else {
77  stat += dphi / (ismatcher->tol_pitch_phi[layer] *std::max(clus_T->getPhiSize(),clus_R->getPhiSize()));
78  }
79  const float delta_z = fabs(clus_T->getPosition(1)-clus_R->getPosition(1));
80  if (ismatcher->single_pixel_z_MVTX) {
81  stat += delta_z / ismatcher->tol_pitch_z_MVTX;
82  } else {
83  stat += delta_z / (ismatcher->tol_pitch_z_MVTX * std::max(clus_T->getZSize(), clus_R->getZSize()));
84  }
85  } break;
86  case 1: {
87  if (ismatcher->single_pixel_phi_INTT) {
88  stat += dphi / ismatcher->tol_pitch_phi[layer];
89  } else {
90  stat += dphi / (ismatcher->tol_pitch_phi[layer] * std::max(clus_T->getPhiSize(), clus_R->getPhiSize()));
91  }
92  } break;
93  case 2: { // TPC
94  if (ismatcher->single_bin_phi_TPC) {
95  stat += dphi / ismatcher->tol_pitch_phi[layer];
96  } else {
97  stat += dphi / (ismatcher->tol_pitch_phi[layer] * std::max(clus_T->getPhiSize(), clus_R->getPhiSize()));
98  }
99  const float delta_t = fabs(clus_T->getPosition(1)-clus_R->getPosition(1));
100  if (ismatcher->single_bin_t_TPC) {
101  stat += delta_t / ismatcher->tol_step_t_TPC;
102  } else {
103  stat += delta_t / (ismatcher->tol_step_t_TPC * std::max(clus_T->getZSize(), clus_R->getZSize()));
104  }
105  } break;
106  case 3: // TPOT
107  break;
108  default:
109  break;
110  }
111  return stat;
112  }
113 
114 
115 }