Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:50

0001 /**
0002  * \class L1GlobalTriggerRecord
0003  * 
0004  * 
0005  * Description: stripped-down record for L1 Global Trigger.  
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *   
0010  * \author: Vasile Mihai Ghete   - HEPHY Vienna
0011  * 
0012  *
0013  */
0014 
0015 // this class header
0016 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerRecord.h"
0017 
0018 // system include files
0019 #include <iomanip>
0020 
0021 // user include files
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 
0024 // constructors
0025 L1GlobalTriggerRecord::L1GlobalTriggerRecord() {
0026   // empty
0027 }
0028 
0029 L1GlobalTriggerRecord::L1GlobalTriggerRecord(const unsigned int numberPhysTriggers,
0030                                              const unsigned int numberTechnicalTriggers) {
0031   m_gtDecisionWord.reserve(numberPhysTriggers);
0032   m_gtTechnicalTriggerWord.reserve(numberTechnicalTriggers);
0033 
0034   m_gtDecisionWordBeforeMask.reserve(numberPhysTriggers);
0035   m_gtTechnicalTriggerWordBeforeMask.reserve(numberTechnicalTriggers);
0036 }
0037 
0038 // copy constructor
0039 L1GlobalTriggerRecord::L1GlobalTriggerRecord(const L1GlobalTriggerRecord& result) {
0040   m_gtGlobalDecision = result.m_gtGlobalDecision;
0041 
0042   m_gtDecisionWord = result.m_gtDecisionWord;
0043   m_gtTechnicalTriggerWord = result.m_gtTechnicalTriggerWord;
0044 
0045   m_gtDecisionWordBeforeMask = result.m_gtDecisionWordBeforeMask;
0046   m_gtTechnicalTriggerWordBeforeMask = result.m_gtTechnicalTriggerWordBeforeMask;
0047 
0048   m_gtPrescaleFactorIndexTech = result.m_gtPrescaleFactorIndexTech;
0049   m_gtPrescaleFactorIndexAlgo = result.m_gtPrescaleFactorIndexAlgo;
0050 }
0051 
0052 // destructor
0053 L1GlobalTriggerRecord::~L1GlobalTriggerRecord() {
0054   // empty now
0055 }
0056 
0057 // assignment operator
0058 L1GlobalTriggerRecord& L1GlobalTriggerRecord::operator=(const L1GlobalTriggerRecord& result) {
0059   if (this != &result) {
0060     m_gtGlobalDecision = result.m_gtGlobalDecision;
0061 
0062     m_gtDecisionWord = result.m_gtDecisionWord;
0063     m_gtTechnicalTriggerWord = result.m_gtTechnicalTriggerWord;
0064 
0065     m_gtDecisionWordBeforeMask = result.m_gtDecisionWordBeforeMask;
0066     m_gtTechnicalTriggerWordBeforeMask = result.m_gtTechnicalTriggerWordBeforeMask;
0067 
0068     m_gtPrescaleFactorIndexTech = result.m_gtPrescaleFactorIndexTech;
0069     m_gtPrescaleFactorIndexAlgo = result.m_gtPrescaleFactorIndexAlgo;
0070   }
0071 
0072   return *this;
0073 }
0074 
0075 // equal operator
0076 bool L1GlobalTriggerRecord::operator==(const L1GlobalTriggerRecord& result) const {
0077   if (m_gtGlobalDecision != result.m_gtGlobalDecision) {
0078     return false;
0079   }
0080 
0081   if (m_gtDecisionWord != result.m_gtDecisionWord) {
0082     return false;
0083   }
0084 
0085   if (m_gtTechnicalTriggerWord != result.m_gtTechnicalTriggerWord) {
0086     return false;
0087   }
0088 
0089   if (m_gtDecisionWordBeforeMask != result.m_gtDecisionWordBeforeMask) {
0090     return false;
0091   }
0092 
0093   if (m_gtTechnicalTriggerWordBeforeMask != result.m_gtTechnicalTriggerWordBeforeMask) {
0094     return false;
0095   }
0096 
0097   if (m_gtPrescaleFactorIndexTech != result.m_gtPrescaleFactorIndexTech) {
0098     return false;
0099   }
0100 
0101   if (m_gtPrescaleFactorIndexAlgo != result.m_gtPrescaleFactorIndexAlgo) {
0102     return false;
0103   }
0104 
0105   // all members identical
0106   return true;
0107 }
0108 
0109 // unequal operator
0110 bool L1GlobalTriggerRecord::operator!=(const L1GlobalTriggerRecord& result) const { return !(result == *this); }
0111 // methods
0112 
0113 // set global decision
0114 void L1GlobalTriggerRecord::setDecision(const bool& dValue) { m_gtGlobalDecision = dValue; }
0115 
0116 // set decision word
0117 void L1GlobalTriggerRecord::setDecisionWord(const DecisionWord& dWordValue) { m_gtDecisionWord = dWordValue; }
0118 
0119 void L1GlobalTriggerRecord::setTechnicalTriggerWord(const TechnicalTriggerWord& ttWordValue) {
0120   m_gtTechnicalTriggerWord = ttWordValue;
0121 }
0122 
0123 // set decision word before applying the masks
0124 void L1GlobalTriggerRecord::setDecisionWordBeforeMask(const DecisionWord& dWordValue) {
0125   m_gtDecisionWordBeforeMask = dWordValue;
0126 }
0127 
0128 void L1GlobalTriggerRecord::setTechnicalTriggerWordBeforeMask(const TechnicalTriggerWord& ttWordValue) {
0129   m_gtTechnicalTriggerWordBeforeMask = ttWordValue;
0130 }
0131 
0132 // print global decision and algorithm decision word
0133 void L1GlobalTriggerRecord::printGtDecision(std::ostream& myCout) const {
0134   myCout << std::endl;
0135   myCout << "\n  Global decision (FinalOR): " << m_gtGlobalDecision << std::endl;
0136 
0137   // decision word (in 64bits words)
0138   int sizeW64 = 64;  // 64 bits words
0139 
0140   int iBit = 0;
0141   int jBit = m_gtDecisionWord.size();
0142   int nrDecWord = m_gtDecisionWord.size() / sizeW64;
0143 
0144   std::ostringstream stream64;
0145 
0146   std::vector<std::string> decWord;
0147   decWord.reserve(nrDecWord);
0148 
0149   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWord.rbegin(); ritBit != m_gtDecisionWord.rend();
0150        ++ritBit) {
0151     stream64 << (*ritBit ? '1' : '0');
0152 
0153     if ((((iBit + 1) % 16) == (sizeW64 % 16))) {
0154       stream64 << " ";
0155     }
0156 
0157     if (((iBit + 1) % sizeW64) == 0) {
0158       std::string iW = stream64.str();
0159       stream64.str("");
0160 
0161       decWord.push_back(iW);
0162     }
0163 
0164     iBit++;
0165     jBit--;
0166   }
0167 
0168   int iWord = 0;
0169 
0170   myCout << "\n  DecisionWord after trigger mask (bitset style)";
0171   for (std::vector<std::string>::reverse_iterator ritWord = decWord.rbegin(); ritWord != decWord.rend(); ++ritWord) {
0172     myCout << "\n  Bits " << iWord * sizeW64 + sizeW64 - 1 << " : " << iWord * sizeW64 << "\n  ";
0173     myCout << *ritWord;
0174 
0175     iWord++;
0176   }
0177 }
0178 
0179 // print technical trigger word (reverse order for vector<bool>)
0180 void L1GlobalTriggerRecord::printTechnicalTrigger(std::ostream& myCout) const {
0181   myCout << "\n  Technical triggers after trigger mask  (bitset style):    \n  ";
0182 
0183   int sizeW64 = 64;  // 64 bits words
0184   int iBit = 0;
0185 
0186   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtTechnicalTriggerWord.rbegin();
0187        ritBit != m_gtTechnicalTriggerWord.rend();
0188        ++ritBit) {
0189     myCout << (*ritBit ? '1' : '0');
0190 
0191     if ((((iBit + 1) % 16) == (sizeW64 % 16)) && (iBit != 63)) {
0192       myCout << " ";
0193     }
0194 
0195     iBit++;
0196   }
0197 }
0198 
0199 // clear the record
0200 void L1GlobalTriggerRecord::reset() {
0201   m_gtGlobalDecision = false;
0202 
0203   for (std::vector<bool>::iterator itBit = m_gtDecisionWord.begin(); itBit != m_gtDecisionWord.end(); ++itBit) {
0204     *itBit = false;
0205   }
0206   for (std::vector<bool>::iterator itBit = m_gtTechnicalTriggerWord.begin(); itBit != m_gtTechnicalTriggerWord.end();
0207        ++itBit) {
0208     *itBit = false;
0209   }
0210   for (std::vector<bool>::iterator itBit = m_gtDecisionWordBeforeMask.begin();
0211        itBit != m_gtDecisionWordBeforeMask.end();
0212        ++itBit) {
0213     *itBit = false;
0214   }
0215 
0216   for (std::vector<bool>::iterator itBit = m_gtTechnicalTriggerWordBeforeMask.begin();
0217        itBit != m_gtTechnicalTriggerWordBeforeMask.end();
0218        ++itBit) {
0219     *itBit = false;
0220   }
0221 
0222   m_gtPrescaleFactorIndexTech = 0;
0223   m_gtPrescaleFactorIndexAlgo = 0;
0224 }
0225 
0226 // pretty print the content of a L1GlobalTriggerRecord
0227 void L1GlobalTriggerRecord::print(std::ostream& myCout) const {
0228   printGtDecision(myCout);
0229 
0230   myCout << std::endl;
0231 
0232   printTechnicalTrigger(myCout);
0233 
0234   myCout << std::endl;
0235   myCout << "\n  Index of prescale factor set for technical triggers: " << m_gtPrescaleFactorIndexTech << std::endl;
0236   myCout << "  Index of prescale factor set for algorithm triggers: " << m_gtPrescaleFactorIndexTech << std::endl;
0237   myCout << std::endl;
0238 }
0239 
0240 // output stream operator
0241 std::ostream& operator<<(std::ostream& streamRec, const L1GlobalTriggerRecord& result) {
0242   result.print(streamRec);
0243   return streamRec;
0244 }