ATLAS Offline Software
DiTauSelectionCuts.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // local include(s)
9 
10 // framework include(s)
12 
13 using namespace TauAnalysisTools;
14 
15 //______________________________________________________________________________
17  : m_sName(sName)
18  , m_hHistCutPre(nullptr)
19  , m_hHistCut(nullptr)
20  , m_tDTST(tDTST)
21 {
22 }
23 
24 //______________________________________________________________________________
26 {
27  // FIXME: could use unique_ptr
28  delete m_hHistCutPre;
29  delete m_hHistCut;
30 }
31 
32 //______________________________________________________________________________
34 {
35  m_hHistCutPre->Write();
36  m_hHistCut->Write();
37 }
38 
39 //______________________________________________________________________________
40 TH1F* DiTauSelectionCut::CreateControlPlot(const char* sName, const char* sTitle, int iBins, double dXLow, double dXUp)
41 {
43  {
44  TH1F* hHist = new TH1F(sName, sTitle, iBins, dXLow, dXUp);
45  hHist->SetDirectory(0);
46  return hHist;
47  }
48 
49  return nullptr;
50 }
51 
52 //______________________________________________________________________________
54 {
55  fillHistogram(xDiTau, *m_hHistCutPre);
56 }
57 
58 //______________________________________________________________________________
60 {
61  fillHistogram(xDiTau, *m_hHistCut);
62 }
63 
64 
65 //______________________________________________________________________________
66 void DiTauSelectionCut::setProperty(const std::string& name, const std::string& value)
67 {
69  if(it == m_mProperties.end() )
70  throw std::runtime_error (("Undeclared property: " + name + "\n").c_str());
71  it->second = value;
72 }
73 
74 //______________________________________________________________________________
75 void DiTauSelectionCut::declareProperty(const std::string& name, std::string& loc)
76 {
77  std::pair<std::string, std::string&> p(name, loc);
78  m_mProperties.insert(p);
79 }
80 
81 //______________________________________________________________________________
82 std::string DiTauSelectionCut::getProperty(const std::string& name)
83 {
85  if(it == m_mProperties.end() )
86  throw std::runtime_error (("Undeclared property: " + name + "\n").c_str());
87 
88  return it->second;
89 }
90 
91 
92 //_______________________________SelectionCutPt_________________________________
93 //______________________________________________________________________________
95  : DiTauSelectionCut("CutPt", tDTST)
96 {
97  m_hHistCutPre = CreateControlPlot("hPt_pre","Pt_pre;di-#tau-p_{T} [GeV]; events",1000,0,1000);
98  m_hHistCut = CreateControlPlot("hPt_cut","Pt_cut;di-#tau-p_{T} [GeV]; events",1000,0,1000);
99 }
100 
101 //______________________________________________________________________________
102 void DiTauSelectionCutPt::fillHistogram(const xAOD::DiTauJet& xDiTau, TH1F& hHist) const
103 {
104  hHist.Fill(xDiTau.pt()/1000.);
105 }
106 
107 //______________________________________________________________________________
109 {
110  info.addCut( "Pt",
111  "Selection of ditaus according to their transverse momentum" );
112 }
113 //______________________________________________________________________________
115  asg::AcceptData& acceptData)
116 {
117  // save ditau pt in GeV
118  double pt = xDiTau.pt() / 1000.;
119  // in case of only one entry in vector, run for lower limits
120  if (m_tDTST->m_vPtRegion.size() == 1)
121  {
122  if ( pt >= m_tDTST->m_vPtRegion.at(0) )
123  {
124  acceptData.setCutResult( "Pt", true );
125  return true;
126  }
127  }
128  unsigned int iNumPtRegion = m_tDTST->m_vPtRegion.size()/2;
129  for( unsigned int iPtRegion = 0; iPtRegion < iNumPtRegion; iPtRegion++ )
130  {
131  if ( pt >= m_tDTST->m_vPtRegion.at(iPtRegion*2) and pt <= m_tDTST->m_vPtRegion.at(iPtRegion*2+1))
132  {
133  acceptData.setCutResult( "Pt", true );
134  return true;
135  }
136  }
137  m_tDTST->msg() << MSG::VERBOSE << "DiTau failed pt requirement, ditau pt [GeV]: " << pt << endmsg;
138  return false;
139 }
140 
141 //_____________________________SelectionCutAbsEta_______________________________
142 //______________________________________________________________________________
144  : DiTauSelectionCut("CutAbsEta", tDTST)
145 {
146  m_hHistCutPre = CreateControlPlot("hEta_pre","Eta_pre;di-#tau-#eta; events",100,-3,3);
147  m_hHistCut = CreateControlPlot("hEta_cut","Eta_cut;di-#tau-#eta; events",100,-3,3);
148 }
149 
150 //______________________________________________________________________________
152 {
153  hHist.Fill(xDiTau.eta());
154 }
155 
156 //______________________________________________________________________________
158 {
159  info.addCut( "AbsEta",
160  "Selection of ditaus according to their absolute pseudorapidity" );
161 }
162 //______________________________________________________________________________
164  asg::AcceptData& acceptData)
165 {
166  // check regions of eta, if ditau is in one region then return true; false otherwise
167  unsigned int iNumEtaRegion = m_tDTST->m_vAbsEtaRegion.size()/2;
168  for( unsigned int iEtaRegion = 0; iEtaRegion < iNumEtaRegion; iEtaRegion++ )
169  {
170  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))
171  {
172  acceptData.setCutResult( "AbsEta", true );
173  return true;
174  }
175  }
176  m_tDTST->msg() << MSG::VERBOSE << "DiTau failed eta requirement, ditau eta: " << xDiTau.eta() << endmsg;
177  return false;
178 }
179 
180 //_______________________________SelectionCutNSubjets_________________________________
181 //______________________________________________________________________________
183  : DiTauSelectionCut("CutNSubjets", tDTST)
184 {
185  m_hHistCutPre = CreateControlPlot("hNSubjets_pre","NSubjets_pre;di-#tau NSubjets; events",30,0,30);
186  m_hHistCut = CreateControlPlot("hNSubjets_cut","NSubjets_cut;di-#tau NSubjets; events",30,0,30);
187 }
188 
189 //______________________________________________________________________________
191 {
192  hHist.Fill(xDiTau.nSubjets());
193 }
194 
195 //______________________________________________________________________________
197 {
198  info.addCut( "NSubjets",
199  "Selection of ditaus according to their number of subjets" );
200 }
201 //______________________________________________________________________________
203  asg::AcceptData& acceptData)
204 {
205  float nsubjets = xDiTau.nSubjets();
206  // in case of only one entry in vector, run for lower limits
207  if (m_tDTST->m_vNSubjetsRegion.size() == 1)
208  {
209  if ( nsubjets >= m_tDTST->m_vNSubjetsRegion.at(0) )
210  {
211  acceptData.setCutResult( "NSubjets", true );
212  return true;
213  }
214  }
215  unsigned int iNumNSubjetsRegion = m_tDTST->m_vNSubjetsRegion.size()/2;
216  for( unsigned int iNSubjetsRegion = 0; iNSubjetsRegion < iNumNSubjetsRegion; iNSubjetsRegion++ )
217  {
218  if ( nsubjets >= m_tDTST->m_vNSubjetsRegion.at(iNSubjetsRegion*2) and nsubjets <= m_tDTST->m_vNSubjetsRegion.at(iNSubjetsRegion*2+1))
219  {
220  acceptData.setCutResult( "NSubjets", true );
221  return true;
222  }
223  }
224  m_tDTST->msg() << MSG::VERBOSE << "DiTau failed NSubjets requirement, ditau number of subjets: " << nsubjets << endmsg;
225  return false;
226 }
227 
grepfile.info
info
Definition: grepfile.py:38
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TauAnalysisTools::DiTauSelectionTool::m_bCreateControlPlots
bool m_bCreateControlPlots
Definition: DiTauSelectionTool.h:122
TauAnalysisTools
Definition: TruthCollectionMakerTau.h:16
TauAnalysisTools::DiTauSelectionCutAbsEta::DiTauSelectionCutAbsEta
DiTauSelectionCutAbsEta(DiTauSelectionTool *tDTST)
Definition: DiTauSelectionCuts.cxx:143
xAOD::DiTauJet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
TauAnalysisTools::DiTauSelectionCutPt::setAcceptInfo
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
Definition: DiTauSelectionCuts.cxx:108
TauAnalysisTools::DiTauSelectionCut::fillHistogramCut
void fillHistogramCut(const xAOD::DiTauJet &xTau)
Definition: DiTauSelectionCuts.cxx:59
DiTauSelectionTool.h
TauAnalysisTools::DiTauSelectionCut
Definition: DiTauSelectionCuts.h:29
skel.it
it
Definition: skel.GENtoEVGEN.py:396
test_pyathena.pt
pt
Definition: test_pyathena.py:11
athena.value
value
Definition: athena.py:124
xAOD::DiTauJet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
TauAnalysisTools::DiTauSelectionCut::CreateControlPlot
TH1F * CreateControlPlot(const char *sName, const char *sTitle, int iBins, double dXLow, double dXUp)
Definition: DiTauSelectionCuts.cxx:40
TauAnalysisTools::DiTauSelectionCut::writeControlHistograms
void writeControlHistograms()
Definition: DiTauSelectionCuts.cxx:33
TauAnalysisTools::DiTauSelectionCut::fillHistogramCutPre
void fillHistogramCutPre(const xAOD::DiTauJet &xTau)
Definition: DiTauSelectionCuts.cxx:53
xAOD::DiTauJet_v1::nSubjets
float nSubjets() const
Definition: DiTauJet_v1.cxx:132
TauAnalysisTools::DiTauSelectionCutAbsEta::fillHistogram
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
Definition: DiTauSelectionCuts.cxx:151
TauAnalysisTools::DiTauSelectionCutNSubjets::accept
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
Definition: DiTauSelectionCuts.cxx:202
TauAnalysisTools::DiTauSelectionCutNSubjets::DiTauSelectionCutNSubjets
DiTauSelectionCutNSubjets(DiTauSelectionTool *tDTST)
Definition: DiTauSelectionCuts.cxx:182
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TauAnalysisTools::DiTauSelectionCut::m_hHistCut
TH1F * m_hHistCut
Definition: DiTauSelectionCuts.h:54
TauAnalysisTools::DiTauSelectionCut::DiTauSelectionCut
DiTauSelectionCut(const std::string &sName, TauAnalysisTools::DiTauSelectionTool *tDTST)
Definition: DiTauSelectionCuts.cxx:16
asg::AcceptInfo
Definition: AcceptInfo.h:28
TauAnalysisTools::DiTauSelectionTool::m_vAbsEtaRegion
std::vector< float > m_vAbsEtaRegion
Definition: DiTauSelectionTool.h:99
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TauAnalysisTools::DiTauSelectionCut::m_mProperties
std::map< std::string, std::string & > m_mProperties
Definition: DiTauSelectionCuts.h:59
DiTauSelectionCuts.h
TauAnalysisTools::DiTauSelectionCut::m_hHistCutPre
TH1F * m_hHistCutPre
Definition: DiTauSelectionCuts.h:53
TauAnalysisTools::DiTauSelectionCutAbsEta::setAcceptInfo
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
Definition: DiTauSelectionCuts.cxx:157
TauAnalysisTools::DiTauSelectionTool::m_vPtRegion
std::vector< float > m_vPtRegion
Definition: DiTauSelectionTool.h:97
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ReadHandle.h
Handle class for reading from StoreGate.
TauAnalysisTools::DiTauSelectionCutPt::DiTauSelectionCutPt
DiTauSelectionCutPt(DiTauSelectionTool *tDTST)
Definition: DiTauSelectionCuts.cxx:94
TauAnalysisTools::DiTauSelectionCut::~DiTauSelectionCut
virtual ~DiTauSelectionCut()
Definition: DiTauSelectionCuts.cxx:25
TauAnalysisTools::DiTauSelectionCut::m_tDTST
DiTauSelectionTool * m_tDTST
Definition: DiTauSelectionCuts.h:56
asg::AcceptData::setCutResult
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition: AcceptData.h:134
TauAnalysisTools::DiTauSelectionCut::fillHistogram
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const =0
AthCommonMsg::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
xAOD::DiTauJet_v1
Definition: DiTauJet_v1.h:31
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
TauAnalysisTools::DiTauSelectionCut::declareProperty
void declareProperty(const std::string &name, std::string &loc)
Definition: DiTauSelectionCuts.cxx:75
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
TauAnalysisTools::DiTauSelectionTool::m_vNSubjetsRegion
std::vector< float > m_vNSubjetsRegion
Definition: DiTauSelectionTool.h:101
TauAnalysisTools::DiTauSelectionTool
Definition: DiTauSelectionTool.h:41
TauAnalysisTools::DiTauSelectionCut::getProperty
std::string getProperty(const std::string &name)
Definition: DiTauSelectionCuts.cxx:82
asg::AcceptData
Definition: AcceptData.h:30
TauAnalysisTools::DiTauSelectionCutAbsEta::accept
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
Definition: DiTauSelectionCuts.cxx:163
TauAnalysisTools::DiTauSelectionCutPt::fillHistogram
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
Definition: DiTauSelectionCuts.cxx:102
TauAnalysisTools::DiTauSelectionCutNSubjets::setAcceptInfo
virtual void setAcceptInfo(asg::AcceptInfo &info) const override
Definition: DiTauSelectionCuts.cxx:196
TauAnalysisTools::DiTauSelectionCut::setProperty
void setProperty(const std::string &name, const std::string &value)
Definition: DiTauSelectionCuts.cxx:66
TauAnalysisTools::DiTauSelectionCutNSubjets::fillHistogram
virtual void fillHistogram(const xAOD::DiTauJet &xTau, TH1F &hHist) const override
Definition: DiTauSelectionCuts.cxx:190
TauAnalysisTools::DiTauSelectionCutPt::accept
virtual bool accept(const xAOD::DiTauJet &xTau, asg::AcceptData &accept) override
Definition: DiTauSelectionCuts.cxx:114