CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/HLTrigger/special/src/HLTPhysicsDeclared.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:   HLTPhysicsDeclared
00004 // Class:     HLTPhysicsDeclared
00005 //
00006 // Original Author:     Luca Malgeri
00007 // Adapted for HLT by:  Andrea Bocci
00008 
00009 // user include files
00010 #include "FWCore/Framework/interface/Frameworkfwd.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EDFilter.h"
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "FWCore/Utilities/interface/InputTag.h"
00015 //
00016 // class declaration
00017 //
00018 
00019 class HLTPhysicsDeclared : public edm::EDFilter {
00020 public:
00021   explicit HLTPhysicsDeclared( const edm::ParameterSet & );
00022   ~HLTPhysicsDeclared();
00023   
00024 private:
00025   virtual bool filter( edm::Event &, const edm::EventSetup & );
00026 
00027   bool          m_invert;
00028   edm::InputTag m_gtDigis;
00029   
00030 };
00031 
00032 // system include files
00033 #include <memory>
00034 
00035 // user include files
00036 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00037 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
00038 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00039 
00040 using namespace edm;
00041 
00042 HLTPhysicsDeclared::HLTPhysicsDeclared(const edm::ParameterSet & config) :
00043   m_invert(  config.getParameter<bool>("invert") ),
00044   m_gtDigis( config.getParameter<edm::InputTag>("L1GtReadoutRecordTag") )
00045 {
00046 }
00047 
00048 HLTPhysicsDeclared::~HLTPhysicsDeclared()
00049 {
00050 }
00051 
00052 bool HLTPhysicsDeclared::filter( edm::Event & event, const edm::EventSetup & setup)
00053 {
00054   bool accept = false;
00055 
00056   if (event.isRealData()) {
00057     // for real data, access the "physics enabled" bit in the L1 GT data
00058     edm::Handle<L1GlobalTriggerReadoutRecord> h_gtDigis;
00059     if (not event.getByLabel(m_gtDigis, h_gtDigis)) {
00060       edm::LogWarning(h_gtDigis.whyFailed()->category()) << h_gtDigis.whyFailed()->what();
00061       // not enough informations to make a decision - reject the event
00062       return false;
00063     } else {
00064       L1GtFdlWord fdlWord = h_gtDigis->gtFdlWord();
00065       if (fdlWord.physicsDeclared() == 1) 
00066         accept = true;
00067     }
00068   } else {
00069     // for MC, assume the "physics enabled" bit to be always set
00070     accept = true;
00071   }
00072 
00073   // if requested, invert the filter decision
00074   if (m_invert)
00075     accept = not accept;
00076 
00077   return accept;
00078 }
00079 
00080 // define this as a framework plug-in
00081 #include "FWCore/Framework/interface/MakerMacros.h"
00082 DEFINE_FWK_MODULE(HLTPhysicsDeclared);