Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1GtEnergySumCondition
0003  *
0004  *
0005  * Description: evaluation of a CondEnergySum 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/L1GtEnergySumCondition.h"
0017 
0018 // system include files
0019 #include <iomanip>
0020 #include <iostream>
0021 
0022 #include <algorithm>
0023 #include <string>
0024 #include <vector>
0025 
0026 // user include files
0027 //   base classes
0028 #include "CondFormats/L1TObjects/interface/L1GtEnergySumTemplate.h"
0029 #include "L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h"
0030 
0031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0032 
0033 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0034 
0035 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFunctions.h"
0036 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
0037 
0038 // constructors
0039 //     default
0040 L1GtEnergySumCondition::L1GtEnergySumCondition() : L1GtConditionEvaluation() {
0041   // empty
0042 }
0043 
0044 //     from base template condition (from event setup usually)
0045 L1GtEnergySumCondition::L1GtEnergySumCondition(const L1GtCondition *eSumTemplate, const L1GlobalTriggerPSB *ptrPSB)
0046     : L1GtConditionEvaluation(),
0047       m_gtEnergySumTemplate(static_cast<const L1GtEnergySumTemplate *>(eSumTemplate)),
0048       m_gtPSB(ptrPSB)
0049 
0050 {
0051   // maximum number of objects received for the evaluation of the condition
0052   // energy sums are global quantities - one object per event
0053 
0054   m_condMaxNumberObjects = 1;
0055 }
0056 
0057 // copy constructor
0058 void L1GtEnergySumCondition::copy(const L1GtEnergySumCondition &cp) {
0059   m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
0060   m_gtPSB = cp.gtPSB();
0061 
0062   m_condMaxNumberObjects = cp.condMaxNumberObjects();
0063   m_condLastResult = cp.condLastResult();
0064   m_combinationsInCond = cp.getCombinationsInCond();
0065 
0066   m_verbosity = cp.m_verbosity;
0067 }
0068 
0069 L1GtEnergySumCondition::L1GtEnergySumCondition(const L1GtEnergySumCondition &cp) : L1GtConditionEvaluation() {
0070   copy(cp);
0071 }
0072 
0073 // destructor
0074 L1GtEnergySumCondition::~L1GtEnergySumCondition() {
0075   // empty
0076 }
0077 
0078 // equal operator
0079 L1GtEnergySumCondition &L1GtEnergySumCondition::operator=(const L1GtEnergySumCondition &cp) {
0080   copy(cp);
0081   return *this;
0082 }
0083 
0084 // methods
0085 void L1GtEnergySumCondition::setGtEnergySumTemplate(const L1GtEnergySumTemplate *eSumTempl) {
0086   m_gtEnergySumTemplate = eSumTempl;
0087 }
0088 
0089 ///   set the pointer to PSB
0090 void L1GtEnergySumCondition::setGtPSB(const L1GlobalTriggerPSB *ptrPSB) { m_gtPSB = ptrPSB; }
0091 
0092 // try all object permutations and check spatial correlations, if required
0093 const bool L1GtEnergySumCondition::evaluateCondition() const {
0094   // number of trigger objects in the condition
0095   // in fact, there is only one object
0096   int iCondition = 0;
0097 
0098   // condition result condResult set to true if the energy sum
0099   // passes all requirements
0100   bool condResult = false;
0101 
0102   // store the indices of the calorimeter objects
0103   // from the combination evaluated in the condition
0104   SingleCombInCond objectsInComb;
0105 
0106   // clear the m_combinationsInCond vector
0107   (combinationsInCond()).clear();
0108 
0109   // clear the indices in the combination
0110   objectsInComb.clear();
0111 
0112   // get energy, phi (ETM and HTM) and overflow for the trigger object
0113 
0114   unsigned int candEt = 0;
0115   unsigned int candPhi = 0;
0116   bool candOverflow = false;
0117 
0118   switch ((m_gtEnergySumTemplate->objectType())[0]) {
0119     case ETT: {
0120       const L1GctEtTotal *cand1 = m_gtPSB->getCandL1ETT();
0121 
0122       if (cand1 == nullptr) {
0123         return false;
0124       }
0125 
0126       candEt = cand1->et();
0127       candOverflow = cand1->overFlow();
0128 
0129       break;
0130     }
0131     case ETM: {
0132       const L1GctEtMiss *cand2 = m_gtPSB->getCandL1ETM();
0133 
0134       if (cand2 == nullptr) {
0135         return false;
0136       }
0137 
0138       candEt = cand2->et();
0139       candPhi = cand2->phi();
0140       candOverflow = cand2->overFlow();
0141 
0142       break;
0143     }
0144     case HTT: {
0145       const L1GctEtHad *cand3 = m_gtPSB->getCandL1HTT();
0146 
0147       if (cand3 == nullptr) {
0148         return false;
0149       }
0150 
0151       candEt = cand3->et();
0152       candOverflow = cand3->overFlow();
0153 
0154       break;
0155     }
0156     case HTM: {
0157       const L1GctHtMiss *cand4 = m_gtPSB->getCandL1HTM();
0158 
0159       if (cand4 == nullptr) {
0160         return false;
0161       }
0162 
0163       candEt = cand4->et();
0164       candPhi = cand4->phi();
0165       candOverflow = cand4->overFlow();
0166 
0167       break;
0168     }
0169     default: {
0170       // should not arrive here
0171       return false;
0172 
0173       break;
0174     }
0175   }
0176 
0177   const L1GtEnergySumTemplate::ObjectParameter objPar = (*(m_gtEnergySumTemplate->objectParameter()))[iCondition];
0178 
0179   // check energy threshold and overflow
0180   // overflow evaluation:
0181   //     for condGEq >=
0182   //         candidate overflow true -> condition true
0183   //         candidate overflow false -> evaluate threshold
0184   //     for condGEq =
0185   //         candidate overflow true -> condition false
0186   //         candidate overflow false -> evaluate threshold
0187   //
0188 
0189   bool condGEqVal = m_gtEnergySumTemplate->condGEq();
0190 
0191   if (condGEqVal) {
0192     if (!candOverflow) {
0193       if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
0194         return false;
0195       }
0196     }
0197   } else {
0198     if (candOverflow) {
0199       return false;
0200     } else {
0201       if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
0202         return false;
0203       }
0204     }
0205   }
0206 
0207   // for ETM and HTM check phi also
0208   // for overflow, the phi requirements are ignored
0209 
0210   if (!candOverflow) {
0211     if ((m_gtEnergySumTemplate->objectType())[0] == ETM) {
0212       // phi bitmask is saved in two uint64_t (see parser)
0213       if (candPhi < 64) {
0214         if (!checkBit(objPar.phiRange0Word, candPhi)) {
0215           return false;
0216         }
0217       } else {
0218         if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
0219           return false;
0220         }
0221       }
0222 
0223     } else if ((m_gtEnergySumTemplate->objectType())[0] == HTM) {
0224       // phi bitmask is in the first word for HTM
0225       if (candPhi < 64) {
0226         if (!checkBit(objPar.phiRange0Word, candPhi)) {
0227           return false;
0228         }
0229       } else {
0230         if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
0231           return false;
0232         }
0233       }
0234     }
0235   }
0236 
0237   // index is always zero, as they are global quantities (there is only one
0238   // object)
0239   int indexObj = 0;
0240 
0241   objectsInComb.push_back(indexObj);
0242   (combinationsInCond()).push_back(objectsInComb);
0243 
0244   // if we get here all checks were successfull for this combination
0245   // set the general result for evaluateCondition to "true"
0246 
0247   condResult = true;
0248   return condResult;
0249 }
0250 
0251 void L1GtEnergySumCondition::print(std::ostream &myCout) const {
0252   m_gtEnergySumTemplate->print(myCout);
0253   L1GtConditionEvaluation::print(myCout);
0254 }