CMS 3D CMS Logo

TauValidationMiniAOD.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TauValidationMiniAOD
4 // Class: TauValidationMiniAOD
5 //
15 //
16 // Original Author: Aniello Spiezia
17 // Created: August 13, 2019
18 
20 
21 using namespace edm;
22 using namespace std;
23 using namespace reco;
24 
26  tauCollection_ = consumes<pat::TauCollection>(iConfig.getParameter<InputTag>("tauCollection"));
27  refCollectionInputTagToken_ = consumes<edm::View<reco::Candidate> >(iConfig.getParameter<InputTag>("RefCollection"));
28  extensionName_ = iConfig.getParameter<string>("ExtensionName");
29  discriminators_ = iConfig.getParameter<std::vector<edm::ParameterSet> >("discriminators");
30 }
31 
33 
35  edm::Run const& iRun,
36  edm::EventSetup const& /* iSetup */) {
37  MonitorElement *ptTemp, *etaTemp, *phiTemp, *massTemp, *decayModeFindingTemp, *decayModeTemp,
38  *byDeepTau2017v2p1VSerawTemp, *byDeepTau2017v2p1VSjetrawTemp, *byDeepTau2017v2p1VSmurawTemp, *summaryTemp;
39  ibooker.setCurrentFolder("RecoTauV/miniAODValidation" + extensionName_);
40 
41  //summary plots
42  histoInfo summaryHinfo = (histoSettings_.exists("summary"))
43  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("summary"))
44  : histoInfo(21, -0.5, 20.5);
45  summaryTemp =
46  ibooker.book1D("summaryPlotNum", "summaryPlotNum", summaryHinfo.nbins, summaryHinfo.min, summaryHinfo.max);
47  summaryMap.insert(std::make_pair("Num", summaryTemp));
48  summaryTemp =
49  ibooker.book1D("summaryPlotDen", "summaryPlotDen", summaryHinfo.nbins, summaryHinfo.min, summaryHinfo.max);
50  summaryMap.insert(std::make_pair("Den", summaryTemp));
51  summaryTemp = ibooker.book1D("summaryPlot", "summaryPlot", summaryHinfo.nbins, summaryHinfo.min, summaryHinfo.max);
52  summaryMap.insert(std::make_pair("", summaryTemp));
53 
54  int j = 0;
55  for (const auto& it : discriminators_) {
56  string DiscriminatorLabel = it.getParameter<string>("discriminator");
57  summaryMap.find("Den")->second->setBinLabel(j + 1, DiscriminatorLabel);
58  summaryMap.find("Num")->second->setBinLabel(j + 1, DiscriminatorLabel);
59  summaryMap.find("")->second->setBinLabel(j + 1, DiscriminatorLabel);
60  j = j + 1;
61  }
62 
63  //other plots
64  histoInfo ptHinfo = (histoSettings_.exists("pt")) ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("pt"))
65  : histoInfo(200, 0., 1000.);
66  histoInfo etaHinfo = (histoSettings_.exists("eta")) ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("eta"))
67  : histoInfo(200, -3, 3.);
68  histoInfo phiHinfo = (histoSettings_.exists("phi")) ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("phi"))
69  : histoInfo(200, -3, 3.);
70  histoInfo massHinfo = (histoSettings_.exists("mass"))
71  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("mass"))
72  : histoInfo(200, 0, 10.);
73  histoInfo decayModeFindingHinfo = (histoSettings_.exists("decayModeFinding"))
74  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("decayModeFinding"))
75  : histoInfo(2, -0.5, 1.5);
76  histoInfo decayModeHinfo = (histoSettings_.exists("decayMode"))
77  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("decayMode"))
78  : histoInfo(11, -0.5, 10.5);
79  histoInfo byDeepTau2017v2p1VSerawHinfo =
80  (histoSettings_.exists("byDeepTau2017v2p1VSeraw"))
81  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("byDeepTau2017v2p1VSeraw"))
82  : histoInfo(200, 0., 1.);
83  histoInfo byDeepTau2017v2p1VSjetrawHinfo =
84  (histoSettings_.exists("byDeepTau2017v2p1VSjetraw"))
85  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("byDeepTau2017v2p1VSjetraw"))
86  : histoInfo(200, 0., 1.);
87  histoInfo byDeepTau2017v2p1VSmurawHinfo =
88  (histoSettings_.exists("byDeepTau2017v2p1VSmuraw"))
89  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("byDeepTau2017v2p1VSmuraw"))
90  : histoInfo(200, 0., 1.);
91  ptTemp = ibooker.book1D("tau_pt", "tau_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
92  etaTemp = ibooker.book1D("tau_eta", "tau_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
93  phiTemp = ibooker.book1D("tau_phi", "tau_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
94  massTemp = ibooker.book1D("tau_mass", "tau_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
95  decayModeFindingTemp = ibooker.book1D("tau_decayModeFinding",
96  "tau_decayModeFinding",
97  decayModeFindingHinfo.nbins,
98  decayModeFindingHinfo.min,
99  decayModeFindingHinfo.max);
100  decayModeTemp =
101  ibooker.book1D("tau_decayMode", "tau_decayMode", decayModeHinfo.nbins, decayModeHinfo.min, decayModeHinfo.max);
102  byDeepTau2017v2p1VSerawTemp = ibooker.book1D("tau_byDeepTau2017v2p1VSeraw",
103  "tau_byDeepTau2017v2p1VSeraw",
104  byDeepTau2017v2p1VSerawHinfo.nbins,
105  byDeepTau2017v2p1VSerawHinfo.min,
106  byDeepTau2017v2p1VSerawHinfo.max);
107  byDeepTau2017v2p1VSjetrawTemp = ibooker.book1D("tau_byDeepTau2017v2p1VSjetraw",
108  "tau_byDeepTau2017v2p1VSjetraw",
109  byDeepTau2017v2p1VSjetrawHinfo.nbins,
110  byDeepTau2017v2p1VSjetrawHinfo.min,
111  byDeepTau2017v2p1VSjetrawHinfo.max);
112  byDeepTau2017v2p1VSmurawTemp = ibooker.book1D("tau_byDeepTau2017v2p1VSmuraw",
113  "tau_byDeepTau2017v2p1VSmuraw",
114  byDeepTau2017v2p1VSmurawHinfo.nbins,
115  byDeepTau2017v2p1VSmurawHinfo.min,
116  byDeepTau2017v2p1VSmurawHinfo.max);
117  ptMap.insert(std::make_pair("", ptTemp));
118  etaMap.insert(std::make_pair("", etaTemp));
119  phiMap.insert(std::make_pair("", phiTemp));
120  massMap.insert(std::make_pair("", massTemp));
121  decayModeFindingMap.insert(std::make_pair("", decayModeFindingTemp));
122  decayModeMap.insert(std::make_pair("", decayModeTemp));
123  byDeepTau2017v2p1VSerawMap.insert(std::make_pair("", byDeepTau2017v2p1VSerawTemp));
124  byDeepTau2017v2p1VSjetrawMap.insert(std::make_pair("", byDeepTau2017v2p1VSjetrawTemp));
125  byDeepTau2017v2p1VSmurawMap.insert(std::make_pair("", byDeepTau2017v2p1VSmurawTemp));
126 }
127 
130  bool isTau = iEvent.getByToken(tauCollection_, taus);
131  if (!isTau) {
132  std::cerr << " Tau collection not found while running TauValidationMiniAOD.cc " << std::endl;
133  return;
134  }
135  typedef edm::View<reco::Candidate> refCandidateCollection;
136  Handle<refCandidateCollection> ReferenceCollection;
137  bool isRef = iEvent.getByToken(refCollectionInputTagToken_, ReferenceCollection);
138  if (!isRef) {
139  std::cerr << " Reference collection not found while running TauValidationMiniAOD.cc " << std::endl;
140  return;
141  }
142  for (refCandidateCollection::const_iterator RefJet = ReferenceCollection->begin();
143  RefJet != ReferenceCollection->end();
144  RefJet++) {
145  float dRmin = 0.15;
146  unsigned matchedTauIndex = -99;
147  for (unsigned iTau = 0; iTau < taus->size(); iTau++) {
148  pat::TauRef tau(taus, iTau);
149  //for (pat::TauCollection::const_iterator tau = taus->begin(); tau != taus->end(); tau++) {
150  //pat::TauRef matchedTau(*tau);
151  float dR = deltaR(tau->eta(), tau->phi(), RefJet->eta(), RefJet->phi());
152  if (dR < dRmin) {
153  dRmin = dR;
154  matchedTauIndex = iTau;
155  }
156  }
157  if (dRmin < 0.15) {
158  pat::TauRef matchedTau(taus, matchedTauIndex);
159  ptMap.find("")->second->Fill(matchedTau->pt());
160  etaMap.find("")->second->Fill(matchedTau->eta());
161  phiMap.find("")->second->Fill(matchedTau->phi());
162  massMap.find("")->second->Fill(matchedTau->mass());
163  decayModeMap.find("")->second->Fill(matchedTau->decayMode());
164  if (matchedTau->isTauIDAvailable("decayModeFinding"))
165  decayModeFindingMap.find("")->second->Fill(matchedTau->tauID("decayModeFinding"));
166  if (matchedTau->isTauIDAvailable("byDeepTau2017v2p1VSeraw"))
167  byDeepTau2017v2p1VSerawMap.find("")->second->Fill(matchedTau->tauID("byDeepTau2017v2p1VSeraw"));
168  if (matchedTau->isTauIDAvailable("byDeepTau2017v2p1VSjetraw"))
169  byDeepTau2017v2p1VSjetrawMap.find("")->second->Fill(matchedTau->tauID("byDeepTau2017v2p1VSjetraw"));
170  if (matchedTau->isTauIDAvailable("byDeepTau2017v2p1VSmuraw"))
171  byDeepTau2017v2p1VSmurawMap.find("")->second->Fill(matchedTau->tauID("byDeepTau2017v2p1VSmuraw"));
172  int j = 0;
173  for (const auto& it : discriminators_) {
174  string currentDiscriminator = it.getParameter<string>("discriminator");
175  double selectionCut = it.getParameter<double>("selectionCut");
176  summaryMap.find("Den")->second->Fill(j);
177  if (matchedTau->tauID(currentDiscriminator) >= selectionCut)
178  summaryMap.find("Num")->second->Fill(j);
179  j = j + 1;
180  }
181  }
182  }
183 }
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
TauValidationMiniAOD(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
fixed size matrix
HLT enums.
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: Run.h:45
bool isTau(const Candidate &part)
Definition: pdgIdUtils.h:11