ATLAS Offline Software
Loading...
Searching...
No Matches
CompetingTRT_DriftCirclesOnTrack.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// CompetingTRT_DriftCirclesOnTrack.cxx, (c) ATLAS Detector software
8
9// Trk
10#include "GaudiKernel/MsgStream.h"
11#include "TrkSurfaces/Surface.h"
12// InDet
14// std
15#include <cmath>
16#include <ostream>
17
18// default constructor
27
28// copy constructor
31 : Trk::CompetingRIOsOnTrack(compROT)
32 , Trk::SurfacePtrHolderDetEl(compROT)
36{
37 std::vector<const InDet::TRT_DriftCircleOnTrack*>::const_iterator rotIter =
38 compROT.m_containedChildRots.begin();
39 for (; rotIter != compROT.m_containedChildRots.end(); ++rotIter) {
40 m_containedChildRots.push_back((*rotIter)->clone());
41 }
42 if (compROT.m_globalPosition) {
43 m_globalPosition.store(
44 std::make_unique<const Amg::Vector3D>(*(compROT.m_globalPosition)));
45 }
46}
47
48// explicit constructor
50 const Trk::Surface* sf,
51 std::vector<const InDet::TRT_DriftCircleOnTrack*>&& childrots,
52 std::vector<AssignmentProb>&& assgnProb,
53 const Trk::LocalParameters& effecLocalPars,
54 const Amg::MatrixX& effecLocalErrMat,
55 int ROTsHaveComSrfc // meaning of the values are described in the definition
56 // of ROTsHaveCommonSurface()
57 )
58 : Trk::CompetingRIOsOnTrack(std::move(assgnProb))
59 , Trk::SurfacePtrHolderDetEl(sf)
61 , m_containedChildRots(std::move(childrots))
62 , m_ROTsHaveCommonSurface(ROTsHaveComSrfc)
63{
64 m_localParams = effecLocalPars;
65 m_localCovariance = effecLocalErrMat;
66}
67
71{
72 if (this != &compROT) {
73 // assignment operator of base class
76
77 // clear rots
80
81 if (compROT.m_globalPosition) {
82 m_globalPosition.store(
83 std::make_unique<const Amg::Vector3D>(*compROT.m_globalPosition));
84 } else if (m_globalPosition) {
85 m_globalPosition.release().reset();
86 }
87 //
89 //
90 std::vector<const InDet::TRT_DriftCircleOnTrack*>::const_iterator rotIter =
91 compROT.m_containedChildRots.begin();
92 for (; rotIter != compROT.m_containedChildRots.end(); ++rotIter)
93 m_containedChildRots.push_back((*rotIter)->clone());
94 }
95 return (*this);
96}
97
101{
102 if (this != &compROT) {
103 // base class move
106 // rots
108 m_containedChildRots = std::move(compROT.m_containedChildRots);
109 m_globalPosition = std::move(compROT.m_globalPosition);
110 m_ROTsHaveCommonSurface = compROT.m_ROTsHaveCommonSurface;
111 }
112 return (*this);
113}
114
119
120void
122{
123 std::vector<const InDet::TRT_DriftCircleOnTrack*>::const_iterator rotIter =
124 m_containedChildRots.begin();
125 for (; rotIter != m_containedChildRots.end(); ++rotIter) {
126 delete (*rotIter);
127 }
128}
129
130MsgStream&
132{
133 using std::ios;
134 out << "Trk::CompetingTRT_DriftCirclesOnTrack with ["
135 << numberOfContainedROTs() << "] competing RIO_OnTrack objects"
136 << std::endl;
137 out << " - "
138 << (this->ROTsHaveCommonSurface(true) ? "on common surface"
139 : "over different surfaces")
140 << " (given prob>cut)" << std::endl;
142 out << " - GlobalPosition : ";
143 if (not m_globalPosition)
144 out << "null pointer" << endmsg;
145 else
146 out << *m_globalPosition << endmsg;
147 return out;
148}
149
150std::ostream&
152{
153 using std::ios;
154 out << "Trk::CompetingTRT_DriftCirclesOnTrack with ["
155 << numberOfContainedROTs() << "] competing RIO_OnTrack objects"
156 << std::endl;
157 out << " - "
158 << (this->ROTsHaveCommonSurface(true) ? "on common surface"
159 : "over different surfaces")
160 << " (given prob>cut)" << std::endl;
162 out << " - GlobalPosition : ";
163 if (not m_globalPosition)
164 out << "null pointer" << std::endl;
165 else
166 out << *m_globalPosition << std::endl;
167 return out;
168}
169
170// Have all the contained ROTs a common associated surface?
171bool
173 const bool withNonVanishingAssignProb) const
174{
175 // if (m_ROTsHaveCommonSurface==0) {
176 // values of int m_ROTsHaveCommonSurface:
177 // no yes NA (ROTs on a common surface) NA means not checked yet
178 // 0 1 2
179 // for all | just ROTs with non-vanishing assgnProb
180 // * 1 | * 3
181 if (withNonVanishingAssignProb) {
182 return (m_ROTsHaveCommonSurface / 3);
183 } else {
184 return (m_ROTsHaveCommonSurface % 3);
185 }
186}
187
188const Amg::Vector3D&
190{
191 if (m_globalPosition) {
192 return *m_globalPosition;
193 }
194 // cannot use the localToGlobal transformation, because the local z-coordinate
195 // along the wire is not known here. The contained TRT_DriftCircleOnTrack use
196 // the full transformation => use the weighted mean of their GlobalPositions
197 // FIXME: introduce a special function in base class, which returns the sum of
198 // assignment probabilities
199 double assgnProbSum = 0.;
200 std::vector<AssignmentProb>::const_iterator assgnProbIter =
201 m_assignProb.begin();
202 for (; assgnProbIter != m_assignProb.end(); ++assgnProbIter) {
203 assgnProbSum += (*assgnProbIter);
204 }
205
206 Amg::Vector3D globalPos(0., 0., 0.);
207 if (assgnProbSum > 0.) {
208 std::vector<const InDet::TRT_DriftCircleOnTrack*>::const_iterator rotIter =
209 std::as_const(m_containedChildRots).begin();
210 assgnProbIter = m_assignProb.begin();
211 for (; rotIter != std::as_const(m_containedChildRots).end();
212 ++rotIter, ++assgnProbIter) {
213 globalPos +=
214 (((*assgnProbIter) / assgnProbSum) * ((*rotIter)->globalPosition()));
215 }
216
217 } else {
218 globalPos = std::as_const(m_containedChildRots)[0]->globalPosition();
219 }
220 m_globalPosition.set(std::make_unique<const Amg::Vector3D>(globalPos));
221 return *m_globalPosition;
222}
223
224void
226{
227 std::cout << "InDet::CompetingTRT_DriftCirclesOnTrack: can not handle ROTs "
228 "in different surfaces without detector specific knowledge "
229 << std::endl;
230}
#define endmsg
Class for competing TRT_DriftCircles, it extends the Trk::CompetingRIOsOnTrack base class.
void clearChildRotVector()
private method to clear the Trk::RIO_OnTrack vector
CompetingTRT_DriftCirclesOnTrack & operator=(const CompetingTRT_DriftCirclesOnTrack &compROT)
Assignment operator.
virtual void setLocalParametersAndErrorMatrix()
recalculate the LocalParameters and ErrorMatrix
const Amg::Vector3D & globalPosition() const
Interface method to get the global Position.
unsigned int numberOfContainedROTs() const
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
CxxUtils::CachedUniquePtr< const Amg::Vector3D > m_globalPosition
The global Position.
bool ROTsHaveCommonSurface(const bool withNonVanishingAssignProb=true) const
Have all the contained ROTs a common associated surface?
MsgStream & dump(MsgStream &out) const
returns some information about this MeasurementBase/CompetingTRT_DriftCirclesOnTrack.
std::vector< const InDet::TRT_DriftCircleOnTrack * > m_containedChildRots
The vector of contained InDet::TRT_DriftCircleOnTrack objects.
std::vector< AssignmentProb > m_assignProb
assignment probabilities of the ROTs
CompetingRIOsOnTrack & operator=(const CompetingRIOsOnTrack &compROT)=default
Assignment operator.
virtual MsgStream & dump(MsgStream &out) const override
returns the some information about the base class members (avoid code duplication)
CompetingRIOsOnTrack()
Default Constructor for POOL.
LocalParameters m_localParams
Amg::MatrixX m_localCovariance
SurfacePtrHolderImplDetEl & operator=(const SurfacePtrHolderImplDetEl &other)
Abstract Base Class for tracking surfaces.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
STL namespace.