CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1Trigger/GlobalTrigger/interface/L1GtEnergySumCondition.h"
00019 
00020 // system include files
00021 #include <iostream>
00022 #include <iomanip>
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <algorithm>
00027 
00028 // user include files
00029 //   base classes
00030 #include "CondFormats/L1TObjects/interface/L1GtEnergySumTemplate.h"
00031 #include "L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h"
00032 
00033 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00034 
00035 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
00036 
00037 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFunctions.h"
00038 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00039 
00040 // constructors
00041 //     default
00042 L1GtEnergySumCondition::L1GtEnergySumCondition() :
00043     L1GtConditionEvaluation() {
00044 
00045     //empty
00046 
00047 }
00048 
00049 //     from base template condition (from event setup usually)
00050 L1GtEnergySumCondition::L1GtEnergySumCondition(const L1GtCondition* eSumTemplate,
00051     const L1GlobalTriggerPSB* ptrPSB) :
00052     L1GtConditionEvaluation(),
00053     m_gtEnergySumTemplate(static_cast<const L1GtEnergySumTemplate*>(eSumTemplate)),
00054     m_gtPSB(ptrPSB)
00055 
00056 {
00057 
00058     // maximum number of objects received for the evaluation of the condition
00059     // energy sums are global quantities - one object per event
00060 
00061     m_condMaxNumberObjects = 1;
00062 
00063 }
00064 
00065 // copy constructor
00066 void L1GtEnergySumCondition::copy(const L1GtEnergySumCondition &cp) {
00067 
00068     m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
00069     m_gtPSB = cp.gtPSB();
00070 
00071     m_condMaxNumberObjects = cp.condMaxNumberObjects();
00072     m_condLastResult = cp.condLastResult();
00073     m_combinationsInCond = cp.getCombinationsInCond();
00074 
00075     m_verbosity = cp.m_verbosity;
00076 
00077 }
00078 
00079 L1GtEnergySumCondition::L1GtEnergySumCondition(const L1GtEnergySumCondition& cp) :
00080     L1GtConditionEvaluation() {
00081 
00082     copy(cp);
00083 
00084 }
00085 
00086 // destructor
00087 L1GtEnergySumCondition::~L1GtEnergySumCondition() {
00088 
00089     // empty
00090 
00091 }
00092 
00093 // equal operator
00094 L1GtEnergySumCondition& L1GtEnergySumCondition::operator= (const L1GtEnergySumCondition& cp)
00095 {
00096     copy(cp);
00097     return *this;
00098 }
00099 
00100 // methods
00101 void L1GtEnergySumCondition::setGtEnergySumTemplate(
00102     const L1GtEnergySumTemplate* eSumTempl) {
00103 
00104     m_gtEnergySumTemplate = eSumTempl;
00105 
00106 }
00107 
00109 void L1GtEnergySumCondition::setGtPSB(const L1GlobalTriggerPSB* ptrPSB) {
00110 
00111     m_gtPSB = ptrPSB;
00112 
00113 }
00114 
00115 // try all object permutations and check spatial correlations, if required
00116 const bool L1GtEnergySumCondition::evaluateCondition() const {
00117 
00118     // number of trigger objects in the condition
00119     // in fact, there is only one object
00120     int iCondition = 0;
00121 
00122     // condition result condResult set to true if the energy sum
00123     // passes all requirements
00124     bool condResult = false;
00125 
00126     // store the indices of the calorimeter objects
00127     // from the combination evaluated in the condition
00128     SingleCombInCond objectsInComb;
00129 
00130     // clear the m_combinationsInCond vector
00131     (combinationsInCond()).clear();
00132 
00133     // clear the indices in the combination
00134     objectsInComb.clear();
00135 
00136     // get energy, phi (ETM and HTM) and overflow for the trigger object
00137 
00138     unsigned int candEt = 0;
00139     unsigned int candPhi = 0;
00140     bool candOverflow = false;
00141 
00142     switch ((m_gtEnergySumTemplate->objectType())[0]) {
00143         case ETT: {
00144             const L1GctEtTotal* cand1 = m_gtPSB->getCandL1ETT();
00145 
00146             if (cand1 == 0) {
00147                 return false;
00148             }
00149 
00150             candEt = cand1->et();
00151             candOverflow = cand1->overFlow();
00152 
00153             break;
00154         }
00155         case ETM: {
00156             const L1GctEtMiss* cand2 = m_gtPSB->getCandL1ETM();
00157 
00158             if (cand2 == 0) {
00159                 return false;
00160             }
00161 
00162             candEt = cand2->et();
00163             candPhi = cand2->phi();
00164             candOverflow = cand2->overFlow();
00165 
00166             break;
00167         }
00168         case HTT: {
00169             const L1GctEtHad* cand3 = m_gtPSB->getCandL1HTT();
00170 
00171             if (cand3 == 0) {
00172                 return false;
00173             }
00174 
00175             candEt = cand3->et();
00176             candOverflow = cand3->overFlow();
00177 
00178             break;
00179         }
00180         case HTM: {
00181             const L1GctHtMiss* cand4 = m_gtPSB->getCandL1HTM();
00182 
00183             if (cand4 == 0) {
00184                 return false;
00185             }
00186 
00187             candEt = cand4->et();
00188             candPhi = cand4->phi();
00189             candOverflow = cand4->overFlow();
00190 
00191             break;
00192         }
00193         default: {
00194             // should not arrive here
00195             return false;
00196 
00197             break;
00198         }
00199     }
00200 
00201     const L1GtEnergySumTemplate::ObjectParameter objPar =
00202         ( *(m_gtEnergySumTemplate->objectParameter()) )[iCondition];
00203 
00204     // check energy threshold and overflow
00205     // overflow evaluation:
00206     //     for condGEq >=
00207     //         candidate overflow true -> condition true
00208     //         candidate overflow false -> evaluate threshold
00209     //     for condGEq =
00210     //         candidate overflow true -> condition false
00211     //         candidate overflow false -> evaluate threshold
00212     //
00213 
00214     bool condGEqVal = m_gtEnergySumTemplate->condGEq();
00215 
00216     if (condGEqVal) {
00217         if (!candOverflow) {
00218             if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
00219                 return false;
00220             }
00221         }
00222     } else {
00223         if (candOverflow) {
00224             return false;
00225         } else {
00226             if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
00227                 return false;
00228             }
00229         }
00230 
00231     }
00232 
00233     // for ETM and HTM check phi also
00234     // for overflow, the phi requirements are ignored
00235 
00236     if (!candOverflow) {
00237         if ( ( m_gtEnergySumTemplate->objectType() )[0] == ETM) {
00238 
00239             // phi bitmask is saved in two uint64_t (see parser)
00240             if (candPhi < 64) {
00241                 if (!checkBit(objPar.phiRange0Word, candPhi)) {
00242 
00243                     return false;
00244                 }
00245             } else {
00246                 if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
00247 
00248                     return false;
00249                 }
00250             }
00251 
00252         } else if ( ( m_gtEnergySumTemplate->objectType() )[0] == HTM) {
00253 
00254             // phi bitmask is in the first word for HTM
00255             if (candPhi < 64) {
00256                 if (!checkBit(objPar.phiRange0Word, candPhi)) {
00257 
00258                     return false;
00259                 }
00260             } else {
00261                 if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
00262 
00263                     return false;
00264                 }
00265             }
00266         }
00267     }
00268 
00269 
00270     // index is always zero, as they are global quantities (there is only one object)
00271     int indexObj = 0;
00272 
00273     objectsInComb.push_back(indexObj);
00274     (combinationsInCond()).push_back(objectsInComb);
00275 
00276     // if we get here all checks were successfull for this combination
00277     // set the general result for evaluateCondition to "true"
00278 
00279     condResult = true;
00280     return condResult;
00281 
00282 }
00283 
00284 void L1GtEnergySumCondition::print(std::ostream& myCout) const {
00285 
00286     m_gtEnergySumTemplate->print(myCout);
00287     L1GtConditionEvaluation::print(myCout);
00288 
00289 }
00290