ATLAS Offline Software
Loading...
Searching...
No Matches
DAF_ValidationNtupleHelper.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// DAF_ValidationNtupleHelper.cxx
7// Source file for class DAF_ValidationNtupleHelper
9// (c) ATLAS Detector software
11// 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#include "TTree.h"
22#include "TBranch.h"
23// Trk
27
28#include "TrkSurfaces/Surface.h"
29
32
33
34// constructor
36 const std::string& t,
37 const std::string& n,
38 const IInterface* p )
39 :
40AthAlgTool(t,n,p),
41 m_residualPullCalculator("Trk::ResidualPullCalculator/ResidualPullCalculator"),
42 m_isUnbiased(nullptr),
43 m_nContainedROTs(nullptr),
44 m_indexOfMaxAssgnProb(nullptr),
45 m_maxAssgnProb(nullptr)
46
47
48 {
49 declareInterface<IValidationNtupleHelperTool>(this);
50 declareProperty("IgnoreMissingTrackCovarianceForPulls", m_ignoreMissTrkCov = false, "Do not warn, if track states do not have covariance matries when calculating pulls");
51 declareProperty("WriteMeasurementPositionOfROTs", m_writeHitPositions = true, "Write measurement positions?");
52 declareProperty("ResidualPullCalculatorTool", m_residualPullCalculator, "Tool to calculate residuals and pulls");
53}
54
55// destructor
57
58
59
64
65 StatusCode sc;
66
67 // get the ResidualPullCalculator
68 sc = m_residualPullCalculator.retrieve();
69 if (sc.isFailure()) {
70 ATH_MSG_FATAL ("Could not retrieve "<< m_residualPullCalculator <<" (to calculate residuals and pulls) " );
71 return sc;
72 }
73
74 return StatusCode::SUCCESS;
75}
76
81 ATH_MSG_INFO ( "finalize() successful in " << name() );
82 return StatusCode::SUCCESS;
83}
84
85
90 TTree* tree,
91 //const std::bitset<8>& detectorType
92 const int& ) {
93
94 // retrieve item (is the used track state unbiased?) from ntuple
95 TBranch* trackStatesUnbiasedBranch = tree->GetBranch("TrackStatesUnbiased");
96 if (!trackStatesUnbiasedBranch) {
97 ATH_MSG_ERROR ("Unable to get Branch TrackStatesUnbiased in ntuple" );
98 return StatusCode::FAILURE;
99 }
100 void* variableAdr = static_cast<void*>(trackStatesUnbiasedBranch->GetAddress());
101 if (!variableAdr) {
102 ATH_MSG_ERROR ( "Unable to get variable address of Branch TrackStatesUnbiased" );
103 return StatusCode::FAILURE;
104 }
105 ATH_MSG_VERBOSE ("Address of variable: " << variableAdr);
106 m_isUnbiased = static_cast<int*>(variableAdr);
107
108 // add items
109 m_nContainedROTs = new std::vector<int>();
110 m_indexOfMaxAssgnProb = new std::vector<int>();
111 m_maxAssgnProb = new std::vector<float>();
112 tree->Branch("CompROTnContainedROTs", &m_nContainedROTs); // number of contained ROTs in the CompetingRIOsOnTrack (1-dim array: CompROTnContainedROTs[nHits])
113 tree->Branch("CompROTindexOfMaxAssgnProb", &m_indexOfMaxAssgnProb); // index of the ROT with the maximum assignment probability
114 tree->Branch("CompROTmaxAssgnProb", &m_maxAssgnProb); // maximum assignment probability
115
116 ATH_MSG_VERBOSE ("added items to ntuple");
117 return StatusCode::SUCCESS;
118}
119
124 const Trk::MeasurementBase* measurement,
125 const Trk::TrackParameters* trkParameters,
126 //const NTuple::Item<long>& numberOfHits,
127 //const std::bitset<8>& detectorType
128 const int&,
129 const bool& isOutlier) {
130
131 if (isOutlier) {
132 // we do nothing for outliers, because competing ROTs are no outliers by definition
133 return StatusCode::SUCCESS;
134 }
135 if (!trkParameters) {
136 ATH_MSG_ERROR ( "no TrackParameters given" );
137 return StatusCode::FAILURE;
138 }
139
140 const Trk::CompetingRIOsOnTrack* comprot = dynamic_cast<const Trk::CompetingRIOsOnTrack*>(measurement);
141 if (comprot) {
142 ATH_MSG_VERBOSE ( "measurement is CompetingRIOsOnTrack, fill ntuple variables" );
143 //--------------------------
144 // status info about compROT
145 m_nContainedROTs->push_back(comprot->numberOfContainedROTs());
146 unsigned int indexOfMaxAssgnProb = comprot->indexOfMaxAssignProb();
147 m_indexOfMaxAssgnProb->push_back(indexOfMaxAssgnProb);
148 m_maxAssgnProb->push_back(comprot->assignmentProbability(indexOfMaxAssgnProb));
149
150 } else {
151 m_nContainedROTs->push_back(0);
152 m_indexOfMaxAssgnProb->push_back(0);
153 m_maxAssgnProb->push_back(0.);
154 ATH_MSG_VERBOSE ( "measurement is not a CompetingRIOsOnTrack, ignore it");
155 }
156 return StatusCode::SUCCESS;
157}
158
160 const int& ) {
161 m_nContainedROTs->clear();
162 m_indexOfMaxAssgnProb->clear();
163 m_maxAssgnProb->clear();
164 return StatusCode::SUCCESS;
165}
166
169 const int&) {
170 // we do nothing with holes
171 return StatusCode::SUCCESS;
172}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
static Double_t sc
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
AssignmentProb assignmentProbability(unsigned int indx) const
returns the AssignmentProbability depending on the integer.
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
unsigned int indexOfMaxAssignProb() const
Index of the ROT with the highest assignment probability.
virtual StatusCode fillHoleData(const Trk::TrackStateOnSurface &, const int &)
fill special data about holes on track (here: do nothing)
ToolHandle< Trk::IResidualPullCalculator > m_residualPullCalculator
The residual and pull calculator tool.
virtual StatusCode fillMeasurementData(const Trk::MeasurementBase *, const Trk::TrackParameters *, const int &detectorType, const bool &isOutlier)
fill Trk::CompetingRIOsOnTrack data
virtual StatusCode resetVariables(const int &detectorType)
reset ntuple variables
bool m_writeHitPositions
jobOption: shall the positions of the contained ROTs be written?
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...
DAF_ValidationNtupleHelper(const std::string &, const std::string &, const IInterface *)
This class is the pure abstract base class for all fittable tracking measurements.
represents the track state (measurement, material, fit parameters and quality) at a surface.
ParametersBase< TrackParametersDim, Charged > TrackParameters
TChain * tree