Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:35

0001 // -*- C++ -*-
0002 //
0003 // Package:    EventWithHistoryProducer
0004 // Class:      EventWithHistoryProducer
0005 //
0006 /**\class EventWithHistoryProducer EventWithHistoryProducer.cc DPGAnalysis/SiStripTools/plugins/EventWithHistoryProducer.cc
0007 
0008  Description: EDProducer of EventWithHistory which rely on the presence of the previous event in the analyzed dataset
0009 
0010  Implementation:
0011      
0012 */
0013 //
0014 // Original Author:  Andrea Venturi
0015 //         Created:  Sun Nov 30 19:05:41 CET 2008
0016 // $Id: EventWithHistoryProducer.cc,v 1.2 2010/01/12 09:13:04 venturia Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/stream/EDProducer.h"
0026 
0027 #include "FWCore/Framework/interface/Event.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 
0033 //#include "DPGAnalysis/SiStripTools/interface/TinyEvent.h"
0034 #include "DPGAnalysis/SiStripTools/interface/EventWithHistory.h"
0035 
0036 //
0037 // class decleration
0038 //
0039 
0040 class EventWithHistoryProducer : public edm::stream::EDProducer<> {
0041 public:
0042   explicit EventWithHistoryProducer(const edm::ParameterSet&);
0043   ~EventWithHistoryProducer() override;
0044 
0045 private:
0046   void produce(edm::Event&, const edm::EventSetup&) override;
0047 
0048   // ----------member data ---------------------------
0049 
0050   const unsigned int _depth;
0051   EventWithHistory _prevHE;
0052 };
0053 
0054 //
0055 // constants, enums and typedefs
0056 //
0057 
0058 //
0059 // static data member definitions
0060 //
0061 
0062 //
0063 // constructors and destructor
0064 //
0065 EventWithHistoryProducer::EventWithHistoryProducer(const edm::ParameterSet& iConfig)
0066     : _depth(iConfig.getUntrackedParameter<unsigned int>("historyDepth")), _prevHE() {
0067   produces<EventWithHistory>();
0068 
0069   //now do what ever other initialization is needed
0070 }
0071 
0072 EventWithHistoryProducer::~EventWithHistoryProducer() {
0073   // do anything here that needs to be done at desctruction time
0074   // (e.g. close files, deallocate resources etc.)
0075 }
0076 
0077 //
0078 // member functions
0079 //
0080 
0081 // ------------ method called to produce the data  ------------
0082 void EventWithHistoryProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0083   using namespace edm;
0084 
0085   std::unique_ptr<EventWithHistory> heOut(
0086       new EventWithHistory(iEvent.id().event(), iEvent.orbitNumber(), iEvent.bunchCrossing()));
0087   heOut->add(_prevHE, _depth);
0088 
0089   if (*heOut < _prevHE)
0090     edm::LogInfo("EventsNotInOrder") << " Events not in order " << _prevHE._event;
0091 
0092   _prevHE = *heOut;
0093   iEvent.put(std::move(heOut));
0094 }
0095 
0096 //define this as a plug-in
0097 DEFINE_FWK_MODULE(EventWithHistoryProducer);