CMS 3D CMS Logo

TrackerModule.cc
Go to the documentation of this file.
7 
9 
10 #include <iostream>
11 #include <sstream>
12 #include <mutex>
13 
14 using namespace std;
15 
16 namespace tmtt {
17 
18  namespace {
19  std::once_flag printOnce;
20  }
21 
22  const float TrackerModule::invRoot12 = sqrt(1. / 12.);
23 
24  //=== Get info about tracker module (where detId is ID of lower sensor in stacked module).
25 
26  TrackerModule::TrackerModule(const TrackerGeometry* trackerGeometry,
27  const TrackerTopology* trackerTopology,
28  const ModuleTypeCfg& moduleTypeCfg,
29  const DetId& detId)
30  : moduleTypeCfg_(moduleTypeCfg) {
31  detId_ = detId; // Det ID of lower sensor in stacked module.
32  stackedDetId_ = trackerTopology->stack(detId); // Det ID of stacked module.
33 
34  // Get min & max (r,phi,z) coordinates of the centre of the two sensors containing this stub.
35  const GeomDetUnit* det0 = trackerGeometry->idToDetUnit(detId);
36  const GeomDetUnit* det1 = trackerGeometry->idToDetUnit(trackerTopology->partnerDetId(detId));
37  specDet_ = dynamic_cast<const PixelGeomDetUnit*>(det0);
38  specTopol_ = dynamic_cast<const PixelTopology*>(&(specDet_->specificTopology()));
39 
40  float R0 = det0->position().perp();
41  float R1 = det1->position().perp();
42  float PHI0 = det0->position().phi();
43  float PHI1 = det1->position().phi();
44  float Z0 = det0->position().z();
45  float Z1 = det1->position().z();
46  moduleMinR_ = std::min(R0, R1);
47  moduleMaxR_ = std::max(R0, R1);
48  moduleMinPhi_ = std::min(PHI0, PHI1);
49  moduleMaxPhi_ = std::max(PHI0, PHI1);
50  moduleMinZ_ = std::min(Z0, Z1);
51  moduleMaxZ_ = std::max(Z0, Z1);
52 
53  // Note if modules are flipped back-to-front.
54  outerModuleAtSmallerR_ = (det0->position().mag() > det1->position().mag());
55 
56  // Note if module is PS or 2S, and whether in barrel or endcap.
57  // From Geometry/TrackerGeometryBuilder/README.md
60 
61  // Encode layer ID (barrel layers: 1-6, endcap disks: 11-15 + 21-25)
62  if (barrel_) {
63  layerId_ = trackerTopology->layer(detId); // barrel layer 1-6 encoded as 1-6
64  } else {
65  layerId_ = 10 * trackerTopology->side(detId) + trackerTopology->tidWheel(detId);
66  }
67  // Get reduced layer ID (in range 1-7), requiring only 3 bits for firmware.
69 
70  // Note module ring in endcap
71  endcapRing_ = barrel_ ? 0 : trackerTopology->tidRing(detId);
72  if (not barrel_) {
73  // Apply bodge, since Topology class annoyingly starts ring count at 1, even in endcap wheels where
74  // inner rings are absent.
75  unsigned int iWheel = trackerTopology->tidWheel(detId);
76  if (iWheel >= 3 && iWheel <= 5)
77  endcapRing_ += 3;
78  }
79 
80  // Note if tilted barrel module & get tilt angle (in range 0 to PI).
81  tiltedBarrel_ = barrel_ && (trackerTopology->tobSide(detId) != BarrelModuleType::flat);
82  float deltaR = std::abs(R1 - R0);
83  float deltaZ = (R1 - R0 > 0) ? (Z1 - Z0) : -(Z1 - Z0);
84  tiltAngle_ = atan(deltaR / deltaZ);
85 
86  // Get sensor strip or pixel pitch using innermost sensor of pair.
87 
88  const Bounds& bounds = det0->surface().bounds();
89  sensorWidth_ = bounds.width(); // Width of sensitive region of sensor (= stripPitch * nStrips).
92  nStrips_ = specTopol_->nrows(); // No. of strips in sensor
93  std::pair<float, float> pitch = specTopol_->pitch();
94  stripPitch_ = pitch.first; // Strip pitch (or pixel pitch along shortest axis)
95  stripLength_ = pitch.second; // Strip length (or pixel pitch along longest axis)
96 
97  // Get module type ID defined by firmware.
98 
100  }
101 
102  //=== Calculate reduced layer ID (in range 1-7), for packing into 3 bits to simplify the firmware.
103 
104  unsigned int TrackerModule::calcLayerIdReduced(unsigned int layerId) {
105  // Don't bother distinguishing two endcaps, as no track can have stubs in both.
106  unsigned int lay = (layerId < 20) ? layerId : layerId - 10;
107 
108  // No genuine track can have stubs in both barrel layer 6 and endcap disk 11 etc., so merge their layer IDs.
109  if (lay == 6)
110  lay = 11;
111  if (lay == 5)
112  lay = 12;
113  if (lay == 4)
114  lay = 13;
115  if (lay == 3)
116  lay = 15;
117  // At this point, the reduced layer ID can have values of 1, 2, 11, 12, 13, 14, 15. So correct to put in range 1-7.
118  if (lay > 10)
119  lay -= 8;
120 
121  if (lay < 1 || lay > 7)
122  throw cms::Exception("LogicError") << "TrackerModule: Reduced layer ID out of expected range";
123 
124  return lay;
125  }
126 
127  //=== Get module type ID defined by firmware.
128 
130  float pitch, float space, bool barrel, bool tiltedBarrel, bool psModule) const {
131  // Calculate unique module type ID, allowing sensor pitch/seperation of module to be determined in FW.
132 
133  unsigned int moduleType = 999;
134  constexpr float tol = 0.001; // Tolerance
135 
136  for (unsigned int i = 0; i < moduleTypeCfg_.pitchVsType.size(); i++) {
137  if (std::abs(pitch - moduleTypeCfg_.pitchVsType[i]) < tol &&
140  moduleType = i;
141  }
142  }
143 
144  if (moduleType == 999) {
145  std::stringstream text;
146  text << "WARNING: TrackerModule found tracker module type unknown to firmware: pitch=" << pitch
147  << " separation=" << space << " barrel=" << barrel << " tilted=" << tiltedBarrel << " PS=" << psModule;
148  std::call_once(
149  printOnce, [](string t) { edm::LogWarning("L1track") << t; }, text.str());
150  }
151  return moduleType;
152  }
153 } // namespace tmtt
static unsigned int calcLayerIdReduced(unsigned int layerId)
T perp() const
Definition: PV3DBase.h:69
unsigned int tobSide(const DetId &id) const
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
T z() const
Definition: PV3DBase.h:61
const DetId & detId() const
Definition: TrackerModule.h:44
unsigned int nStrips_
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
unsigned int tidWheel(const DetId &id) const
virtual int nrows() const =0
unsigned int side(const DetId &id) const
unsigned int moduleTypeID_
unsigned int calcModuleType(float pitch, float space, bool barrel, bool tiltedBarrel, bool psModule) const
const PixelGeomDetUnit * specDet_
unsigned int layerId() const
Definition: TrackerModule.h:67
unsigned int layer(const DetId &id) const
std::vector< bool > tiltedVsType
Definition: TrackerModule.h:34
bool psModule() const
Definition: TrackerModule.h:64
ModuleType getDetectorType(DetId) const
T sqrt(T t)
Definition: SSEVec.h:19
T mag() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint32_t stack(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
DetId partnerDetId(const DetId &id) const
static constexpr auto TOB
unsigned int layerId_
Definition: DetId.h:17
static constexpr auto TIB
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
static const double Z0
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
std::vector< double > pitchVsType
Definition: TrackerModule.h:30
unsigned int endcapRing_
std::vector< double > spaceVsType
Definition: TrackerModule.h:31
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
bool barrel() const
Definition: TrackerModule.h:65
unsigned int tidRing(const DetId &id) const
Definition: Bounds.h:18
ModuleTypeCfg moduleTypeCfg_
virtual std::pair< float, float > pitch() const =0
const PixelTopology * specTopol_
Log< level::Warning, false > LogWarning
std::vector< bool > barrelVsType
Definition: TrackerModule.h:32
unsigned int layerIdReduced_
bool tiltedBarrel() const
Definition: TrackerModule.h:73
const Bounds & bounds() const
Definition: Surface.h:87