Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:59

0001 /**\class CSCALCTDigi
0002  *
0003  * Digi for ALCT trigger primitives.
0004  *
0005  *
0006  * \author N. Terentiev, CMU
0007  */
0008 
0009 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include <iomanip>
0012 #include <iostream>
0013 
0014 using namespace std;
0015 
0016 namespace {
0017   enum Pattern_Info { NUM_LAYERS = 6, ALCT_PATTERN_WIDTH = 5 };
0018 
0019   CSCALCTDigi::WireContainer makeEmptyContainer() {
0020     CSCALCTDigi::WireContainer ret;
0021     ret.resize(NUM_LAYERS);
0022     for (auto& p : ret) {
0023       p.resize(ALCT_PATTERN_WIDTH);
0024     }
0025     return ret;
0026   }
0027 }  // namespace
0028 
0029 CSCALCTDigi::WireContainer const& CSCALCTDigi::emptyContainer() {
0030   static WireContainer const s_container = makeEmptyContainer();
0031   return s_container;
0032 }
0033 
0034 /// Constructors
0035 CSCALCTDigi::CSCALCTDigi(const uint16_t valid,
0036                          const uint16_t quality,
0037                          const uint16_t accel,
0038                          const uint16_t patternb,
0039                          const uint16_t keywire,
0040                          const uint16_t bx,
0041                          const uint16_t trknmb,
0042                          const uint16_t hmt,
0043                          const Version version)
0044     : valid_(valid),
0045       quality_(quality),
0046       accel_(accel),
0047       patternb_(patternb),
0048       keywire_(keywire),
0049       bx_(bx),
0050       trknmb_(trknmb),
0051       hmt_(hmt),
0052       version_(version) {}
0053 
0054 /// Default
0055 CSCALCTDigi::CSCALCTDigi() {
0056   clear();  // set contents to zero
0057 }
0058 
0059 /// Clears this ALCT.
0060 void CSCALCTDigi::clear() {
0061   valid_ = 0;
0062   quality_ = 0;
0063   accel_ = 0;
0064   patternb_ = 0;
0065   keywire_ = 0;
0066   bx_ = 0;
0067   trknmb_ = 0;
0068   fullbx_ = 0;
0069   hmt_ = 0;
0070   hits_.clear();
0071   version_ = Version::Legacy;
0072 }
0073 
0074 uint16_t CSCALCTDigi::getHMT() const { return (isRun3() ? hmt_ : std::numeric_limits<uint16_t>::max()); }
0075 
0076 void CSCALCTDigi::setHMT(const uint16_t h) { hmt_ = isRun3() ? h : std::numeric_limits<uint16_t>::max(); }
0077 
0078 void CSCALCTDigi::setRun3(const bool isRun3) { version_ = isRun3 ? Version::Run3 : Version::Legacy; }
0079 
0080 bool CSCALCTDigi::operator>(const CSCALCTDigi& rhs) const {
0081   bool returnValue = false;
0082 
0083   // Early ALCTs are always preferred to the ones found at later bx's.
0084   if (getBX() < rhs.getBX()) {
0085     returnValue = true;
0086   }
0087   if (getBX() != rhs.getBX()) {
0088     return returnValue;
0089   }
0090 
0091   // The > operator then checks the quality of ALCTs.
0092   // If two qualities are equal, the ALCT furthest from the beam axis
0093   // (lowest eta, highest wire group number) is selected.
0094   uint16_t quality1 = getQuality();
0095   uint16_t quality2 = rhs.getQuality();
0096   if (quality1 > quality2) {
0097     returnValue = true;
0098   } else if (quality1 == quality2 && getKeyWG() > rhs.getKeyWG()) {
0099     returnValue = true;
0100   }
0101   return returnValue;
0102 }
0103 
0104 bool CSCALCTDigi::operator==(const CSCALCTDigi& rhs) const {
0105   // Exact equality.
0106   bool returnValue = false;
0107   if (isValid() == rhs.isValid() && getQuality() == rhs.getQuality() && getAccelerator() == rhs.getAccelerator() &&
0108       getCollisionB() == rhs.getCollisionB() && getKeyWG() == rhs.getKeyWG() && getBX() == rhs.getBX()) {
0109     returnValue = true;
0110   }
0111   return returnValue;
0112 }
0113 
0114 bool CSCALCTDigi::operator!=(const CSCALCTDigi& rhs) const {
0115   // True if == is false.
0116   bool returnValue = true;
0117   if ((*this) == rhs)
0118     returnValue = false;
0119   return returnValue;
0120 }
0121 
0122 /// Debug
0123 void CSCALCTDigi::print() const {
0124   if (isValid()) {
0125     edm::LogVerbatim("CSCDigi") << "CSC ALCT #" << setw(1) << getTrknmb() << ": Valid = " << setw(1) << isValid()
0126                                 << " Quality = " << setw(2) << getQuality() << " Accel. = " << setw(1)
0127                                 << getAccelerator() << " PatternB = " << setw(1) << getCollisionB()
0128                                 << " Key wire group = " << setw(3) << getKeyWG() << " BX = " << setw(2) << getBX()
0129                                 << " Full BX = " << std::setw(1) << getFullBX();
0130   } else {
0131     edm::LogVerbatim("CSCDigi") << "Not a valid Anode LCT.";
0132   }
0133 }
0134 
0135 std::ostream& operator<<(std::ostream& o, const CSCALCTDigi& digi) {
0136   return o << "CSC ALCT #" << digi.getTrknmb() << ": Valid = " << digi.isValid() << " Quality = " << digi.getQuality()
0137            << " Accel. = " << digi.getAccelerator() << " PatternB = " << digi.getCollisionB()
0138            << " Key wire group = " << digi.getKeyWG() << " BX = " << digi.getBX();
0139 }