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  //=== Get module type ID defined by firmware.
103 
105  float pitch, float space, bool barrel, bool tiltedBarrel, bool psModule) const {
106  // Calculate unique module type ID, allowing sensor pitch/seperation of module to be determined in FW.
107 
108  unsigned int moduleType = 999;
109  constexpr float tol = 0.001; // Tolerance
110 
111  for (unsigned int i = 0; i < moduleTypeCfg_.pitchVsType.size(); i++) {
112  if (std::abs(pitch - moduleTypeCfg_.pitchVsType[i]) < tol &&
115  moduleType = i;
116  }
117  }
118 
119  if (moduleType == 999) {
120  std::stringstream text;
121  text << "WARNING: TrackerModule found tracker module type unknown to firmware: pitch=" << pitch
122  << " separation=" << space << " barrel=" << barrel << " tilted=" << tiltedBarrel << " PS=" << psModule;
123  std::call_once(
124  printOnce, [](string t) { edm::LogWarning("L1track") << t; }, text.str());
125  }
126  return moduleType;
127  }
128 } // namespace tmtt
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 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:23
T mag() const
Definition: PV3DBase.h:64
static unsigned int calcLayerIdReduced(unsigned int layerId)
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