ATLAS Offline Software
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,
141  const Trk::TrackParameters*,
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 }
Trk::HitPositionNtupleHelper::fillHoleData
virtual StatusCode fillHoleData(const Trk::TrackStateOnSurface &, const int &)
fill special data about holes on track (here: do nothing)
Definition: HitPositionNtupleHelper.cxx:210
Trk::HitPositionNtupleHelper::initialize
StatusCode initialize()
initialize
Definition: HitPositionNtupleHelper.cxx:65
Trk::LocalParameters
Definition: LocalParameters.h:98
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
MeasurementBase.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Surface.h
TrackStateDefs.h
tree
TChain * tree
Definition: tile_monitor.h:30
Trk::LocalParameters::contains
bool contains(ParamDefs par) const
The simple check for the clients whether the parameter is contained.
HitPositionNtupleHelper.h
Trk::loc2
@ loc2
generic first and second local coordinate
Definition: ParamDefs.h:41
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::HitPositionNtupleHelper::finalize
StatusCode finalize()
finalize
Definition: HitPositionNtupleHelper.cxx:87
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::HitPositionNtupleHelper::~HitPositionNtupleHelper
~HitPositionNtupleHelper()
Trk::HitPositionNtupleHelper::HitPositionNtupleHelper
HitPositionNtupleHelper(const std::string &, const std::string &, const IInterface *)
Definition: HitPositionNtupleHelper.cxx:31
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
Trk::MeasurementBase::globalPosition
virtual const Amg::Vector3D & globalPosition() const =0
Interface method to get the global Position.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
Trk::HitPositionNtupleHelper::addNtupleItems
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...
Definition: HitPositionNtupleHelper.cxx:111
AthAlgTool
Definition: AthAlgTool.h:26
Trk::HitPositionNtupleHelper::resetVariables
virtual StatusCode resetVariables(const int &detectorType)
reset ntuple variables
Definition: HitPositionNtupleHelper.cxx:189
Trk::loc1
@ loc1
Definition: ParamDefs.h:40
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::HitPositionNtupleHelper::fillMeasurementData
virtual StatusCode fillMeasurementData(const Trk::MeasurementBase *, const Trk::TrackParameters *, const int &detectorType, const bool &isOutlier)
fill hit position data
Definition: HitPositionNtupleHelper.cxx:139