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