Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-01 01:02:24

0001 //
0002 // Original Author:  Pietro Govoni
0003 //         Created:  Thu Aug 10 16:21:22 CEST 2006
0004 //
0005 //
0006 
0007 // system include files
0008 #include <memory>
0009 
0010 // user include files
0011 #include "FWCore/Framework/interface/Frameworkfwd.h"
0012 
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 
0018 #include "RecoTBCalo/EcalTBRecProducers/interface/IsTBH4Type.h"
0019 #include "TBDataFormats/EcalTBObjects/interface/EcalTBEventHeader.h"
0020 
0021 //
0022 // constants, enums and typedefs
0023 //
0024 
0025 //
0026 // static data member definitions
0027 //
0028 
0029 //
0030 // constructors and destructor
0031 //
0032 IsTBH4Type::IsTBH4Type(const edm::ParameterSet& iConfig) {
0033   //now do what ever initialization is needed
0034   eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
0035   eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
0036   typeToFlag_ = iConfig.getParameter<std::string>("typeToFlag");
0037   notFound_ = iConfig.getUntrackedParameter<bool>("ifHeaderNotFound", false);
0038 }
0039 
0040 //
0041 // member functions
0042 //
0043 
0044 // ------------ method called to produce the data  ------------
0045 bool IsTBH4Type::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0046   using namespace edm;
0047 
0048   Handle<EcalTBEventHeader> pEventHeader;
0049   const EcalTBEventHeader* evtHeader = nullptr;
0050   iEvent.getByLabel(eventHeaderProducer_, pEventHeader);
0051   if (!pEventHeader.isValid()) {
0052     edm::LogError("IsTBH4Type") << "Event Header collection not found";
0053   } else {
0054     evtHeader = pEventHeader.product();  // get a ptr to the product
0055   }
0056 
0057   if (!evtHeader)
0058     return notFound_;
0059   //   std::cout << "PIETRO " << evtHeader->eventType () << std::endl ;
0060   //   std::cout << "PIETRO " << (evtHeader->eventType () != typeToFlag_) << std::endl ;
0061   if (evtHeader->eventType() != typeToFlag_)
0062     return false;
0063 
0064   return true;
0065 }