Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1GtJetCountsCondition
0003  *
0004  *
0005  * Description: evaluation of a CondJetCounts condition.
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 "L1Trigger/GlobalTrigger/interface/L1GtJetCountsCondition.h"
0017 
0018 // system include files
0019 #include <iomanip>
0020 #include <iostream>
0021 
0022 #include <vector>
0023 
0024 // user include files
0025 //   base classes
0026 #include "L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h"
0027 
0028 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
0029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0030 
0031 #include "CondFormats/L1TObjects/interface/L1GtJetCountsTemplate.h"
0032 
0033 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
0034 
0035 // constructors
0036 //     default
0037 L1GtJetCountsCondition::L1GtJetCountsCondition() : L1GtConditionEvaluation() {
0038   // empty
0039 }
0040 
0041 //     from base template condition (from event setup usually)
0042 L1GtJetCountsCondition::L1GtJetCountsCondition(const L1GtCondition *jcTemplate,
0043                                                const L1GlobalTriggerPSB *ptrPSB,
0044                                                const int nrL1JetCounts)
0045     : L1GtConditionEvaluation(),
0046       m_gtJetCountsTemplate(static_cast<const L1GtJetCountsTemplate *>(jcTemplate)),
0047       m_gtPSB(ptrPSB),
0048       m_numberL1JetCounts(nrL1JetCounts) {
0049   // maximum number of objects received for the evaluation of the condition
0050   // no objects, in fact, just a number
0051   m_condMaxNumberObjects = 1;
0052 }
0053 
0054 // copy constructor
0055 void L1GtJetCountsCondition::copy(const L1GtJetCountsCondition &cp) {
0056   m_gtJetCountsTemplate = cp.gtJetCountsTemplate();
0057   m_gtPSB = cp.gtPSB();
0058 
0059   m_condMaxNumberObjects = cp.condMaxNumberObjects();
0060   m_condLastResult = cp.condLastResult();
0061   m_combinationsInCond = cp.getCombinationsInCond();
0062 
0063   m_verbosity = cp.m_verbosity;
0064 }
0065 
0066 L1GtJetCountsCondition::L1GtJetCountsCondition(const L1GtJetCountsCondition &cp) : L1GtConditionEvaluation() {
0067   copy(cp);
0068 }
0069 
0070 // destructor
0071 L1GtJetCountsCondition::~L1GtJetCountsCondition() {
0072   // empty
0073 }
0074 
0075 // equal operator
0076 L1GtJetCountsCondition &L1GtJetCountsCondition::operator=(const L1GtJetCountsCondition &cp) {
0077   copy(cp);
0078   return *this;
0079 }
0080 
0081 // methods
0082 void L1GtJetCountsCondition::setGtJetCountsTemplate(const L1GtJetCountsTemplate *jcTemplate) {
0083   m_gtJetCountsTemplate = jcTemplate;
0084 }
0085 
0086 ///   set the pointer to PSB
0087 void L1GtJetCountsCondition::setGtPSB(const L1GlobalTriggerPSB *ptrPSB) { m_gtPSB = ptrPSB; }
0088 
0089 // try all object permutations and check spatial correlations, if required
0090 const bool L1GtJetCountsCondition::evaluateCondition() const {
0091   // number of trigger objects in the condition
0092   // in fact, there is only one object
0093   int iCondition = 0;
0094 
0095   // condition result condResult will be set to true if the jet counts
0096   // passes the requirement
0097   bool condResult = false;
0098 
0099   // store the index of the JetCount object
0100   // from the combination evaluated in the condition
0101   SingleCombInCond objectsInComb;
0102 
0103   // clear the m_combinationsInCond vector
0104   (combinationsInCond()).clear();
0105 
0106   // get the jet counts (event / condition)
0107   const L1GctJetCounts *jetCounts = m_gtPSB->getCandL1JetCounts();
0108 
0109   // protection against missing jet counts collection
0110   if (jetCounts == nullptr) {
0111     return false;
0112   }
0113 
0114   const L1GtJetCountsTemplate::ObjectParameter objPar = (*(m_gtJetCountsTemplate->objectParameter()))[iCondition];
0115 
0116   unsigned int cIndex = objPar.countIndex;
0117 
0118   if (cIndex >= m_numberL1JetCounts) {
0119     edm::LogError("L1GlobalTrigger") << "\nL1GtJetCountsCondition error: countIndex " << cIndex
0120                                      << "greater than maximum allowed count = " << m_numberL1JetCounts
0121                                      << "\n  ==> condResult = false " << std::endl;
0122     return false;
0123   }
0124 
0125   unsigned int countValue = jetCounts->count(cIndex);
0126 
0127   // check countThreshold
0128   if (!checkThreshold(objPar.countThreshold, countValue, m_gtJetCountsTemplate->condGEq())) {
0129     return false;
0130   }
0131 
0132   // index is always zero, as they are global quantities (there is only one
0133   // object)
0134   int indexObj = 0;
0135 
0136   objectsInComb.push_back(indexObj);
0137   (combinationsInCond()).push_back(objectsInComb);
0138 
0139   // if we get here all checks were successful for this combination
0140   // set the general result for evaluateCondition to "true"
0141 
0142   condResult = true;
0143   return condResult;
0144 }
0145 
0146 void L1GtJetCountsCondition::print(std::ostream &myCout) const {
0147   m_gtJetCountsTemplate->print(myCout);
0148   L1GtConditionEvaluation::print(myCout);
0149 }