ATLAS Offline Software
Loading...
Searching...
No Matches
HitPositionNtupleHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6// HitPositionNtupleHelper.cxx
7// Source file for class HitPositionNtupleHelper
9// (c) ATLAS Detector software
11// Anna.Franckowiak@cern.ch, Sebastian.Fleischmann@cern.ch
13
14
15//Gaudi
16#include "GaudiKernel/SmartDataPtr.h"
17#include "GaudiKernel/ITHistSvc.h"
18
19#include "GaudiKernel/ISvcLocator.h"
20
21// Trk
24
26//#include "TrkParameters/TrackParameters.h"
27#include "TrkSurfaces/Surface.h"
28#include "TTree.h"
29
30// constructor
32 const std::string& t,
33 const std::string& n,
34 const IInterface* p )
35 :
36 AthAlgTool(t,n,p),
37
38 m_hitX(nullptr), // do careful initialisation so we can issue a safe delete
39 m_hitY(nullptr),
40 m_hitZ(nullptr),
41 m_hitRadius(nullptr),
42 m_hitPhi(nullptr),
43 m_hitLoc1(nullptr),
44 m_hitLoc2(nullptr),
45 m_hitSurfaceX(nullptr),
46 m_hitSurfaceY(nullptr),
47 m_hitSurfaceZ(nullptr),
48 m_hitSurfaceRadius(nullptr),
49 m_hitSurfacePhi(nullptr),
50 m_hitSurfaceTheta(nullptr)
51
52 {
53 declareInterface<IValidationNtupleHelperTool>(this);
54 //declareProperty("IgnoreMissingTrackCovarianceForPulls", mjo_ignoreMissTrkCov = false);
55}
56
57// destructor
59
60
61
66
67 m_hitX = new std::vector<float>();
68 m_hitY = new std::vector<float>();
69 m_hitZ = new std::vector<float>();
70 m_hitRadius = new std::vector<float>();
71 m_hitPhi = new std::vector<float>();
72 m_hitLoc1 = new std::vector<float>();
73 m_hitLoc2 = new std::vector<float>();
74 m_hitSurfaceX = new std::vector<float>();
75 m_hitSurfaceY = new std::vector<float>();
76 m_hitSurfaceZ = new std::vector<float>();
77 m_hitSurfaceRadius = new std::vector<float>();
78 m_hitSurfacePhi = new std::vector<float>();
79 m_hitSurfaceTheta = new std::vector<float>();
80
81 return StatusCode::SUCCESS;
82}
83
88
89 delete m_hitX;
90 delete m_hitY;
91 delete m_hitZ;
92 delete m_hitRadius;
93 delete m_hitPhi;
94 delete m_hitLoc1;
95 delete m_hitLoc2;
96 delete m_hitSurfaceX;
97 delete m_hitSurfaceY;
98 delete m_hitSurfaceZ;
99 delete m_hitSurfaceRadius;
100 delete m_hitSurfacePhi;
101 delete m_hitSurfaceTheta;
102
103 ATH_MSG_INFO ("finalize() successful in " << name() );
104 return StatusCode::SUCCESS;
105}
106
107
112 TTree* tree,
113 const int& ) {
114
115
116 // add items
117 tree->Branch("HitX", &m_hitX);
118 tree->Branch("HitY", &m_hitY);
119 tree->Branch("HitZ", &m_hitZ);
120 tree->Branch("HitRadius", &m_hitRadius);
121 tree->Branch("HitPhi", &m_hitPhi);
122 tree->Branch("HitLocal1", &m_hitLoc1);
123 tree->Branch("HitLocal2", &m_hitLoc2);
124 tree->Branch("HitSurfaceX", &m_hitSurfaceX);
125 tree->Branch("HitSurfaceY", &m_hitSurfaceY);
126 tree->Branch("HitSurfaceZ", &m_hitSurfaceZ);
127 tree->Branch("HitSurfaceRadius", &m_hitSurfaceRadius);
128 tree->Branch("HitSurfacePhi", &m_hitSurfacePhi);
129 tree->Branch("HitSurfaceTheta", &m_hitSurfaceTheta);
130
131
132 ATH_MSG_VERBOSE ("added items to ntuple");
133 return StatusCode::SUCCESS;
134}
135
140 const Trk::MeasurementBase* measurement,
142 const int& /*detectorType*/,
143 const bool&) {
144
145
146 if (!measurement) {
147 ATH_MSG_ERROR ("no MeasurementBase given");
148 return StatusCode::FAILURE;
149 }
150 //--------------------------
151 // hit position info
152
153 // get surface, local and global parameters of the measurement
154 const Trk::Surface& hitSurface = measurement->associatedSurface();
155 const Amg::Vector3D& sfc = hitSurface.center();
156
157 const Trk::LocalParameters& lp = measurement->localParameters();
158 const Amg::Vector3D& gp = measurement->globalPosition();
159
160 // fill measurement global position
161 m_hitX->push_back( float(gp.x()) );
162 m_hitY->push_back( float(gp.y()) );
163 m_hitZ->push_back( float(gp.z()) );
164 m_hitRadius->push_back( float(gp.perp()) );
165 m_hitPhi->push_back( float(gp.phi()) );
166
167 // fill surface global position
168 m_hitSurfaceX->push_back( float(sfc.x()) );
169 m_hitSurfaceY->push_back( float(sfc.y()) );
170 m_hitSurfaceZ->push_back( float(sfc.z()) );
171 m_hitSurfaceRadius->push_back( float(sfc.perp()) );
172 m_hitSurfacePhi->push_back( float(sfc.phi()) );
173 m_hitSurfaceTheta->push_back( float(sfc.theta()) );
174
175 // fill measurement local positions - those which are measured
176 if (lp.contains(Trk::loc1))
177 m_hitLoc1->push_back( float(lp[Trk::loc1]) );
178 else
179 m_hitLoc1->push_back( s_errorEntry );
180
181 if (lp.contains(Trk::loc2))
182 m_hitLoc2->push_back( float(lp[Trk::loc2]) );
183 else
184 m_hitLoc2->push_back( s_errorEntry );
185
186 return StatusCode::SUCCESS;
187}
188
190 const int& ) {
191 m_hitX->clear();
192 m_hitY->clear();
193 m_hitZ->clear();
194 m_hitRadius->clear();
195 m_hitPhi->clear();
196 m_hitLoc1->clear();
197 m_hitLoc2->clear();
198 m_hitSurfaceX->clear();
199 m_hitSurfaceY->clear();
200 m_hitSurfaceZ->clear();
201 m_hitSurfaceRadius->clear();
202 m_hitSurfacePhi->clear();
203 m_hitSurfaceTheta->clear();
204
205 return StatusCode::SUCCESS;
206}
207
208
209
212 const int&) {
213 // we do nothing with holes
214 return StatusCode::SUCCESS;
215}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
static const float s_errorEntry
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
HitPositionNtupleHelper(const std::string &, const std::string &, const IInterface *)
virtual StatusCode fillMeasurementData(const Trk::MeasurementBase *, const Trk::TrackParameters *, const int &detectorType, const bool &isOutlier)
fill hit position data
std::vector< float > * m_hitZ
x-coordinate of GlobalPosition of the measurement UNIT:mm
std::vector< float > * m_hitSurfaceX
x-coordinate of GlobalPosition of the center of the measurement surface UNIT:mm
std::vector< float > * m_hitSurfacePhi
phi() of the center of the measurement surface UNIT:rad
std::vector< float > * m_hitRadius
perp() of GlobalPosition of the measurement UNIT:mm
std::vector< float > * m_hitPhi
phi() of GlobalPosition of the measurement UNIT:rad
std::vector< float > * m_hitSurfaceY
y-coordinate of GlobalPosition of the center of the measurement surface UNIT:mm
virtual StatusCode resetVariables(const int &detectorType)
reset ntuple variables
std::vector< float > * m_hitSurfaceZ
z-coordinate of GlobalPosition of the center of the measurement surface UNIT:mm
std::vector< float > * m_hitX
x-coordinate of GlobalPosition of the measurement UNIT:mm
std::vector< float > * m_hitSurfaceTheta
theta() of the center of the measurement surface UNIT:rad
std::vector< float > * m_hitY
y-coordinate of GlobalPosition of the measurement UNIT:mm
virtual StatusCode addNtupleItems(TTree *tree, const int &detectorType)
add items to the ntuple and configure the helper tool: should be called once (per detector type) by t...
std::vector< float > * m_hitLoc2
Trk::loc2 of the local position.
virtual StatusCode fillHoleData(const Trk::TrackStateOnSurface &, const int &)
fill special data about holes on track (here: do nothing)
std::vector< float > * m_hitSurfaceRadius
perp() of the center of the measurement surface UNIT:mm
std::vector< float > * m_hitLoc1
Trk::loc1 of the local position of the measurement UNIT:mm.
bool contains(ParamDefs par) const
The simple check for the clients whether the parameter is contained.
This class is the pure abstract base class for all fittable tracking measurements.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
virtual const Amg::Vector3D & globalPosition() const =0
Interface method to get the global Position.
Abstract Base Class for tracking surfaces.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
represents the track state (measurement, material, fit parameters and quality) at a surface.
Eigen::Matrix< double, 3, 1 > Vector3D
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ loc1
Definition ParamDefs.h:34
ParametersBase< TrackParametersDim, Charged > TrackParameters
TChain * tree