ATLAS Offline Software
InnerDetector
InDetValidation
InDetTruthVertexValidation
util
VertexTruthMatchTest.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//ROOT
6
#include <TFile.h>
7
#include <TH1.h>
8
9
#ifdef ROOTCORE
10
#include "
xAODRootAccess/Init.h
"
11
#include "
xAODRootAccess/TEvent.h
"
12
#include "
xAODRootAccess/TStore.h
"
13
#endif
14
15
#include "
xAODEventInfo/EventInfo.h
"
16
#include "
xAODTracking/VertexContainer.h
"
17
#include "
xAODTracking/TrackParticleContainer.h
"
18
19
#include "
InDetTruthVertexValidation/InDetVertexTruthMatchTool.h
"
20
#include "
InDetTruthVertexValidation/InDetVertexTruthMatchUtils.h
"
21
22
#include "
AsgMessaging/MessageCheck.h
"
23
24
int
main
(
int
argc
,
char
*
argv
[] ) {
25
26
using namespace
asg::msgUserCode;
27
28
const
char
*
APP_NAME
=
argv
[0];
29
30
//check for filename
31
if
(
argc
< 2 ) {
32
Error(
APP_NAME
,
"No file name argument"
);
33
Error(
APP_NAME
,
" Usage: %s xAOD_file_name [nEntries]"
,
APP_NAME
);
34
return
1;
35
}
36
37
//init app
38
bool
result
=
xAOD::Init
(
APP_NAME
);
39
if
(!
result
) {
40
Error(
APP_NAME
,
"Failed to init"
);
41
return
1;
42
}
43
44
//open file
45
const
char
*
fileName
=
argv
[1];
46
Info(
APP_NAME
,
"Opening file: %s"
,
fileName
);
47
TFile *
file
=
new
TFile(
fileName
,
"READ"
);
48
49
xAOD::TEvent
event
(
xAOD::TEvent::kClassAccess
);
50
result
=
event
.readFrom(
file
);
51
if
(!
result
) {
52
Error(
APP_NAME
,
"Failed to have TEvent read file"
);
53
return
1;
54
}
55
56
//create transient object store
57
xAOD::TStore
store
;
58
59
Long64_t
entries
=
event
.getEntries();
60
if
(
argc
> 2 ) {
61
const
Long64_t
e
= atoll(
argv
[2] );
62
if
(
e
<
entries
)
63
entries
=
e
;
64
}
65
66
//Tool to test
67
InDetVertexTruthMatchTool
matchTool(
"VertexTruthMatchTool"
);
68
69
//config
70
matchTool.
msg
().setLevel(
MSG::DEBUG
);
71
ATH_CHECK
( matchTool.setProperty(
"trackMatchProb"
, 0.7 ) );
72
ATH_CHECK
( matchTool.setProperty(
"vertexMatchWeight"
, 0.7 ) );
73
ATH_CHECK
( matchTool.
initialize
() );
74
75
TFile
fout
(
"output.root"
,
"RECREATE"
);
76
fout
.cd();
77
78
//some inclusive test plots
79
TH1F
* h_cat =
new
TH1F
(
"vertexMatchTypes"
,
"Number of vertices of each type"
,4,-0.5,3.5);
80
h_cat->GetXaxis()->SetBinLabel(1,
"Matched"
);
81
h_cat->GetXaxis()->SetBinLabel(2,
"Merged"
);
82
h_cat->GetXaxis()->SetBinLabel(3,
"Split"
);
83
h_cat->GetXaxis()->SetBinLabel(4,
"Fake"
);
84
85
86
//plot some things for the best reco match to hard-scatter event
87
TH1F
* h_cat_hs =
new
TH1F
(
"vertexTypes_hardScatter"
,
"Number of events of each type"
,5,-0.5,4.5);
88
h_cat_hs->GetXaxis()->SetBinLabel(1,
"Clean"
);
89
h_cat_hs->GetXaxis()->SetBinLabel(2,
"Low PU"
);
90
h_cat_hs->GetXaxis()->SetBinLabel(3,
"High PU"
);
91
h_cat_hs->GetXaxis()->SetBinLabel(4,
"Split"
);
92
h_cat_hs->GetXaxis()->SetBinLabel(5,
"No match"
);
93
94
//Loop
95
for
( Long64_t
entry
= 0;
entry
<
entries
; ++
entry
) {
96
97
event
.getEntry(
entry
);
98
99
const
xAOD::EventInfo
* ei =
nullptr
;
100
result
=
event
.retrieve( ei,
"EventInfo"
);
101
if
(!
result
) {
102
Error(
APP_NAME
,
"Failed to retrieve EventInfo on entry %i"
,
static_cast<
int
>
(
entry
));
103
return
1;
104
}
105
106
if
(
entry
% 100 == 0 ) {
107
Info(
APP_NAME
,
108
"===Start event %i, run %i; %i events processed so far==="
,
109
static_cast<
int
>
( ei->
eventNumber
() ),
110
static_cast<
int
>
( ei->
runNumber
() ),
111
static_cast<
int
>
(
entry
) );
112
}
113
114
//get vertices
115
const
xAOD::VertexContainer
* vxContainer =
nullptr
;
116
result
=
event
.retrieve( vxContainer,
"PrimaryVertices"
);
117
if
(!
result
) {
118
Error(
APP_NAME
,
"Failed to retrieve PrimaryVertices on entry %i"
,
static_cast<
int
>
(
entry
));
119
return
1;
120
}
121
122
int
status
= matchTool.
matchVertices
( *vxContainer );
123
if
(!
status
) {
124
Error(
APP_NAME
,
"Bad status from matching tool on entry %i"
,
static_cast<
int
>
(
entry
));
125
continue
;
126
}
127
128
//accessor for the matching type
129
xAOD::Vertex::Decorator<InDetVertexTruthMatchUtils::VertexMatchType>
matchTypeDecor(
"VertexMatchType"
);
130
131
//fill the category histogram for all vertices
132
for
(
auto
vxit : *vxContainer ) {
133
h_cat->Fill( matchTypeDecor( *vxit ) );
134
}
135
136
//get the matching type for hard scatter and fill
137
h_cat_hs->Fill(
InDetVertexTruthMatchUtils::classifyHardScatter
( *vxContainer ) );
138
139
//get the best match for the hard scatter
140
//const xAOD::Vertex * hsMatch = InDetVertexTruthMatchUtils::bestHardScatterMatch( *vxContainer );
141
142
}
143
144
h_cat->Write();
145
h_cat_hs->Write();
146
fout
.Close();
147
148
return
0;
149
}
AllowedVariables::e
e
Definition:
AsgElectronSelectorTool.cxx:37
SGTest::store
TestStore store
Definition:
TestStore.cxx:23
get_generator_info.result
result
Definition:
get_generator_info.py:21
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
InDetVertexTruthMatchTool::matchVertices
virtual StatusCode matchVertices(const xAOD::VertexContainer &vxContainer) const override
Definition:
InDetVertexTruthMatchTool.cxx:136
InDetVertexTruthMatchUtils::classifyHardScatter
HardScatterType classifyHardScatter(const xAOD::VertexContainer &vxContainer)
Definition:
InDetVertexTruthMatchUtils.cxx:70
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition:
Control/xAODRootAccess/xAODRootAccess/TEvent.h:101
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
InDetVertexTruthMatchTool
Class for vertex truth matching.
Definition:
InDetVertexTruthMatchTool.h:24
InDetVertexTruthMatchUtils.h
FortranAlgorithmOptions.fileName
fileName
Definition:
FortranAlgorithmOptions.py:13
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition:
Decorator.h:59
LArCellNtuple.argv
argv
Definition:
LArCellNtuple.py:152
dqt_zlumi_alleff_HIST.fout
fout
Definition:
dqt_zlumi_alleff_HIST.py:59
MessageCheck.h
macros for messaging and checking status codes
APP_NAME
#define APP_NAME
Definition:
BoostedXbbTag.cxx:23
TEvent.h
InDetVertexTruthMatchTool::initialize
virtual StatusCode initialize() override final
Dummy implementation of the initialisation function.
Definition:
InDetVertexTruthMatchTool.cxx:19
file
TFile * file
Definition:
tile_monitor.h:29
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
Init.h
DQHistogramMergeRegExp.argc
argc
Definition:
DQHistogramMergeRegExp.py:20
main
int main(int argc, char *argv[])
Definition:
VertexTruthMatchTest.cxx:24
DataVector
Derived DataVector<T>.
Definition:
DataVector.h:794
GetAllXsec.entry
list entry
Definition:
GetAllXsec.py:132
InDetVertexTruthMatchTool.h
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition:
EventInfo_v1.h:43
VertexContainer.h
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition:
TStore.h:44
DEBUG
#define DEBUG
Definition:
page_access.h:11
AthCommonMsg::msg
MsgStream & msg() const
Definition:
AthCommonMsg.h:24
entries
double entries
Definition:
listroot.cxx:49
merge.status
status
Definition:
merge.py:17
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition:
TrigEgammaMonitorHelper.py:24
TStore.h
TrackParticleContainer.h
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition:
Control/xAODRootAccess/xAODRootAccess/TEvent.h:85
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition:
Init.cxx:31
Generated on Fri Jan 10 2025 21:21:28 for ATLAS Offline Software by
1.8.18