CMS 3D CMS Logo

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 40 of file AlignmentParameters.h.

Constructor & Destructor Documentation

AlignmentParameters::AlignmentParameters ( )

Default constructor.

Definition at line 10 of file AlignmentParameters.cc.

10  :
11  theAlignable( nullptr),
12  theUserVariables( nullptr),
13  bValid(true)
14 {}
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 18 of file AlignmentParameters.cc.

References theData.

19  :
20  theAlignable(object),
22  theUserVariables(nullptr),
23  bValid(true)
24 {
25  // is the data consistent?
26  theData->checkConsistency();
27 }
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 31 of file AlignmentParameters.cc.

References theData.

33  :
34  theAlignable(object),
36  theUserVariables(nullptr),
37  bValid(true)
38 {
39  // is the data consistent?
40  theData->checkConsistency();
41 }
AlignmentParametersData::DataContainer DataContainer
bool bValid
True if parameters are valid.
AlignmentUserVariables * theUserVariables
AlignmentParameters::AlignmentParameters ( Alignable object,
const DataContainer data 
)

Constructor.

Definition at line 45 of file AlignmentParameters.cc.

References theData.

46  :
47  theAlignable(object),
48  theData(data),
49  theUserVariables(nullptr),
50  bValid(true)
51 {
52  // is the data consistent?
53  theData->checkConsistency();
54 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool bValid
True if parameters are valid.
AlignmentUserVariables * theUserVariables
AlignmentParameters::~AlignmentParameters ( )
virtual

Destructor.

Definition at line 58 of file AlignmentParameters.cc.

References theUserVariables.

59 {
60  if ( theUserVariables ) delete theUserVariables;
61 }
AlignmentUserVariables * theUserVariables

Member Function Documentation

Alignable * AlignmentParameters::alignable ( void  ) const
virtual void AlignmentParameters::apply ( )
pure virtual

apply parameters to alignable

Implemented in TwoBowedSurfacesAlignmentParameters, BowedSurfaceAlignmentParameters, BeamSpotAlignmentParameters, RigidBodyAlignmentParameters, and SurveyParameters.

Referenced by heavyIonTools.ConfigureHeavyIons::__call__(), editorTools.UserCodeTool::__call__(), HiCoreTools.RestrictInputToAOD::__call__(), coreTools.RunOnData::__call__(), trackTools.MakeAODTrackCandidates::__call__(), runJetUncertainties.RunJetUncertainties::__call__(), metTools.AddMETCollection::__call__(), heavyIonTools.ProductionDefaults::__call__(), editorTools.ChangeSource::__call__(), HiCoreTools.RemoveMCMatching::__call__(), cmsswVersionTools.PickRelValInputFiles::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__call__(), heavyIonTools.SelectionDefaults::__call__(), HiCoreTools.RemoveAllPATObjectsBut::__call__(), heavyIonTools.DisbaleMonteCarloDeps::__call__(), HiCoreTools.RemoveSpecificPATObjects::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), trackTools.MakeTrackCandidates::__call__(), tauTools.AddTauCollection::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), HiCoreTools.RemoveCleaning::__call__(), HiCoreTools.AddCleaning::__call__(), trigTools.SwitchOnTriggerMatchingStandAlone::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.AddJetCollection::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.UpdateJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), and AlignmentParameterStore::applyParameters().

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 198 of file AlignmentParameters.cc.

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

Referenced by selectedCovariance().

200 {
201 
202  int nRows = m.num_row();
203  int size = sel.size();
204 
205  // Check size matching
206  if ( nRows != size )
207  throw cms::Exception("LogicError") << "Size mismatch in parameters"
208  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
209 
210  // If OK, continue
211  std::vector<int> rowvec;
212  for ( int i=0; i<nRows; i++ )
213  if ( sel[i] ) rowvec.push_back(i);
214 
215  int nSelectedRows = rowvec.size();
216  AlgebraicSymMatrix result( nSelectedRows, 0 );
217  for (int i=0; i<nSelectedRows; i++)
218  for (int j=0; j<nSelectedRows; j++)
219  result[i][j] = m[ rowvec[i] ][ rowvec[j] ];
220 
221  return result;
222 
223 }
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 227 of file AlignmentParameters.cc.

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

Referenced by selectedParameters().

229 {
230 
231  int nRows = m.num_row();
232  int size = sel.size();
233 
234  // Check size matching
235  if ( nRows != size )
236  throw cms::Exception("LogicError") << "Size mismatch in parameters"
237  << " (input vector = " << nRows << ", selection: " << size << ")";
238 
239  // If OK, continue
240  std::vector<int> rowvec;
241  for ( int i=0; i<nRows; i++ )
242  if ( sel[i] ) rowvec.push_back(i);
243 
244  int nSelectedRows=rowvec.size();
245  AlgebraicVector result( nSelectedRows, 0 );
246  for ( int i=0; i<nSelectedRows; i++ )
247  result[i] = m[ (int)rowvec[i] ];
248 
249  return result;
250 
251 }
CLHEP::HepVector AlgebraicVector
int size(void) const
Get number of parameters.
const AlgebraicSymMatrix & AlignmentParameters::covariance ( void  ) const

