CMS 3D CMS Logo

PatZjetsElectronAnalyzer.cc
Go to the documentation of this file.
1 #include <map>
2 #include <string>
3 
4 #include "TH1.h"
5 
12 
14 
16 
17 public:
19  ~PatZjetsElectronAnalyzer() override;
20 
21 private:
22 
23  void beginJob() override ;
24  void analyze(const edm::Event&, const edm::EventSetup&) override;
25  void endJob() override ;
26 
27  // simple map to contain all histograms;
28  // histograms are booked in the beginJob()
29  // method
30  std::map<std::string,TH1F*> histContainer_;
31 
32  // input tags
34 };
35 
38  srcToken_(consumes<edm::View<pat::Electron> >(iConfig.getUntrackedParameter<edm::InputTag>("src")))
39 {
40 }
41 
43 {
44 }
45 
46 void
48 {
49  // get electron collection
51  iEvent.getByToken(srcToken_,elecs);
52 
53  // loop electrons
54  for(edm::View<pat::Electron>::const_iterator elec=elecs->begin(); elec!=elecs->end(); ++elec){
55  // fill simple histograms
56  histContainer_["pt" ]->Fill( elec->pt () );
57  histContainer_["eta" ]->Fill( elec->eta() );
58  histContainer_["phi" ]->Fill( elec->phi() );
59  histContainer_["iso" ]->Fill((elec->trackIso()+elec->caloIso())/elec->pt() );
60  histContainer_["eop" ]->Fill( elec->eSeedClusterOverP() );
61  histContainer_["clus"]->Fill( elec->e1x5()/elec->e5x5() );
62  // fill enegry flow histogram for isolation
63  for(int bin=1; bin<=histContainer_["dr"]->GetNbinsX(); ++bin){
64  double lowerEdge = histContainer_["dr"]->GetBinLowEdge(bin);
65  double upperEdge = histContainer_["dr"]->GetBinLowEdge(bin)+histContainer_["dr"]->GetBinWidth(bin);
66  histContainer_["dr"]->Fill(histContainer_["dr"]->GetBinCenter(bin), elec->trackIsoDeposit()->depositWithin(upperEdge) - elec->trackIsoDeposit()->depositWithin(lowerEdge));
67  }
68  // fill electron id histograms
69  if( elec->electronID("eidRobustLoose") > 0.5 )
70  histContainer_["eIDs" ]->Fill(0);
71  if( elec->electronID("eidRobustTight") > 0.5 )
72  histContainer_["eIDs" ]->Fill(1);
73  if( elec->electronID("eidLoose" ) > 0.5 )
74  histContainer_["eIDs" ]->Fill(2);
75  if( elec->electronID("eidTight" ) > 0.5 )
76  histContainer_["eIDs" ]->Fill(3);
77  if( elec->electronID("eidRobustHighEnergy") > 0.5 )
78  histContainer_["eIDs" ]->Fill(4);
79  }
80 }
81 
82 void
84 {
85  // register to the TFileService
87 
88  // book histograms:
89  histContainer_["pt" ]=fs->make<TH1F>("pt" , "pt" , 150, 0., 150.);
90  histContainer_["eta" ]=fs->make<TH1F>("eta" , "eta" , 50, 0., 5.);
91  histContainer_["phi" ]=fs->make<TH1F>("phi" , "phi" , 60, 3.14, 3.14);
92  histContainer_["iso" ]=fs->make<TH1F>("iso" , "iso" , 30, 0., 10.);
93  histContainer_["dr" ]=fs->make<TH1F>("dr" , "dr" , 40, 0., 1.);
94  histContainer_["eop" ]=fs->make<TH1F>("eop" , "eop" , 40, 0., 1.);
95  histContainer_["clus"]=fs->make<TH1F>("clus" , "clus" , 40, 0., 1.);
96  histContainer_["eIDs"]=fs->make<TH1F>("eIDs" , "eIDS" , 5, 0., 5.);
97 }
98 
99 void
101 {
102 }
103 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
void analyze(const edm::Event &, const edm::EventSetup &) override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
edm::EDGetTokenT< edm::View< pat::Electron > > srcToken_
bin
set the eta bin as selection string.
std::map< std::string, TH1F * > histContainer_
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
PatZjetsElectronAnalyzer(const edm::ParameterSet &)