Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:49

0001 #ifndef L1Trigger_TrackFindingTMTT_TrackerModule_h
0002 #define L1Trigger_TrackFindingTMTT_TrackerModule_h
0003 
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 #include "DataFormats/Common/interface/Ref.h"
0006 #include "DataFormats/Common/interface/DetSetVector.h"
0007 #include "FWCore/Framework/interface/Frameworkfwd.h"
0008 
0009 #include <vector>
0010 #include <set>
0011 #include <array>
0012 #include <map>
0013 #include <cmath>
0014 
0015 class TrackerGeometry;
0016 class TrackerTopology;
0017 class PixelGeomDetUnit;
0018 class PixelTopology;
0019 
0020 namespace tmtt {
0021 
0022   //=== Get info about tracker module
0023 
0024   class TrackerModule {
0025   public:
0026     enum BarrelModuleType { tiltedMinusZ = 1, tiltedPlusZ = 2, flat = 3 };
0027 
0028     // Info used to define firmware module type.
0029     struct ModuleTypeCfg {
0030       std::vector<double> pitchVsType;
0031       std::vector<double> spaceVsType;
0032       std::vector<bool> barrelVsType;
0033       std::vector<bool> psVsType;
0034       std::vector<bool> tiltedVsType;
0035     };
0036 
0037     // Here detId is ID of lower sensor in stacked module.
0038     TrackerModule(const TrackerGeometry* trackerGeometry,
0039                   const TrackerTopology* trackerTopology,
0040                   const ModuleTypeCfg& moduleTypeCfg,
0041                   const DetId& detId);
0042 
0043     // Det ID of lower sensor in stacked module.
0044     const DetId& detId() const { return detId_; }
0045     unsigned int rawDetId() const { return detId_.rawId(); }
0046     // Det ID of stacked module.
0047     const DetId& stackedDetId() const { return stackedDetId_; }
0048     unsigned int rawStackedDetId() const { return stackedDetId_.rawId(); }
0049     // Tracker specific DetUnit & topology.
0050     const PixelGeomDetUnit* specDet() const { return specDet_; }
0051     const PixelTopology* specTopol() const { return specTopol_; }
0052     // Coordinates of centre of two sensors in (r,phi,z)
0053     float minR() const { return moduleMinR_; }
0054     float maxR() const { return moduleMaxR_; }
0055     float minPhi() const { return moduleMinPhi_; }
0056     float maxPhi() const { return moduleMaxPhi_; }
0057     float minZ() const { return moduleMinZ_; }
0058     float maxZ() const { return moduleMaxZ_; }
0059     // Polar angle of module.
0060     float theta() const { return atan2(moduleMinR_, moduleMinZ_); }
0061     // Which of two sensors in module is furthest from beam-line?
0062     bool outerModuleAtSmallerR() const { return outerModuleAtSmallerR_; }
0063     // Module type: PS or 2S?
0064     bool psModule() const { return psModule_; }
0065     bool barrel() const { return barrel_; }
0066     // Tracker layer ID number (1-6 = barrel layer; 11-15 = endcap A disk; 21-25 = endcap B disk)
0067     unsigned int layerId() const { return layerId_; }
0068     // Reduced layer ID (in range 1-7), for  packing into 3 bits to simplify the firmware.
0069     unsigned int layerIdReduced() const { return layerIdReduced_; }
0070     // Endcap ring of module (returns zero in case of barrel)
0071     unsigned int endcapRing() const { return endcapRing_; }
0072     // True if stub is in tilted barrel module.
0073     bool tiltedBarrel() const { return tiltedBarrel_; }
0074     // Angle between normal to module and beam-line along +ve z axis. (In range -PI/2 to +PI/2).
0075     float tiltAngle() const { return tiltAngle_; }
0076     // Width of sensitive region of sensor.
0077     float sensorWidth() const { return sensorWidth_; }
0078     // Sensor spacing in module
0079     float sensorSpacing() const { return sensorSpacing_; }
0080     // No. of strips in sensor.
0081     unsigned int nStrips() const { return nStrips_; }
0082     // Strip pitch (or pixel pitch along shortest axis).
0083     float stripPitch() const { return stripPitch_; }
0084     // Strip length (or pixel pitch along longest axis).
0085     float stripLength() const { return stripLength_; }
0086     // Hit resolution perpendicular to strip (or to longest pixel axis). Measures phi.
0087     float sigmaPerp() const { return invRoot12 * stripPitch_; }
0088     // Hit resolution parallel to strip (or to longest pixel axis). Measures r or z.
0089     float sigmaPar() const { return invRoot12 * stripLength_; }
0090     // Sensor pitch over separation.
0091     float pitchOverSep() const { return stripPitch_ / sensorSpacing_; }
0092     // "B" parameter correction for module tilt.
0093     float paramB() const { return std::abs(cos(theta() - tiltAngle()) / sin(theta())); }
0094     // Module type ID defined by firmware.
0095     unsigned int moduleTypeID() const { return moduleTypeID_; }
0096 
0097     //--- Utilties
0098 
0099     // Calculate reduced layer ID (in range 1-7), for  packing into 3 bits to simplify the firmware.
0100     static unsigned int calcLayerIdReduced(unsigned int layerId) {
0101       // Don't bother distinguishing two endcaps, as no track can have stubs in both.
0102       unsigned int lay = (layerId < 20) ? layerId : layerId - 10;
0103 
0104       // No genuine track can have stubs in both barrel layer 6 and endcap disk 11 etc., so merge their layer IDs.
0105       if (lay == 6)
0106         lay = 11;
0107       else if (lay == 5)
0108         lay = 12;
0109       else if (lay == 4)
0110         lay = 13;
0111       else if (lay == 3)
0112         lay = 15;
0113       // 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.
0114       if (lay > 10)
0115         lay -= 8;
0116 
0117       if (lay < 1 || lay > 7)
0118         throw cms::Exception("LogicError") << "TrackerModule: Reduced layer ID out of expected range";
0119 
0120       return lay;
0121     }
0122 
0123     // Get module type ID defined by firmware.
0124     unsigned int calcModuleType(float pitch, float space, bool barrel, bool tiltedBarrel, bool psModule) const;
0125 
0126   private:
0127     DetId detId_;
0128     DetId stackedDetId_;
0129     const PixelGeomDetUnit* specDet_;
0130     const PixelTopology* specTopol_;
0131     float moduleMinR_;
0132     float moduleMaxR_;
0133     float moduleMinPhi_;
0134     float moduleMaxPhi_;
0135     float moduleMinZ_;
0136     float moduleMaxZ_;
0137     bool outerModuleAtSmallerR_;
0138     bool psModule_;
0139     bool barrel_;
0140     unsigned int layerId_;
0141     unsigned int layerIdReduced_;
0142     unsigned int endcapRing_;
0143     bool tiltedBarrel_;
0144     float tiltAngle_;
0145     float sensorWidth_;
0146     float sensorSpacing_;
0147     unsigned int nStrips_;
0148     float stripPitch_;
0149     float stripLength_;
0150     unsigned int moduleTypeID_;
0151 
0152     ModuleTypeCfg moduleTypeCfg_;
0153 
0154     static const float invRoot12;
0155   };
0156 
0157 }  // namespace tmtt
0158 #endif