CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/L1Trigger/GlobalTrigger/src/L1GtHfRingEtSumsCondition.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1Trigger/GlobalTrigger/interface/L1GtHfRingEtSumsCondition.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/L1GctHFRingEtSums.h"
00032 
00033 #include "CondFormats/L1TObjects/interface/L1GtHfRingEtSumsTemplate.h"
00034 
00035 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00036 
00037 // constructors
00038 //     default
00039 L1GtHfRingEtSumsCondition::L1GtHfRingEtSumsCondition() :
00040     L1GtConditionEvaluation() {
00041 
00042     //empty
00043 
00044 }
00045 
00046 //     from base template condition (from event setup usually)
00047 L1GtHfRingEtSumsCondition::L1GtHfRingEtSumsCondition(
00048         const L1GtCondition* etTemplate, const L1GlobalTriggerPSB* ptrPSB) :
00049     L1GtConditionEvaluation(), m_gtHfRingEtSumsTemplate(
00050             static_cast<const L1GtHfRingEtSumsTemplate*> (etTemplate)), 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 number
00056     m_condMaxNumberObjects = 1;
00057 
00058 }
00059 
00060 // copy constructor
00061 void L1GtHfRingEtSumsCondition::copy(const L1GtHfRingEtSumsCondition &cp) {
00062 
00063     m_gtHfRingEtSumsTemplate = cp.gtHfRingEtSumsTemplate();
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 L1GtHfRingEtSumsCondition::L1GtHfRingEtSumsCondition(const L1GtHfRingEtSumsCondition& cp) :
00075     L1GtConditionEvaluation() {
00076 
00077     copy(cp);
00078 
00079 }
00080 
00081 // destructor
00082 L1GtHfRingEtSumsCondition::~L1GtHfRingEtSumsCondition() {
00083 
00084     // empty
00085 
00086 }
00087 
00088 // equal operator
00089 L1GtHfRingEtSumsCondition& L1GtHfRingEtSumsCondition::operator= (const L1GtHfRingEtSumsCondition& cp)
00090 {
00091     copy(cp);
00092     return *this;
00093 }
00094 
00095 // methods
00096 void L1GtHfRingEtSumsCondition::setGtHfRingEtSumsTemplate(const L1GtHfRingEtSumsTemplate* etTemplate) {
00097 
00098     m_gtHfRingEtSumsTemplate = etTemplate;
00099 
00100 }
00101 
00103 void L1GtHfRingEtSumsCondition::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 L1GtHfRingEtSumsCondition::evaluateCondition() const {
00111 
00112     // number of trigger objects in the condition
00113     // no objects, in fact, just a number
00114     int iCondition = 0;
00115 
00116     // condition result condResult will be set to true if the HF Ring Et sums
00117     // passes the requirement
00118     bool condResult = false;
00119 
00120     // store the index of the HfRingEtSums 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 Ring Et sums (event / condition)
00128     const L1GctHFRingEtSums* etSumCand = m_gtPSB->getCandL1HfRingEtSums();
00129 
00130     // protection against missing HF Ring Et sums collection
00131     if (etSumCand == 0) {
00132         return false;
00133     }
00134 
00135     const L1GtHfRingEtSumsTemplate::ObjectParameter objPar =
00136         ( *(m_gtHfRingEtSumsTemplate->objectParameter()) )[iCondition];
00137 
00138     // FIXME ask GCT to provide a method to retrieve it
00139     const unsigned int numberL1HfRingEtSums = 4;
00140 
00141     const unsigned int cIndex = objPar.etSumIndex;
00142     if (cIndex >= numberL1HfRingEtSums) {
00143 
00144         edm::LogError("L1GlobalTrigger") << "\nL1GtHfRingEtSumsCondition error: etSumIndex "
00145             << cIndex << "greater than GCT maximum index = " << numberL1HfRingEtSums
00146             << "\n  ==> condResult = false " << std::endl;
00147         return false;
00148 
00149     }
00150 
00151     const unsigned int etSumValue = etSumCand->etSum(cIndex);
00152 
00153     // check countThreshold
00154     if ( !checkThreshold(objPar.etSumThreshold, etSumValue, m_gtHfRingEtSumsTemplate->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 L1GtHfRingEtSumsCondition::print(std::ostream& myCout) const {
00174 
00175     m_gtHfRingEtSumsTemplate->print(myCout);
00176     L1GtConditionEvaluation::print(myCout);
00177 
00178 }
00179