Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-03 00:12:28

0001 #include "L1Trigger/TrackTrigger/interface/SensorModule.h"
0002 #include "L1Trigger/TrackTrigger/interface/Setup.h"
0003 #include "DataFormats/GeometrySurface/interface/Plane.h"
0004 
0005 #include <cmath>
0006 #include <algorithm>
0007 #include <iterator>
0008 #include <vector>
0009 
0010 namespace tt {
0011 
0012   SensorModule::SensorModule(const Setup* setup, const DetId& detId, int dtcId, int modId)
0013       : detId_(detId), dtcId_(dtcId), modId_(modId) {
0014     const TrackerGeometry* trackerGeometry = setup->trackerGeometry();
0015     const TrackerTopology* trackerTopology = setup->trackerTopology();
0016     const GeomDetUnit* geomDetUnit = trackerGeometry->idToDetUnit(detId);
0017     const PixelTopology* pixelTopology =
0018         dynamic_cast<const PixelTopology*>(&(dynamic_cast<const PixelGeomDetUnit*>(geomDetUnit)->specificTopology()));
0019     const Plane& plane = dynamic_cast<const PixelGeomDetUnit*>(geomDetUnit)->surface();
0020     const GlobalPoint pos0 = GlobalPoint(geomDetUnit->position());
0021     const GlobalPoint pos1 =
0022         GlobalPoint(trackerGeometry->idToDetUnit(trackerTopology->partnerDetId(detId))->position());
0023     // detector region [0-8]
0024     const int region = dtcId_ / setup->numDTCsPerRegion();
0025     // module radius in cm
0026     r_ = pos0.perp();
0027     // module phi w.r.t. detector region_ centre in rad
0028     phi_ = deltaPhi(pos0.phi() - (region + .5) * setup->baseRegion());
0029     // module z in cm
0030     z_ = pos0.z();
0031     // sensor separation in cm
0032     sep_ = (pos1 - pos0).mag();
0033     // sensor pitch in cm [strip=.009,pixel=.01]
0034     pitchRow_ = pixelTopology->pitch().first;
0035     // sensor length in cm [strip=5,pixel=.15625]
0036     pitchCol_ = pixelTopology->pitch().second;
0037     // number of columns [2S=2,PS=8]
0038     numColumns_ = pixelTopology->ncolumns();
0039     // number of rows [2S=8*127,PS=8*120]
0040     numRows_ = pixelTopology->nrows();
0041     // +z or -z
0042     side_ = pos0.z() >= 0.;
0043     // main sensor inside or outside
0044     flipped_ = pos0.mag() > pos1.mag();
0045     // barrel or endcap
0046     barrel_ = detId.subdetId() == StripSubdetector::TOB;
0047     // Pixel-Strip or 2Strip module
0048     psModule_ = trackerGeometry->getDetectorType(detId) == TrackerGeometry::ModuleType::Ph2PSP;
0049     // module tilt angle measured w.r.t. beam axis (0=barrel), tk layout measures w.r.t. radial axis
0050     tilt_ = flipped_ ? std::atan2(pos1.z() - pos0.z(), pos0.perp() - pos1.perp())
0051                      : std::atan2(pos0.z() - pos1.z(), pos1.perp() - pos0.perp());
0052     // sinus of module tilt measured w.r.t. beam axis (0=barrel), tk layout measures w.r.t. radial axis
0053     sinTilt_ = std::sin(tilt_);
0054     // cosinus of module tilt measured w.r.t. beam axis (+-1=endcap), tk layout measures w.r.t. radial axis
0055     cosTilt_ = std::cos(tilt_);
0056     // layer id [barrel: 0-5, endcap: 0-4]
0057     const int layer =
0058         (barrel_ ? trackerTopology->layer(detId) : trackerTopology->tidWheel(detId)) - setup->offsetLayerId();
0059     // layer id [1-6,11-15]
0060     layerId_ = layer + setup->offsetLayerId() + (barrel_ ? 0 : setup->offsetLayerDisks());
0061     // TTStub row needs flip of sign
0062     signRow_ = std::signbit(deltaPhi(plane.rotation().x().phi() - pos0.phi()));
0063     // TTStub col needs flip of sign
0064     signCol_ = !barrel_ && !side_;
0065     // TTStub bend needs flip of sign
0066     signBend_ = barrel_ || (!barrel_ && side_);
0067     // determing sensor type
0068     if (barrel_ && psModule_)
0069       type_ = BarrelPS;
0070     if (barrel_ && !psModule_)
0071       type_ = Barrel2S;
0072     if (!barrel_ && psModule_)
0073       type_ = DiskPS;
0074     if (!barrel_ && !psModule_)
0075       type_ = Disk2S;
0076     // encoding for 2S endcap radii
0077     encodedR_ = -1;
0078     if (type_ == Disk2S) {
0079       const int offset = setup->hybridNumRingsPS(layer);
0080       const int ring = trackerTopology->tidRing(detId);
0081       encodedR_ = numColumns_ * (ring - offset);
0082     }
0083     // r and z offsets
0084     if (barrel_) {
0085       offsetR_ = setup->hybridLayerR(layer);
0086       offsetZ_ = 0.;
0087     } else {
0088       offsetR_ = 0.;
0089       offsetZ_ = side_ ? setup->hybridDiskZ(layer) : -setup->hybridDiskZ(layer);
0090     }
0091     const TypeTilt typeTilt = static_cast<TypeTilt>(trackerTopology->tobSide(detId));
0092     // getting bend window size
0093     double windowSize(-1.);
0094     if (barrel_) {
0095       if (typeTilt == flat)
0096         windowSize = setup->windowSizeBarrelLayer(layerId_);
0097       else {
0098         int ladder = trackerTopology->tobRod(detId);
0099         if (typeTilt == tiltedMinus)
0100           // Corrected ring number, bet 0 and barrelNTilt.at(layer), in ascending |z|
0101           ladder = 1 + setup->numTiltedLayerRing(layerId_) - ladder;
0102         windowSize = setup->windowSizeTiltedLayerRing(layerId_, ladder);
0103       }
0104     } else {
0105       const int ring = trackerTopology->tidRing(detId);
0106       const int lay = layer + setup->offsetLayerId();
0107       windowSize = setup->windowSizeEndcapDisksRing(lay, ring);
0108     }
0109     windowSize_ = windowSize / setup->baseWindowSize();
0110     // calculate tilt correction parameter used to project r to z uncertainty
0111     tiltCorrectionSlope_ = barrel_ ? 0. : 1.;
0112     tiltCorrectionIntercept_ = barrel_ ? 1. : 0.;
0113     tilted_ = false;
0114     if (typeTilt == tiltedMinus || typeTilt == tiltedPlus) {
0115       tilted_ = true;
0116       tiltCorrectionSlope_ = setup->tiltApproxSlope();
0117       tiltCorrectionIntercept_ = setup->tiltApproxIntercept();
0118     }
0119     // stub uncertainty
0120     scattering_ = setup->scattering();
0121     dR_ = std::abs(sinTilt_) * pitchCol_;
0122     dPhi_ = pitchRow_ / r_;
0123     dZ_ = std::abs(cosTilt_) * pitchCol_ + dR_ * std::abs(z_) / r_;
0124   }
0125 
0126   unsigned int SensorModule::ringId(const Setup* setup) const {
0127     // In barrel PS: Tilted module ring no. (Increasing 1 to 12 as |z| increases)
0128     // In barrel 2S: 0
0129     // In disk: Endcap module ring number (1-15) in endcap disks
0130 
0131     // See  https://github.com/cms-sw/cmssw/tree/master/Geometry/TrackerNumberingBuilder
0132     const TrackerTopology* trackerTopology = setup->trackerTopology();
0133     enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
0134     const TypeBarrel type = static_cast<TypeBarrel>(trackerTopology->tobSide(detId_));
0135     bool tiltedBarrel = barrel_ && (type == tiltedMinus || type == tiltedPlus);
0136     unsigned int ringId = 0;
0137     // Tilted module ring no. (Increasing 1 to 12 as |z| increases).
0138     if (tiltedBarrel) {
0139       ringId = trackerTopology->tobRod(detId_);
0140       if (type == tiltedMinus) {
0141         unsigned int layp1 = trackerTopology->layer(detId_);
0142         unsigned int nTilted = setup->numTiltedLayerRing(layp1);
0143         ringId = 1 + nTilted - ringId;
0144       }
0145     } else {
0146       ringId = barrel_ ? 0 : trackerTopology->tidRing(detId_);
0147     }
0148     return ringId;
0149   }
0150 
0151 }  // namespace tt