CMS 3D CMS Logo

PUDumper.cc
Go to the documentation of this file.
2 
5  pileupSummaryToken_ = consumes<std::vector<PileupSummaryInfo> >(iConfig.getParameter<edm::InputTag>("pileupSummary"));
6 
7  // create TTree
9  PUTree_ = fs->make<TTree>("pileup", "pileup");
10 
11  PUTree_->Branch("runNumber", &runNumber, "runNumber/I");
12  PUTree_->Branch("eventNumber", &eventNumber, "eventNumber/l");
13  PUTree_->Branch("lumiBlock", &lumiBlock, "lumiBlock/I");
14 
15  PUTree_->Branch("nBX", &nBX, "nBX/I");
16  PUTree_->Branch("BX", BX_, "BX[nBX]/I");
17  PUTree_->Branch("nPUtrue", &nPUtrue_, "nPUtrue/I");
18  PUTree_->Branch("nPUobs", nPUobs_, "nPUobs[nBX]/I");
19 }
20 
21 // ----------------------------------------------------------------
22 
25 
26 // ----------------------------------------------------------------
27 
29 void PUDumper::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
30  // get the PU collection
32  if (!iEvent.isRealData()) {
33  iEvent.getByToken(pileupSummaryToken_, PupInfo);
34  } else
35  return;
36 
37  runNumber = iEvent.id().run();
38  eventNumber = iEvent.id().event();
39  if (iEvent.isRealData()) {
40  lumiBlock = iEvent.luminosityBlock();
41  } else {
42  lumiBlock = -1;
43  }
44 
45  // loop on BX
46  nBX = 0;
47  std::vector<PileupSummaryInfo>::const_iterator PVI;
48  nPUtrue_ = PupInfo->begin()->getTrueNumInteractions();
49 
50  for (PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
51  BX_[nBX] = PVI->getBunchCrossing();
52  nPUobs_[nBX] = PVI->getPU_NumInteractions();
53 #ifdef DEBUG
54  std::cout << "PUDumper::runNumber: " << runNumber_ << " BX[1]: " << BX_[1] << " nPUtrue: " << nPUtrue_
55  << " nPUobs[1]: " << nPUobs_[1] << std::endl;
56 #endif
57  nBX++;
58  }
59  PUTree_->Fill();
60 }
61 
static const char runNumber_[]
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > pileupSummaryToken_
Definition: PUDumper.h:32
Int_t nBX
Definition: PUDumper.h:40
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TTree * PUTree_
Definition: PUDumper.h:34
Int_t nPUtrue_
Definition: PUDumper.h:42
Int_t nPUobs_[100]
Definition: PUDumper.h:43
PUDumper(const edm::ParameterSet &)
ctor
Definition: PUDumper.cc:4
Int_t lumiBlock
lumi section
Definition: PUDumper.h:38
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Long64_t eventNumber
Definition: PUDumper.h:37
~PUDumper() override
dtor
Definition: PUDumper.cc:24
Int_t BX_[100]
Definition: PUDumper.h:41
Int_t runNumber
Definition: PUDumper.h:36
void analyze(const edm::Event &, const edm::EventSetup &) override
the actual analyze method
Definition: PUDumper.cc:29