CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/EventFilter/L1GlobalTriggerRawToDigi/src/L1GtTriggerMenuLiteProducer.cc

Go to the documentation of this file.
00001 
00019 // this class header
00020 #include "EventFilter/L1GlobalTriggerRawToDigi/interface/L1GtTriggerMenuLiteProducer.h"
00021 
00022 // system include files
00023 #include <iostream>
00024 
00025 // user include files
00026 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
00027 
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029 #include "FWCore/Utilities/interface/InputTag.h"
00030 
00031 #include "FWCore/Framework/interface/EventSetup.h"
00032 #include "FWCore/Framework/interface/ESHandle.h"
00033 #include "FWCore/Framework/interface/Run.h"
00034 
00035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00036 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00037 
00038 #include "CondFormats/L1TObjects/interface/L1GtStableParameters.h"
00039 #include "CondFormats/DataRecord/interface/L1GtStableParametersRcd.h"
00040 
00041 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00042 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00043 
00044 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00045 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
00046 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
00047 
00048 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00049 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00050 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00051 
00052 // constructor(s)
00053 L1GtTriggerMenuLiteProducer::L1GtTriggerMenuLiteProducer(
00054         const edm::ParameterSet& parSet) :
00055     m_l1GtStableParCacheID(0ULL), m_numberPhysTriggers(0),
00056 
00057     m_numberTechnicalTriggers(0),
00058 
00059     m_l1GtMenuCacheID(0ULL),
00060 
00061     m_l1GtTmAlgoCacheID(0ULL), m_l1GtTmTechCacheID(0ULL),
00062 
00063     m_l1GtPfAlgoCacheID(0ULL), m_l1GtPfTechCacheID(0ULL),
00064 
00065     m_physicsDaqPartition(0) {
00066 
00067     // EDM product in Run Data
00068     produces<L1GtTriggerMenuLite, edm::InRun>();
00069 
00070 }
00071 
00072 // destructor
00073 L1GtTriggerMenuLiteProducer::~L1GtTriggerMenuLiteProducer() {
00074 
00075     // empty
00076 
00077 }
00078 
00079 void L1GtTriggerMenuLiteProducer::retrieveL1EventSetup(const edm::EventSetup& evSetup) {
00080 
00081     // get / update the stable parameters from the EventSetup
00082     // local cache & check on cacheIdentifier
00083 
00084     unsigned long long l1GtStableParCacheID =
00085             evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
00086 
00087     if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
00088 
00089         edm::ESHandle<L1GtStableParameters> l1GtStablePar;
00090         evSetup.get<L1GtStableParametersRcd>().get(l1GtStablePar);
00091         m_l1GtStablePar = l1GtStablePar.product();
00092 
00093         // number of physics triggers
00094         m_numberPhysTriggers = m_l1GtStablePar->gtNumberPhysTriggers();
00095 
00096         // number of technical triggers
00097         m_numberTechnicalTriggers =
00098                 m_l1GtStablePar->gtNumberTechnicalTriggers();
00099 
00100         //
00101         m_l1GtStableParCacheID = l1GtStableParCacheID;
00102 
00103     }
00104 
00105     // get / update the prescale factors from the EventSetup
00106     // local cache & check on cacheIdentifier
00107 
00108     unsigned long long l1GtPfAlgoCacheID =
00109             evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
00110 
00111     if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
00112 
00113         edm::ESHandle<L1GtPrescaleFactors> l1GtPfAlgo;
00114         evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
00115         m_l1GtPfAlgo = l1GtPfAlgo.product();
00116 
00117         m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
00118 
00119         m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
00120 
00121     }
00122 
00123     unsigned long long l1GtPfTechCacheID = evSetup.get<
00124             L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
00125 
00126     if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
00127 
00128         edm::ESHandle<L1GtPrescaleFactors> l1GtPfTech;
00129         evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().get(l1GtPfTech);
00130         m_l1GtPfTech = l1GtPfTech.product();
00131 
00132         m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
00133 
00134         m_l1GtPfTechCacheID = l1GtPfTechCacheID;
00135 
00136     }
00137 
00138     // get / update the trigger mask from the EventSetup
00139     // local cache & check on cacheIdentifier
00140 
00141     unsigned long long l1GtTmAlgoCacheID =
00142             evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
00143 
00144     if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
00145 
00146         edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo;
00147         evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtTmAlgo);
00148         m_l1GtTmAlgo = l1GtTmAlgo.product();
00149 
00150         m_triggerMaskAlgoTrig = &(m_l1GtTmAlgo->gtTriggerMask());
00151 
00152         m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
00153 
00154     }
00155 
00156     unsigned long long l1GtTmTechCacheID =
00157             evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
00158 
00159     if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
00160 
00161         edm::ESHandle<L1GtTriggerMask> l1GtTmTech;
00162         evSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTmTech);
00163         m_l1GtTmTech = l1GtTmTech.product();
00164 
00165         m_triggerMaskTechTrig = &(m_l1GtTmTech->gtTriggerMask());
00166 
00167         m_l1GtTmTechCacheID = l1GtTmTechCacheID;
00168 
00169     }
00170 
00171 
00172     // get / update the trigger menu from the EventSetup
00173     // local cache & check on cacheIdentifier
00174 
00175     unsigned long long l1GtMenuCacheID =
00176             evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
00177 
00178     if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
00179 
00180         edm::ESHandle<L1GtTriggerMenu> l1GtMenu;
00181         evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
00182         m_l1GtMenu = l1GtMenu.product();
00183 
00184         m_algorithmMap = &(m_l1GtMenu->gtAlgorithmMap());
00185         m_algorithmAliasMap = &(m_l1GtMenu->gtAlgorithmAliasMap());
00186 
00187         m_technicalTriggerMap = &(m_l1GtMenu->gtTechnicalTriggerMap());
00188 
00189         m_l1GtMenuCacheID = l1GtMenuCacheID;
00190 
00191     }
00192 
00193 }
00194 
00195 // member functions
00196 
00197 void L1GtTriggerMenuLiteProducer::beginJob() {
00198     // empty
00199 }
00200 
00201 void L1GtTriggerMenuLiteProducer::beginRun(edm::Run& iRun,
00202         const edm::EventSetup& evSetup) {
00203 
00204     //
00205 
00206     retrieveL1EventSetup(evSetup);
00207 
00208     // produce the L1GtTriggerMenuLite
00209     std::auto_ptr<L1GtTriggerMenuLite> gtTriggerMenuLite(new L1GtTriggerMenuLite());
00210 
00211     // lite L1 trigger menu
00212 
00213     gtTriggerMenuLite->setGtTriggerMenuInterface(m_l1GtMenu->gtTriggerMenuInterface());
00214     gtTriggerMenuLite->setGtTriggerMenuName(m_l1GtMenu->gtTriggerMenuName());
00215     gtTriggerMenuLite->setGtTriggerMenuImplementation(m_l1GtMenu->gtTriggerMenuImplementation());
00216 
00217     gtTriggerMenuLite->setGtScaleDbKey(m_l1GtMenu->gtScaleDbKey());
00218 
00219     //
00220     L1GtTriggerMenuLite::L1TriggerMap algMap;
00221     for (CItAlgo itAlgo = m_algorithmMap->begin(); itAlgo
00222             != m_algorithmMap->end(); itAlgo++) {
00223 
00224         unsigned int bitNumber = (itAlgo->second).algoBitNumber();
00225         algMap[bitNumber] = itAlgo->first;
00226 
00227     }
00228 
00229     gtTriggerMenuLite->setGtAlgorithmMap(algMap);
00230 
00231     //
00232     L1GtTriggerMenuLite::L1TriggerMap algAliasMap;
00233     for (CItAlgo itAlgo = m_algorithmAliasMap->begin(); itAlgo
00234             != m_algorithmAliasMap->end(); itAlgo++) {
00235 
00236         unsigned int bitNumber = (itAlgo->second).algoBitNumber();
00237         algAliasMap[bitNumber] = itAlgo->first;
00238 
00239     }
00240 
00241     gtTriggerMenuLite->setGtAlgorithmAliasMap(algAliasMap);
00242 
00243     //
00244     L1GtTriggerMenuLite::L1TriggerMap techMap;
00245     for (CItAlgo itAlgo = m_technicalTriggerMap->begin(); itAlgo
00246             != m_technicalTriggerMap->end(); itAlgo++) {
00247 
00248         unsigned int bitNumber = (itAlgo->second).algoBitNumber();
00249         techMap[bitNumber] = itAlgo->first;
00250 
00251     }
00252 
00253     gtTriggerMenuLite->setGtTechnicalTriggerMap(techMap);
00254 
00255     // trigger masks
00256     std::vector<unsigned int> triggerMaskAlgoTrig(m_numberPhysTriggers, 0);
00257     int iBit = -1;
00258 
00259     for (std::vector<unsigned int>::const_iterator
00260             itBit = m_triggerMaskAlgoTrig->begin();
00261             itBit != m_triggerMaskAlgoTrig->end();
00262             itBit++) {
00263 
00264         iBit++;
00265         triggerMaskAlgoTrig[iBit] = (*itBit) & (1 << m_physicsDaqPartition);
00266     }
00267     gtTriggerMenuLite->setGtTriggerMaskAlgoTrig(triggerMaskAlgoTrig);
00268 
00269     //
00270     std::vector<unsigned int> triggerMaskTechTrig(m_numberTechnicalTriggers, 0);
00271     iBit = -1;
00272 
00273     for (std::vector<unsigned int>::const_iterator
00274             itBit = m_triggerMaskTechTrig->begin();
00275             itBit != m_triggerMaskTechTrig->end();
00276             itBit++) {
00277 
00278         iBit++;
00279         triggerMaskTechTrig[iBit] = (*itBit) & (1 << m_physicsDaqPartition);
00280     }
00281     gtTriggerMenuLite->setGtTriggerMaskTechTrig(triggerMaskTechTrig);
00282 
00283 
00284     //
00285     gtTriggerMenuLite->setGtPrescaleFactorsAlgoTrig(*m_prescaleFactorsAlgoTrig);
00286     gtTriggerMenuLite->setGtPrescaleFactorsTechTrig(*m_prescaleFactorsTechTrig);
00287 
00288 
00289     // print menu, trigger masks and prescale factors
00290     if (edm::isDebugEnabled()) {
00291 
00292         LogDebug("L1GtTriggerMenuLiteProducer") << *gtTriggerMenuLite;
00293 
00294     }
00295 
00296     // put records into event
00297     iRun.put(gtTriggerMenuLite);
00298 
00299 }
00300 
00301 void L1GtTriggerMenuLiteProducer::produce(edm::Event& iEvent,
00302         const edm::EventSetup& evSetup) {
00303 
00304 
00305 }
00306 
00307 void L1GtTriggerMenuLiteProducer::endRun(edm::Run& iRun,
00308         const edm::EventSetup& evSetup) {
00309 
00310     // empty
00311 
00312 }
00313 
00314 //
00315 void L1GtTriggerMenuLiteProducer::endJob() {
00316 
00317     // empty now
00318 }
00319 
00320 // static class members
00321 
00322 //define this as a plug-in
00323 DEFINE_FWK_MODULE( L1GtTriggerMenuLiteProducer);