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"))
6 {
8 
9  mult_ = fs->make<TH1F>("mult", "multiplicity (electrons)", 10, 0 , 10);
10  en_ = fs->make<TH1F>("en" , "energy (electrons)" , 60, 0., 300.);
11  pt_ = fs->make<TH1F>("pt" , "pt (electrons)" , 60, 0., 300.);
12  eta_ = fs->make<TH1F>("eta" , "eta (electrons)" , 30, -3., 3.);
13  phi_ = fs->make<TH1F>("phi" , "phi (electrons)" , 40, -4., 4.);
14 }
15 
17 {
18 }
19 
20 void
22 {
24  evt.getByToken(inputToken_, elecs);
25 
26  // fill histograms
27 
28  mult_->Fill( elecs->size() );
29  for(std::vector<pat::Electron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
30  en_ ->Fill( elec->energy() );
31  pt_ ->Fill( elec->pt() );
32  eta_->Fill( elec->eta() );
33  phi_->Fill( elec->phi() );
34  }
35 
36  // produce printout if desired
37 
38  if( elecs->empty() || !verbose_ )
39  return;
40 
41  unsigned i=0;
42 
43  std::cout << "======================================================="
44  << std::endl;
45  std::cout << std::setw(5 ) << "ele :"
46  << std::setw(13) << "et :"
47  << std::setw(13) << "eta :"
48  << std::setw(13) << "phi :"
49  << std::setw(11) << "relIso" << std::endl;
50  std::cout << "-------------------------------------------------------"
51  << std::endl;
52  for(std::vector<pat::Electron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
53  std::cout << std::setw(3 ) << i << " : "
54  << std::setw(10) << elec->pt() << " : "
55  << std::setw(10) << elec->eta() << " : "
56  << std::setw(10) << elec->phi() << " : "
57  << std::setw(10) << (elec->dr03TkSumPt()+elec->dr03EcalRecHitSumEt()+elec->dr03HcalTowerSumEt())/elec->et() << std::endl;
58  i++;
59  }
60  std::cout << "======================================================="
61  << std::endl;
62 }
63 
65 {
66 }
67 
69 {
70 }
71 
void endJob() override
~TopElecAnalyzer() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
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.