00001 00017 // this class header 00018 #include "L1Trigger/GlobalTrigger/interface/L1GtJetCountsCondition.h" 00019 00020 // system include files 00021 #include <iostream> 00022 #include <iomanip> 00023 00024 #include <vector> 00025 00026 // user include files 00027 // base classes 00028 #include "L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h" 00029 00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h" 00031 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h" 00032 00033 #include "CondFormats/L1TObjects/interface/L1GtJetCountsTemplate.h" 00034 00035 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h" 00036 00037 // constructors 00038 // default 00039 L1GtJetCountsCondition::L1GtJetCountsCondition() : 00040 L1GtConditionEvaluation() { 00041 00042 //empty 00043 00044 } 00045 00046 // from base template condition (from event setup usually) 00047 L1GtJetCountsCondition::L1GtJetCountsCondition(const L1GtCondition* jcTemplate, 00048 const L1GlobalTriggerPSB* ptrPSB, const int nrL1JetCounts) : 00049 L1GtConditionEvaluation(), 00050 m_gtJetCountsTemplate(static_cast<const L1GtJetCountsTemplate*>(jcTemplate)), 00051 m_gtPSB(ptrPSB), 00052 m_numberL1JetCounts(nrL1JetCounts) 00053 { 00054 00055 // maximum number of objects received for the evaluation of the condition 00056 // no objects, in fact, just a number 00057 m_condMaxNumberObjects = 1; 00058 00059 } 00060 00061 // copy constructor 00062 void L1GtJetCountsCondition::copy(const L1GtJetCountsCondition &cp) { 00063 00064 m_gtJetCountsTemplate = cp.gtJetCountsTemplate(); 00065 m_gtPSB = cp.gtPSB(); 00066 00067 m_condMaxNumberObjects = cp.condMaxNumberObjects(); 00068 m_condLastResult = cp.condLastResult(); 00069 m_combinationsInCond = cp.getCombinationsInCond(); 00070 00071 } 00072 00073 L1GtJetCountsCondition::L1GtJetCountsCondition(const L1GtJetCountsCondition& cp) : 00074 L1GtConditionEvaluation() { 00075 00076 copy(cp); 00077 00078 } 00079 00080 // destructor 00081 L1GtJetCountsCondition::~L1GtJetCountsCondition() { 00082 00083 // empty 00084 00085 } 00086 00087 // equal operator 00088 L1GtJetCountsCondition& L1GtJetCountsCondition::operator= (const L1GtJetCountsCondition& cp) 00089 { 00090 copy(cp); 00091 return *this; 00092 } 00093 00094 // methods 00095 void L1GtJetCountsCondition::setGtJetCountsTemplate(const L1GtJetCountsTemplate* jcTemplate) { 00096 00097 m_gtJetCountsTemplate = jcTemplate; 00098 00099 } 00100 00102 void L1GtJetCountsCondition::setGtPSB(const L1GlobalTriggerPSB* ptrPSB) { 00103 00104 m_gtPSB = ptrPSB; 00105 00106 } 00107 00108 // try all object permutations and check spatial correlations, if required 00109 const bool L1GtJetCountsCondition::evaluateCondition() const { 00110 00111 // number of trigger objects in the condition 00112 // in fact, there is only one object 00113 int iCondition = 0; 00114 00115 // condition result condResult will be set to true if the jet counts 00116 // passes the requirement 00117 bool condResult = false; 00118 00119 // store the index of the JetCount object 00120 // from the combination evaluated in the condition 00121 SingleCombInCond objectsInComb; 00122 00123 // clear the m_combinationsInCond vector 00124 (*m_combinationsInCond).clear(); 00125 00126 // get the jet counts (event / condition) 00127 const L1GctJetCounts* jetCounts = m_gtPSB->getCandL1JetCounts(); 00128 00129 // protection against missing jet counts collection 00130 if (jetCounts == 0) { 00131 return false; 00132 } 00133 00134 const L1GtJetCountsTemplate::ObjectParameter objPar = 00135 ( *(m_gtJetCountsTemplate->objectParameter()) )[iCondition]; 00136 00137 unsigned int cIndex = objPar.countIndex; 00138 00139 if (cIndex >= m_numberL1JetCounts) { 00140 00141 edm::LogError("L1GtJetCountsCondition") << "\nL1GtJetCountsCondition error: countIndex " 00142 << cIndex << "greater than maximum allowed count = " << m_numberL1JetCounts 00143 << "\n ==> condResult = false " << std::endl; 00144 return false; 00145 00146 } 00147 00148 unsigned int countValue = jetCounts->count(cIndex); 00149 00150 // check countThreshold 00151 if ( !checkThreshold(objPar.countThreshold, countValue, m_gtJetCountsTemplate->condGEq()) ) { 00152 00153 return false; 00154 } 00155 00156 // index is always zero, as they are global quantities (there is only one object) 00157 int indexObj = 0; 00158 00159 objectsInComb.push_back(indexObj); 00160 (*m_combinationsInCond).push_back(objectsInComb); 00161 00162 // if we get here all checks were successful for this combination 00163 // set the general result for evaluateCondition to "true" 00164 00165 condResult = true; 00166 return condResult; 00167 00168 } 00169 00170 void L1GtJetCountsCondition::print(std::ostream& myCout) const { 00171 00172 m_gtJetCountsTemplate->print(myCout); 00173 L1GtConditionEvaluation::print(myCout); 00174 00175 } 00176