Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:38

0001 #include "Calibration/EcalAlCaRecoProducers/plugins/PUDumper.h"
0002 
0003 //! ctor
0004 PUDumper::PUDumper(const edm::ParameterSet& iConfig) {
0005   pileupSummaryToken_ = consumes<std::vector<PileupSummaryInfo> >(iConfig.getParameter<edm::InputTag>("pileupSummary"));
0006 
0007   // create TTree
0008   edm::Service<TFileService> fs;
0009   PUTree_ = fs->make<TTree>("pileup", "pileup");
0010 
0011   PUTree_->Branch("runNumber", &runNumber, "runNumber/I");
0012   PUTree_->Branch("eventNumber", &eventNumber, "eventNumber/l");
0013   PUTree_->Branch("lumiBlock", &lumiBlock, "lumiBlock/I");
0014 
0015   PUTree_->Branch("nBX", &nBX, "nBX/I");
0016   PUTree_->Branch("BX", BX_, "BX[nBX]/I");
0017   PUTree_->Branch("nPUtrue", &nPUtrue_, "nPUtrue/I");
0018   PUTree_->Branch("nPUobs", nPUobs_, "nPUobs[nBX]/I");
0019 }
0020 
0021 // ----------------------------------------------------------------
0022 
0023 //! dtor
0024 PUDumper::~PUDumper() {}
0025 
0026 // ----------------------------------------------------------------
0027 
0028 //! loop over the reco particles and count leptons
0029 void PUDumper::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0030   // get the PU collection
0031   edm::Handle<std::vector<PileupSummaryInfo> > PupInfo;
0032   if (!iEvent.isRealData()) {
0033     iEvent.getByToken(pileupSummaryToken_, PupInfo);
0034   } else
0035     return;
0036 
0037   runNumber = iEvent.id().run();
0038   eventNumber = iEvent.id().event();
0039   if (iEvent.isRealData()) {
0040     lumiBlock = iEvent.luminosityBlock();
0041   } else {
0042     lumiBlock = -1;
0043   }
0044 
0045   // loop on BX
0046   nBX = 0;
0047   std::vector<PileupSummaryInfo>::const_iterator PVI;
0048   nPUtrue_ = PupInfo->begin()->getTrueNumInteractions();
0049 
0050   for (PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
0051     BX_[nBX] = PVI->getBunchCrossing();
0052     nPUobs_[nBX] = PVI->getPU_NumInteractions();
0053 #ifdef DEBUG
0054     std::cout << "PUDumper::runNumber: " << runNumber_ << "   BX[1]: " << BX_[1] << "   nPUtrue: " << nPUtrue_
0055               << "   nPUobs[1]: " << nPUobs_[1] << std::endl;
0056 #endif
0057     nBX++;
0058   }
0059   PUTree_->Fill();
0060 }
0061 
0062 DEFINE_FWK_MODULE(PUDumper);