Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:37

0001 /**                                                                                                             
0002  * \class MuonShowerCondition                                                                                
0003  *                                                                                                               
0004  *                                                                                                                  
0005  * Description: evaluation of High Multiplicity Triggers (HMTs) based on the presence and type of a muon shower.                             
0006  *                                                                                                                      
0007  * Implementation:                                                                                                     
0008  *    This condition class checks for the presente of a valid muon shower in the event.                                                                  
0009  *    If present, according to the condition parsed by the xml menu 
0010  *    (five possibilities for the 2023 Run 3 implementation: MuonShower0, MuonShower1, MuonShower2, MuonShowerOutOfTime0, MuonShowerOutOfTime1)
0011  *    the corresponding boolean flag is checked (isOneNominalInTime, isOneTightInTime, isTwoLooseDiffSectorsInTime, musOutOfTime0, musOutOfTime1).   
0012  *    If it is set to 1, the condition is satisfied and the object  is saved.
0013  *    Note that for the start of Run 3 only two cases were considered in the menu: Nominal and Tight muon showers,  
0014  *    an additional case is added for the 2023 data-taking: TwoLooseDiffSectors muon showers.
0015  *  
0016  * \author: S. Dildick (2021) - Rice University                                                    
0017  *         
0018  * \fixes by: E. Fontanesi, E. Yigitbasi, A. Loeliger (2023)                                                                                                
0019  * \adding TwoLooseDiffSectors HMT: E. Fontanesi                                                                                                
0020  *         
0021  */
0022 
0023 // this class header
0024 #include "L1Trigger/L1TGlobal/interface/MuonShowerCondition.h"
0025 
0026 // system include files
0027 #include <iostream>
0028 #include <iomanip>
0029 
0030 #include <string>
0031 #include <vector>
0032 #include <algorithm>
0033 
0034 // user include files
0035 //   base classes
0036 #include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h"
0037 #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
0038 #include "DataFormats/L1Trigger/interface/MuonShower.h"
0039 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0040 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0041 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0042 
0043 // constructors
0044 //     default
0045 l1t::MuonShowerCondition::MuonShowerCondition() : ConditionEvaluation() {
0046   // empty
0047 }
0048 
0049 //     from base template condition (from event setup usually)
0050 l1t::MuonShowerCondition::MuonShowerCondition(const GlobalCondition* muonShowerTemplate,
0051                                               const GlobalBoard* ptrGTL,
0052                                               const int nrL1MuShower)
0053     : ConditionEvaluation(),
0054       m_gtMuonShowerTemplate(static_cast<const MuonShowerTemplate*>(muonShowerTemplate)),
0055       m_gtGTL(ptrGTL) {
0056   m_condMaxNumberObjects = nrL1MuShower;
0057 }
0058 
0059 // copy constructor
0060 void l1t::MuonShowerCondition::copy(const l1t::MuonShowerCondition& cp) {
0061   m_gtMuonShowerTemplate = cp.gtMuonShowerTemplate();
0062   m_gtGTL = cp.gtGTL();
0063 
0064   m_condMaxNumberObjects = cp.condMaxNumberObjects();
0065   m_condLastResult = cp.condLastResult();
0066   m_combinationsInCond = cp.getCombinationsInCond();
0067 
0068   m_verbosity = cp.m_verbosity;
0069 }
0070 
0071 l1t::MuonShowerCondition::MuonShowerCondition(const l1t::MuonShowerCondition& cp) : ConditionEvaluation() { copy(cp); }
0072 
0073 // destructor
0074 l1t::MuonShowerCondition::~MuonShowerCondition() {
0075   // empty
0076 }
0077 
0078 // equal operator
0079 l1t::MuonShowerCondition& l1t::MuonShowerCondition::operator=(const l1t::MuonShowerCondition& cp) {
0080   copy(cp);
0081   return *this;
0082 }
0083 
0084 // methods
0085 void l1t::MuonShowerCondition::setGtMuonShowerTemplate(const MuonShowerTemplate* muonTempl) {
0086   m_gtMuonShowerTemplate = muonTempl;
0087 }
0088 
0089 /// Set the pointer to GTL
0090 void l1t::MuonShowerCondition::setGtGTL(const GlobalBoard* ptrGTL) { m_gtGTL = ptrGTL; }
0091 
0092 // Try all object permutations
0093 const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const {
0094   bool condResult = false;
0095 
0096   /* Number of trigger objects in the condition:
0097   // it is always 1 because at the uGT there is only one shower object per BX (that can be of several types).
0098   // See DN2020_033_v4 (sections 7.5 and 7.6) for reference
0099   */
0100   int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
0101 
0102   const BXVector<std::shared_ptr<l1t::MuonShower>>* candVec = m_gtGTL->getCandL1MuShower();
0103 
0104   // Look at objects in BX = BX + relativeBX
0105   int useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx();
0106   LogDebug("MuonShowerCondition") << "Considering BX " << useBx << std::endl;
0107 
0108   // Fail condition if attempting to get BX outside of range
0109   if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
0110     return false;
0111   }
0112 
0113   // Store the indices of the shower objects from the combination evaluated in the condition
0114   SingleCombInCond objectsInComb;
0115   objectsInComb.reserve(nObjInCond);
0116 
0117   // Clear the m_combinationsInCond vector
0118   combinationsInCond().clear();
0119   // Clear the indices in the combination
0120   objectsInComb.clear();
0121 
0122   /* If no candidates, no need to check further.
0123   // If there is a muon shower trigger, the size of the candidates vector is always 4:
0124   // in fact, we have four muon shower objects created in the Global Board.
0125   */
0126   int numberObjects = candVec->size(useBx);
0127   if (numberObjects < 1) {
0128     return false;
0129   }
0130 
0131   std::vector<int> index(numberObjects);
0132   for (int i = 0; i < numberObjects; ++i) {
0133     index[i] = i;
0134   }
0135 
0136   // index is always zero, as they are global quantities (there is only one object)
0137   int indexObj = 0;
0138 
0139   bool passCondition = false;
0140 
0141   for (int i = 0; i < numberObjects; i++) {
0142     passCondition = checkObjectParameter(0, *(candVec->at(useBx, index[i])), index[i]);  //BLW Change for BXVector
0143     condResult |= passCondition;
0144     if (passCondition) {
0145       LogDebug("MuonShowerCondition")
0146           << "===> MuShowerCondition::evaluateCondition, PASS! This muon shower passed the condition." << std::endl;
0147       objectsInComb.push_back(indexObj);
0148     } else
0149       LogDebug("MuonShowerCondition")
0150           << "===> MuShowerCondition::evaluateCondition, FAIL! This muon shower failed the condition." << std::endl;
0151   }
0152 
0153   // if we get here all checks were successfull for this combination
0154   // set the general result for evaluateCondition to "true"
0155   (combinationsInCond()).push_back(objectsInComb);
0156 
0157   return condResult;
0158 }
0159 
0160 /**
0161  * checkObjectParameter - Check if the bit associated to the type of shower is set to 1
0162  *
0163  * @param iCondition The number of the condition.
0164  * @param cand The candidate to compare.
0165  * @return The result of the check on the condition (false if a condition does not exist)
0166  */
0167 
0168 const bool l1t::MuonShowerCondition::checkObjectParameter(const int iCondition,
0169                                                           const l1t::MuonShower& cand,
0170                                                           const unsigned int index) const {
0171   // number of objects in condition
0172   int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
0173 
0174   if (iCondition >= nObjInCond || iCondition < 0) {
0175     return false;
0176   }
0177 
0178   const MuonShowerTemplate::ObjectParameter objPar = (*(m_gtMuonShowerTemplate->objectParameter()))[iCondition];
0179 
0180   LogDebug("L1TGlobal") << "\n MuonShowerTemplate::ObjectParameter (utm objects, checking which condition is parsed): "
0181                         << std::hex << "\n\t MuonShower0 = 0x " << objPar.MuonShower0 << "\n\t MuonShower1 = 0x "
0182                         << objPar.MuonShower1 << "\n\t MuonShower2 = 0x " << objPar.MuonShower2
0183                         << "\n\t MuonShowerOutOfTime0 = 0x " << objPar.MuonShowerOutOfTime0
0184                         << "\n\t MuonShowerOutOfTime1 = 0x " << objPar.MuonShowerOutOfTime1 << std::endl;
0185 
0186   LogDebug("L1TGlobal") << "\n l1t::MuonShower (uGT emulator bits): "
0187                         << "\n\t MuonShower0: isOneNominalInTime() = " << cand.isOneNominalInTime()
0188                         << "\n\t MuonShower1: isOneTightInTime() = " << cand.isOneTightInTime()
0189                         << "\n\t MuonShower2: isTwoLooseDiffSectorsInTime() = " << cand.isTwoLooseDiffSectorsInTime()
0190                         << "\n\t MuonShowerOutOfTime0: musOutOfTime0() = " << cand.musOutOfTime0()
0191                         << "\n\t MuonShowerOutOfTime1: musOutOfTime1() = " << cand.musOutOfTime1() << std::endl;
0192 
0193   // Check oneNominalInTime
0194   if (cand.isOneNominalInTime() != objPar.MuonShower0) {
0195     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower0 requirement" << std::endl;
0196     return false;
0197   }
0198   // Check oneTightInTime
0199   if (cand.isOneTightInTime() != objPar.MuonShower1) {
0200     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower1 requirement" << std::endl;
0201     return false;
0202   }
0203   // Check twoLooseInTime
0204   if (cand.isTwoLooseDiffSectorsInTime() != objPar.MuonShower2) {
0205     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower2 requirement" << std::endl;
0206     return false;
0207   }
0208   if (cand.musOutOfTime0() != objPar.MuonShowerOutOfTime0) {
0209     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime0 requirement" << std::endl;
0210     return false;
0211   }
0212   if (cand.musOutOfTime1() != objPar.MuonShowerOutOfTime1) {
0213     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime1 requirement" << std::endl;
0214     return false;
0215   }
0216 
0217   return true;
0218 }
0219 
0220 void l1t::MuonShowerCondition::print(std::ostream& myCout) const {
0221   m_gtMuonShowerTemplate->print(myCout);
0222   ConditionEvaluation::print(myCout);
0223 }