CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DPGAnalysis/Skims/src/PhysDecl.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/PhysDecl.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 PhysDecl::PhysDecl(const edm::ParameterSet& iConfig)
00034 {
00035   applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter",true);
00036   debugOn     = iConfig.getUntrackedParameter<bool>("debugOn",false);
00037   hlTriggerResults_ = iConfig.getParameter<edm::InputTag> ("HLTriggerResults");
00038   init_ = false;
00039 }
00040 
00041 PhysDecl::~PhysDecl()
00042 {
00043 }
00044 
00045 bool PhysDecl::filter( edm::Event& iEvent, const edm::EventSetup& iSetup)
00046 {
00047 
00048   bool accepted = false;
00049 
00050   int ievt = iEvent.id().event();
00051   int irun = iEvent.id().run();
00052   int ils = iEvent.luminosityBlock();
00053   int bx = iEvent.bunchCrossing();
00054 
00055 
00056   //hlt info
00057   edm::Handle<TriggerResults> HLTR;
00058   iEvent.getByLabel(hlTriggerResults_,HLTR);
00059 
00060   if(HLTR.isValid())
00061     {
00062       if (!init_) {
00063         init_=true;
00064         const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTR);
00065         hlNames_=triggerNames.triggerNames();
00066       }
00067       if(debugOn)
00068         {
00069           std::cout << "HLT_debug: Run " << irun << " Ev " << ievt << " LB " << ils << " BX " << bx << " Acc: " ;
00070           const unsigned int n(hlNames_.size());
00071           for (unsigned int i=0; i!=n; ++i) 
00072             {
00073               if (HLTR->accept(i)) 
00074                 {
00075                   std::cout << hlNames_[i] << ",";
00076                 }
00077             }
00078           std::cout << std::endl;
00079         }
00080       
00081     }
00082 
00083   // trigger info
00084 
00085   edm::Handle<L1GlobalTriggerReadoutRecord> gtrr_handle;
00086   iEvent.getByLabel("gtDigis", gtrr_handle);
00087   L1GlobalTriggerReadoutRecord const* gtrr = gtrr_handle.product();
00088  
00089   L1GtFdlWord fdlWord = gtrr->gtFdlWord();
00090   //   std::cout << "phys decl. bit=" << fdlWord.physicsDeclared() << std::endl;
00091   if (fdlWord.physicsDeclared() ==1) accepted=true;
00092 
00093 
00094   if (debugOn) {
00095     
00096     std::cout << "PhysDecl_debug: Run " << irun << " Event " << ievt << " Lumi Block " << ils << " Bunch Crossing " << bx << " Accepted " << accepted << std::endl;
00097   }
00098  
00099   if (applyfilter)
00100     return accepted;
00101   else
00102     return true;
00103 
00104 }
00105 
00106 //define this as a plug-in
00107 DEFINE_FWK_MODULE(PhysDecl);