// -*- C++ -*- // // Class: PlayBackRead // /**\class PlayBackRead Description: read back playback information */ // // Original Author: Mike Hildreth // Created: 17 Aug 2014 // // // system include files #include #include #include // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/Algorithms.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ModuleContextSentry.h" #include "FWCore/Framework/interface/TriggerNamesService.h" #include "FWCore/ServiceRegistry/interface/InternalContext.h" #include "FWCore/ServiceRegistry/interface/ModuleCallingContext.h" #include "FWCore/ServiceRegistry/interface/ParentContext.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Provenance/interface/Provenance.h" #include "DataFormats/Provenance/interface/BranchDescription.h" #include "SimDataFormats/CrossingFrame/interface/CrossingFramePlaybackInfoExtended.h" #include "FWCore/Utilities/interface/TypeID.h" #include "SimDataFormats/CrossingFrame/interface/CrossingFramePlaybackInfoExtended.h" #include "PlayBackRead.h" using namespace edm; PlayBackRead::PlayBackRead(const edm::ParameterSet& iConfig) : inputTagPlayback_() // level_(iConfig.getUntrackedParameter("PrintLevel")) { std::string labelPlayback; if (iConfig.exists("LabelPlayback")) { labelPlayback = iConfig.getParameter("LabelPlayback"); inputTagPlayback_ = InputTag(labelPlayback, "", edm::InputTag::kSkipCurrentProcess); consumes(inputTagPlayback_); } } PlayBackRead::~PlayBackRead() { // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) } // // member functions // // ------------ method called to analyze the data ------------ void PlayBackRead::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { edm::Handle playbackInfo_H; bool got = iEvent.getByLabel(inputTagPlayback_, playbackInfo_H); if (!got) { throw cms::Exception("MixingProductNotFound") << " No " "CrossingFramePlaybackInfoExtended on the input file, but you want playback information" << std::endl; } int minBunch_ = -3; int maxBunch_ = 3; // Have to know min, max bunch from original configuration file for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) { // 0 as first argument picks out minbias input stream // for this bunch crossing, retrieve list of events that were mixed: const std::vector& playEventID = playbackInfo_H->getStartEventId(0, bunchIdx); std::cout << " Bunch: " << bunchIdx << std::endl; for( const auto& event : playEventID) { std::cout << " Event ID " << event << std::endl; } } }