CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/L1Trigger/GlobalTrigger/src/L1GtHfBitCountsCondition.cc

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