Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:57

0001 /**
0002  * \class ExternalCondition
0003  *
0004  *
0005  * Description: evaluation of a CondExternal condition.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  *
0011  */
0012 
0013 // this class header
0014 #include "L1Trigger/L1TGlobal/interface/ExternalCondition.h"
0015 
0016 // system include files
0017 #include <iostream>
0018 #include <iomanip>
0019 
0020 #include <string>
0021 #include <vector>
0022 #include <algorithm>
0023 
0024 // user include files
0025 //   base classes
0026 #include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h"
0027 #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
0028 #include "DataFormats/L1Trigger/interface/L1Candidate.h"
0029 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0030 
0031 #include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
0032 
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0035 
0036 // constructors
0037 //     default
0038 l1t::ExternalCondition::ExternalCondition() : ConditionEvaluation() {
0039   //empty
0040 }
0041 
0042 //     from base template condition (from event setup usually)
0043 l1t::ExternalCondition::ExternalCondition(const GlobalCondition* eSumTemplate, const GlobalBoard* ptrGTB)
0044     : ConditionEvaluation(),
0045       m_gtExternalTemplate(static_cast<const ExternalTemplate*>(eSumTemplate)),
0046       m_uGtB(ptrGTB)
0047 
0048 {
0049   // maximum number of objects received for the evaluation of the condition
0050   // energy sums are global quantities - one object per event
0051 
0052   m_condMaxNumberObjects = 1;  //blw ???
0053 }
0054 
0055 // copy constructor
0056 void l1t::ExternalCondition::copy(const l1t::ExternalCondition& cp) {
0057   m_gtExternalTemplate = cp.gtExternalTemplate();
0058   m_uGtB = cp.getuGtB();
0059 
0060   m_condMaxNumberObjects = cp.condMaxNumberObjects();
0061   m_condLastResult = cp.condLastResult();
0062   m_combinationsInCond = cp.getCombinationsInCond();
0063 
0064   m_verbosity = cp.m_verbosity;
0065 }
0066 
0067 l1t::ExternalCondition::ExternalCondition(const l1t::ExternalCondition& cp) : ConditionEvaluation() { copy(cp); }
0068 
0069 // destructor
0070 l1t::ExternalCondition::~ExternalCondition() {
0071   // empty
0072 }
0073 
0074 // equal operator
0075 l1t::ExternalCondition& l1t::ExternalCondition::operator=(const l1t::ExternalCondition& cp) {
0076   copy(cp);
0077   return *this;
0078 }
0079 
0080 // methods
0081 void l1t::ExternalCondition::setGtExternalTemplate(const ExternalTemplate* eSumTempl) {
0082   m_gtExternalTemplate = eSumTempl;
0083 }
0084 
0085 ///   set the pointer to uGT GlobalBoard
0086 void l1t::ExternalCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; }
0087 
0088 // try all object permutations and check spatial correlations, if required
0089 const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const {
0090   LogDebug("L1TGlobal") << "Evaluating External Condition " << m_gtExternalTemplate->condName() << " on Channel "
0091                         << m_gtExternalTemplate->extChannel() << " relative Bx "
0092                         << m_gtExternalTemplate->condRelativeBx() << std::endl;
0093   // number of trigger objects in the condition
0094   // in fact, there is only one object
0095   //    int iCondition = 0;
0096 
0097   // condition result condResult set to true if the energy sum
0098   // passes all requirements
0099   bool condResult = false;
0100 
0101   // store the indices of the calorimeter objects
0102   // from the combination evaluated in the condition
0103   SingleCombInCond objectsInComb;
0104 
0105   // clear the m_combinationsInCond vector
0106   (combinationsInCond()).clear();
0107 
0108   // clear the indices in the combination
0109   objectsInComb.clear();
0110 
0111   const BXVector<const GlobalExtBlk*>* candVec = m_uGtB->getCandL1External();
0112 
0113   // Look at objects in bx = bx + relativeBx
0114   int useBx = bxEval + m_gtExternalTemplate->condRelativeBx();
0115   unsigned int exCondCh = m_gtExternalTemplate->extChannel();
0116 
0117   // Fail condition if attempting to get Bx outside of range
0118   if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
0119     return false;
0120   }
0121 
0122   int numberObjects = candVec->size(useBx);
0123   if (numberObjects < 1) {
0124     return false;
0125   }
0126 
0127   //get external block (should only be one for the bx)
0128   GlobalExtBlk ext = *(candVec->at(useBx, 0));
0129   //ext.print(std::cout);
0130 
0131   // check external bit
0132   if (!ext.getExternalDecision(exCondCh)) {
0133     LogDebug("L1TGlobal") << "\t\t External Condition was not set" << std::endl;
0134     return false;
0135   }
0136 
0137   // index is always zero, as they are global quantities (there is only one object)
0138   int indexObj = 0;
0139 
0140   //Do we need this?
0141   objectsInComb.push_back(indexObj);
0142   (combinationsInCond()).push_back(objectsInComb);
0143 
0144   // if we get here all checks were successfull for this combination
0145   // set the general result for evaluateCondition to "true"
0146   condResult = true;
0147   LogDebug("L1TGlobal") << "\t\t Congrats, External Condition was set!" << std::endl;
0148 
0149   return condResult;
0150 }
0151 
0152 void l1t::ExternalCondition::print(std::ostream& myCout) const {
0153   m_gtExternalTemplate->print(myCout);
0154   ConditionEvaluation::print(myCout);
0155 }