Get parameter covariance matrix.

Definition at line 99 of file AlignmentParameters.cc.

References theData.

Referenced by MillePedeAlignmentAlgorithm::areEmptyParams(), SurveyAlignment::iterate(), PedeReader::setParameter(), AlignmentParametersIORoot::writeOne(), and AlignmentParametersIO::writeOneOrigRigidBody().

100 {
101  return theData->covariance();
102 }
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 255 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().

257 {
258 
259  int nRows = m.num_row();
260  int size = sel.size();
261 
262  std::vector<int> rowvec;
263  for ( int i=0; i<size; i++ )
264  if ( sel[i] ) rowvec.push_back(i);
265 
266  // Check size matching
267  if( nRows != static_cast<int>(rowvec.size()) )
268  throw cms::Exception("LogicError") << "Size mismatch in parameters"
269  << " (input symmatrix = " << nRows << ", selection: " << size << ")";
270 
271  // If OK, continue
272  AlgebraicSymMatrix result(size,0);
273  for ( int i=0; i<nRows; i++ )
274  for (int j=0; j<nRows; j++)
275  result[ rowvec[i] ][ rowvec[j] ] = m[i][j];
276 
277  return result;
278 }
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 282 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().

284 {
285 
286  int nRows = m.num_row();
287  int size = sel.size();
288 
289  std::vector<int> rowvec;
290  for ( int i=0; i<size; i++ )
291  if (sel[i]==true) rowvec.push_back(i);
292 
293  // Check size matching
294  if( nRows != static_cast<int>(rowvec.size()) )
295  throw cms::Exception("LogicError") << "Size mismatch in parameters"
296  << " (input vector = " << nRows << ", selection: " << size << ")";
297 
298  // If OK, continue
299  AlgebraicVector result(size,0);
300  for (int i=0; i<nRows; i++) result[ rowvec[i] ] = m[i];
301  return result;
302 
303 }
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 152 of file AlignmentParameters.cc.

References Alignable::firstCompsWithParams(), and theAlignable.

Referenced by AlignmentParametersIORoot::writeOne().

153 {
154  if (!theAlignable) {
155  edm::LogError("Alignment") << "@SUB=AlignmentParameters::hierarchyLevel"
156  << "Called for AlignmentParameters without pointer to Alignable";
157  return 0;
158  }
159 
160  align::Alignables comps;
162  if (comps.empty()) return 0;
163 
164  unsigned int maxLevelOfComp = 0;
165  for (const auto& iAli: comps) {// firstCompsWithParams guaranties that alignmentParameters() != 0:
166  const unsigned int compResult = iAli->alignmentParameters()->hierarchyLevel();
167  // levels might be different for components, get largest:
168  if (maxLevelOfComp < compResult) maxLevelOfComp = compResult;
169  }
170 
171  return maxLevelOfComp + 1;
172 }
bool firstCompsWithParams(Alignables &paramComps) const
Definition: Alignable.cc:68
std::vector< Alignable * > Alignables
Definition: Utilities.h:32
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 85 of file AlignmentParameters.cc.

References collapseSymMatrix(), and theData.

Referenced by AlignmentParameterStore::selectParameters().

86 {
87  return collapseSymMatrix( theData->covariance(), theData->selector() );
88 }
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 106 of file AlignmentParameters.cc.

References derivatives(), hgcalPlots::ncols, numSelected(), and selector().

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

108 {
109  const AlgebraicMatrix dev(this->derivatives(tsos, alignableDet));
110 
111  const int ncols = dev.num_col();
112  const int nrows = dev.num_row();
113  const int nsel = numSelected();
114 
115  AlgebraicMatrix seldev(nsel, ncols);
116 
117  int ir2 = 0;
118  for (int irow = 0; irow < nrows; ++irow) {
119  if (this->selector()[irow]) {
120  for (int icol = 0; icol < ncols; ++icol) {
121  seldev[ir2][icol] = dev[irow][icol];
122  }
123  ++ir2;
124  }
125  }
126 
127  return seldev;
128 }
const std::vector< bool > & selector(void) const
Get alignment parameter selector vector.
CLHEP::HepMatrix AlgebraicMatrix
int numSelected(void) const
Get number of selected parameters.
virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const =0
Get derivatives of selected parameters.
AlgebraicVector AlignmentParameters::selectedParameters ( void  ) const

Get selected parameters.

Definition at line 78 of file AlignmentParameters.cc.

References collapseVector(), and theData.

Referenced by AlignmentParameterStore::selectParameters().

79 {
80  return collapseVector( theData->parameters(), theData->selector() );
81 }
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 136 of file AlignmentParameters.h.

Referenced by isValid(), and setValid().

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

Definition at line 134 of file AlignmentParameters.h.

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