Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-11 03:56:59

0001 #ifndef CSCDigi_CSCALCTDigi_h
0002 #define CSCDigi_CSCALCTDigi_h
0003 
0004 /**\class CSCALCTDigi
0005  *
0006  * Digi for ALCT trigger primitives.
0007  *
0008  *
0009  * \author N. Terentiev, CMU
0010  */
0011 
0012 #include <cstdint>
0013 #include <iosfwd>
0014 #include <limits>
0015 #include <vector>
0016 
0017 class CSCALCTDigi {
0018 public:
0019   enum class Version { Legacy = 0, Run3 };
0020 
0021   typedef std::vector<std::vector<uint16_t>> WireContainer;
0022 
0023   /// Constructors
0024   CSCALCTDigi(const uint16_t valid,
0025               const uint16_t quality,
0026               const uint16_t accel,
0027               const uint16_t patternb,
0028               const uint16_t keywire,
0029               const uint16_t bx,
0030               const uint16_t trknmb = 0,
0031               const uint16_t hmt = 0,
0032               const Version version = Version::Legacy);
0033   /// default
0034   CSCALCTDigi();
0035 
0036   /// clear this ALCT
0037   void clear();
0038 
0039   /// check ALCT validity (1 - valid ALCT)
0040   bool isValid() const { return valid_; }
0041 
0042   /// set valid
0043   void setValid(const uint16_t valid) { valid_ = valid; }
0044 
0045   /// return quality of a pattern
0046   uint16_t getQuality() const { return quality_; }
0047 
0048   /// set quality
0049   void setQuality(const uint16_t quality) { quality_ = quality; }
0050 
0051   /// return Accelerator bit
0052   /// 1-Accelerator pattern, 0-CollisionA or CollisionB pattern
0053   uint16_t getAccelerator() const { return accel_; }
0054 
0055   /// set accelerator bit
0056   void setAccelerator(const uint16_t accelerator) { accel_ = accelerator; }
0057 
0058   /// return Collision Pattern B bit
0059   /// 1-CollisionB pattern (accel_ = 0),
0060   /// 0-CollisionA pattern (accel_ = 0)
0061   uint16_t getCollisionB() const { return patternb_; }
0062 
0063   /// set Collision Pattern B bit
0064   void setCollisionB(const uint16_t collision) { patternb_ = collision; }
0065 
0066   /// return key wire group
0067   uint16_t getKeyWG() const { return keywire_; }
0068 
0069   /// set key wire group
0070   void setKeyWG(const uint16_t keyWG) { keywire_ = keyWG; }
0071 
0072   /// return BX - five low bits of BXN counter tagged by the ALCT
0073   uint16_t getBX() const { return bx_; }
0074 
0075   /// set BX
0076   void setBX(const uint16_t BX) { bx_ = BX; }
0077 
0078   /// return track number (1,2)
0079   uint16_t getTrknmb() const { return trknmb_; }
0080 
0081   /// Set track number (1,2) after sorting ALCTs.
0082   void setTrknmb(const uint16_t number) { trknmb_ = number; }
0083 
0084   /// return 12-bit full BX.
0085   uint16_t getFullBX() const { return fullbx_; }
0086 
0087   /// Set 12-bit full BX.
0088   void setFullBX(const uint16_t fullbx) { fullbx_ = fullbx; }
0089 
0090   /// return the high multiplicity bits
0091   uint16_t getHMT() const;
0092 
0093   /// set the high multiplicity bits
0094   void setHMT(const uint16_t hmt);
0095 
0096   /// True if the first ALCT has a larger quality, or if it has the same
0097   /// quality but a larger wire group.
0098   bool operator>(const CSCALCTDigi&) const;
0099 
0100   /// True if all members (except the number) of both ALCTs are equal.
0101   bool operator==(const CSCALCTDigi&) const;
0102 
0103   /// True if the preceding one is false.
0104   bool operator!=(const CSCALCTDigi&) const;
0105 
0106   /// Print content of digi.
0107   void print() const;
0108 
0109   /// set wiregroup number
0110   void setWireGroup(uint16_t wiregroup) { keywire_ = wiregroup; }
0111 
0112   /// Distinguish Run-1/2 from Run-3
0113   bool isRun3() const { return version_ == Version::Run3; }
0114 
0115   void setRun3(const bool isRun3);
0116 
0117   // wire hits in this ALCT
0118   const WireContainer& getHits() const { return hits_.empty() ? emptyContainer() : hits_; }
0119 
0120   void setHits(const WireContainer& hits) { hits_ = hits; }
0121 
0122 private:
0123   static const WireContainer& emptyContainer();
0124   uint16_t valid_;
0125   uint16_t quality_;
0126   uint16_t accel_;
0127   uint16_t patternb_;  // not used since 2007
0128   uint16_t keywire_;
0129   uint16_t bx_;
0130   uint16_t trknmb_;
0131   uint16_t fullbx_;
0132   // In Run-3, CSC trigger data will include the high-multiplicity
0133   // bits for a chamber. These bits may indicate the observation of
0134   // "exotic" events. This data member was included in a prototype.
0135   // Later on, we developed a dedicated object: "CSCShowerDigi<Anode>"
0136   uint16_t hmt_;
0137 
0138   Version version_;
0139   // which hits are in this ALCT?
0140   WireContainer hits_;
0141 };
0142 
0143 std::ostream& operator<<(std::ostream& o, const CSCALCTDigi& digi);
0144 #endif