Imperial Analysis
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ICPileupInfoProducer.cc
Go to the documentation of this file.
2 #include <memory>
3 #include <string>
4 #include <vector>
5 #include "FWCore/Framework/interface/Event.h"
6 #include "FWCore/Framework/interface/EventSetup.h"
7 #include "FWCore/Framework/interface/MakerMacros.h"
8 #include "FWCore/ParameterSet/interface/ParameterSet.h"
9 #include "FWCore/Utilities/interface/InputTag.h"
10 #include "DataFormats/Common/interface/Handle.h"
11 #include "DataFormats/Common/interface/View.h"
12 #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
17 
18 ICPileupInfoProducer::ICPileupInfoProducer(const edm::ParameterSet& config)
19  : input_(config.getParameter<edm::InputTag>("input")),
20  branch_(config.getParameter<std::string>("branch")) {
21  consumes<edm::View<PileupSummaryInfo>>(input_);
22  info_ = new std::vector<ic::PileupInfo>();
23  PrintHeaderWithProduces(config, input_, branch_);
24 }
25 
27 
28 void ICPileupInfoProducer::produce(edm::Event& event,
29  const edm::EventSetup& setup) {
30  edm::Handle<edm::View<PileupSummaryInfo> > info_handle;
31  event.getByLabel(input_, info_handle);
32  info_->clear();
33  info_->resize(info_handle->size());
34  for (unsigned i = 0; i < info_handle->size(); ++i) {
35  PileupSummaryInfo const& src = info_handle->at(i);
36  ic::PileupInfo& dest = info_->at(i);
37  dest.set_num_interactions(src.getPU_NumInteractions());
38  dest.set_bunch_crossing(src.getBunchCrossing());
39  dest.set_true_num_interactions(src.getTrueNumInteractions());
40  }
41 }
42 
43 void ICPileupInfoProducer::beginJob() {
44  ic::StaticTree::tree_->Branch(branch_.c_str(), &info_);
45 }
46 
47 void ICPileupInfoProducer::endJob() {
48 }
49 
50 // define this as a plug-in
Stores information on the in-time or out-of-time simulated pileup interactions.
Definition: PileupInfo.hh:14
void set_bunch_crossing(int const &bunch_crossing)
Bunch crossing where zero implies in-time and non-zero out-of-time.
Definition: PileupInfo.hh:40
DEFINE_FWK_MODULE(ICPileupInfoProducer)
void set_true_num_interactions(float const &true_num_interactions)
True number of interactions used as Poisson mean for sampling.
Definition: PileupInfo.hh:45
static TTree * tree_
Definition: StaticTree.hh:13
ICPileupInfoProducer(const edm::ParameterSet &)
void set_num_interactions(int const &num_interactions)
Poisson-sampled number of interactions.
Definition: PileupInfo.hh:35
Definition: Consumes.h:19
See documentation here.
void PrintHeaderWithProduces(edm::ParameterSet const &config, edm::InputTag const &in, std::string branch)