Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:39

0001 #include "L1Trigger/TrackerDTC/interface/SensorModule.h"
0002 #include "L1Trigger/TrackerDTC/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 trackerDTC {
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 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     sin_ = 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     cos_ = 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     // getting bend window size
0095     double windowSize(-1.);
0096     if (barrel_) {
0097       enum TypeBarrel { nonBarrel = 0, tiltedMinus = 1, tiltedPlus = 2, flat = 3 };
0098       const TypeBarrel type = static_cast<TypeBarrel>(trackerTopology->tobSide(detId));
0099       if (type == flat)
0100         windowSize = setup.windowSizeBarrelLayer(layerId_);
0101       else {
0102         int ladder = trackerTopology->tobRod(detId);
0103         if (type == tiltedMinus)
0104           // Corrected ring number, bet 0 and barrelNTilt.at(layer), in ascending |z|
0105           ladder = 1 + setup.numTiltedLayerRing(layerId_) - ladder;
0106         windowSize = setup.windowSizeTiltedLayerRing(layerId_, ladder);
0107       }
0108     } else {
0109       const int ring = trackerTopology->tidRing(detId);
0110       const int lay = layer + setup.offsetLayerId();
0111       windowSize = setup.windowSizeEndcapDisksRing(lay, ring);
0112     }
0113     windowSize_ = windowSize / setup.baseWindowSize();
0114     // getting encoded layer id
0115     const vector<int>& encodingLayerId = setup.encodingLayerId(dtcId_);
0116     const auto pos = find(encodingLayerId.begin(), encodingLayerId.end(), layerId_);
0117     encodedLayerId_ = distance(encodingLayerId.begin(), pos);
0118   }
0119 
0120 }  // namespace trackerDTC