ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkValidation
TrkValTools
src
DirectTrackNtupleWriterTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// DirectTrackNtupleWriterTool.cxx
7
// Source file for class DirectTrackNtupleWriterTool
9
// (c) ATLAS Detector software
11
// Sebastian.Fleischmann@cern.ch
13
14
// Gaudi/root
15
#include "GaudiKernel/ITHistSvc.h"
16
#include "TTree.h"
17
18
// Trk
19
#include "
DirectTrackNtupleWriterTool.h
"
20
#include "
TrkValInterfaces/ITrackValidationNtupleTool.h
"
21
#include "
TrkTrack/Track.h
"
22
#include "
TrkExInterfaces/IExtrapolator.h
"
23
24
// constructor
25
Trk::DirectTrackNtupleWriterTool::DirectTrackNtupleWriterTool
(
26
const
std::string& t,
27
const
std::string& n,
28
const
IInterface* p )
29
:
30
AthAlgTool
(t,n,p),
31
m_ValidationNtupleTools
(),
32
m_extrapolatorHandle
(
"Trk::Extrapolator/InDetExtrapolator"
),
33
m_nt
(nullptr),
34
m_doTruth
(true)
35
{
36
declareInterface<IDirectTrackNtupleWriter>(
this
);
37
// Declare tool handles
38
declareProperty
(
"ValidationNtupleTools"
,
m_ValidationNtupleTools
,
"set of tools to write the validation ntuple"
);
39
declareProperty
(
"ExtrapolatorTool"
,
m_extrapolatorHandle
,
"Extrapolator, eg for tracks without Pergiee parameters"
);
40
41
// Declare the properties
42
declareProperty
(
"NtupleFileName"
,
m_ntupleFileName
=
"/NTUPLES/FILE1"
,
"Ntuple file handle"
);
43
declareProperty
(
"NtupleDirectoryName"
,
m_ntupleDirName
=
"FitterValidation"
,
"dircetory name for ntuple tree"
);
44
declareProperty
(
"NtupleTreeName"
,
m_ntupleTreeName
=
"Validation"
,
"Name of the ntuple tree"
);
45
declareProperty
(
"DoTruth"
,
m_doTruth
,
"Write truth data?"
);
46
}
47
48
// destructor
49
Trk::DirectTrackNtupleWriterTool::~DirectTrackNtupleWriterTool
() =
default
;
50
51
52
53
54
// initialize
55
StatusCode
Trk::DirectTrackNtupleWriterTool::initialize
() {
56
57
StatusCode
sc
(StatusCode::SUCCESS);
58
59
// retrieve pointer to THistSvc
60
SmartIF<ITHistSvc> tHistSvc{service(
"THistSvc"
)};
61
ATH_CHECK
( tHistSvc.isValid() );
62
63
// ---------------------------
64
// create tree and register it to THistSvc
65
m_nt
=
new
TTree(TString(
m_ntupleTreeName
),
"Track Validation"
);
66
// NB: we must not delete the tree, this is done by THistSvc
67
std::string fullNtupleName =
"/"
+
m_ntupleFileName
+
"/"
+
m_ntupleDirName
+
"/"
+
m_ntupleTreeName
;
68
ATH_CHECK
( tHistSvc->regTree(fullNtupleName,
m_nt
) );
69
70
// Get Validation ntuple Tools
71
ATH_CHECK
(
m_ValidationNtupleTools
.retrieve() );
72
73
// add the ntuple branches to our tree
74
ToolHandleArray< Trk::ITrackValidationNtupleTool >::iterator itTools;
75
itTools =
m_ValidationNtupleTools
.begin();
76
for
( ; itTools !=
m_ValidationNtupleTools
.end(); ++itTools ) {
77
if
(((*itTools)->addNtupleItems(
m_nt
)).isFailure()) {
78
ATH_MSG_ERROR
(
"ValidationNtupleTool could not add its branches for tree "
<< fullNtupleName);
79
return
StatusCode::FAILURE;
80
}
81
}
82
83
// FIXME retrieve extrapolator
84
85
return
StatusCode::SUCCESS;
86
}
87
91
StatusCode
Trk::DirectTrackNtupleWriterTool::finalize
() {
92
93
ATH_MSG_DEBUG
(
"start finalize() in "
<< name());
94
return
StatusCode::SUCCESS;
95
}
96
100
StatusCode
Trk::DirectTrackNtupleWriterTool::writeTrackData
(
101
const
Trk::Track
& track,
102
const
int
iterationIndex,
103
const
unsigned
int
fitStatCode ) {
104
// const Trk::FitterStatusCode fitStatCode ) const {
105
106
ATH_MSG_VERBOSE
(
"in writeTrackData(trk, indx)"
);
107
108
ToolHandleArray< Trk::ITrackValidationNtupleTool >::iterator itTools;
109
itTools =
m_ValidationNtupleTools
.begin();
110
for
( ; itTools !=
m_ValidationNtupleTools
.end(); ++itTools ) {
111
if
(((*itTools)->fillTrackData( track, iterationIndex, fitStatCode )).isFailure()) {
112
ATH_MSG_ERROR
(
"Validation Ntuple Tool could not fill track data."
);
113
return
StatusCode::FAILURE;
114
}
115
}
116
117
//----------------------------------------------
118
// write the ntuple record out (once per call)
119
return
writeRecord
(
m_nt
);
120
}
121
125
StatusCode
Trk::DirectTrackNtupleWriterTool::writeTrackParticleData
(
126
const
Trk::TrackParticleBase
& particlebase ) {
127
128
ATH_MSG_VERBOSE
(
"in writeTrackParticleData()"
);
129
130
ToolHandleArray< Trk::ITrackValidationNtupleTool >::iterator itTools;
131
itTools =
m_ValidationNtupleTools
.begin();
132
for
( ; itTools !=
m_ValidationNtupleTools
.end(); ++itTools ) {
133
if
(((*itTools)->fillTrackParticleData( particlebase )).isFailure()) {
134
ATH_MSG_ERROR
(
"Validation Ntuple Tool could not fill particlebase data."
);
135
return
StatusCode::FAILURE;
136
}
137
}
138
139
//----------------------------------------------
140
// write the ntuple record out (once per call)
141
return
writeRecord
(
m_nt
);
142
}
143
147
StatusCode
Trk::DirectTrackNtupleWriterTool::writeRecord
(TTree*
tree
) {
148
if
(!
tree
)
return
StatusCode::FAILURE;
149
tree
->Fill();
150
// reset variables for next call
151
ToolHandleArray< Trk::ITrackValidationNtupleTool >::iterator itTools;
152
itTools =
m_ValidationNtupleTools
.begin();
153
for
( ; itTools !=
m_ValidationNtupleTools
.end(); ++itTools ) (*itTools)->resetVariables();
154
return
StatusCode::SUCCESS;
155
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DirectTrackNtupleWriterTool.h
IExtrapolator.h
ITrackValidationNtupleTool.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
Track.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
Trk::DirectTrackNtupleWriterTool::DirectTrackNtupleWriterTool
DirectTrackNtupleWriterTool(const std::string &, const std::string &, const IInterface *)
Definition
DirectTrackNtupleWriterTool.cxx:25
Trk::DirectTrackNtupleWriterTool::~DirectTrackNtupleWriterTool
~DirectTrackNtupleWriterTool()
Trk::DirectTrackNtupleWriterTool::writeRecord
StatusCode writeRecord(TTree *tree)
write the filled data into the ntuple
Definition
DirectTrackNtupleWriterTool.cxx:147
Trk::DirectTrackNtupleWriterTool::writeTrackData
virtual StatusCode writeTrackData(const Trk::Track &, const int iterationIndex, const unsigned int fitStatCode)
fill AND write ntuple data of a given track
Definition
DirectTrackNtupleWriterTool.cxx:100
Trk::DirectTrackNtupleWriterTool::m_ntupleFileName
std::string m_ntupleFileName
jobOption: Ntuple file name
Definition
DirectTrackNtupleWriterTool.h:76
Trk::DirectTrackNtupleWriterTool::m_doTruth
bool m_doTruth
switch to turn truth on/off
Definition
DirectTrackNtupleWriterTool.h:80
Trk::DirectTrackNtupleWriterTool::finalize
StatusCode finalize()
finalize
Definition
DirectTrackNtupleWriterTool.cxx:91
Trk::DirectTrackNtupleWriterTool::m_ntupleTreeName
std::string m_ntupleTreeName
jobOption: Ntuple tree name
Definition
DirectTrackNtupleWriterTool.h:78
Trk::DirectTrackNtupleWriterTool::m_extrapolatorHandle
ToolHandle< Trk::IExtrapolator > m_extrapolatorHandle
extrapolator, in case tracks do not have Perigee
Definition
DirectTrackNtupleWriterTool.h:75
Trk::DirectTrackNtupleWriterTool::writeTrackParticleData
virtual StatusCode writeTrackParticleData(const Trk::TrackParticleBase &)
fill AND write ntuple data of a given track particle
Definition
DirectTrackNtupleWriterTool.cxx:125
Trk::DirectTrackNtupleWriterTool::m_ValidationNtupleTools
ToolHandleArray< Trk::ITrackValidationNtupleTool > m_ValidationNtupleTools
set of tools for writting Trk::Track into the Ntuple
Definition
DirectTrackNtupleWriterTool.h:74
Trk::DirectTrackNtupleWriterTool::m_nt
TTree * m_nt
Pointer to the NTuple tree.
Definition
DirectTrackNtupleWriterTool.h:79
Trk::DirectTrackNtupleWriterTool::initialize
StatusCode initialize()
Definition
DirectTrackNtupleWriterTool.cxx:55
Trk::DirectTrackNtupleWriterTool::m_ntupleDirName
std::string m_ntupleDirName
jobOption: Ntuple directory name
Definition
DirectTrackNtupleWriterTool.h:77
Trk::TrackParticleBase
Definition
TrackParticleBase.h:41
Trk::Track
The ATLAS Track class.
Definition
Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0