ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
HeavyIonPhys
HIEventUtils
util
run_vertex_tool_test.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
#ifdef XAOD_STANDALONE
6
#include <memory>
7
#include <string>
8
#include "
xAODRootAccess/Init.h
"
9
#include "
xAODRootAccess/TEvent.h
"
10
#include "
AsgMessaging/Check.h
"
11
#include "CxxUtils/make_unique.h"
12
#include "
HIEventUtils/HIVertexSelectionTool.h
"
13
#include "
xAODTracking/VertexContainer.h
"
14
#include "
InDetTrackSelectionTool/InDetTrackSelectionTool.h
"
15
#include "TError.h"
16
#include "TFile.h"
17
18
using
std::string;
19
using
std::unique_ptr;
20
using
CxxUtils::make_unique;
21
22
int
main
(
int
argc,
char
* argv[])
23
{
24
string
appName =
argv
[0];
25
if
( !
xAOD::Init
(appName.data()).isSuccess() ) {
26
Error
( appName.data(),
"Could not call xAOD::Init()"
);
27
return
1;
28
}
29
30
string
fileName
;
31
// Check if we received a file name:
32
if
( argc < 2 ) {
33
fileName
=
getenv
(
"ROOTCORE_TEST_FILE"
);
34
if
(
fileName
.empty()) {
35
Error
( appName.data(),
"No file name received!"
);
36
Error
( appName.data(),
" Usage: %s [xAOD file name]"
, appName.data() );
37
return
1;
38
}
39
}
else
{
40
fileName
=
argv
[ 1 ];
41
}
42
43
unique_ptr<TFile>
fin
( TFile::Open(
fileName
.data(),
"READ"
) );
44
45
auto
event
= make_unique<xAOD::TEvent>(
fin
.get(),
xAOD::TEvent::kClassAccess
);
46
Long64_t
entries
=
event
->getEntries();
47
Info
( appName.data(),
"Number of events in file: %llu"
,
entries
);
48
49
auto
vertexSelTool = make_unique< HI::HIVertexSelectionTool >(
"vertexSelectionTool"
);
50
ASG_CHECK_SA
( appName, vertexSelTool->setProperty(
"MinNTrk"
, 10 ) );
51
ASG_CHECK_SA
( appName, vertexSelTool->setProperty(
"MinRmsPt"
, 10000. ) );
52
53
auto
vtxTrkTool = make_unique<InDet::InDetTrackSelectionTool>(
"vtxTrkTool"
,
"HILoose"
);
54
ToolHandle< InDet::IInDetTrackSelectionTool > vtxTrkToolHandle = vtxTrkTool.get();
55
ASG_CHECK_SA
( appName, vtxTrkTool->initialize() );
56
ASG_CHECK_SA
( appName, vertexSelTool->setProperty(
"TrackSelectionTool"
, vtxTrkToolHandle ) );
57
58
ASG_CHECK_SA
( appName, vertexSelTool->initialize() );
59
60
61
Long64_t nVtxPass = 0;
62
Long64_t nVtxFail = 0;
63
for
(Long64_t i_evt=0; i_evt<
entries
; ++i_evt) {
64
event
->getEntry( i_evt );
65
66
const
xAOD::VertexContainer
* vertices =
nullptr
;
67
if
( !
event
->retrieve( vertices,
"PrimaryVertices"
).isSuccess() ) {
68
Error
( appName.data(),
"Could not retrieve PrimaryVertices"
);
69
return
1;
70
}
71
72
for
(
const
auto
* vtx : *vertices) {
73
if
(vertexSelTool->accept( *vtx )) nVtxPass++;
74
else
nVtxFail++;
75
}
76
77
}
78
Info
( appName.data(),
"%llu passed."
, nVtxPass );
79
Info
( appName.data(),
"%llu failed."
, nVtxFail );
80
81
ASG_CHECK_SA
( appName, vertexSelTool->finalize() );
82
ASG_CHECK_SA
( appName, vtxTrkTool->finalize() );
83
return
0;
84
}
85
#endif
// XAOD_STANDALONE
Check.h
ASG_CHECK_SA
#define ASG_CHECK_SA(SOURCE, EXP)
Helper macro for checking the status code of a call outside of an ASG tool.
Definition
Check.h:76
TEvent.h
HIVertexSelectionTool.h
InDetTrackSelectionTool.h
Init.h
VertexContainer.h
unique_ptr
STL class.
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:73
main
int main()
Definition
hello.cxx:18
entries
double entries
Definition
listroot.cxx:49
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition
Error.h:16
LArCellNtuple.argv
argv
Definition
LArCellNtuple.py:167
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition
SCT_ConditionsUtilities.cxx:17
TRT::Track::event
@ event
Definition
InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:52
ZDCMsg::Info
@ Info
Definition
ZDCMsg.h:20
compute_lumi.fin
fin
Definition
compute_lumi.py:19
jobOptions.fileName
fileName
Definition
jobOptions.SuperChic_ALP2.py:39
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition
Init.cxx:31
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition
VertexContainer.h:14
Generated on
for ATLAS Offline Software by
1.17.0