File indexing completed on 2024-09-07 04:37:07
0001 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0002 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0003 #include "Geometry/CommonTopologies/interface/PixelGeomDetUnit.h"
0004 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0005 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008 #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h"
0009
0010 #include <iostream>
0011 #include <sstream>
0012 #include <mutex>
0013
0014 using namespace std;
0015
0016 namespace tmtt {
0017
0018 namespace {
0019 std::once_flag printOnce;
0020 }
0021
0022 const float TrackerModule::invRoot12 = sqrt(1. / 12.);
0023
0024
0025
0026 TrackerModule::TrackerModule(const TrackerGeometry* trackerGeometry,
0027 const TrackerTopology* trackerTopology,
0028 const ModuleTypeCfg& moduleTypeCfg,
0029 const DetId& detId)
0030 : moduleTypeCfg_(moduleTypeCfg) {
0031 detId_ = detId;
0032 stackedDetId_ = trackerTopology->stack(detId);
0033
0034
0035 const GeomDetUnit* det0 = trackerGeometry->idToDetUnit(detId);
0036 const GeomDetUnit* det1 = trackerGeometry->idToDetUnit(trackerTopology->partnerDetId(detId));
0037 specDet_ = dynamic_cast<const PixelGeomDetUnit*>(det0);
0038 specTopol_ = dynamic_cast<const PixelTopology*>(&(specDet_->specificTopology()));
0039
0040 float R0 = det0->position().perp();
0041 float R1 = det1->position().perp();
0042 float PHI0 = det0->position().phi();
0043 float PHI1 = det1->position().phi();
0044 float Z0 = det0->position().z();
0045 float Z1 = det1->position().z();
0046 moduleMinR_ = std::min(R0, R1);
0047 moduleMaxR_ = std::max(R0, R1);
0048 moduleMinPhi_ = std::min(PHI0, PHI1);
0049 moduleMaxPhi_ = std::max(PHI0, PHI1);
0050 moduleMinZ_ = std::min(Z0, Z1);
0051 moduleMaxZ_ = std::max(Z0, Z1);
0052
0053
0054 outerModuleAtSmallerR_ = (det0->position().mag() > det1->position().mag());
0055
0056
0057
0058 psModule_ = (trackerGeometry->getDetectorType(detId) == TrackerGeometry::ModuleType::Ph2PSP);
0059 barrel_ = detId.subdetId() == StripSubdetector::TOB || detId.subdetId() == StripSubdetector::TIB;
0060
0061
0062 if (barrel_) {
0063 layerId_ = trackerTopology->layer(detId);
0064 } else {
0065 layerId_ = 10 * trackerTopology->side(detId) + trackerTopology->tidWheel(detId);
0066 }
0067
0068 layerIdReduced_ = TrackerModule::calcLayerIdReduced(layerId_);
0069
0070
0071 endcapRing_ = barrel_ ? 0 : trackerTopology->tidRing(detId);
0072 if (not barrel_) {
0073
0074
0075 unsigned int iWheel = trackerTopology->tidWheel(detId);
0076 if (iWheel >= 3 && iWheel <= 5)
0077 endcapRing_ += 3;
0078 }
0079
0080
0081 tiltedBarrel_ = barrel_ && (trackerTopology->tobSide(detId) != BarrelModuleType::flat);
0082 float deltaR = std::abs(R1 - R0);
0083 float deltaZ = (R1 - R0 > 0) ? (Z1 - Z0) : -(Z1 - Z0);
0084 tiltAngle_ = atan(deltaR / deltaZ);
0085
0086
0087
0088 const Bounds& bounds = det0->surface().bounds();
0089 sensorWidth_ = bounds.width();
0090 sensorSpacing_ = sqrt((moduleMaxR_ - moduleMinR_) * (moduleMaxR_ - moduleMinR_) +
0091 (moduleMaxZ_ - moduleMinZ_) * (moduleMaxZ_ - moduleMinZ_));
0092 nStrips_ = specTopol_->nrows();
0093 std::pair<float, float> pitch = specTopol_->pitch();
0094 stripPitch_ = pitch.first;
0095 stripLength_ = pitch.second;
0096
0097
0098
0099 moduleTypeID_ = TrackerModule::calcModuleType(stripPitch_, sensorSpacing_, barrel_, tiltedBarrel_, psModule_);
0100 }
0101
0102
0103
0104 unsigned int TrackerModule::calcModuleType(
0105 float pitch, float space, bool barrel, bool tiltedBarrel, bool psModule) const {
0106
0107
0108 unsigned int moduleType = 999;
0109 constexpr float tol = 0.001;
0110
0111 for (unsigned int i = 0; i < moduleTypeCfg_.pitchVsType.size(); i++) {
0112 if (std::abs(pitch - moduleTypeCfg_.pitchVsType[i]) < tol &&
0113 std::abs(space - moduleTypeCfg_.spaceVsType[i]) < tol && barrel == moduleTypeCfg_.barrelVsType[i] &&
0114 tiltedBarrel == moduleTypeCfg_.tiltedVsType[i] && psModule == moduleTypeCfg_.psVsType[i]) {
0115 moduleType = i;
0116 }
0117 }
0118
0119 if (moduleType == 999) {
0120 std::stringstream text;
0121 text << "WARNING: TrackerModule found tracker module type unknown to firmware: pitch=" << pitch
0122 << " separation=" << space << " barrel=" << barrel << " tilted=" << tiltedBarrel << " PS=" << psModule;
0123 std::call_once(printOnce, [](string t) { edm::LogWarning("L1track") << t; }, text.str());
0124 }
0125 return moduleType;
0126 }
0127 }