CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/L1TriggerOffline/L1Analyzer/src/TriggerOperation.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    TriggerOperation
00004 // Class:      TriggerOperation
00005 // 
00013 //
00014 // Original Author:  Georgia KARAPOSTOLI
00015 //         Created:  Wed Feb 11 18:34:11 CET 2009
00016 // $Id: TriggerOperation.cc,v 1.2 2009/12/14 22:23:20 wmtan Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 #include <vector>
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/Frameworkfwd.h"
00027 #include "FWCore/Framework/interface/EDAnalyzer.h"
00028 
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00034 
00035 #include "FWCore/Framework/interface/ESHandle.h"
00036 
00037 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00038 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00039 
00040 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00041 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00042 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00043 
00044 #include "FWCore/Framework/interface/MakerMacros.h"
00045 #include "L1TriggerOffline/L1Analyzer/interface/SimpleHBits.h"
00046 //
00047 // class decleration
00048 //
00049 
00050 using namespace std;
00051 
00052 class TriggerOperation : public edm::EDAnalyzer {
00053    public:
00054       explicit TriggerOperation(const edm::ParameterSet&);
00055       ~TriggerOperation();
00056 
00057 
00058    private:
00059       virtual void beginJob() ;
00060       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00061       virtual void endJob() ;
00062 
00063   edm::InputTag m_l1GtReadoutRecord;
00064 
00065 //   /// trigger masks
00066 //   const L1GtTriggerMask* m_l1GtTmAlgo;
00067 //   unsigned long long m_l1GtTmAlgoCacheID;
00068   
00069 //   const L1GtTriggerMask* m_l1GtTmTech;
00070 //   unsigned long long m_l1GtTmTechCacheID;
00071   
00072 //   std::vector<unsigned int> m_triggerMaskAlgoTrig;
00073 //   std::vector<unsigned int> m_triggerMaskTechTrig;
00074   
00075   SimpleHBits *m_TriggerBits;
00076 
00077   // vector<int> nBits;
00078 
00079       // ----------member data ---------------------------
00080 };
00081 
00082 //
00083 // constants, enums and typedefs
00084 //
00085 
00086 //
00087 // static data member definitions
00088 //
00089 
00090 //
00091 // constructors and destructor
00092 //
00093 TriggerOperation::TriggerOperation(const edm::ParameterSet& iConfig) :
00094   m_l1GtReadoutRecord(iConfig.getUntrackedParameter<edm::InputTag>("L1GtReadoutRecordTag"))
00095 {
00096    //now do what ever initialization is needed
00097   m_TriggerBits = new SimpleHBits("TriggerBits",iConfig);
00098 
00099    // initialize cached IDs
00100     
00101   //   m_l1GtTmAlgoCacheID = 0;
00102 //     m_l1GtTmTechCacheID = 0;
00103 
00104   // m_l1GtReadoutRecord(iConfig.getUntrackedParameter<edm::InputTag>("L1GtReadoutRecordTag"));
00105 }
00106 
00107 
00108 TriggerOperation::~TriggerOperation()
00109 {
00110  
00111    // do anything here that needs to be done at desctruction time
00112    // (e.g. close files, deallocate resources etc.)
00113   delete m_TriggerBits;
00114 }
00115 
00116 
00117 //
00118 // member functions
00119 //
00120 
00121 // ------------ method called to for each event  ------------
00122 void
00123 TriggerOperation::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00124 {
00125    using namespace edm;
00126 
00127   // get L1GlobalTriggerReadoutRecord
00128    edm::Handle<L1GlobalTriggerReadoutRecord> gtRecord;
00129    iEvent.getByLabel(m_l1GtReadoutRecord, gtRecord);
00130    
00131    if (!gtRecord.isValid()) {
00132      
00133      LogDebug("L1GlobalTriggerRecordProducer")
00134        << "\n\n Error: no L1GlobalTriggerReadoutRecord found with input tag "
00135        << m_l1GtReadoutRecord
00136        << "\n Returning empty L1GlobalTriggerRecord.\n\n"
00137        << std::endl;
00138      
00139      return;
00140    }
00141    
00142    DecisionWord algoDecisionWord = gtRecord->decisionWord();    
00143    TechnicalTriggerWord techDecisionWord = gtRecord->technicalTriggerWord();   
00144    
00145    int tBit=0;
00146    
00147    for (std::vector<bool>::iterator 
00148           itBit = algoDecisionWord.begin(); itBit != algoDecisionWord.end(); ++itBit) {
00149      bool algoTrigger = algoDecisionWord.at(tBit);
00150      if (algoTrigger) {m_TriggerBits->FillTB(static_cast<float>(tBit));}
00151      tBit++;
00152    }
00153    
00154 #ifdef THIS_IS_AN_EVENT_EXAMPLE
00155    Handle<ExampleData> pIn;
00156    iEvent.getByLabel("example",pIn);
00157 #endif
00158    
00159 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
00160    ESHandle<SetupData> pSetup;
00161    iSetup.get<SetupRecord>().get(pSetup);
00162 #endif
00163 }
00164 
00165 
00166 // ------------ method called once each job just before starting event loop  ------------
00167 void 
00168 TriggerOperation::beginJob()
00169 {
00170 }
00171 
00172 // ------------ method called once each job just after ending the event loop  ------------
00173 void 
00174 TriggerOperation::endJob() {
00175 }
00176 
00177 //define this as a plug-in
00178 DEFINE_FWK_MODULE(TriggerOperation);