Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-09 00:01:10

0001 // this class header
0002 #include "L1Trigger/L1TGlobal/interface/MuonShowerCondition.h"
0003 
0004 // system include files
0005 #include <iostream>
0006 #include <iomanip>
0007 
0008 #include <string>
0009 #include <vector>
0010 #include <algorithm>
0011 
0012 // user include files
0013 //   base classes
0014 #include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h"
0015 #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
0016 
0017 #include "DataFormats/L1Trigger/interface/MuonShower.h"
0018 
0019 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0020 
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0023 
0024 // constructors
0025 //     default
0026 l1t::MuonShowerCondition::MuonShowerCondition() : ConditionEvaluation() {
0027   // empty
0028 }
0029 
0030 //     from base template condition (from event setup usually)
0031 l1t::MuonShowerCondition::MuonShowerCondition(const GlobalCondition* muonShowerTemplate,
0032                                               const GlobalBoard* ptrGTL,
0033                                               const int nrL1MuShower)
0034     : ConditionEvaluation(),
0035       m_gtMuonShowerTemplate(static_cast<const MuonShowerTemplate*>(muonShowerTemplate)),
0036       m_gtGTL(ptrGTL) {
0037   m_condMaxNumberObjects = nrL1MuShower;
0038 }
0039 
0040 // copy constructor
0041 void l1t::MuonShowerCondition::copy(const l1t::MuonShowerCondition& cp) {
0042   m_gtMuonShowerTemplate = cp.gtMuonShowerTemplate();
0043   m_gtGTL = cp.gtGTL();
0044 
0045   m_condMaxNumberObjects = cp.condMaxNumberObjects();
0046   m_condLastResult = cp.condLastResult();
0047   m_combinationsInCond = cp.getCombinationsInCond();
0048 
0049   m_verbosity = cp.m_verbosity;
0050 }
0051 
0052 l1t::MuonShowerCondition::MuonShowerCondition(const l1t::MuonShowerCondition& cp) : ConditionEvaluation() { copy(cp); }
0053 
0054 // destructor
0055 l1t::MuonShowerCondition::~MuonShowerCondition() {
0056   // empty
0057 }
0058 
0059 // equal operator
0060 l1t::MuonShowerCondition& l1t::MuonShowerCondition::operator=(const l1t::MuonShowerCondition& cp) {
0061   copy(cp);
0062   return *this;
0063 }
0064 
0065 // methods
0066 void l1t::MuonShowerCondition::setGtMuonShowerTemplate(const MuonShowerTemplate* muonTempl) {
0067   m_gtMuonShowerTemplate = muonTempl;
0068 }
0069 
0070 ///   set the pointer to GTL
0071 void l1t::MuonShowerCondition::setGtGTL(const GlobalBoard* ptrGTL) { m_gtGTL = ptrGTL; }
0072 
0073 // try all object permutations and check spatial correlations, if required
0074 const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const {
0075   // number of trigger objects in the condition
0076   int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
0077 
0078   // the candidates
0079   const BXVector<const l1t::MuonShower*>* candVec = m_gtGTL->getCandL1MuShower();
0080 
0081   // Look at objects in bx = bx + relativeBx
0082   int useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx();
0083 
0084   // Fail condition if attempting to get Bx outside of range
0085   if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
0086     return false;
0087   }
0088 
0089   // store the indices of the shower objects
0090   // from the combination evaluated in the condition
0091   SingleCombInCond objectsInComb;
0092   objectsInComb.reserve(nObjInCond);
0093 
0094   // clear the m_combinationsInCond vector
0095   (combinationsInCond()).clear();
0096 
0097   // clear the indices in the combination
0098   objectsInComb.clear();
0099 
0100   // If no candidates, no use looking any further.
0101   int numberObjects = candVec->size(useBx);
0102   if (numberObjects < 1) {
0103     return false;
0104   }
0105 
0106   std::vector<int> index(numberObjects);
0107 
0108   for (int i = 0; i < numberObjects; ++i) {
0109     index[i] = i;
0110   }
0111 
0112   bool condResult = false;
0113 
0114   // index is always zero, as they are global quantities (there is only one object)
0115   int indexObj = 0;
0116 
0117   objectsInComb.push_back(indexObj);
0118   (combinationsInCond()).push_back(objectsInComb);
0119 
0120   // if we get here all checks were successfull for this combination
0121   // set the general result for evaluateCondition to "true"
0122 
0123   condResult = true;
0124   return condResult;
0125 }
0126 
0127 // load muon candidates
0128 const l1t::MuonShower* l1t::MuonShowerCondition::getCandidate(const int bx, const int indexCand) const {
0129   return (m_gtGTL->getCandL1MuShower())->at(bx, indexCand);  //BLW Change for BXVector
0130 }
0131 
0132 /**
0133  * checkObjectParameter - Compare a single particle with a numbered condition.
0134  *
0135  * @param iCondition The number of the condition.
0136  * @param cand The candidate to compare.
0137  *
0138  * @return The result of the comparison (false if a condition does not exist).
0139  */
0140 
0141 const bool l1t::MuonShowerCondition::checkObjectParameter(const int iCondition,
0142                                                           const l1t::MuonShower& cand,
0143                                                           const unsigned int index) const {
0144   // number of objects in condition
0145   int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
0146 
0147   if (iCondition >= nObjInCond || iCondition < 0) {
0148     return false;
0149   }
0150 
0151   const MuonShowerTemplate::ObjectParameter objPar = (*(m_gtMuonShowerTemplate->objectParameter()))[iCondition];
0152 
0153   LogDebug("L1TGlobal") << "\n MuonShowerTemplate::ObjectParameter : " << std::hex << "\n\t MuonShower0 = 0x "
0154                         << objPar.MuonShower0 << "\n\t MuonShower1 = 0x " << objPar.MuonShower1
0155                         << "\n\t MuonShowerOutOfTime0 = 0x " << objPar.MuonShowerOutOfTime0
0156                         << "\n\t MuonShowerOutOfTime1 = 0x " << objPar.MuonShowerOutOfTime1 << std::endl;
0157 
0158   LogDebug("L1TGlobal") << "\n l1t::MuonShower : "
0159                         << "\n\t MuonShower0 = 0x " << cand.mus0() << "\n\t MuonShower1 = 0x " << cand.mus1()
0160                         << "\n\t MuonShowerOutOfTime0 = 0x " << cand.musOutOfTime0()
0161                         << "\n\t MuonShowerOutOfTime1 = 0x " << cand.musOutOfTime1() << std::dec << std::endl;
0162 
0163   // check oneNominalInTime
0164   if (cand.mus0() != objPar.MuonShower0) {
0165     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower0 requirement" << std::endl;
0166     return false;
0167   }
0168   if (cand.mus1() != objPar.MuonShower1) {
0169     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower1 requirement" << std::endl;
0170     return false;
0171   }
0172   if (cand.musOutOfTime0() != objPar.MuonShowerOutOfTime0) {
0173     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime0 requirement" << std::endl;
0174     return false;
0175   }
0176   if (cand.musOutOfTime1() != objPar.MuonShowerOutOfTime1) {
0177     LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime1 requirement" << std::endl;
0178     return false;
0179   }
0180 
0181   return true;
0182 }
0183 
0184 void l1t::MuonShowerCondition::print(std::ostream& myCout) const {
0185   m_gtMuonShowerTemplate->print(myCout);
0186 
0187   ConditionEvaluation::print(myCout);
0188 }