CMS 3D CMS Logo

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