CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/L1Trigger/GlobalTrigger/src/L1GtJetCountsCondition.cc

Go to the documentation of this file.
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     m_verbosity = cp.m_verbosity;
00072 
00073 }
00074 
00075 L1GtJetCountsCondition::L1GtJetCountsCondition(const L1GtJetCountsCondition& cp) :
00076     L1GtConditionEvaluation() {
00077 
00078     copy(cp);
00079 
00080 }
00081 
00082 // destructor
00083 L1GtJetCountsCondition::~L1GtJetCountsCondition() {
00084 
00085     // empty
00086 
00087 }
00088 
00089 // equal operator
00090 L1GtJetCountsCondition& L1GtJetCountsCondition::operator= (const L1GtJetCountsCondition& cp)
00091 {
00092     copy(cp);
00093     return *this;
00094 }
00095 
00096 // methods
00097 void L1GtJetCountsCondition::setGtJetCountsTemplate(const L1GtJetCountsTemplate* jcTemplate) {
00098 
00099     m_gtJetCountsTemplate = jcTemplate;
00100 
00101 }
00102 
00104 void L1GtJetCountsCondition::setGtPSB(const L1GlobalTriggerPSB* ptrPSB) {
00105 
00106     m_gtPSB = ptrPSB;
00107 
00108 }
00109 
00110 // try all object permutations and check spatial correlations, if required
00111 const bool L1GtJetCountsCondition::evaluateCondition() const {
00112 
00113     // number of trigger objects in the condition
00114     // in fact, there is only one object
00115     int iCondition = 0;
00116 
00117     // condition result condResult will be set to true if the jet counts
00118     // passes the requirement
00119     bool condResult = false;
00120 
00121     // store the index of the JetCount object
00122     // from the combination evaluated in the condition
00123     SingleCombInCond objectsInComb;
00124 
00125     // clear the m_combinationsInCond vector
00126     (*m_combinationsInCond).clear();
00127 
00128     // get the jet counts (event / condition)
00129     const L1GctJetCounts* jetCounts = m_gtPSB->getCandL1JetCounts();
00130 
00131     // protection against missing jet counts collection
00132     if (jetCounts == 0) {
00133         return false;
00134     }
00135 
00136     const L1GtJetCountsTemplate::ObjectParameter objPar =
00137         ( *(m_gtJetCountsTemplate->objectParameter()) )[iCondition];
00138 
00139     unsigned int cIndex = objPar.countIndex;
00140 
00141     if (cIndex >= m_numberL1JetCounts) {
00142 
00143         edm::LogError("L1GtJetCountsCondition") << "\nL1GtJetCountsCondition error: countIndex "
00144             << cIndex << "greater than maximum allowed count = " << m_numberL1JetCounts
00145             << "\n  ==> condResult = false " << std::endl;
00146         return false;
00147 
00148     }
00149 
00150     unsigned int countValue = jetCounts->count(cIndex);
00151 
00152     // check countThreshold
00153     if ( !checkThreshold(objPar.countThreshold, countValue, m_gtJetCountsTemplate->condGEq()) ) {
00154 
00155         return false;
00156     }
00157 
00158     // index is always zero, as they are global quantities (there is only one object)
00159     int indexObj = 0;
00160 
00161     objectsInComb.push_back(indexObj);
00162     (*m_combinationsInCond).push_back(objectsInComb);
00163 
00164     // if we get here all checks were successful for this combination
00165     // set the general result for evaluateCondition to "true"
00166 
00167     condResult = true;
00168     return condResult;
00169 
00170 }
00171 
00172 void L1GtJetCountsCondition::print(std::ostream& myCout) const {
00173 
00174     m_gtJetCountsTemplate->print(myCout);
00175     L1GtConditionEvaluation::print(myCout);
00176 
00177 }
00178