CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/FWCore/Modules/src/EventAuxiliaryHistoryProducer.cc

Go to the documentation of this file.
00001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00002 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00004 #include "FWCore/Framework/interface/EDProducer.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
00007 #include "FWCore/Framework/interface/MakerMacros.h"
00008 #include <deque>
00009 
00010 namespace edm {
00011 
00012   class EventAuxiliaryHistoryProducer : public EDProducer {
00013   public:
00014     explicit EventAuxiliaryHistoryProducer(ParameterSet const&);
00015     virtual ~EventAuxiliaryHistoryProducer();
00016 
00017     static void fillDescriptions(ConfigurationDescriptions& descriptions);
00018     virtual void produce(Event& e, EventSetup const& c);
00019     void endJob();
00020 
00021   private:
00022     unsigned int depth_;
00023     std::deque<EventAuxiliary> history_; 
00024   };
00025 
00026   EventAuxiliaryHistoryProducer::EventAuxiliaryHistoryProducer(ParameterSet const& ps):
00027     depth_(ps.getParameter<unsigned int>("historyDepth")),
00028     history_() {
00029       produces<std::vector<EventAuxiliary> > ();
00030   }
00031 
00032   EventAuxiliaryHistoryProducer::~EventAuxiliaryHistoryProducer() {
00033   }
00034 
00035   void EventAuxiliaryHistoryProducer::produce(Event& e, EventSetup const&) {
00036     EventAuxiliary aux(e.id(), "", e.time(), e.isRealData(), e.experimentType(),
00037                        e.bunchCrossing(), EventAuxiliary::invalidStoreNumber, e.orbitNumber()); 
00038   //EventAuxiliary const& aux = e.auxiliary(); // when available
00039     if(history_.size() > 0) {
00040       if(history_.back().id().next(aux.luminosityBlock()) != aux.id()) history_.clear();
00041       if(history_.size() >= depth_) history_.pop_front();
00042     }
00043 
00044     history_.push_back(aux);
00045 
00046     //Serialize into std::vector 
00047     std::auto_ptr<std::vector<EventAuxiliary > > result(new std::vector<EventAuxiliary>);
00048     for(size_t j = 0; j < history_.size(); ++j) { 
00049       result->push_back(history_[j]);
00050     }
00051     e.put(result);
00052   }
00053 
00054   void EventAuxiliaryHistoryProducer::endJob() {
00055   }
00056 
00057 
00058   void
00059   EventAuxiliaryHistoryProducer::fillDescriptions(ConfigurationDescriptions& descriptions) {
00060     ParameterSetDescription desc;
00061     desc.add<unsigned int>("historyDepth");
00062     descriptions.add("eventAuxiliaryHistory", desc);
00063   }
00064 }
00065 
00066 using edm::EventAuxiliaryHistoryProducer;
00067 DEFINE_FWK_MODULE(EventAuxiliaryHistoryProducer);