CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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->size()<1 || !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 
int i
Definition: DBlmapReader.cc:9
virtual void beginJob()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
virtual void analyze(const edm::Event &, const edm::EventSetup &)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
TopElecAnalyzer(const edm::ParameterSet &)
edm::EDGetTokenT< std::vector< pat::Electron > > inputToken_
tuple cout
Definition: gather_cfg.py:121
virtual void endJob()
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")