Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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