Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:55:08

0001 /**
0002 \class EnergySumZdcCondition
0003  *
0004  *
0005  * Description: evaluation of a CondEnergySum condition for ZDC objects.
0006  *
0007  * Implementation: This class is built following the EnergySumCondition class 
0008  *                 and is adapted to evaluate a condition on ZDC objects as a threshold on an energy sum value.
0009  *                 The object types are kZDCP and kZDCM and share the standard EtSum DataFormat.
0010  *
0011  * \author: Elisa Fontanesi and Christopher Mc Ginn
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h"
0017 
0018 // system include files
0019 #include <iostream>
0020 #include <iomanip>
0021 
0022 #include <string>
0023 #include <vector>
0024 #include <algorithm>
0025 
0026 // user include files
0027 //   base classes
0028 #include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h"
0029 #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
0030 #include "DataFormats/L1Trigger/interface/L1Candidate.h"
0031 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0032 
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0035 
0036 // constructors
0037 //     default
0038 l1t::EnergySumZdcCondition::EnergySumZdcCondition() : ConditionEvaluation() {
0039   //empty
0040 }
0041 
0042 //     from base template condition (from event setup usually)
0043 l1t::EnergySumZdcCondition::EnergySumZdcCondition(const GlobalCondition* eSumTemplate, const GlobalBoard* ptrGTB)
0044     : ConditionEvaluation(),
0045       m_gtEnergySumZdcTemplate(static_cast<const EnergySumZdcTemplate*>(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;
0053 }
0054 
0055 // copy constructor
0056 void l1t::EnergySumZdcCondition::copy(const l1t::EnergySumZdcCondition& cp) {
0057   m_gtEnergySumZdcTemplate = cp.gtEnergySumZdcTemplate();
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::EnergySumZdcCondition::EnergySumZdcCondition(const l1t::EnergySumZdcCondition& cp) : ConditionEvaluation() {
0068   copy(cp);
0069 }
0070 
0071 // destructor
0072 l1t::EnergySumZdcCondition::~EnergySumZdcCondition() = default;
0073 
0074 // equal operator
0075 l1t::EnergySumZdcCondition& l1t::EnergySumZdcCondition::operator=(const l1t::EnergySumZdcCondition& cp) {
0076   copy(cp);
0077   return *this;
0078 }
0079 
0080 // methods
0081 void l1t::EnergySumZdcCondition::setGtEnergySumZdcTemplate(const EnergySumZdcTemplate* eSumTempl) {
0082   m_gtEnergySumZdcTemplate = eSumTempl;
0083 }
0084 
0085 // set the pointer to uGT GlobalBoard
0086 void l1t::EnergySumZdcCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; }
0087 
0088 // try all object permutations and check spatial correlations, if required
0089 const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const {
0090   // number of trigger objects in the condition: there is only one object
0091   int iCondition = 0;
0092 
0093   // condition result condResult set to true if the energy sum
0094   // passes all requirements
0095   bool condResult = false;
0096 
0097   // store the indices of the calorimeter objects
0098   // from the combination evaluated in the condition
0099   SingleCombInCond objectsInComb;
0100 
0101   // clear the m_combinationsInCond vector
0102   (combinationsInCond()).clear();
0103 
0104   // clear the indices in the combination
0105   objectsInComb.clear();
0106 
0107   const BXVector<const l1t::EtSum*>* candVecZdc = m_uGtB->getCandL1EtSumZdc();
0108 
0109   // Look at objects in bx = bx + relativeBx
0110   int useBx = bxEval + m_gtEnergySumZdcTemplate->condRelativeBx();
0111 
0112   // Fail condition if attempting to get Bx outside of range
0113   if ((useBx < candVecZdc->getFirstBX()) || (useBx > candVecZdc->getLastBX())) {
0114     return false;
0115   }
0116 
0117   // If no candidates, no use looking any further
0118   int numberObjectsZdc = candVecZdc->size(useBx);
0119 
0120   if (numberObjectsZdc < 1) {
0121     return false;
0122   }
0123 
0124   const EnergySumZdcTemplate::ObjectParameter objPar = (*(m_gtEnergySumZdcTemplate->objectParameter()))[iCondition];
0125   l1t::EtSum::EtSumType type;
0126   switch ((m_gtEnergySumZdcTemplate->objectType())[0]) {
0127     case gtZDCP:
0128       type = l1t::EtSum::EtSumType::kZDCP;
0129       break;
0130     case gtZDCM:
0131       type = l1t::EtSum::EtSumType::kZDCM;
0132       break;
0133     default:
0134       edm::LogError("L1TGlobal")
0135           << "\n  Error: "
0136           << "Unmatched object type from template to EtSumZdcType, (m_gtEnergySumZdcTemplate->objectType())[0] = "
0137           << (m_gtEnergySumZdcTemplate->objectType())[0] << std::endl;
0138       type = l1t::EtSum::EtSumType::kZDCP;
0139       break;
0140   }
0141 
0142   // Definition in CondFormats/L1TObjects/interface/L1GtCondition.h:
0143   // condGEqVal indicates the operator used for the condition (>=, =): true for >=
0144   bool condGEqVal = m_gtEnergySumZdcTemplate->condGEq();
0145 
0146   l1t::EtSum candZdcPlus;
0147   l1t::EtSum candZdcMinus;
0148   unsigned int candZDCPEsum = 0;
0149   unsigned int candZDCMEsum = 0;
0150   bool myres = false;
0151 
0152   for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) {
0153     l1t::EtSum candZdc = *(candVecZdc->at(useBx, iEtSum));
0154 
0155     if (candZdc.getType() != type)
0156       continue;
0157 
0158     if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCP) {
0159       candZdcPlus = *(candVecZdc->at(useBx, iEtSum));
0160       candZDCPEsum = candZdcPlus.hwPt();
0161       myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCPEsum, condGEqVal);
0162     } else if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCM) {
0163       candZdcMinus = *(candVecZdc->at(useBx, iEtSum));
0164       candZDCMEsum = candZdcMinus.hwPt();
0165       myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCMEsum, condGEqVal);
0166     } else {
0167       LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed ZDC checkThreshold" << std::endl;
0168       return false;
0169     }
0170 
0171     LogDebug("L1TGlobal") << "CANDZdc: " << candZdc.hwPt() << ", " << useBx << ", " << candZdc.getType();
0172 
0173     LogDebug("L1TGlobal")
0174         << "----------------------------------------------> ZDC EtSumType object from EnergySumZdcTemplate"
0175         << "\n objPar.etLowThreshold = " << objPar.etLowThreshold
0176         << "\n objPar.etHighThreshold = " << objPar.etHighThreshold << "\n candZDCPEsum = " << candZDCPEsum
0177         << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres
0178         << std::endl;
0179   }
0180 
0181   if (not myres)
0182     return false;
0183 
0184   // index is always zero, as they are global quantities (there is only one object)
0185   int indexObj = 0;
0186 
0187   objectsInComb.push_back(indexObj);
0188   (combinationsInCond()).push_back(objectsInComb);
0189 
0190   // if we get here all checks were successful for this combination
0191   // set the general result for evaluateCondition to "true"
0192   condResult = true;
0193   return condResult;
0194 }
0195 
0196 void l1t::EnergySumZdcCondition::print(std::ostream& myCout) const {
0197   m_gtEnergySumZdcTemplate->print(myCout);
0198   ConditionEvaluation::print(myCout);
0199 }