CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
AlignmentParameters Class Referenceabstract

#include <AlignmentParameters.h>

Inheritance diagram for AlignmentParameters:
BeamSpotAlignmentParameters BowedSurfaceAlignmentParameters RigidBodyAlignmentParameters SurveyParameters TwoBowedSurfacesAlignmentParameters RigidBodyAlignmentParameters4D

Public Types

typedef
AlignmentParametersData::DataContainer 
DataContainer
 

Public Member Functions

Alignablealignable (void) const
 Get pointer to corresponding alignable. More...
 
 AlignmentParameters ()
 Default constructor. More...
 
 AlignmentParameters (Alignable *object, const AlgebraicVector &par, const AlgebraicSymMatrix &cov)
 Constructor from given input. More...
 
 AlignmentParameters (Alignable *object, const AlgebraicVector &par, const AlgebraicSymMatrix &cov, const std::vector< bool > &sel)
 Constructor including selection of active parameters. More...
 
 AlignmentParameters (Alignable *object, const DataContainer &data)
 Constructor. More...
 
virtual void apply ()=0
 apply parameters to alignable More...
 
virtual AlignmentParametersclone (const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
 Enforce clone methods in derived classes. More...
 
virtual AlignmentParameterscloneFromSelected (const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const =0
 
const AlgebraicSymMatrixcovariance (void) const
 Get parameter covariance matrix. More...
 
virtual AlgebraicMatrix derivatives (const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
 Get derivatives of selected parameters. More...
 
virtual unsigned int hierarchyLevel () const
 
bool isValid (void) const
 Get validity flag. More...
 
int numSelected (void) const
 Get number of selected parameters. More...
 
const AlgebraicVectorparameters (void) const
 Get alignment parameters. More...
 
AlgebraicSymMatrix selectedCovariance (void) const
 Get covariance matrix of selected parameters. More...
 
virtual AlgebraicMatrix selectedDerivatives (const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const
 
AlgebraicVector selectedParameters (void) const
 Get selected parameters. More...
 
const std::vector< bool > & selector (void) const
 Get alignment parameter selector vector. More...
 
void setUserVariables (AlignmentUserVariables *auv)
 Set pointer to user variables. More...
 
void setValid (bool v)
 Set validity flag. More...
 
int size (void) const
 Get number of parameters. More...
 
virtual int type () const =0
 tell type (AlignmentParametersFactory::ParametersType - but no circular dependency) More...
 
AlignmentUserVariablesuserVariables (void) const
 Get pointer to user variables. More...
 
virtual ~AlignmentParameters ()
 Destructor. More...
 

Protected Member Functions

AlgebraicSymMatrix collapseSymMatrix (const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
 
AlgebraicVector collapseVector (const AlgebraicVector &m, const std::vector< bool > &sel) const
 
AlgebraicSymMatrix expandSymMatrix (const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
 
AlgebraicVector expandVector (const AlgebraicVector &m, const std::vector< bool > &sel) const
 

Protected Attributes

bool bValid
 True if parameters are valid. More...
 
AlignabletheAlignable
 
DataContainer theData
 
AlignmentUserVariablestheUserVariables
 

Detailed Description

Base class for alignment parameters

It contains a parameter vector of size N and a covariance matrix of size NxN. There is a pointer to the Alignable to which the parameters belong. There is also a pointer to UserVariables. Parameters can be enabled/disabled using theSelector. bValid declares if the parameters are 'valid'. The methods selected set/return only the active parameters/derivatives/covariance as subvector/submatrix of reduced size.

Date:
2010/10/26 19:50:21
Revision:
1.9

(last update by

Author:
flucke

)

Definition at line 35 of file AlignmentParameters.h.

Member Typedef Documentation

Definition at line 37 of file AlignmentParameters.h.

Constructor & Destructor Documentation

AlignmentParameters::AlignmentParameters ( )

Default constructor.

Definition at line 9 of file AlignmentParameters.cc.

9 : theAlignable(nullptr), theUserVariables(nullptr), bValid(true) {}
bool bValid
True if parameters are valid.
AlignmentUserVariables * theUserVariables
AlignmentParameters::AlignmentParameters ( Alignable object,
const AlgebraicVector par,
const AlgebraicSymMatrix cov 
)

Constructor from given input.

Definition at line 12 of file AlignmentParameters.cc.

References theData.

13  : theAlignable(object),
15  theUserVariables(nullptr),
16  bValid(true) {
17  // is the data consistent?
18  theData->checkConsistency();
19 }
AlignmentParametersData::DataContainer DataContainer
bool bValid
True if parameters are valid.
AlignmentUserVariables * theUserVariables
AlignmentParameters::AlignmentParameters ( Alignable object,
const AlgebraicVector par,
const AlgebraicSymMatrix cov,
const std::vector< bool > &  sel 
)

Constructor including selection of active parameters.

Definition at line 22 of file AlignmentParameters.cc.

References theData.

26  : theAlignable(object),
28  theUserVariables(nullptr),
29  bValid(true) {
30  // is the data consistent?
31  theData->checkConsistency();
32 }
AlignmentParametersData::DataContainer DataContainer
bool bValid
True if parameters are valid.
AlignmentUserVariables * theUserVariables
AlignmentParameters::AlignmentParameters ( Alignable object,
const DataContainer data 
)

Constructor.

Definition at line 35 of file AlignmentParameters.cc.

References theData.

36  : theAlignable(object), theData(data), theUserVariables(nullptr), bValid(true) {
37  // is the data consistent?
38  theData->checkConsistency();
39 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
bool bValid
True if parameters are valid.
AlignmentUserVariables * theUserVariables
AlignmentParameters::~AlignmentParameters ( )
virtual

Destructor.

Definition at line 42 of file AlignmentParameters.cc.

References theUserVariables.

42  {
43  if (theUserVariables)
44  delete theUserVariables;
45 }
AlignmentUserVariables * theUserVariables

Member Function Documentation

Alignable * AlignmentParameters::alignable ( void  ) const
virtual void AlignmentParameters::apply ( )
pure virtual
virtual AlignmentParameters* AlignmentParameters::clone ( const AlgebraicVector par,
const AlgebraicSymMatrix cov 
) const
pure virtual
virtual AlignmentParameters* AlignmentParameters::cloneFromSelected ( const AlgebraicVector par,
const AlgebraicSymMatrix cov 
) const
pure virtual
AlgebraicSymMatrix AlignmentParameters::collapseSymMatrix ( const AlgebraicSymMatrix m,
const std::vector< bool > &  sel 
) const
protected

Definition at line 140 of file AlignmentParameters.cc.

References Exception, mps_fire::i, dqmiolumiharvest::j, mps_fire::result, and size().

Referenced by selectedCovariance().

141  {
142  int nRows = m.num_row();
143  int size = sel.size();
144 
145  // Check size matching
146  if (nRows != size)
147  throw cms::Exception("LogicError") << "Size mismatch in parameters"
148  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
149 
150  // If OK, continue
151  std::vector<int> rowvec;
152  for (int i = 0; i < nRows; i++)
153  if (sel[i])
154  rowvec.push_back(i);
155 
156  int nSelectedRows = rowvec.size();
157  AlgebraicSymMatrix result(nSelectedRows, 0);
158  for (int i = 0; i < nSelectedRows; i++)
159  for (int j = 0; j < nSelectedRows; j++)
160  result[i][j] = m[rowvec[i]][rowvec[j]];
161 
162  return result;
163 }
tuple result
Definition: mps_fire.py:311
int size(void) const
Get number of parameters.
CLHEP::HepSymMatrix AlgebraicSymMatrix
AlgebraicVector AlignmentParameters::collapseVector ( const AlgebraicVector m,
const std::vector< bool > &  sel 
) const
protected

Definition at line 166 of file AlignmentParameters.cc.

References Exception, mps_fire::i, mps_fire::result, and size().

Referenced by selectedParameters().

166  {
167  int nRows = m.num_row();
168  int size = sel.size();
169 
170  // Check size matching
171  if (nRows != size)
172  throw cms::Exception("LogicError") << "Size mismatch in parameters"
173  << " (input vector = " << nRows << ", selection: " << size << ")";
174 
175  // If OK, continue
176  std::vector<int> rowvec;
177  for (int i = 0; i < nRows; i++)
178  if (sel[i])
179  rowvec.push_back(i);
180 
181  int nSelectedRows = rowvec.size();
182  AlgebraicVector result(nSelectedRows, 0);
183  for (int i = 0; i < nSelectedRows; i++)
184  result[i] = m[(int)rowvec[i]];
185 
186  return result;
187 }
tuple result
Definition: mps_fire.py:311
CLHEP::HepVector AlgebraicVector
int size(void) const
Get number of parameters.
const AlgebraicSymMatrix & AlignmentParameters::covariance ( void  ) const
virtual AlgebraicMatrix AlignmentParameters::derivatives ( const TrajectoryStateOnSurface tsos,
const AlignableDetOrUnitPtr alidet 
) const
pure virtual
AlgebraicSymMatrix AlignmentParameters::expandSymMatrix ( const AlgebraicSymMatrix m,
const std::vector< bool > &  sel 
) const
protected

Definition at line 190 of file AlignmentParameters.cc.

References Exception, mps_fire::i, dqmiolumiharvest::j, mps_fire::result, and size().

Referenced by BeamSpotAlignmentParameters::cloneFromSelected(), RigidBodyAlignmentParameters::cloneFromSelected(), RigidBodyAlignmentParameters4D::cloneFromSelected(), BowedSurfaceAlignmentParameters::cloneFromSelected(), and TwoBowedSurfacesAlignmentParameters::cloneFromSelected().

191  {
192  int nRows = m.num_row();
193  int size = sel.size();
194 
195  std::vector<int> rowvec;
196  for (int i = 0; i < size; i++)
197  if (sel[i])
198  rowvec.push_back(i);
199 
200  // Check size matching
201  if (nRows != static_cast<int>(rowvec.size()))
202  throw cms::Exception("LogicError") << "Size mismatch in parameters"
203  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
204 
205  // If OK, continue
206  AlgebraicSymMatrix result(size, 0);
207  for (int i = 0; i < nRows; i++)
208  for (int j = 0; j < nRows; j++)
209  result[rowvec[i]][rowvec[j]] = m[i][j];
210 
211  return result;
212 }
tuple result
Definition: mps_fire.py:311
int size(void) const
Get number of parameters.
CLHEP::HepSymMatrix AlgebraicSymMatrix
AlgebraicVector AlignmentParameters::expandVector ( const AlgebraicVector m,
const std::vector< bool > &  sel 
) const
protected

Definition at line 215 of file AlignmentParameters.cc.

References Exception, mps_fire::i, mps_fire::result, and size().

Referenced by BeamSpotAlignmentParameters::cloneFromSelected(), RigidBodyAlignmentParameters::cloneFromSelected(), RigidBodyAlignmentParameters4D::cloneFromSelected(), BowedSurfaceAlignmentParameters::cloneFromSelected(), and TwoBowedSurfacesAlignmentParameters::cloneFromSelected().

215  {
216  int nRows = m.num_row();
217  int size = sel.size();
218 
219  std::vector<int> rowvec;
220  for (int i = 0; i < size; i++)
221  if (sel[i] == true)
222  rowvec.push_back(i);
223 
224  // Check size matching
225  if (nRows != static_cast<int>(rowvec.size()))
226  throw cms::Exception("LogicError") << "Size mismatch in parameters"
227  << " (input vector = " << nRows << ", selection: " << size << ")";
228 
229  // If OK, continue
230  AlgebraicVector result(size, 0);
231  for (int i = 0; i < nRows; i++)
232  result[rowvec[i]] = m[i];
233  return result;
234 }
tuple result
Definition: mps_fire.py:311
CLHEP::HepVector AlgebraicVector
int size(void) const
Get number of parameters.
unsigned int AlignmentParameters::hierarchyLevel ( ) const
virtual

How many levels of Alignables with parameters can be found in the substructures of the Alignable of these parameters? E.g. 0: lowest level, i.e. no components of hte Alignable have parameters, n: up to n generations of components have parameters (some 'branches' may have less)

Definition at line 107 of file AlignmentParameters.cc.

References Alignable::firstCompsWithParams(), and theAlignable.

Referenced by AlignmentParametersIORoot::writeOne().

107  {
108  if (!theAlignable) {
109  edm::LogError("Alignment") << "@SUB=AlignmentParameters::hierarchyLevel"
110  << "Called for AlignmentParameters without pointer to Alignable";
111  return 0;
112  }
113 
114  align::Alignables comps;
116  if (comps.empty())
117  return 0;
118 
119  unsigned int maxLevelOfComp = 0;
120  for (const auto& iAli : comps) { // firstCompsWithParams guaranties that alignmentParameters() != 0:
121  const unsigned int compResult = iAli->alignmentParameters()->hierarchyLevel();
122  // levels might be different for components, get largest:
123  if (maxLevelOfComp < compResult)
124  maxLevelOfComp = compResult;
125  }
126 
127  return maxLevelOfComp + 1;
128 }
Log< level::Error, false > LogError
bool firstCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:62
std::vector< Alignable * > Alignables
Definition: Utilities.h:31
bool AlignmentParameters::isValid ( void  ) const
int AlignmentParameters::numSelected ( void  ) const
const AlgebraicVector & AlignmentParameters::parameters ( void  ) const
AlgebraicSymMatrix AlignmentParameters::selectedCovariance ( void  ) const

Get covariance matrix of selected parameters.

Definition at line 59 of file AlignmentParameters.cc.

References collapseSymMatrix(), and theData.

Referenced by AlignmentParameterStore::selectParameters().

59  {
60  return collapseSymMatrix(theData->covariance(), theData->selector());
61 }
AlgebraicSymMatrix collapseSymMatrix(const AlgebraicSymMatrix &m, const std::vector< bool > &sel) const
AlgebraicMatrix AlignmentParameters::selectedDerivatives ( const TrajectoryStateOnSurface tsos,
const AlignableDetOrUnitPtr alidet 
) const
virtual

Reimplemented in BeamSpotAlignmentParameters, RigidBodyAlignmentParameters, and SurveyParameters.

Definition at line 70 of file AlignmentParameters.cc.

References derivatives(), numSelected(), and selector().

Referenced by CompositeAlignmentParameters::derivativesLegacy(), HIPAlignmentAlgorithm::processHit1D(), and HIPAlignmentAlgorithm::processHit2D().

71  {
72  const AlgebraicMatrix dev(this->derivatives(tsos, alignableDet));
73 
74  const int ncols = dev.num_col();
75  const int nrows = dev.num_row();
76  const int nsel = numSelected();
77 
78  AlgebraicMatrix seldev(nsel, ncols);
79 
80  int ir2 = 0;
81  for (int irow = 0; irow < nrows; ++irow) {
82  if (this->selector()[irow]) {
83  for (int icol = 0; icol < ncols; ++icol) {
84  seldev[ir2][icol] = dev[irow][icol];
85  }
86  ++ir2;
87  }
88  }
89 
90  return seldev;
91 }
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
CLHEP::HepMatrix AlgebraicMatrix
int numSelected(void) const
Get number of selected parameters.
AlgebraicVector AlignmentParameters::selectedParameters ( void  ) const

Get selected parameters.

Definition at line 54 of file AlignmentParameters.cc.

References collapseVector(), and theData.

Referenced by AlignmentParameterStore::selectParameters().

54  {
55  return collapseVector(theData->parameters(), theData->selector());
56 }
AlgebraicVector collapseVector(const AlgebraicVector &m, const std::vector< bool > &sel) const
const std::vector< bool > & AlignmentParameters::selector ( void  ) const
void AlignmentParameters::setUserVariables ( AlignmentUserVariables auv)
void AlignmentParameters::setValid ( bool  v)
int AlignmentParameters::size ( void  ) const
virtual int AlignmentParameters::type ( ) const
pure virtual
AlignmentUserVariables * AlignmentParameters::userVariables ( void  ) const

Member Data Documentation

bool AlignmentParameters::bValid
protected

True if parameters are valid.

Definition at line 127 of file AlignmentParameters.h.

Referenced by isValid(), and setValid().

Alignable* AlignmentParameters::theAlignable
protected
DataContainer AlignmentParameters::theData
protected
AlignmentUserVariables* AlignmentParameters::theUserVariables
protected

Definition at line 125 of file AlignmentParameters.h.

Referenced by setUserVariables(), userVariables(), and ~AlignmentParameters().