ATLAS Offline Software
AlignTSOS.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include "TrkSurfaces/Surface.h"
10 
11 #include <iostream>
12 
13 namespace Trk {
14 
15  //________________________________________________________________________
18  const RIO_OnTrack * rio,
20  : TrackStateOnSurface(tsos)
21  , m_module(module)
22  , m_rio(rio)
23  , m_crio(nullptr)
24  , m_unbiasedTrackPars(nullptr)
25  , m_derivatives(nullptr)
26  , m_isvalid(true)
27  , m_measType(measType)
28  , m_measDir(Trk::x)
29  , m_alphaStrip(0)
30  , m_derivativesVtx(nullptr)
31  {
32  if(!module)
33  m_isvalid = false;
34 
35  const TrkDetElementBase * detelement(nullptr);
37 
38  m_detelements.push_back(detelement);
39  }
40 
41  //________________________________________________________________________
44  const CompetingRIOsOnTrack* crio,
46  : TrackStateOnSurface(tsos)
47  , m_module(module)
48  , m_rio(nullptr)
49  , m_crio(crio)
50  , m_unbiasedTrackPars(nullptr)
51  , m_derivatives(nullptr)
52  , m_isvalid(true)
53  , m_measType(measType)
54  , m_measDir(Trk::x)
55  , m_alphaStrip(0)
56  , m_derivativesVtx(nullptr)
57  {
58  if(!module)
59  m_isvalid = false;
60 
61  for (unsigned int irio = 0; irio < crio->numberOfContainedROTs(); irio++) {
62  const Trk::RIO_OnTrack& rio = crio->rioOnTrack(irio);
64  }
65  }
66 
67  //________________________________________________________________________
70  : TrackStateOnSurface(tsos)
71  , m_module(nullptr)
72  , m_rio(nullptr)
73  , m_crio(nullptr)
74  , m_unbiasedTrackPars(nullptr)
75  , m_derivatives(nullptr)
76  , m_isvalid(false)
77  , m_measType(measType)
78  , m_measDir(Trk::x)
79  , m_alphaStrip(0)
80  , m_derivativesVtx(nullptr)
81  {
82  m_detelements.push_back(nullptr);
83  }
84 
85  //________________________________________________________________________
87  {
88  delete m_unbiasedTrackPars;
89  delete m_derivatives;
90  }
91 
92  //________________________________________________________________________
94  : TrackStateOnSurface(atsos)
95  , m_module(atsos.m_module)
96  , m_rio(atsos.m_rio)
97  , m_crio(atsos.m_crio)
98  , m_unbiasedTrackPars(atsos.m_unbiasedTrackPars ? atsos.m_unbiasedTrackPars->clone() : nullptr)
99  , m_residuals(atsos.m_residuals)
100  , m_detelements(atsos.m_detelements)
101  , m_derivatives(atsos.m_derivatives ? new std::vector<Amg::VectorX>(*(atsos.m_derivatives)) : nullptr)
102  , m_isvalid(atsos.m_isvalid)
103  , m_measType(atsos.m_measType)
104  , m_measDir(atsos.m_measDir)
105  , m_alphaStrip(atsos.m_alphaStrip)
106  , m_derivativesVtx(atsos.m_derivativesVtx)
107  {
108  }
109 
110  //________________________________________________________________________
112  {
113  if(this != &atsos) {
114 
115  // assign TrackStateOnSurface contents
117 
118  // copy the rest
119  m_module = atsos.m_module;
120  m_rio = atsos.m_rio;
121  m_crio = atsos.m_crio;
122 
123  m_residuals.clear();
124  m_residuals = atsos.m_residuals;
125 
126  m_detelements.clear();
128 
129  m_isvalid = atsos.m_isvalid;
130  m_measType = atsos.m_measType;
131  m_measDir = atsos.m_measDir;
132  m_alphaStrip = atsos.m_alphaStrip;
133 
134  delete m_unbiasedTrackPars;
136 
137  delete m_derivatives;
138  m_derivatives = atsos.m_derivatives ? new std::vector<Amg::VectorX>(*(atsos.m_derivatives)) : nullptr;
139 
141  }
142 
143  return *this;
144  }
145 
146  //________________________________________________________________________
148  {
149  Identifier id(0);
150  const MeasurementBase* mesb = this->measurementOnTrack();
151  const RIO_OnTrack* rio = dynamic_cast<const RIO_OnTrack*>(mesb);
152  if (rio) id=rio->identify();
153  return id;
154  }
155 
156  //________________________________________________________________________
157  const RIO_OnTrack* AlignTSOS::rio() const {
158  if (m_rio) return m_rio;
159  else if (m_crio) return &(m_crio->rioOnTrack(0));
160  else return nullptr;
161  }
162 
163  //________________________________________________________________________
164  MsgStream& operator << ( MsgStream& sl, const AlignTSOS& atsos)
165  {
166  //sl <<"\t"<<atsos.dumpType()
167  // << std::setw(11) << std::showpos<< std::scientific
168  // <<"\tres[0]="<<atsos.residual(0)<<", err[0]="<<atsos.residualErrorSq(0)
169  // <<", dchi2="<<std::noshowpos
170  // <<atsos.residual(0)*atsos.residual(0)/atsos.residualErrorSq(0)<<endmsg;
171  sl <<"\t"<<atsos.dumpType()<<" ("<<atsos.dumpMeasType()<<", direction "<<atsos.dumpMeasDir()<<")"<<endmsg;
172  sl << " --> ";
173 
174  int ires(0);
175  std::vector<Residual>::const_iterator itRes = atsos.firstResidual();
176  std::vector<Residual>::const_iterator itRes_end = atsos.lastResidual();
177  for( ; itRes != itRes_end ; ++itRes, ++ires) {
178  double resnorm = itRes->residualNorm();
179  if(ires){
180  std::ios_base::fmtflags f(sl.stream().flags());
181  sl << endmsg << " --> ";
182  sl << ires << ": res="
183  << std::setw(11) << std::showpos << std::scientific
184  << itRes->residual() <<" res/err="<<resnorm
185  << ", dchi2="<<std::noshowpos<<resnorm*resnorm
186  << resetiosflags(std::ios::floatfield);
187  sl.flags(f);
188  }
189  }
190  return sl;
191  }
192 
193  //________________________________________________________________________
194  std::string AlignTSOS::dumpMeasType() const
195  {
196  switch(m_measType) {
197  case Trk::TrackState::unidentified: return "none";
198  case Trk::TrackState::Pixel: return "Pixel";
199  case Trk::TrackState::SCT: return "SCT";
200  case Trk::TrackState::TRT: return "TRT";
201  case Trk::TrackState::MDT: return "MDT";
202  case Trk::TrackState::CSC: return "CSC";
203  case Trk::TrackState::RPC: return "RPC";
204  case Trk::TrackState::TGC: return "TGC";
205  case Trk::TrackState::Pseudo: return "Pseudo";
206  case Trk::TrackState::Vertex: return "Vertex";
207  case Trk::TrackState::Segment: return "Segment";
208  case Trk::TrackState::SpacePoint: return "SpacePoint";
209  default: return "UNDEFINED";
210  }
211  }
212 
213  //________________________________________________________________________
214  std::string AlignTSOS::dumpMeasDir() const
215  {
216  switch(m_measDir) {
217  case Trk::x: return "X";
218  case Trk::y: return "Y";
219  case Trk::z: return "Z";
220  default: return "?";
221  }
222  }
223 
224 } // end namespace
225 
Trk::y
@ y
Definition: ParamDefs.h:56
TrkDetElementBase.h
Trk::TrackState::Vertex
@ Vertex
Definition: TrackStateDefs.h:36
Trk::TrackStateOnSurface::operator=
Trk::TrackStateOnSurface & operator=(const Trk::TrackStateOnSurface &rhs)
Definition: TrackStateOnSurface.cxx:110
Trk::TrackState::RPC
@ RPC
Definition: TrackStateDefs.h:33
Trk::TrackState::Pixel
@ Pixel
Definition: TrackStateDefs.h:28
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:30
Trk::Surface::associatedDetectorElement
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
Trk::AlignTSOS::m_residuals
std::vector< Residual > m_residuals
Definition: AlignTSOS.h:165
Trk::AlignTSOS::rio
const RIO_OnTrack * rio() const
returns RIO_OnTrack or leading RIO of CompetingRIOsOnTrack (assigned by c'tor)
Definition: AlignTSOS.cxx:157
Trk::z
@ z
global position (cartesian)
Definition: ParamDefs.h:57
Trk::TrackState::TRT
@ TRT
Definition: TrackStateDefs.h:30
Trk::AlignTSOS::m_derivatives
std::vector< Amg::VectorX > * m_derivatives
Definition: AlignTSOS.h:169
CompetingRIOsOnTrack.h
Surface.h
Trk::TrackState::Segment
@ Segment
Definition: TrackStateDefs.h:37
Trk::TrackState::MDT
@ MDT
Definition: TrackStateDefs.h:31
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
Trk::AlignTSOS
Definition: AlignTSOS.h:37
Trk::AlignModule
Definition: AlignModule.h:45
Trk::TrackStateOnSurface::dumpType
std::string dumpType() const
returns a string with the expanded type of the object (i.e.
Definition: TrackStateOnSurface.cxx:147
Trk::TrackStateOnSurface::measurementOnTrack
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
Trk::TrkDetElementBase
Definition: TrkDetElementBase.h:52
Trk::TrackState::TGC
@ TGC
Definition: TrackStateDefs.h:34
Trk::AlignTSOS::m_isvalid
bool m_isvalid
Definition: AlignTSOS.h:171
Trk::AlignTSOS::AlignTSOS
AlignTSOS()
Trk::TrackState::unidentified
@ unidentified
Definition: TrackStateDefs.h:27
Trk::AlignTSOS::m_alphaStrip
double m_alphaStrip
Definition: AlignTSOS.h:177
Trk::AlignTSOS::m_measDir
Trk::ParamDefs m_measDir
direction of measurement (set to Trk::x by default)
Definition: AlignTSOS.h:175
python.Utilities.clone
clone
Definition: Utilities.py:134
Trk::AlignTSOS::module
const AlignModule * module() const
accessor method for AlignModule to which tsos belongs
Definition: AlignTSOS.h:69
AlignTSOS.h
Trk::TrackState::SpacePoint
@ SpacePoint
Definition: TrackStateDefs.h:38
Trk::AlignTSOS::m_detelements
std::vector< const TrkDetElementBase * > m_detelements
Definition: AlignTSOS.h:167
python.PyAthena.module
module
Definition: PyAthena.py:131
Trk::AlignTSOS::m_derivativesVtx
std::vector< Amg::VectorX > * m_derivativesVtx
Definition: AlignTSOS.h:179
Trk::CompetingRIOsOnTrack::rioOnTrack
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
Trk::AlignTSOS::dumpMeasType
std::string dumpMeasType() const
returns string corresponding to the measurement type
Definition: AlignTSOS.cxx:194
Trk::AlignTSOS::dumpMeasDir
std::string dumpMeasDir() const
returns string corresponding to the measurement direction
Definition: AlignTSOS.cxx:214
Trk::AlignTSOS::m_module
AlignModule * m_module
Definition: AlignTSOS.h:159
Trk::CompetingRIOsOnTrack::numberOfContainedROTs
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
Trk::AlignTSOS::operator=
AlignTSOS & operator=(const AlignTSOS &atsos)
asignment operator
Definition: AlignTSOS.cxx:111
Trk::TrackState::Pseudo
@ Pseudo
Definition: TrackStateDefs.h:35
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
vector
Definition: MultiHisto.h:13
Trk::AlignTSOS::lastResidual
std::vector< Residual >::const_iterator lastResidual() const
returns last Residual iterator
Definition: AlignTSOS.h:107
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
Trk::TrackState::MeasurementType
MeasurementType
enum describing the flavour of MeasurementBase
Definition: TrackStateDefs.h:26
Trk::AlignTSOS::detelement
const TrkDetElementBase * detelement(int i=0) const
method for retrieving detector elements (one if RIO, more if CRIO)
Definition: AlignTSOS.h:110
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Trk::AlignTSOS::m_crio
const CompetingRIOsOnTrack * m_crio
Definition: AlignTSOS.h:161
Trk::AlignTSOS::m_unbiasedTrackPars
const TrackParameters * m_unbiasedTrackPars
Definition: AlignTSOS.h:163
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::AlignTSOS::m_measType
TrackState::MeasurementType m_measType
Definition: AlignTSOS.h:173
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
RIO_OnTrack.h
Trk::AlignTSOS::m_rio
const RIO_OnTrack * m_rio
Definition: AlignTSOS.h:160
Trk::AlignTSOS::identify
Identifier identify() const
returns Identifier of RIO
Definition: AlignTSOS.cxx:147
Trk::AlignTSOS::~AlignTSOS
virtual ~AlignTSOS()
destructor
Definition: AlignTSOS.cxx:86
Trk::operator<<
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
Definition: AlignModule.cxx:204
Trk::AlignTSOS::crio
const CompetingRIOsOnTrack * crio() const
returns CompetingRIOsOnTrack
Definition: AlignTSOS.h:92
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
Trk::TrackState::CSC
@ CSC
Definition: TrackStateDefs.h:32
Trk::RIO_OnTrack::associatedSurface
virtual const Surface & associatedSurface() const override=0
returns the surface for the local to global transformation
Trk::TrackState::SCT
@ SCT
Definition: TrackStateDefs.h:29
Trk::AlignTSOS::firstResidual
std::vector< Residual >::const_iterator firstResidual() const
returns first Residual iterator
Definition: AlignTSOS.h:104
Trk::x
@ x
Definition: ParamDefs.h:55
Trk::ParametersBase::clone
virtual ParametersBase< DIM, T > * clone() const override=0
clone method for polymorphic deep copy
Identifier
Definition: IdentifierFieldParser.cxx:14