ATLAS Offline Software
LocalParameters.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // LocalParameters.cxx, (c) ATLAS Detector software
8 
9 #include <typeinfo>
10 // Trk
13 //Gaudi
14 #include "GaudiKernel/MsgStream.h"
15 
16 namespace {
17 const Trk::ProjectionMatricesSet s_projectionMatrices(5);
18 }
19 
21  : Amg::VectorX(1), m_parameterkey(0) {
22  Amg::VectorX::operator[](0) = par1.first;
23  m_parameterkey |= 1 << int(par1.second);
24 }
25 
27  : Amg::VectorX(2), m_parameterkey(3) {
28  Amg::VectorX::operator[](0) = lp[Trk::locX];
29  Amg::VectorX::operator[](1) = lp[Trk::locY];
30 }
31 
33  const Trk::DefinedParameter& par2)
34  : Amg::VectorX(2), m_parameterkey(0) {
35  Amg::VectorX::operator[](0) = par1.first;
36  m_parameterkey |= 1 << int(par1.second);
37 
38  Amg::VectorX::operator[](1) = par2.first;
39  m_parameterkey |= 1 << int(par2.second);
40 }
41 
43  double tloc2,
44  double tphi,
45  double ttheta,
46  double tqOverP)
47  : Amg::VectorX(5), m_parameterkey(31) {
48  Amg::VectorX::operator[](0) = tloc1;
49  Amg::VectorX::operator[](1) = tloc2;
50  Amg::VectorX::operator[](2) = tphi;
51  Amg::VectorX::operator[](3) = ttheta;
52  Amg::VectorX::operator[](4) = tqOverP;
53 }
54 
55 Trk::LocalParameters::LocalParameters(const std::vector<Trk::DefinedParameter>& parms)
56  : Amg::VectorX(parms.size()),
57  m_parameterkey(0) {
58  const size_t parSize = parms.size();
59  assert(parSize > 0 && parSize <= 5);
60  // fill the Amg::VectorX
61  std::vector<Trk::DefinedParameter>::const_iterator parIter = parms.begin();
62  for (size_t idx = 0; idx < parSize; ++idx) {
63  Amg::VectorX::operator[](idx) = parIter->first;
64  m_parameterkey |= 1 << int(parIter->second);
65  ++parIter;
66  }
67 }
68 
70  return s_projectionMatrices.reductionMatrix(m_parameterkey);
71 }
72 
74  return s_projectionMatrices.expansionMatrix(m_parameterkey);
75 }
76 
78 {
79  if (m_parameterkey == 31 || m_parameterkey == 1 || m_parameterkey == 3) {
80  return Amg::VectorX::operator[](par);
81  }
82  return Amg::VectorX::operator[](
83  s_projectionMatrices.accessor(m_parameterkey, par));
84 }
85 
87 {
88  if (m_parameterkey == 31 || m_parameterkey == 1 || m_parameterkey == 3) {
89  return Amg::VectorX::operator[](par);
90  }
91  return Amg::VectorX::operator[](
92  s_projectionMatrices.accessor(m_parameterkey, par));
93 }
94 
95 namespace Trk {
96 
98 MsgStream& operator << ( MsgStream& sl, const Trk::LocalParameters& lp)
99 {
100  std::streamsize ss = sl.precision();
101  sl << std::setiosflags(std::ios::fixed)<< std::setprecision(3);
102  sl << "Trk::LocalParameters " <<": (";
103  for (int ipar=0; ipar<lp.dimension(); ++ipar)
104  { sl << lp(ipar);
105  if (ipar+1 < lp.dimension()) { sl << ", ";
106  } else { sl << ") - key: "<< lp.m_parameterkey << "(";}
107  }
108 
109  for (int itag = 0, ipos=1; itag<5; ++itag, ipos*=2)
110  { bool bit = (lp.m_parameterkey & ipos);
111  if (bit) { sl << "1";
112  } else { sl << "0";}
113  }
114  sl << ")";
115  sl.precision (ss); sl<<std::resetiosflags(std::ios::fixed);
116 
117  return sl;
118 }
119 
120 std::ostream& operator << ( std::ostream& sl, const Trk::LocalParameters& lp)
121 {
122  std::streamsize ss = sl.precision();
123  sl << std::setiosflags(std::ios::fixed)<< std::setprecision(3);
124  sl << "Trk::LocalParameters " <<": (";
125  for (int ipar=0; ipar<lp.dimension(); ++ipar)
126  { sl << lp(ipar);
127  if (ipar+1 < lp.dimension()) { sl << ", ";
128  } else { sl << ") - key: "<< lp.m_parameterkey << "(";}
129  }
130 
131  for (int itag = 0, ipos=1; itag<5; ++itag, ipos*=2)
132  { bool bit = (lp.m_parameterkey & ipos);
133  if (bit) { sl << "1";
134  } else { sl << "0";
135  }
136  }
137  sl << ")";
138  sl.precision (ss); sl<<std::resetiosflags(std::ios::fixed);
139 
140 
141  return sl;
142 }
143 
144 
145 } // namespace Trk
146 
147 
Trk::LocalParameters::reductionMatrix
const Amg::MatrixX & reductionMatrix() const
Reduction matrix from 5x5 to the [dimension()]x[dimension()].
Definition: LocalParameters.cxx:69
Trk::LocalParameters::expansionMatrix
const Amg::MatrixX & expansionMatrix() const
Expansion matrix from 5x5 to the [dimension()]x[dimension()].
Definition: LocalParameters.cxx:73
Trk::LocalParameters
Definition: LocalParameters.h:98
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:30
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::ProjectionMatricesSet
the matrices to access the variably-dimensioned local parameters and map them to the defined five tra...
Definition: ProjectionMatricesSet.h:29
Trk::ParamDefs
ParamDefs
Definition: ParamDefs.h:32
Trk::LocalParameters::LocalParameters
LocalParameters()=default
Default constructor used for POOL.
Trk::DefinedParameter
std::pair< double, ParamDefs > DefinedParameter
Definition: DefinedParameter.h:27
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
DefinedParameter.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::LocalParameters::operator[]
const double & operator[](ParamDefs par) const
Read from data members.
Definition: LocalParameters.cxx:77
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
LocalParameters.h
Trk::LocalParameters::dimension
int dimension() const
Dimension of this localParameters() vector.
Trk::LocalParameters::m_parameterkey
int m_parameterkey
Definition: LocalParameters.h:179
Trk::operator<<
MsgStream & operator<<(MsgStream &sl, const AlignModule &alignModule)
overload of << operator for MsgStream for debug output
Definition: AlignModule.cxx:204
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69