CMS 3D CMS Logo

TopElecAnalyzer.cc
Go to the documentation of this file.
2 
4  : inputToken_(consumes<std::vector<pat::Electron> >(cfg.getParameter<edm::InputTag>("input"))),
5  verbose_(cfg.getParameter<bool>("verbose")) {
7 
8  mult_ = fs->make<TH1F>("mult", "multiplicity (electrons)", 10, 0, 10);
9  en_ = fs->make<TH1F>("en", "energy (electrons)", 60, 0., 300.);
10  pt_ = fs->make<TH1F>("pt", "pt (electrons)", 60, 0., 300.);
11  eta_ = fs->make<TH1F>("eta", "eta (electrons)", 30, -3., 3.);
12  phi_ = fs->make<TH1F>("phi", "phi (electrons)", 40, -4., 4.);
13 }
14 
16 
19  evt.getByToken(inputToken_, elecs);
20 
21  // fill histograms
22 
23  mult_->Fill(elecs->size());
24  for (std::vector<pat::Electron>::const_iterator elec = elecs->begin(); elec != elecs->end(); ++elec) {
25  en_->Fill(elec->energy());
26  pt_->Fill(elec->pt());
27  eta_->Fill(elec->eta());
28  phi_->Fill(elec->phi());
29  }
30 
31  // produce printout if desired
32 
33  if (elecs->empty() || !verbose_)
34  return;
35 
36  unsigned i = 0;
37 
38  std::cout << "=======================================================" << std::endl;
39  std::cout << std::setw(5) << "ele :" << std::setw(13) << "et :" << std::setw(13) << "eta :" << std::setw(13)
40  << "phi :" << std::setw(11) << "relIso" << std::endl;
41  std::cout << "-------------------------------------------------------" << std::endl;
42  for (std::vector<pat::Electron>::const_iterator elec = elecs->begin(); elec != elecs->end(); ++elec) {
43  std::cout << std::setw(3) << i << " : " << std::setw(10) << elec->pt() << " : " << std::setw(10) << elec->eta()
44  << " : " << std::setw(10) << elec->phi() << " : " << std::setw(10)
45  << (elec->dr03TkSumPt() + elec->dr03EcalRecHitSumEt() + elec->dr03HcalTowerSumEt()) / elec->et()
46  << std::endl;
47  i++;
48  }
49  std::cout << "=======================================================" << std::endl;
50 }
51 
53 
void endJob() override
~TopElecAnalyzer() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
TopElecAnalyzer(const edm::ParameterSet &)
Definition: HeavyIon.h:7
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< std::vector< pat::Electron > > inputToken_
void beginJob() override
HLT enums.