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
GeomDet::position
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
TrackerTopology::side
unsigned int side(const DetId &id) const
Definition: TrackerTopology.cc:28
mps_fire.i
i
Definition: mps_fire.py:428
tmtt::TrackerModule::moduleMinR_
float moduleMinR_
Definition: TrackerModule.h:110
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
Bounds::width
virtual float width() const =0
tmtt::TrackerModule::tiltedBarrel
bool tiltedBarrel() const
Definition: TrackerModule.h:73
MessageLogger.h
tmtt::TrackerModule::sensorSpacing_
float sensorSpacing_
Definition: TrackerModule.h:125
TrackerGeometry.h
tmtt::TrackerModule::tiltAngle_
float tiltAngle_
Definition: TrackerModule.h:123
GeomDet
Definition: GeomDet.h:27
PixelTopology.h
tmtt::TrackerModule::ModuleTypeCfg
Definition: TrackerModule.h:29
min
T min(T a, T b)
Definition: MathUtil.h:58
TrackerTopology
Definition: TrackerTopology.h:16
PixelTopology::pitch
virtual std::pair< float, float > pitch() const =0
tmtt::TrackerModule::layerId_
unsigned int layerId_
Definition: TrackerModule.h:119
Bounds
Definition: Bounds.h:18
tmtt::TrackerModule::tiltedBarrel_
bool tiltedBarrel_
Definition: TrackerModule.h:122
TrackerTopology::layer
unsigned int layer(const DetId &id) const
Definition: TrackerTopology.cc:47
tmtt::TrackerModule::endcapRing_
unsigned int endcapRing_
Definition: TrackerModule.h:121
TrackerTopology::stack
uint32_t stack(const DetId &id) const
Definition: TrackerTopology.cc:104
tmtt::TrackerModule::moduleMaxR_
float moduleMaxR_
Definition: TrackerModule.h:111
tmtt::TrackerModule::moduleMaxZ_
float moduleMaxZ_
Definition: TrackerModule.h:115
tmtt::TrackerModule::specDet_
const PixelGeomDetUnit * specDet_
Definition: TrackerModule.h:108
TrackerGeometry::getDetectorType
ModuleType getDetectorType(DetId) const
Definition: TrackerGeometry.cc:247
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TrackerTopology::tidRing
unsigned int tidRing(const DetId &id) const
Definition: TrackerTopology.h:218
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
tmtt::TrackerModule::moduleTypeCfg_
ModuleTypeCfg moduleTypeCfg_
Definition: TrackerModule.h:131
TrackerGeometry::idToDetUnit
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: TrackerGeometry.cc:183
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
tmtt::TrackerModule::barrel
bool barrel() const
Definition: TrackerModule.h:65
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
tmtt::TrackerModule::moduleMinPhi_
float moduleMinPhi_
Definition: TrackerModule.h:112
TrackerTopology.h
tmtt::TrackerModule::calcModuleType
unsigned int calcModuleType(float pitch, float space, bool barrel, bool tiltedBarrel, bool psModule) const
Definition: TrackerModule.cc:129
tmtt::TrackerModule::calcLayerIdReduced
static unsigned int calcLayerIdReduced(unsigned int layerId)
Definition: TrackerModule.cc:104
tmtt::TrackerModule::specTopol_
const PixelTopology * specTopol_
Definition: TrackerModule.h:109
tmtt::TrackerModule::ModuleTypeCfg::tiltedVsType
std::vector< bool > tiltedVsType
Definition: TrackerModule.h:34
tmtt::TrackerModule::moduleMaxPhi_
float moduleMaxPhi_
Definition: TrackerModule.h:113
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::bounds
const Bounds & bounds() const
Definition: Surface.h:87
tmtt::TrackerModule::nStrips_
unsigned int nStrips_
Definition: TrackerModule.h:126
TrackerTopology::partnerDetId
DetId partnerDetId(const DetId &id) const
Definition: TrackerTopology.cc:233
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
TrackerModule.h
tmtt::TrackerModule::barrel_
bool barrel_
Definition: TrackerModule.h:118
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
tmtt::TrackerModule::psModule_
bool psModule_
Definition: TrackerModule.h:117
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PixelGeomDetUnit::specificTopology
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: PixelGeomDetUnit.cc:17
tmtt::TrackerModule::stripPitch_
float stripPitch_
Definition: TrackerModule.h:127
PixelGeomDetUnit.h
tmtt::TrackerModule::layerIdReduced_
unsigned int layerIdReduced_
Definition: TrackerModule.h:120
tmtt::TrackerModule::moduleMinZ_
float moduleMinZ_
Definition: TrackerModule.h:114
tmtt::TrackerModule::sensorWidth_
float sensorWidth_
Definition: TrackerModule.h:124
tmtt::TrackerModule::stackedDetId_
DetId stackedDetId_
Definition: TrackerModule.h:107
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
std
Definition: JetResolutionObject.h:76
tmtt::TrackerModule::outerModuleAtSmallerR_
bool outerModuleAtSmallerR_
Definition: TrackerModule.h:116
L1TkHTMissProducer_cfi.deltaZ
deltaZ
Definition: L1TkHTMissProducer_cfi.py:13
tmtt::TrackerModule::layerId
unsigned int layerId() const
Definition: TrackerModule.h:67
Exception
Definition: hltDiff.cc:245
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
tmtt::TrackerModule::moduleTypeID_
unsigned int moduleTypeID_
Definition: TrackerModule.h:129
tmtt::TrackerModule::ModuleTypeCfg::spaceVsType
std::vector< double > spaceVsType
Definition: TrackerModule.h:31
tmtt::TrackerModule::detId_
DetId detId_
Definition: TrackerModule.h:106
tmtt::TrackerModule::ModuleTypeCfg::psVsType
std::vector< bool > psVsType
Definition: TrackerModule.h:33
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
runonSM.text
text
Definition: runonSM.py:43
tmtt::TrackerModule::detId
const DetId & detId() const
Definition: TrackerModule.h:44
HLT_FULL_cff.R0
R0
Definition: HLT_FULL_cff.py:8652
PixelTopology::nrows
virtual int nrows() const =0
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
tmtt::TrackerModule::psModule
bool psModule() const
Definition: TrackerModule.h:64
tmtt
=== This is the base class for the linearised chi-squared track fit algorithms.
Definition: Array2D.h:16
StripSubdetector.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
tmtt::TrackerModule::ModuleTypeCfg::barrelVsType
std::vector< bool > barrelVsType
Definition: TrackerModule.h:32
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
TrackerTopology::tobSide
unsigned int tobSide(const DetId &id) const
Definition: TrackerTopology.h:180
Z0
static const double Z0
Definition: CastorGeometryData.h:32
TrackerGeometry::ModuleType::Ph2PSP
tmtt::TrackerModule::ModuleTypeCfg::pitchVsType
std::vector< double > pitchVsType
Definition: TrackerModule.h:30
tmtt::TrackerModule::stripLength_
float stripLength_
Definition: TrackerModule.h:128
TrackerGeometry
Definition: TrackerGeometry.h:14