ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigAnalysis
TriggerMatchingTool
src
TestMatchingToolAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
TestMatchingToolAlg.h
"
7
#include "
xAODBase/IParticleContainer.h
"
8
9
#include "TH1D.h"
10
#include "TFile.h"
11
12
StatusCode
TestMatchingToolAlg::initialize
() {
13
m_tmt
.setTypeAndName(
"Trig::MatchingTool/MyMatchingTool"
);
14
CHECK
(
m_tmt
.retrieve());
//important to retrieve here, because TrigDecisionTool must be initialized before event loop
15
return
StatusCode::SUCCESS;
16
}
17
18
StatusCode
TestMatchingToolAlg::execute
(
const
EventContext&
/*ctx*/
) {
19
20
//For more documentation on the tool, see: https://twiki.cern.ch/twiki/bin/view/Atlas/XAODMatchingTool
21
//As of Feb 2016:
22
//Recommended threshold for egamma triggers: 0.07
23
//Recommended threshold for muon triggers: 0.1
24
25
//here's an example of using the tool
26
const
xAOD::IParticleContainer
* electrons = 0;
27
const
xAOD::IParticleContainer
*
taus
= 0;
28
const
xAOD::IParticleContainer
*muons = 0;
29
CHECK
(
evtStore
()->retrieve( electrons,
"Electrons"
));
30
CHECK
(
evtStore
()->retrieve( muons,
"Muons"
) );
31
CHECK
(
evtStore
()->retrieve(
taus
,
"TauJets"
) );
32
if
(electrons)
ATH_MSG_INFO
(
"Offline Electron container size "
<< electrons->size());
33
if
(muons)
ATH_MSG_INFO
(
"Offline Muon container size "
<< muons->
size
());
34
if
(
taus
)
ATH_MSG_INFO
(
"Offline Tau container size "
<<
taus
->size());
35
//tool takes a vector of IParticles, and a trigger chain expression
36
//can also take a single IParticle for single object trigger matching
37
std::vector<const xAOD::IParticle*> myParticles;
38
39
//here's an example of a single object trigger
40
bool
res
(
false
);
41
if
(electrons) {
42
for
(
uint
i = 0; i< electrons->size(); i++) {
43
myParticles.clear();
44
myParticles.push_back( electrons->at(i) );
45
res
=
m_tmt
->match(myParticles,
"HLT_e17_lhloose"
,0.07
/*explicit dR threhsold*/
);
46
m_matches
[
"HLT_e17_lhloose"
] +=
res
;
47
ATH_MSG_INFO
(
"HLT_e17_lhloose Matching Decision = "
<<
res
);
48
49
// here's an example of a combined trigger
50
// e-mu
51
if
(muons){
52
53
for
(
uint
j = 0; j < muons->
size
(); j++) {
54
myParticles.clear();
55
myParticles.push_back(electrons->at(i));
56
myParticles.push_back(muons->
at
(j));
57
res
=
m_tmt
->match(myParticles,
"HLT_e17_lhloose_mu14"
);
58
m_matches
[
"HLT_e17_lhloose_mu14"
] +=
res
;
59
ATH_MSG_INFO
(
"HLT_e17_lhloose_mu14 = "
<<
res
);
60
}
61
}
62
// e-tau
63
if
(
taus
){
64
for
(
uint
j = 0; j <
taus
->size(); j++) {
65
myParticles.clear();
66
myParticles.push_back(electrons->at(i));
67
myParticles.push_back(
taus
->at(j));
68
res
=
m_tmt
->match(myParticles,
"HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo"
);
69
m_matches
[
"HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo"
] +=
res
;
70
ATH_MSG_INFO
(
"HLT_e17_lhmedium_iloose_tau25_medium1_tracktwo = "
<<
res
);
71
}
72
}
73
}
74
}
75
76
// here's an example for muon trigger, using the method for single-object trigger matching
77
if
(muons){
78
for
(
auto
muon : *muons) {
79
res
=
m_tmt
->match(*muon,
"HLT_mu18"
);
80
m_matches
[
"HLT_mu18"
] +=
res
;
81
ATH_MSG_INFO
(
"HLT_mu18 = "
<<
res
);
82
}
83
}
84
// here's an examplefor a tau trigger
85
if
(
taus
){
86
for
(
uint
j = 0; j <
taus
->size(); j++) {
87
res
=
m_tmt
->match(*
taus
->at(j),
"HLT_tau25_loose1_ptonly"
);
88
m_matches
[
"HLT_tau25_loose1_ptonly"
] +=
res
;
89
ATH_MSG_INFO
(
"HLT_tau25_loose1_ptonly = "
<<
res
);
90
}
91
}
92
93
//here's an example for a dilepton trigger
94
//form pairs to test a dilepton trigger
95
if
(electrons) {
96
for
(
uint
i = 0; i< electrons->size(); i++) {
97
for
(
uint
j = i+1; j < electrons->size(); j++) {
98
myParticles.clear();
99
myParticles.push_back( electrons->at(i) );
100
myParticles.push_back( electrons->at(j) );
101
res
=
m_tmt
->match(myParticles,
"HLT_2e17_lhloose"
, 0.07);
102
m_matches
[
"HLT_2e17_lhloose"
] +=
res
;
103
ATH_MSG_INFO
(
"HLT_2e17_lhloose Matching Decision = "
<<
res
);
104
}
105
}
106
}
107
108
return
StatusCode::SUCCESS;
109
}
110
111
StatusCode
TestMatchingToolAlg::finalize
() {
112
//write results out to a file ... single bin histograms
113
TFile f1(
"TestMatchingToolAlg.results.root"
,
"RECREATE"
);
114
for
(
auto
& t :
m_matches
) {
115
TH1D*
h
=
new
TH1D(t.first.c_str(),t.first.c_str(),1,0,1);
116
h
->SetBinContent(1,t.second);
117
h
->Write();
118
}
119
f1.Close();
120
return
StatusCode::SUCCESS;
121
}
122
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
res
std::pair< std::vector< unsigned int >, bool > res
Definition
JetGroupProductTest.cxx:11
uint
unsigned int uint
Definition
LArOFPhaseFill.cxx:19
taus
static Double_t taus
Definition
LArPhysWaveHECTool.cxx:37
TestMatchingToolAlg.h
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
h
Header file for AthHistogramAlgorithm.
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TestMatchingToolAlg::m_tmt
ToolHandle< Trig::IMatchingTool > m_tmt
Definition
TestMatchingToolAlg.h:25
TestMatchingToolAlg::m_matches
std::map< std::string, int > m_matches
Definition
TestMatchingToolAlg.h:27
TestMatchingToolAlg::finalize
virtual StatusCode finalize()
Definition
TestMatchingToolAlg.cxx:111
TestMatchingToolAlg::execute
virtual StatusCode execute(const EventContext &ctx)
Execute method.
Definition
TestMatchingToolAlg.cxx:18
TestMatchingToolAlg::initialize
virtual StatusCode initialize()
Definition
TestMatchingToolAlg.cxx:12
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
IParticleContainer.h
Generated on
for ATLAS Offline Software by
1.17.0