ATLAS Offline Software
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
21  , Trk::SurfacePtrHolderDetEl(nullptr)
22  , m_globalPosition{}
23  , m_containedChildRots()
24  , m_ROTsHaveCommonSurface(8)
25 {
26 }
27 
28 // copy constructor
31  : Trk::CompetingRIOsOnTrack(compROT)
32  , Trk::SurfacePtrHolderDetEl(compROT)
33  , m_globalPosition{}
34  , m_containedChildRots{}
35  , m_ROTsHaveCommonSurface(compROT.m_ROTsHaveCommonSurface)
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))
60  , m_globalPosition{}
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
79  m_containedChildRots.clear();
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 
100  InDet::CompetingTRT_DriftCirclesOnTrack&& compROT) noexcept
101 {
102  if (this != &compROT) {
103  // base class move
106  // rots
107  clearChildRotVector();
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 
116 {
118 }
119 
120 void
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 
130 MsgStream&
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 
150 std::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?
171 bool
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 
188 const 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 
224 void
226 {
227  std::cout << "InDet::CompetingTRT_DriftCirclesOnTrack: can not handle ROTs "
228  "in different surfaces without detector specific knowledge "
229  << std::endl;
230 }
Trk::LocalParameters
Definition: LocalParameters.h:98
CompetingTRT_DriftCirclesOnTrack.h
InDet::CompetingTRT_DriftCirclesOnTrack::m_containedChildRots
std::vector< const InDet::TRT_DriftCircleOnTrack * > m_containedChildRots
The vector of contained InDet::TRT_DriftCircleOnTrack objects.
Definition: CompetingTRT_DriftCirclesOnTrack.h:124
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
Trk::SurfacePtrHolderImplDetEl::operator=
SurfacePtrHolderImplDetEl & operator=(const SurfacePtrHolderImplDetEl &other)
copy assingmemnt if surface is free we clone/copy.
Definition: SurfaceHolderImpl.h:192
InDet::CompetingTRT_DriftCirclesOnTrack::numberOfContainedROTs
unsigned int numberOfContainedROTs() const
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
Definition: CompetingTRT_DriftCirclesOnTrack.h:159
Trk::CompetingRIOsOnTrack::dump
virtual MsgStream & dump(MsgStream &out) const override
returns the some information about the base class members (avoid code duplication)
Definition: CompetingRIOsOnTrack.cxx:115
InDet::CompetingTRT_DriftCirclesOnTrack::~CompetingTRT_DriftCirclesOnTrack
virtual ~CompetingTRT_DriftCirclesOnTrack()
Destructor.
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:115
Surface.h
InDet::CompetingTRT_DriftCirclesOnTrack::operator=
CompetingTRT_DriftCirclesOnTrack & operator=(const CompetingTRT_DriftCirclesOnTrack &compROT)
Assignment operator.
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:69
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
Trk::SurfacePtrHolderDetEl
Trk::SurfacePtrHolderImplDetEl< Surface > SurfacePtrHolderDetEl
Definition: SurfaceHolders.h:36
InDet::CompetingTRT_DriftCirclesOnTrack::dump
MsgStream & dump(MsgStream &out) const
returns some information about this MeasurementBase/CompetingTRT_DriftCirclesOnTrack.
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:131
Trk::CompetingRIOsOnTrack::operator=
CompetingRIOsOnTrack & operator=(const CompetingRIOsOnTrack &compROT)=default
Assignment operator.
Trk::MeasurementBaseType::CompetingRIOsOnTrack
@ CompetingRIOsOnTrack
Definition: MeasurementBase.h:50
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
InDet::CompetingTRT_DriftCirclesOnTrack::CompetingTRT_DriftCirclesOnTrack
CompetingTRT_DriftCirclesOnTrack()
Default Constructor for POOL.
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:19
InDet::CompetingTRT_DriftCirclesOnTrack::clearChildRotVector
void clearChildRotVector()
private method to clear the Trk::RIO_OnTrack vector
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:121
Trk::CompetingRIOsOnTrack::m_assignProb
std::vector< AssignmentProb > m_assignProb
assignment probabilities of the ROTs
Definition: CompetingRIOsOnTrack.h:125
InDet::CompetingTRT_DriftCirclesOnTrack::m_ROTsHaveCommonSurface
int m_ROTsHaveCommonSurface
Definition: CompetingTRT_DriftCirclesOnTrack.h:131
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
InDet::CompetingTRT_DriftCirclesOnTrack
Class for competing TRT_DriftCircles, it extends the Trk::CompetingRIOsOnTrack base class.
Definition: CompetingTRT_DriftCirclesOnTrack.h:48
InDet::CompetingTRT_DriftCirclesOnTrack::globalPosition
const Amg::Vector3D & globalPosition() const
Interface method to get the global Position.
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:189
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
InDet::CompetingTRT_DriftCirclesOnTrack::setLocalParametersAndErrorMatrix
virtual void setLocalParametersAndErrorMatrix()
recalculate the LocalParameters and ErrorMatrix
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:225
InDet::CompetingTRT_DriftCirclesOnTrack::ROTsHaveCommonSurface
bool ROTsHaveCommonSurface(const bool withNonVanishingAssignProb=true) const
Have all the contained ROTs a common associated surface? If withNonVanishingAssignProb==true just the...
Definition: CompetingTRT_DriftCirclesOnTrack.cxx:172
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
InDet::CompetingTRT_DriftCirclesOnTrack::m_globalPosition
CxxUtils::CachedUniquePtr< const Amg::Vector3D > m_globalPosition
The global Position.
Definition: CompetingTRT_DriftCirclesOnTrack.h:121