Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-06 22:54:48

0001 #ifndef __L1TMuon_TriggerPrimitive_h__
0002 #define __L1TMuon_TriggerPrimitive_h__
0003 //
0004 // Class: L1TMuon::TriggerPrimitive
0005 //
0006 // Info: This class implements a unifying layer between DT, CSC and RPC
0007 //       trigger primitives (TPs) such that TPs from different subsystems
0008 //       can be queried for their position and orientation information
0009 //       in a consistent way amongst all subsystems.
0010 //
0011 // Note: Not all input data types are persistable, so we make local
0012 //       copies of all data from various digi types.
0013 //
0014 //       At the end of the day this should represent the output of some
0015 //       common sector receiver module.
0016 //
0017 // Author: L. Gray (FNAL)
0018 //
0019 
0020 #include <cstdint>
0021 #include <vector>
0022 #include <iosfwd>
0023 
0024 #include "DataFormats/DetId/interface/DetId.h"
0025 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0026 #include "DataFormats/L1TMuon/interface/L1TMuonSubsystems.h"
0027 
0028 // DT digi types
0029 class DTChamberId;
0030 class L1MuDTChambPhDigi;
0031 class L1MuDTChambThDigi;
0032 
0033 // CSC digi types
0034 class CSCCorrelatedLCTDigi;
0035 class CSCDetId;
0036 
0037 // RPC digi types
0038 class RPCRecHit;
0039 class RPCDigi;
0040 class RPCDetId;
0041 
0042 // CPPF digi types
0043 namespace l1t {
0044   class CPPFDigi;
0045 }
0046 
0047 // GEM digi types
0048 class GEMPadDigiCluster;
0049 class GEMDetId;
0050 
0051 // ME0 digi types
0052 class ME0TriggerDigi;
0053 class ME0DetId;
0054 
0055 namespace L1TMuon {
0056 
0057   class TriggerPrimitive {
0058   public:
0059     // define the data we save locally from each subsystem type
0060     // variables in these structs keep their colloquial meaning
0061     // within a subsystem
0062     // for RPCs you have to unroll the digi-link and raw det-id
0063     struct RPCData {
0064       RPCData()
0065           : strip(0),
0066             strip_low(0),
0067             strip_hi(0),
0068             phi_int(0),
0069             theta_int(0),
0070             emtf_sector(0),
0071             emtf_link(0),
0072             bx(0),
0073             valid(0),
0074             x(0.),
0075             y(0.),
0076             time(0.),
0077             isCPPF(false) {}
0078       uint16_t strip;
0079       uint16_t strip_low;    // for use in clustering
0080       uint16_t strip_hi;     // for use in clustering
0081       uint16_t phi_int;      // for CPPFDigis in EMTF
0082       uint16_t theta_int;    // for CPPFDigis in EMTF
0083       uint16_t emtf_sector;  // for CPPFDigis in EMTF
0084       uint16_t emtf_link;    // for CPPFDigis in EMTF
0085       int16_t bx;
0086       int16_t valid;
0087       float x;     // local coordinate x (use floating-point for now)
0088       float y;     // local coordinate y (use floating-point for now)
0089       float time;  // time (use floating-point for now)
0090       bool isCPPF;
0091     };
0092 
0093     struct CSCData {
0094       CSCData()
0095           : trknmb(0),
0096             valid(0),
0097             quality(0),
0098             keywire(0),
0099             strip(0),
0100             pattern(0),
0101             bend(0),
0102             bx(0),
0103             mpclink(0),
0104             bx0(0),
0105             syncErr(0),
0106             cscID(0),
0107             alct_quality(0),
0108             clct_quality(0),
0109             // run-3
0110             pattern_run3(0),
0111             strip_quart_bit(0),
0112             strip_eighth_bit(0),
0113             strip_quart(0),
0114             strip_eighth(0),
0115             slope(0) {}
0116       uint16_t trknmb;
0117       uint16_t valid;
0118       uint16_t quality;
0119       uint16_t keywire;
0120       uint16_t strip;
0121       uint16_t pattern;
0122       uint16_t bend;
0123       uint16_t bx;
0124       uint16_t mpclink;
0125       uint16_t bx0;
0126       uint16_t syncErr;
0127       uint16_t cscID;
0128       uint16_t alct_quality;  // extra info for ALCT (wires)
0129       uint16_t clct_quality;  // extra info for CLCT (strips)
0130       // run-3
0131       uint16_t pattern_run3;
0132       uint16_t strip_quart_bit;
0133       uint16_t strip_eighth_bit;
0134       uint16_t strip_quart;
0135       uint16_t strip_eighth;
0136       uint16_t slope;
0137     };
0138 
0139     struct DTData {
0140       DTData()
0141           : bx(0),
0142             wheel(0),
0143             sector(0),
0144             station(0),
0145             radialAngle(0),
0146             bendingAngle(0),
0147             qualityCode(0),
0148             Ts2TagCode(0),
0149             BxCntCode(0),
0150             RpcBit(-10),
0151             theta_bti_group(0),
0152             segment_number(0),
0153             theta_code(0),
0154             theta_quality(0) {}
0155       // from ChambPhDigi (corresponds to a TRACO)
0156       // this gives us directly the phi
0157       int bx;            // relative? bx number
0158       int wheel;         // wheel number -3,-2,-1,1,2,3
0159       int sector;        // 1-12 in DT speak (these correspond to CSC sub-sectors)
0160       int station;       // 1-4 radially outwards
0161       int radialAngle;   // packed phi in a sector
0162       int bendingAngle;  // angle of segment relative to chamber
0163       int qualityCode;   // need to decode
0164       int Ts2TagCode;    // ??
0165       int BxCntCode;     // ????
0166       int RpcBit;        // 0: DT only, 1: DT segment BX corrected by RPC, 2: RPC only
0167       // from ChambThDigi (corresponds to a BTI)
0168       // we have to root out the eta manually
0169       // theta super layer == SL 1
0170       // station four has no theta super-layer
0171       // bti_idx == -1 means there was no theta trigger for this segment
0172       int theta_bti_group;
0173       int segment_number;  // position(i)
0174       int theta_code;
0175       int theta_quality;
0176     };
0177 
0178     // See documentation in DataFormats/GEMDigi/interface/GEMPadDigiCluster.h
0179     struct GEMData {
0180       GEMData() : pad(0), pad_low(0), pad_hi(0), bx(0) {}
0181       uint16_t pad;
0182       uint16_t pad_low;  // for use in clustering
0183       uint16_t pad_hi;   // for use in clustering
0184       int16_t bx;
0185     };
0186 
0187     // See documentation in DataFormats/GEMDigi/interface/ME0TriggerDigi.h
0188     struct ME0Data {
0189       ME0Data() : chamberid(0), quality(0), phiposition(0), partition(0), deltaphi(0), bend(0), bx(0) {}
0190       uint16_t chamberid;
0191       uint16_t quality;
0192       uint16_t phiposition;
0193       uint16_t partition;
0194       uint16_t deltaphi;
0195       uint16_t bend;
0196       uint16_t bx;
0197     };
0198 
0199     // Persistency
0200     TriggerPrimitive() : _id(0), _subsystem(kNSubsystems) {}
0201 
0202     // Constructors from DT data
0203     TriggerPrimitive(const DTChamberId& detid, const L1MuDTChambPhDigi& digi_phi, const int segment_number);
0204     TriggerPrimitive(const DTChamberId& detid, const L1MuDTChambThDigi& digi_th, const int theta_bti_group);
0205     TriggerPrimitive(const DTChamberId& detid,
0206                      const L1MuDTChambPhDigi& digi_phi,
0207                      const L1MuDTChambThDigi& digi_th,
0208                      const int theta_bti_group);
0209 
0210     // Constructor from CSC data
0211     TriggerPrimitive(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi);
0212 
0213     // Constructors from RPC data
0214     TriggerPrimitive(const RPCDetId& detid, const RPCDigi& digi);
0215     TriggerPrimitive(const RPCDetId& detid, const RPCRecHit& rechit);
0216 
0217     // Constructor from CPPF data
0218     TriggerPrimitive(const RPCDetId& detid, const l1t::CPPFDigi& digi);
0219 
0220     // Constructor from GEM data
0221     TriggerPrimitive(const GEMDetId& detid, const GEMPadDigiCluster& digi);
0222 
0223     // Constructor from ME0 data
0224     TriggerPrimitive(const ME0DetId& detid, const ME0TriggerDigi& digi);
0225 
0226     // Copy constructor
0227     TriggerPrimitive(const TriggerPrimitive& tp);
0228     TriggerPrimitive& operator=(const TriggerPrimitive& tp);
0229     bool operator==(const TriggerPrimitive& tp) const;
0230 
0231     // return the subsystem we belong to
0232     subsystem_type subsystem() const { return _subsystem; }
0233 
0234     void setCMSGlobalEta(double eta) { _eta = eta; }
0235     void setCMSGlobalPhi(double phi) { _phi = phi; }
0236     void setCMSGlobalRho(double rho) { _rho = rho; }
0237 
0238     double getCMSGlobalEta() const { return _eta; }
0239     double getCMSGlobalPhi() const { return _phi; }
0240     double getCMSGlobalRho() const { return _rho; }
0241 
0242     GlobalPoint getCMSGlobalPoint() const {
0243       double theta = 2. * std::atan(std::exp(-_eta));
0244       return GlobalPoint(GlobalPoint::Cylindrical(_rho, _phi, _rho / std::tan(theta)));
0245     }
0246 
0247     // this is the relative bending angle with respect to the
0248     // current phi position.
0249     // The total angle of the track is phi + bendAngle
0250     void setThetaBend(double theta) { _theta = theta; }
0251     double getThetaBend() const { return _theta; }
0252 
0253     template <typename IDType>
0254     IDType detId() const {
0255       return IDType(_id);
0256     }
0257 
0258     // accessors to raw subsystem data
0259     void setDTData(const DTData& dt) { _dt = dt; }
0260     void setCSCData(const CSCData& csc) { _csc = csc; }
0261     void setRPCData(const RPCData& rpc) { _rpc = rpc; }
0262     void setGEMData(const GEMData& gem) { _gem = gem; }
0263     void setME0Data(const ME0Data& me0) { _me0 = me0; }
0264 
0265     DTData getDTData() const { return _dt; }
0266     CSCData getCSCData() const { return _csc; }
0267     RPCData getRPCData() const { return _rpc; }
0268     GEMData getGEMData() const { return _gem; }
0269     ME0Data getME0Data() const { return _me0; }
0270 
0271     DTData& accessDTData() { return _dt; }
0272     CSCData& accessCSCData() { return _csc; }
0273     RPCData& accessRPCData() { return _rpc; }
0274     GEMData& accessGEMData() { return _gem; }
0275     ME0Data& accessME0Data() { return _me0; }
0276 
0277     // consistent accessors to common information
0278     int getBX() const;
0279     int getStrip() const;
0280     int getWire() const;
0281     int getPattern() const;
0282     DetId rawId() const { return _id; }
0283 
0284     unsigned getGlobalSector() const { return _globalsector; }
0285     unsigned getSubSector() const { return _subsector; }
0286 
0287     void print(std::ostream&) const;
0288 
0289   private:
0290     // Translate to 'global' position information at the level of 60
0291     // degree sectors. Use CSC sectors as a template
0292     template <typename IDType>
0293     void calculateGlobalSector(const IDType& chid, unsigned& globalsector, unsigned& subsector) const {
0294       // Not sure if this is ever going to get implemented
0295       globalsector = 0;
0296       subsector = 0;
0297     }
0298 
0299     DTData _dt;
0300     CSCData _csc;
0301     RPCData _rpc;
0302     GEMData _gem;
0303     ME0Data _me0;
0304 
0305     DetId _id;
0306 
0307     subsystem_type _subsystem;
0308 
0309     unsigned _globalsector;   // [1,6] in 60 degree sectors
0310     unsigned _subsector;      // [1,2] in 30 degree partitions of a sector
0311     double _eta, _phi, _rho;  // global pseudorapidity, phi, rho
0312     double _theta;            // bend angle with respect to ray from (0,0,0)
0313   };
0314 
0315 }  // namespace L1TMuon
0316 
0317 #endif