CMS 3D CMS Logo

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