Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:10

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