CMS 3D CMS Logo

PatTopSelectionAnalyzer.cc
Go to the documentation of this file.
1 #include <map>
2 #include <string>
3 
4 #include "TH1.h"
5 
12 
17 
19 public:
23  ~PatTopSelectionAnalyzer() override;
24 
25 private:
27  void beginJob() override;
29  void analyze(const edm::Event&, const edm::EventSetup&) override;
31  void endJob() override;
32 
34  bool booked(const std::string histName) const { return hists_.find(histName) != hists_.end(); };
36  void fill(const std::string histName, double value) const {
37  if (booked(histName))
38  hists_.find(histName)->second->Fill(value);
39  };
40 
41  // simple map to contain all histograms;
42  // histograms are booked in the beginJob()
43  // method
44  std::map<std::string, TH1F*> hists_;
45 
46  // input tags
51 };
52 
54  : hists_(),
55  elecsToken_(consumes<edm::View<pat::Electron> >(iConfig.getUntrackedParameter<edm::InputTag>("elecs"))),
56  muonsToken_(consumes<edm::View<pat::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("muons"))),
57  jetsToken_(consumes<edm::View<pat::Jet> >(iConfig.getUntrackedParameter<edm::InputTag>("jets"))),
58  metToken_(consumes<edm::View<pat::MET> >(iConfig.getUntrackedParameter<edm::InputTag>("met"))) {}
59 
61 
63  // get electron collection
65  iEvent.getByToken(elecsToken_, elecs);
66 
67  // get muon collection
69  iEvent.getByToken(muonsToken_, muons);
70 
71  // get jet collection
73  iEvent.getByToken(jetsToken_, jets);
74 
75  // get met collection
77  iEvent.getByToken(metToken_, met);
78 
79  // fill yield
80  fill("yield", 0.5);
81 
82  // fill quantities for leading elec and elec multiplicity
83  fill("elecMult", elecs->size());
84  if (elecs->begin() != elecs->end()) {
85  fill("elecIso", (elecs->begin()->trackIso() + elecs->begin()->caloIso()) / elecs->begin()->pt());
86  fill("elecPt", elecs->begin()->pt());
87  }
88 
89  // fill quantities for leading muon and muon multiplicity
90  fill("muonMult", muons->size());
91  if (muons->begin() != muons->end()) {
92  fill("muonIso", (muons->begin()->trackIso() + muons->begin()->caloIso()) / muons->begin()->pt());
93  fill("muonPt", muons->begin()->pt());
94  }
95 
96  // fill quantities for leading jets and jet multiplicity
97  // jet pt is corrected up to L3Absolute
98  fill("jetMult", jets->size());
99  if (!jets->empty())
100  fill("jet0Pt", (*jets)[0].pt());
101  if (jets->size() > 1)
102  fill("jet1Pt", (*jets)[1].pt());
103  if (jets->size() > 2)
104  fill("jet2Pt", (*jets)[2].pt());
105  if (jets->size() > 3)
106  fill("jet3Pt", (*jets)[3].pt());
107 
108  // fill MET
109  fill("met", met->empty() ? 0 : (*met)[0].et());
110 }
111 
113  // register to the TFileService
115 
116  // book histograms:
117  hists_["yield"] = fs->make<TH1F>("yield", "electron multiplicity", 1, 0., 1.);
118  hists_["elecMult"] = fs->make<TH1F>("elecMult", "electron multiplicity", 10, 0., 10.);
119  hists_["elecIso"] = fs->make<TH1F>("elecIso", "electron isolation", 20, 0., 1.);
120  hists_["elecPt"] = fs->make<TH1F>("elecPt", "electron pt", 30, 0., 150.);
121  hists_["muonMult"] = fs->make<TH1F>("muonMult", "muon multiplicity", 10, 0., 10.);
122  hists_["muonIso"] = fs->make<TH1F>("muonIso", "muon isolation", 20, 0., 1.);
123  hists_["muonPt"] = fs->make<TH1F>("muonPt", "muon pt", 30, 0., 150.);
124  hists_["jetMult"] = fs->make<TH1F>("jetMult", "jet multiplicity", 15, 0., 15.);
125  hists_["jet0Pt"] = fs->make<TH1F>("jet0Pt", "1. leading jet pt", 50, 0., 250.);
126  hists_["jet1Pt"] = fs->make<TH1F>("jet1Pt", "1. leading jet pt", 50, 0., 250.);
127  hists_["jet2Pt"] = fs->make<TH1F>("jet2Pt", "1. leading jet pt", 50, 0., 200.);
128  hists_["jet3Pt"] = fs->make<TH1F>("jet3Pt", "1. leading jet pt", 50, 0., 200.);
129  hists_["met"] = fs->make<TH1F>("met", "missing E_{T}", 25, 0., 200.);
130 }
131 
133 
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
PatTopSelectionAnalyzer::~PatTopSelectionAnalyzer
~PatTopSelectionAnalyzer() override
default destructor
Definition: PatTopSelectionAnalyzer.cc:60
sistrip::View
View
Definition: ConstantsForView.h:26
edm::EDGetTokenT
Definition: EDGetToken.h:33
Electron
Definition: Electron.py:1
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
PatTopSelectionAnalyzer::endJob
void endJob() override
everything that needs to be done after the event loop
Definition: PatTopSelectionAnalyzer.cc:132
EDAnalyzer.h
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle
Definition: AssociativeIterator.h:50
Muon
Definition: Muon.py:1
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
PatTopSelectionAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
everything that needs to be done during the event loop
Definition: PatTopSelectionAnalyzer.cc:62
PatTopSelectionAnalyzer::beginJob
void beginJob() override
everything that needs to be done before the event loop
Definition: PatTopSelectionAnalyzer.cc:112
MakerMacros.h
PatTopSelectionAnalyzer
Definition: PatTopSelectionAnalyzer.cc:18
PatTopSelectionAnalyzer::metToken_
edm::EDGetTokenT< edm::View< pat::MET > > metToken_
Definition: PatTopSelectionAnalyzer.cc:50
PatTopSelectionAnalyzer::elecsToken_
edm::EDGetTokenT< edm::View< pat::Electron > > elecsToken_
Definition: PatTopSelectionAnalyzer.cc:47
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Jet
Definition: Jet.py:1
PatTopSelectionAnalyzer::PatTopSelectionAnalyzer
PatTopSelectionAnalyzer(const edm::ParameterSet &)
default constructor
Definition: PatTopSelectionAnalyzer.cc:53
Service.h
singleTopDQM_cfi.elecs
elecs
Definition: singleTopDQM_cfi.py:41
PatTopSelectionAnalyzer::jetsToken_
edm::EDGetTokenT< edm::View< pat::Jet > > jetsToken_
Definition: PatTopSelectionAnalyzer.cc:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
PatTopSelectionAnalyzer::muonsToken_
edm::EDGetTokenT< edm::View< pat::Muon > > muonsToken_
Definition: PatTopSelectionAnalyzer.cc:48
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
value
Definition: value.py:1
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
MET.h
Jet.h
InputTag.h
PatTopSelectionAnalyzer::booked
bool booked(const std::string histName) const
check if histogram was booked
Definition: PatTopSelectionAnalyzer.cc:34
PatTopSelectionAnalyzer::hists_
std::map< std::string, TH1F * > hists_
Definition: PatTopSelectionAnalyzer.cc:39
MET
PatTopSelectionAnalyzer::fill
void fill(const std::string histName, double value) const
fill histogram if it had been booked before
Definition: PatTopSelectionAnalyzer.cc:36
Electron.h
ParameterSet.h
edm::Event
Definition: Event.h:73
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64