CMS 3D CMS Logo

SiStripHitEfficiencyHelpers.h
Go to the documentation of this file.
1 #ifndef SiStripHitEfficiencyHelpers_H
2 #define SiStripHitEfficiencyHelpers_H
3 
4 // A bunch of helper functions to deal with menial tasks in the
5 // hit efficiency computation for the PCL workflow
6 
7 #include <string>
8 #include <fmt/printf.h>
12 
13 namespace {
14 
15  enum bounds {
16  k_LayersStart = 0,
17  k_LayersAtTIBEnd = 4,
18  k_LayersAtTOBEnd = 10,
19  k_LayersAtTIDEnd = 13,
20  k_LayersAtTECEnd = 22,
21  k_END_OF_LAYERS = 23
22  };
23 
24  inline unsigned int checkLayer(unsigned int iidd, const TrackerTopology* tTopo) {
25  switch (DetId(iidd).subdetId()) {
27  return tTopo->tibLayer(iidd);
29  return tTopo->tobLayer(iidd) + bounds::k_LayersAtTIBEnd;
31  return tTopo->tidWheel(iidd) + bounds::k_LayersAtTOBEnd;
33  return tTopo->tecWheel(iidd) + bounds::k_LayersAtTIDEnd;
34  default:
35  return bounds::k_LayersStart;
36  }
37  }
38 
39  inline std::string layerName(unsigned int k, const bool showRings, const unsigned int nTEClayers) {
40  const std::string ringlabel{showRings ? "R" : "D"};
41  if (k > bounds::k_LayersStart && k <= bounds::k_LayersAtTIBEnd) {
42  return fmt::format("TIB L{:d}", k);
43  } else if (k > bounds::k_LayersAtTIBEnd && k <= bounds::k_LayersAtTOBEnd) {
44  return fmt::format("TOB L{:d}", k - bounds::k_LayersAtTIBEnd);
45  } else if (k > bounds::k_LayersAtTOBEnd && k <= bounds::k_LayersAtTIDEnd) {
46  return fmt::format("TID {0}{1:d}", ringlabel, k - bounds::k_LayersAtTOBEnd);
47  } else if (k > bounds::k_LayersAtTIDEnd && k <= bounds::k_LayersAtTIDEnd + nTEClayers) {
48  return fmt::format("TEC {0}{1:d}", ringlabel, k - bounds::k_LayersAtTIDEnd);
49  } else {
50  return "";
51  }
52  }
53 
54  inline double checkConsistency(const StripClusterParameterEstimator::LocalValues& parameters,
55  double xx,
56  double xerr) {
57  double error = sqrt(parameters.second.xx() + xerr * xerr);
58  double separation = abs(parameters.first.x() - xx);
59  double consistency = separation / error;
60  return consistency;
61  }
62 
63  inline bool isDoubleSided(unsigned int iidd, const TrackerTopology* tTopo) {
64  unsigned int layer;
65  switch (DetId(iidd).subdetId()) {
67  layer = tTopo->tibLayer(iidd);
68  return (layer == 1 || layer == 2);
70  layer = tTopo->tobLayer(iidd) + 4;
71  return (layer == 5 || layer == 6);
73  layer = tTopo->tidRing(iidd) + 10;
74  return (layer == 11 || layer == 12);
76  layer = tTopo->tecRing(iidd) + 13;
77  return (layer == 14 || layer == 15 || layer == 18);
78  default:
79  return false;
80  }
81  }
82 
83  inline bool check2DPartner(unsigned int iidd, const std::vector<TrajectoryMeasurement>& traj) {
84  unsigned int partner_iidd = 0;
85  bool found2DPartner = false;
86  // first get the id of the other detector
87  if ((iidd & 0x3) == 1)
88  partner_iidd = iidd + 1;
89  if ((iidd & 0x3) == 2)
90  partner_iidd = iidd - 1;
91  // next look in the trajectory measurements for a measurement from that detector
92  // loop through trajectory measurements to find the partner_iidd
93  for (const auto& tm : traj) {
94  if (tm.recHit()->geographicalId().rawId() == partner_iidd) {
95  found2DPartner = true;
96  }
97  }
98  return found2DPartner;
99  }
100 
101  inline bool isInBondingExclusionZone(
102  unsigned int iidd, unsigned int TKlayers, double yloc, double yErr, const TrackerTopology* tTopo) {
103  constexpr float exclusionWidth = 0.4;
104  constexpr float TOBexclusion = 0.0;
105  constexpr float TECexRing5 = -0.89;
106  constexpr float TECexRing6 = -0.56;
107  constexpr float TECexRing7 = 0.60;
108 
109  //Added by Chris Edelmaier to do TEC bonding exclusion
110  const int subdetector = ((iidd >> 25) & 0x7);
111  const int ringnumber = ((iidd >> 5) & 0x7);
112 
113  bool inZone = false;
114  //New TOB and TEC bonding region exclusion zone
115  if ((TKlayers >= 5 && TKlayers < 11) || ((subdetector == 6) && ((ringnumber >= 5) && (ringnumber <= 7)))) {
116  //There are only 2 cases that we need to exclude for
117  float highzone = 0.0;
118  float lowzone = 0.0;
119  float higherr = yloc + 5.0 * yErr;
120  float lowerr = yloc - 5.0 * yErr;
121  if (TKlayers >= 5 && TKlayers < 11) {
122  //TOB zone
123  highzone = TOBexclusion + exclusionWidth;
124  lowzone = TOBexclusion - exclusionWidth;
125  } else if (ringnumber == 5) {
126  //TEC ring 5
127  highzone = TECexRing5 + exclusionWidth;
128  lowzone = TECexRing5 - exclusionWidth;
129  } else if (ringnumber == 6) {
130  //TEC ring 6
131  highzone = TECexRing6 + exclusionWidth;
132  lowzone = TECexRing6 - exclusionWidth;
133  } else if (ringnumber == 7) {
134  //TEC ring 7
135  highzone = TECexRing7 + exclusionWidth;
136  lowzone = TECexRing7 - exclusionWidth;
137  }
138  //Now that we have our exclusion region, we just have to properly identify it
139  if ((highzone <= higherr) && (highzone >= lowerr))
140  inZone = true;
141  if ((lowzone >= lowerr) && (lowzone <= higherr))
142  inZone = true;
143  if ((higherr <= highzone) && (higherr >= lowzone))
144  inZone = true;
145  if ((lowerr >= lowzone) && (lowerr <= highzone))
146  inZone = true;
147  }
148  return inZone;
149  }
150 
151  struct ClusterInfo {
152  float xResidual;
153  float xResidualPull;
154  float xLocal;
155  ClusterInfo(float xRes, float xResPull, float xLoc) : xResidual(xRes), xResidualPull(xResPull), xLocal(xLoc) {}
156  };
157 
158  inline float calcPhi(float x, float y) {
159  float phi = 0;
160  if ((x >= 0) && (y >= 0))
161  phi = std::atan(y / x);
162  else if ((x >= 0) && (y <= 0))
163  phi = std::atan(y / x) + 2 * M_PI;
164  else if ((x <= 0) && (y >= 0))
165  phi = std::atan(y / x) + M_PI;
166  else
167  phi = std::atan(y / x) + M_PI;
168  phi = phi * 180.0 / M_PI;
169 
170  return phi;
171  }
172 
173 } // namespace
174 #endif
std::pair< LocalPoint, LocalError > LocalValues
unsigned int tobLayer(const DetId &id) const
constexpr char const * layerName[numberOfLayers]
TString subdetector
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
constexpr std::array< uint8_t, layerIndexSize > layer
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI
Definition: DetId.h:17
float x
unsigned int tidRing(const DetId &id) const
unsigned int tibLayer(const DetId &id) const