Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-29 02:32:25

0001 #ifndef DataFormats_CSCDigi_CSCCorrelatedLCTDigi_h
0002 #define DataFormats_CSCDigi_CSCCorrelatedLCTDigi_h
0003 
0004 /**\class CSCCorrelatedLCTDigi
0005  *
0006  * Digi for Correlated LCT trigger primitives.
0007  *
0008  *
0009  * \author L. Gray, UF
0010  */
0011 
0012 #include <cstdint>
0013 #include <iosfwd>
0014 #include <limits>
0015 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
0016 #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
0017 #include "DataFormats/GEMDigi/interface/GEMPadDigi.h"
0018 
0019 class CSCCorrelatedLCTDigi {
0020 public:
0021   enum class Version { Legacy = 0, Run3 };
0022   // for data vs emulator studies
0023   enum LCTBXMask { kBXDataMask = 0x1 };
0024 
0025   /// SIMULATION ONLY ////
0026   enum Type {
0027     CLCTALCT,      // CLCT-centric
0028     ALCTCLCT,      // ALCT-centric
0029     ALCTCLCTGEM,   // ALCT-CLCT-1 GEM pad
0030     ALCTCLCT2GEM,  // ALCT-CLCT-2 GEM pads in coincidence
0031     ALCT2GEM,      // ALCT-2 GEM pads in coincidence
0032     CLCT2GEM,      // CLCT-2 GEM pads in coincidence
0033     CLCTONLY,      // Missing ALCT
0034     ALCTONLY       // Missing CLCT
0035   };
0036 
0037   /// Constructors
0038   CSCCorrelatedLCTDigi(const uint16_t trknmb,
0039                        const uint16_t valid,
0040                        const uint16_t quality,
0041                        const uint16_t keywire,
0042                        const uint16_t strip,
0043                        const uint16_t pattern,
0044                        const uint16_t bend,
0045                        const uint16_t bx,
0046                        const uint16_t mpclink = 0,
0047                        const uint16_t bx0 = 0,
0048                        const uint16_t syncErr = 0,
0049                        const uint16_t cscID = 0,
0050                        const Version version = Version::Legacy,
0051                        const bool run3_quart_strip_bit = false,
0052                        const bool run3_eighth_strip_bit = false,
0053                        const uint16_t run3_pattern = 0,
0054                        const uint16_t run3_slope = 0,
0055                        const int type = ALCTCLCT);
0056 
0057   /// default (calls clear())
0058   CSCCorrelatedLCTDigi();
0059 
0060   /// clear this LCT
0061   void clear();
0062 
0063   /// return track number
0064   uint16_t getTrknmb() const { return trknmb; }
0065 
0066   /// return valid pattern bit
0067   bool isValid() const { return valid; }
0068 
0069   /// return the Quality
0070   uint16_t getQuality() const { return quality; }
0071 
0072   /// return the key wire group. counts from 0.
0073   uint16_t getKeyWG() const { return keywire; }
0074 
0075   /// return the key halfstrip from 0,159
0076   uint16_t getStrip(uint16_t n = 2) const;
0077 
0078   /// set single quart strip bit
0079   void setQuartStripBit(const bool quartStripBit) { run3_quart_strip_bit_ = quartStripBit; }
0080 
0081   /// get single quart strip bit
0082   bool getQuartStripBit() const { return run3_quart_strip_bit_; }
0083 
0084   /// set single eighth strip bit
0085   void setEighthStripBit(const bool eighthStripBit) { run3_eighth_strip_bit_ = eighthStripBit; }
0086 
0087   /// get single eighth strip bit
0088   bool getEighthStripBit() const { return run3_eighth_strip_bit_; }
0089 
0090   /*
0091     Strips are numbered starting from 1 in CMSSW
0092     Half-strips, quarter-strips and eighth-strips are numbered starting from 0
0093     The table below shows the correct numbering
0094     ---------------------------------------------------------------------------------
0095     strip     |               1               |                 2                   |
0096     ---------------------------------------------------------------------------------
0097     1/2-strip |       0       |       1       |       2         |         3         |
0098     ---------------------------------------------------------------------------------
0099     1/4-strip |   0   |   1   |   2   |   3   |   4   |    5    |    6    |    7    |
0100     ---------------------------------------------------------------------------------
0101     1/8-strip | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
0102     ---------------------------------------------------------------------------------
0103 
0104     Note: the CSC geometry also has a strip offset of +/- 0.25 strips. When comparing the
0105     CLCT/LCT position with the true muon position, take the offset into account!
0106    */
0107   float getFractionalStrip(uint16_t n = 2) const;
0108 
0109   /// return the Run-2 pattern ID
0110   uint16_t getPattern() const { return pattern; }
0111 
0112   /// return the Run-3 pattern ID
0113   uint16_t getRun3Pattern() const { return run3_pattern_; }
0114 
0115   /// return the slope
0116   uint16_t getSlope() const { return run3_slope_; }
0117 
0118   /// slope in number of half-strips/layer
0119   /// negative means left-bending
0120   /// positive means right-bending
0121   float getFractionalSlope() const;
0122 
0123   /// return left/right bending
0124   /// 0: left-bending (negative delta-strip / delta layer)
0125   /// 1: right-bending (positive delta-strip / delta layer)
0126   uint16_t getBend() const { return bend; }
0127 
0128   /// return BX
0129   uint16_t getBX() const { return bx; }
0130 
0131   /// return 1-bit BX as in data
0132   uint16_t getBXData() const { return bx & kBXDataMask; }
0133 
0134   /// return CLCT pattern number (in use again Feb 2011)
0135   /// This function should not be used for Run-3
0136   uint16_t getCLCTPattern() const;
0137 
0138   /// return strip type (obsolete since mid-2008)
0139   uint16_t getStripType() const { return ((pattern & 0x8) >> 3); }
0140 
0141   /// return MPC link number, 0 means not sorted, 1-3 give MPC sorting rank
0142   uint16_t getMPCLink() const { return mpclink; }
0143 
0144   uint16_t getCSCID() const { return cscID; }
0145   uint16_t getBX0() const { return bx0; }
0146   uint16_t getSyncErr() const { return syncErr; }
0147 
0148   /// Run-3 introduces high-multiplicity bits for CSCs.
0149   /// The allocation is different for ME1/1 and non-ME1/1
0150   /// chambers. Both LCTs in a chamber are needed for the complete
0151   /// high-multiplicity trigger information
0152   uint16_t getHMT() const;
0153 
0154   /// Set track number (1,2) after sorting LCTs.
0155   void setTrknmb(const uint16_t number) { trknmb = number; }
0156 
0157   /// Set mpc link number after MPC sorting
0158   void setMPCLink(const uint16_t& link) { mpclink = link; }
0159 
0160   /// Print content of correlated LCT digi
0161   void print() const;
0162 
0163   ///Comparison
0164   bool operator==(const CSCCorrelatedLCTDigi&) const;
0165   bool operator!=(const CSCCorrelatedLCTDigi& rhs) const { return !(this->operator==(rhs)); }
0166 
0167   /// set wiregroup number
0168   void setWireGroup(const uint16_t wiregroup) { keywire = wiregroup; }
0169 
0170   /// set quality code
0171   void setQuality(const uint16_t q) { quality = q; }
0172 
0173   /// set valid
0174   void setValid(const uint16_t v) { valid = v; }
0175 
0176   /// set strip
0177   void setStrip(const uint16_t s) { strip = s; }
0178 
0179   /// set pattern
0180   void setPattern(const uint16_t p) { pattern = p; }
0181 
0182   /// set Run-3 pattern
0183   void setRun3Pattern(const uint16_t pattern) { run3_pattern_ = pattern; }
0184 
0185   /// set the slope
0186   void setSlope(const uint16_t slope) { run3_slope_ = slope; }
0187 
0188   /// set bend
0189   void setBend(const uint16_t b) { bend = b; }
0190 
0191   /// set bx
0192   void setBX(const uint16_t b) { bx = b; }
0193 
0194   /// set bx0
0195   void setBX0(const uint16_t b) { bx0 = b; }
0196 
0197   /// set syncErr
0198   void setSyncErr(const uint16_t s) { syncErr = s; }
0199 
0200   /// set cscID
0201   void setCSCID(const uint16_t c) { cscID = c; }
0202 
0203   /// set high-multiplicity bits
0204   void setHMT(const uint16_t h);
0205 
0206   /// Distinguish Run-1/2 from Run-3
0207   bool isRun3() const { return version_ == Version::Run3; }
0208 
0209   void setRun3(const bool isRun3);
0210 
0211   int getType() const { return type_; }
0212 
0213   void setType(int type) { type_ = type; }
0214 
0215   void setALCT(const CSCALCTDigi& alct) { alct_ = alct; }
0216   void setCLCT(const CSCCLCTDigi& clct) { clct_ = clct; }
0217   void setGEM1(const GEMPadDigi& gem) { gem1_ = gem; }
0218   void setGEM2(const GEMPadDigi& gem) { gem2_ = gem; }
0219   const CSCALCTDigi& getALCT() const { return alct_; }
0220   const CSCCLCTDigi& getCLCT() const { return clct_; }
0221   const GEMPadDigi& getGEM1() const { return gem1_; }
0222   const GEMPadDigi& getGEM2() const { return gem2_; }
0223 
0224 private:
0225   // Note: The Run-3 data format is substantially different than the
0226   // Run-1/2 data format. Some explanation is provided below. For
0227   // more information, please check "DN-20-016".
0228 
0229   // Run-1, Run-2 and Run-3 trknmb is either 1 or 2.
0230   uint16_t trknmb;
0231   // In Run-3, the valid will be encoded as a quality
0232   // value "000" or "00".
0233   uint16_t valid;
0234   // In Run-3, the LCT quality number will be 2 or 3 bits
0235   // For ME1/1 chambers: 3 bits
0236   // For non-ME1/1 chambers: 2 bits
0237   uint16_t quality;
0238   // 7-bit key wire
0239   uint16_t keywire;
0240   // actually the 8-bit half-strip number
0241   uint16_t strip;
0242   // Run-1/2 pattern number.
0243   // For Run-3 CLCTs, please use run3_pattern_. For some backward
0244   // compatibility the trigger emulator translates run3_pattern_
0245   // approximately into pattern_ with a lookup table
0246   uint16_t pattern;
0247   // Common definition for left/right bending in Run-1, Run-2 and Run-3.
0248   // 0: right; 1: left
0249   uint16_t bend;
0250   uint16_t bx;
0251   uint16_t mpclink;
0252   uint16_t bx0;
0253   // The synchronization bit is actually not used by MPC or EMTF
0254   uint16_t syncErr;
0255   // 4-bit CSC chamber identifier
0256   uint16_t cscID;
0257 
0258   // new members in Run-3:
0259 
0260   // In Run-3, CSC trigger data will include the high-multiplicity
0261   // bits for a chamber. These bits may indicate the observation of
0262   // "exotic" events. This data member was included in a prototype.
0263   // Later on, we developed a dedicated object: "CSCShowerDigi"
0264   uint16_t hmt;
0265   // 1/4-strip bit set by CCLUT (see DN-19-059)
0266   bool run3_quart_strip_bit_;
0267   // 1/8-strip bit set by CCLUT
0268   bool run3_eighth_strip_bit_;
0269   // In Run-3, the CLCT digi has 3-bit pattern ID, 0 through 4
0270   uint16_t run3_pattern_;
0271   // 4-bit bending value. There will be 16 bending values * 2 (left/right)
0272   uint16_t run3_slope_;
0273 
0274   /// SIMULATION ONLY ////
0275   int type_;
0276 
0277   CSCALCTDigi alct_;
0278   CSCCLCTDigi clct_;
0279   GEMPadDigi gem1_;
0280   GEMPadDigi gem2_;
0281 
0282   Version version_;
0283 };
0284 
0285 std::ostream& operator<<(std::ostream& o, const CSCCorrelatedLCTDigi& digi);
0286 
0287 #endif