ATLAS Offline Software
Loading...
Searching...
No Matches
DiTauSelectionCuts.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// local include(s)
9
10using namespace TauAnalysisTools;
11
12//______________________________________________________________________________
14 : m_sName(sName)
15 , m_hHistCutPre(nullptr)
16 , m_hHistCut(nullptr)
17 , m_tDTST(tDTST)
18{}
19
20//______________________________________________________________________________
22{
23 // FIXME: could use unique_ptr
24 delete m_hHistCutPre;
25 delete m_hHistCut;
26}
27
28//______________________________________________________________________________
34
35//______________________________________________________________________________
36TH1F* DiTauSelectionCut::CreateControlPlot(const char* sName, const char* sTitle, int iBins, double dXLow, double dXUp)
37{
38 if (m_tDTST->m_bCreateControlPlots)
39 {
40 TH1F* hHist = new TH1F(sName, sTitle, iBins, dXLow, dXUp);
41 hHist->SetDirectory(0);
42 return hHist;
43 }
44
45 return nullptr;
46}
47
48//______________________________________________________________________________
53
54//______________________________________________________________________________
59
60
61//______________________________________________________________________________
62void DiTauSelectionCut::setProperty(const std::string& name, const std::string& value)
63{
64 std::map<std::string, std::string&>::iterator it = m_mProperties.find(name);
65 if(it == m_mProperties.end() )
66 throw std::runtime_error (("Undeclared property: " + name + "\n").c_str());
67 it->second = value;
68}
69
70//______________________________________________________________________________
71void DiTauSelectionCut::declareProperty(const std::string& name, std::string& loc)
72{
73 std::pair<std::string, std::string&> p(name, loc);
74 m_mProperties.insert(p);
75}
76
77//______________________________________________________________________________
78std::string DiTauSelectionCut::getProperty(const std::string& name)
79{
80 std::map<std::string, std::string&>::iterator it = m_mProperties.find(name);
81 if(it == m_mProperties.end() )
82 throw std::runtime_error (("Undeclared property: " + name + "\n").c_str());
83
84 return it->second;
85}
86
87
88//_______________________________SelectionCutPt_________________________________
89//______________________________________________________________________________
91 : DiTauSelectionCut("CutPt", tDTST)
92{
93 m_hHistCutPre = CreateControlPlot("hPt_pre","Pt_pre;di-#tau-p_{T} [GeV]; events",1000,0,1000);
94 m_hHistCut = CreateControlPlot("hPt_cut","Pt_cut;di-#tau-p_{T} [GeV]; events",1000,0,1000);
95}
96
97//______________________________________________________________________________
98void DiTauSelectionCutPt::fillHistogram(const xAOD::DiTauJet& xDiTau, TH1F& hHist) const
99{
100 hHist.Fill(xDiTau.pt()/1000.);
101}
102
103//______________________________________________________________________________
105{
106 info.addCut( "Pt",
107 "Selection of ditaus according to their transverse momentum" );
108}
109//______________________________________________________________________________
111 asg::AcceptData& acceptData)
112{
113 // save ditau pt in GeV
114 double pt = xDiTau.pt() / 1000.;
115 // in case of only one entry in vector, run for lower limits
116 if (m_tDTST->m_vPtRegion.size() == 1)
117 {
118 if ( pt >= m_tDTST->m_vPtRegion.at(0) )
119 {
120 acceptData.setCutResult( "Pt", true );
121 return true;
122 }
123 }
124 unsigned int iNumPtRegion = m_tDTST->m_vPtRegion.size()/2;
125 for( unsigned int iPtRegion = 0; iPtRegion < iNumPtRegion; iPtRegion++ )
126 {
127 if ( pt >= m_tDTST->m_vPtRegion.at(iPtRegion*2) and pt <= m_tDTST->m_vPtRegion.at(iPtRegion*2+1))
128 {
129 acceptData.setCutResult( "Pt", true );
130 return true;
131 }
132 }
133 m_tDTST->msg() << MSG::VERBOSE << "DiTau failed pt requirement, ditau pt [GeV]: " << pt << endmsg;
134 return false;
135}
136
137//_____________________________SelectionCutAbsEta_______________________________
138//______________________________________________________________________________
140 : DiTauSelectionCut("CutAbsEta", tDTST)
141{
142 m_hHistCutPre = CreateControlPlot("hEta_pre","Eta_pre;di-#tau-#eta; events",100,-3,3);
143 m_hHistCut = CreateControlPlot("hEta_cut","Eta_cut;di-#tau-#eta; events",100,-3,3);
144}
145
146//______________________________________________________________________________
147void DiTauSelectionCutAbsEta::fillHistogram(const xAOD::DiTauJet& xDiTau, TH1F& hHist) const
148{
149 hHist.Fill(xDiTau.eta());
150}
151
152//______________________________________________________________________________
154{
155 info.addCut( "AbsEta",
156 "Selection of ditaus according to their absolute pseudorapidity" );
157}
158//______________________________________________________________________________
160 asg::AcceptData& acceptData)
161{
162 // check regions of eta, if ditau is in one region then return true; false otherwise
163 unsigned int iNumEtaRegion = m_tDTST->m_vAbsEtaRegion.size()/2;
164 for( unsigned int iEtaRegion = 0; iEtaRegion < iNumEtaRegion; iEtaRegion++ )
165 {
166 if ( std::abs( xDiTau.eta() ) >= m_tDTST->m_vAbsEtaRegion.at(iEtaRegion*2) and std::abs( xDiTau.eta() ) <= m_tDTST->m_vAbsEtaRegion.at(iEtaRegion*2+1))
167 {
168 acceptData.setCutResult( "AbsEta", true );
169 return true;
170 }
171 }
172 m_tDTST->msg() << MSG::VERBOSE << "DiTau failed eta requirement, ditau eta: " << xDiTau.eta() << endmsg;
173 return false;
174}
175
176//_______________________________SelectionCutNSubjets_________________________________
177//______________________________________________________________________________
179 : DiTauSelectionCut("CutNSubjets", tDTST)
180{
181 m_hHistCutPre = CreateControlPlot("hNSubjets_pre","NSubjets_pre;di-#tau NSubjets; events",30,0,30);
182 m_hHistCut = CreateControlPlot("hNSubjets_cut","NSubjets_cut;di-#tau NSubjets; events",30,0,30);
183}
184
185//______________________________________________________________________________
186void DiTauSelectionCutNSubjets::fillHistogram(const xAOD::DiTauJet& xDiTau, TH1F& hHist) const
187{
188 hHist.Fill(xDiTau.nSubjets());
189}
190
191//______________________________________________________________________________
193{
194 info.addCut( "NSubjets",
195 "Selection of ditaus according to their number of subjets" );
196}
197//______________________________________________________________________________
199 asg::AcceptData& acceptData)
200{
201 float nsubjets = xDiTau.nSubjets();
202 // in case of only one entry in vector, run for lower limits
203 if (m_tDTST->m_vNSubjetsRegion.size() == 1)
204 {
205 if ( nsubjets >= m_tDTST->m_vNSubjetsRegion.at(0) )
206 {
207 acceptData.setCutResult( "NSubjets", true );
208 return true;
209 }
210 }
211 unsigned int iNumNSubjetsRegion = m_tDTST->m_vNSubjetsRegion.size()/2;
212 for( unsigned int iNSubjetsRegion = 0; iNSubjetsRegion < iNumNSubjetsRegion; iNSubjetsRegion++ )
213 {
214 if ( nsubjets >= m_tDTST->m_vNSubjetsRegion.at(iNSubjetsRegion*2) and nsubjets <= m_tDTST->m_vNSubjetsRegion.at(iNSubjetsRegion*2+1))
215 {
216 acceptData.setCutResult( "NSubjets", true );
217 return true;
218 }
219 }
220 m_tDTST->msg() << MSG::VERBOSE << "DiTau failed NSubjets requirement, ditau number of subjets: " << nsubjets << endmsg;
221 return false;
222}
223
224//____________________________SelectionCutAbsCharge_____________________________
225//______________________________________________________________________________
227 : DiTauSelectionCut("CutAbsCharge", tDTST),
228 m_bDiTauCharge(-1234)
229{
230 m_hHistCutPre = CreateControlPlot("hCharge_pre","Charge_pre;charge; events",7,-3.5,3.5);
231 m_hHistCut = CreateControlPlot("hCharge_cut","Charge_cut;charge; events",7,-3.5,3.5);
232}
233
234//______________________________________________________________________________
235void DiTauSelectionCutAbsCharge::fillHistogram(const xAOD::DiTauJet& /*xTau*/, TH1F& hHist) const
236{
237 hHist.Fill(m_bDiTauCharge);
238}
239
240//______________________________________________________________________________
242{
243 info.addCut( "AbsCharge",
244 "Selection of taus according to their absolute charge" );
245}
246//______________________________________________________________________________
248 asg::AcceptData& acceptData)
249{
250 m_bDiTauCharge = 0;
251 static const SG::ConstAccessor<float> acc_charge ("charge");
252 if ( acc_charge.isAvailable(xTau) ) {
253 m_bDiTauCharge = acc_charge(xTau);
254 } else {
255 for (const auto& xTrack : xTau.trackLinks()) {
256 if (!xTrack.isValid())
257 continue;
258
259 if(xTau.nSubjets() >= 2){
260 for (int i = 0; i < 2; ++i) { // loop over two leading subjets
261 TLorentzVector tlvSubjet = TLorentzVector();
262 tlvSubjet.SetPtEtaPhiE(xTau.subjetPt(i), xTau.subjetEta(i),
263 xTau.subjetPhi(i), xTau.subjetE(i));
264 double dR = tlvSubjet.DeltaR((*xTrack)->p4());
265 if (dR < 0.1) {
266 m_bDiTauCharge += (*xTrack)->charge();
267 break; //prevents double counting of tracks
268 }
269 } // loop over subjets
270 }
271 } // loop over tracks
272 }
273
274 // check charge, if ditau has one of the charges requiered then return true; false otherwise
275 for( unsigned int iCharge = 0; iCharge < m_tDTST->m_vAbsCharges.size(); iCharge++ )
276 {
277 if ( std::abs( m_bDiTauCharge ) == m_tDTST->m_vAbsCharges.at(iCharge) )
278 {
279 acceptData.setCutResult( "AbsCharge", true );
280 return true;
281 }
282 }
283 m_tDTST->msg() << MSG::VERBOSE << "DiTau failed charge requirement, ditau charge: " << m_bDiTauCharge << endmsg;
284 return false;
285
286}
287
288//___________________________SelectionCutOmniScore_____________________________
289//______________________________________________________________________________
291 : DiTauSelectionCut("CutOmniScore", tDTST)
292{
293 m_hHistCutPre = CreateControlPlot("hOmniScore_pre","OmniScore_pre;OmniScore; events",100,0,1);
294 m_hHistCut = CreateControlPlot("hOmniScore_cut","OmniScore_cut;OmniScore; events",100,0,1);
295}
296//______________________________________________________________________________
298{
299 static const SG::ConstAccessor<float> acc_OmniScore("omni_score");
300 hHist.Fill(acc_OmniScore(xTau));
301}
302//______________________________________________________________________________
304{
305 info.addCut( "OmniScore",
306 "Selection of taus according to their OmniScore" );
307}
308//______________________________________________________________________________
310 asg::AcceptData& acceptData)
311{
312 // check OmniScore score, if tau has a OmniScore score in one of the regions requiered then return true; false otherwise
313 static const SG::ConstAccessor<float> acc ("omni_score");
314 float dOmniScore = acc(xTau);
315 unsigned int iNumOmniScoreRegion = m_tDTST->m_vOmniScoreRegion.size()/2;
316 for( unsigned int iOmniScoreRegion = 0; iOmniScoreRegion < iNumOmniScoreRegion; iOmniScoreRegion++ )
317 {
318 if ( dOmniScore >= m_tDTST->m_vOmniScoreRegion.at(iOmniScoreRegion*2) and dOmniScore <= m_tDTST->m_vOmniScoreRegion.at(iOmniScoreRegion*2+1))
319 {
320 acceptData.setCutResult( "OmniScore", true );
321 return true;
322 }
323 }
324 m_tDTST->msg() << MSG::VERBOSE << "Tau failed OmniScore requirement, tau OmniScore: " << dOmniScore << endmsg;
325 return false;
326}
327
328//_____________________________SelectionCutOmniIDWP______________________________
329//_______________________________________________________________________________
331 : DiTauSelectionCut("CutOmniIDWP", tDTST)
332{
333 m_hHistCutPre = CreateControlPlot("hOmniIDWP_pre","OmniIDWP_pre;; events",8,-.5,7.5);
334 m_hHistCut = CreateControlPlot("hOmniIDWP_cut","OmniIDWP_cut;; events",8,-.5,7.5);
335 // only proceed if histograms are defined
336 if (!m_hHistCutPre or !m_hHistCut)
337 return;
338
339 m_hHistCutPre->GetXaxis()->SetBinLabel(1,"!VeryLoose");
340 m_hHistCutPre->GetXaxis()->SetBinLabel(2,"VeryLoose");
341 m_hHistCutPre->GetXaxis()->SetBinLabel(3,"!Loose");
342 m_hHistCutPre->GetXaxis()->SetBinLabel(4,"Loose");
343 m_hHistCutPre->GetXaxis()->SetBinLabel(5,"!Medium");
344 m_hHistCutPre->GetXaxis()->SetBinLabel(6,"Medium");
345 m_hHistCutPre->GetXaxis()->SetBinLabel(7,"!Tight");
346 m_hHistCutPre->GetXaxis()->SetBinLabel(8,"Tight");
347 m_hHistCut->GetXaxis()->SetBinLabel(1,"!VeryLoose");
348 m_hHistCut->GetXaxis()->SetBinLabel(2,"VeryLoose");
349 m_hHistCut->GetXaxis()->SetBinLabel(3,"!Loose");
350 m_hHistCut->GetXaxis()->SetBinLabel(4,"Loose");
351 m_hHistCut->GetXaxis()->SetBinLabel(5,"!Medium");
352 m_hHistCut->GetXaxis()->SetBinLabel(6,"Medium");
353 m_hHistCut->GetXaxis()->SetBinLabel(7,"!Tight");
354 m_hHistCut->GetXaxis()->SetBinLabel(8,"Tight");
355}
356
357//______________________________________________________________________________
359{
360 if(m_tDTST->m_useOmniScore){
361 static const SG::ConstAccessor<char> acc_OmniVeryLoose("omni_score_VL");
362 static const SG::ConstAccessor<char> acc_OmniLoose("omni_score_L");
363 static const SG::ConstAccessor<char> acc_OmniMedium("omni_score_M");
364 static const SG::ConstAccessor<char> acc_OmniTight("omni_score_T");
365 hHist.Fill(acc_OmniVeryLoose(xTau));
366 hHist.Fill(acc_OmniLoose(xTau)+2);
367 hHist.Fill(acc_OmniMedium(xTau)+4);
368 hHist.Fill(acc_OmniTight(xTau)+6);
369 }
370}
371
372//______________________________________________________________________________
374{
375 info.addCut( "OmniIDWP",
376 "Selection of ditaus according to their OmniIDScore" );
377}
378//______________________________________________________________________________
380 asg::AcceptData& acceptData)
381{
382 // check Omni ID working point, if ditau passes OmniID working point then return true; false otherwise
383 bool bPass = false;
384 switch (m_tDTST->m_iOmniIDWP)
385 {
386 case OMNIIDNONE:
387 bPass = true;
388 break;
389 case OMNIIDVERYLOOSE:
390 static const SG::ConstAccessor<char> acc_OmniVeryLoose("omni_score_VL");
391 if (!acc_OmniVeryLoose.isAvailable(xTau)) m_tDTST->msg() << MSG::WARNING << "Omni VeryLoose WP not available" << endmsg;
392 else bPass = acc_OmniVeryLoose(xTau);
393 break;
394 case OMNIIDLOOSE:
395 static const SG::ConstAccessor<char> acc_OmniLoose("omni_score_L");
396 if (!acc_OmniLoose.isAvailable(xTau)) m_tDTST->msg() << MSG::WARNING << "Omni Loose WP not available" << endmsg;
397 else bPass = acc_OmniLoose(xTau);
398 break;
399 case OMNIIDMEDIUM:
400 static const SG::ConstAccessor<char> acc_OmniMedium("omni_score_M");
401 if (!acc_OmniMedium.isAvailable(xTau)) m_tDTST->msg() << MSG::WARNING << "Omni Medium WP not available" << endmsg;
402 else bPass = acc_OmniMedium(xTau);
403 break;
404 case OMNIIDTIGHT:
405 static const SG::ConstAccessor<char> acc_OmniTight("omni_score_T");
406 if (!acc_OmniTight.isAvailable(xTau)) m_tDTST->msg() << MSG::WARNING << "Omni Tight WP not available" << endmsg;
407 else bPass = acc_OmniTight(xTau);
408 break;
409 default:
410 m_tDTST->msg() << MSG::WARNING << "The Omni ID working point with the enum " << m_tDTST->m_iOmniIDWP << " is not available" << endmsg;
411 break;
412 }
413 if (bPass)
414 {
415 acceptData.setCutResult( "OmniIDWP", true );
416 return true;
417 }
418 m_tDTST->msg() << MSG::VERBOSE << "DiTau failed OmniIDWP requirement" << endmsg;
419 return false;
420}
421
422
#define endmsg
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
DiTauSelectionCutPt(DiTauSelectionTool *tDTST)
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
std::map< std::string, std::string & > m_mProperties
void fillHistogramCut(const xAOD::DiTauJet &xTau)
void fillHistogramCutPre(const xAOD::DiTauJet &xTau)
void setProperty(const std::string &name, const std::string &value)
TH1F * CreateControlPlot(const char *sName, const char *sTitle, int iBins, double dXLow, double dXUp)
void declareProperty(const std::string &name, std::string &loc)
DiTauSelectionCut(const std::string &sName, TauAnalysisTools::DiTauSelectionTool *tDTST)
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const =0
std::string getProperty(const std::string &name)
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition AcceptData.h:134
virtual double eta() const
The pseudorapidity ( ) of the particle.
float subjetEta(unsigned int numSubjet) const
virtual double pt() const
The transverse momentum ( ) of the particle.
float subjetE(unsigned int numSubjet) const
float subjetPt(unsigned int numSubjet) const
float subjetPhi(unsigned int numSubjet) const
const TrackParticleLinks_t & trackLinks() const
float nSubjets() const
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition DiTauJet.h:17