CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DPGAnalysis/Skims/src/HLTInspect.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:   BeamSplash
00004 // Class:     BeamSPlash
00005 //
00006 //
00007 // Original Author:  Luca Malgeri
00008 
00009 #include <memory>
00010 #include <vector>
00011 #include <map>
00012 #include <set>
00013 
00014 // user include files
00015 #include "DPGAnalysis/Skims/interface/HLTInspect.h"
00016 
00017 #include "FWCore/Utilities/interface/InputTag.h"
00018 #include "FWCore/Framework/interface/Frameworkfwd.h"
00019 #include "FWCore/Framework/interface/EDFilter.h"
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/Framework/interface/MakerMacros.h"
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 #include "FWCore/Framework/interface/ESHandle.h"
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
00026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00027 #include "DataFormats/Common/interface/TriggerResults.h"
00028 #include "FWCore/Common/interface/TriggerNames.h"
00029 
00030 using namespace edm;
00031 using namespace std;
00032 
00033 HLTInspect::HLTInspect(const edm::ParameterSet& iConfig)
00034 {
00035   hlTriggerResults_ = iConfig.getParameter<edm::InputTag> ("HLTriggerResults");
00036   init_ = false;
00037 }
00038 
00039 HLTInspect::~HLTInspect()
00040 {
00041 }
00042 void HLTInspect::analyze(const edm::Event& iEvent, const edm::EventSetup& c)
00043 {
00044 
00045 
00046   int ievt = iEvent.id().event();
00047   int irun = iEvent.id().run();
00048   int ils = iEvent.luminosityBlock();
00049   int bx = iEvent.bunchCrossing();
00050 //
00051 // trigger type
00052 //
00053   int trigger_type=-1;
00054   if (iEvent.isRealData())  trigger_type = iEvent.experimentType();
00055 
00056 
00057   //hlt info
00058   edm::Handle<TriggerResults> HLTR;
00059   iEvent.getByLabel(hlTriggerResults_,HLTR);
00060 
00061 
00062   if(HLTR.isValid() == false) {
00063         std::cout<< " HLTInspect Error - Could not access Results with name "<<hlTriggerResults_<<std::endl;
00064   }
00065   if(HLTR.isValid())
00066     {
00067       if (!init_) {
00068         init_=true;
00069         const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTR);
00070         hlNames_=triggerNames.triggerNames();
00071       }
00072       std::cout << "HLTInspect: Run " << irun << " Ev " << ievt << " LB " << ils << " BX " << bx << " Type "<<trigger_type<< " Acc: " ;
00073       const unsigned int n(hlNames_.size());
00074       for (unsigned int i=0; i!=n; ++i) 
00075             {
00076               if (HLTR->accept(i)) 
00077                 {
00078                   std::cout << hlNames_[i] << ",";
00079                 }
00080             }
00081           std::cout << std::endl;
00082         }
00083       
00084     
00085 }
00086 //define this as a plug-in
00087 DEFINE_FWK_MODULE(HLTInspect);