CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

AlignmentParameters Class Reference

#include <AlignmentParameters.h>

Inheritance diagram for AlignmentParameters:
BeamSpotAlignmentParameters BowedSurfaceAlignmentParameters RigidBodyAlignmentParameters SurveyParameters TwoBowedSurfacesAlignmentParameters RigidBodyAlignmentParameters4D

List of all members.

Public Types

typedef
AlignmentParametersData::DataContainer 
DataContainer

Public Member Functions

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

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.
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:
2011/09/19 11:44:21
Revision:
1.10

(last update by

Author:
mussgill

)

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.

                                         :
  theAlignable( 0),
  theUserVariables( 0),
  bValid(true)
{}
AlignmentParameters::AlignmentParameters ( Alignable object,
const AlgebraicVector par,
const AlgebraicSymMatrix cov 
)

Constructor from given input.

Definition at line 18 of file AlignmentParameters.cc.

References theData.

                                                                        :
  theAlignable(object),
  theData( DataContainer( new AlignmentParametersData(par,cov) ) ),
  theUserVariables(0),
  bValid(true)
{
  // is the data consistent?
  theData->checkConsistency();
}
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.

                                                                     :
  theAlignable(object),
  theData( DataContainer( new AlignmentParametersData(par,cov,sel) ) ),
  theUserVariables(0),
  bValid(true)
{
  // is the data consistent?
  theData->checkConsistency();
}
AlignmentParameters::AlignmentParameters ( Alignable object,
const DataContainer data 
)

Constructor.

Definition at line 45 of file AlignmentParameters.cc.

References theData.

                                                                                            :
  theAlignable(object),
  theData(data),
  theUserVariables(0),
  bValid(true)
{
  // is the data consistent?
  theData->checkConsistency();
}
AlignmentParameters::~AlignmentParameters ( ) [virtual]

Destructor.

Definition at line 58 of file AlignmentParameters.cc.

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

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

Referenced by selectedCovariance().

{

  int nRows = m.num_row();
  int size  = sel.size();

  // Check size matching
  if ( nRows != size ) 
    throw cms::Exception("LogicError") << "Size mismatch in parameters";

  // If OK, continue
  std::vector<int> rowvec;
  for ( int i=0; i<nRows; i++ ) 
    if ( sel[i] ) rowvec.push_back(i);
 
  int nSelectedRows = rowvec.size();
  AlgebraicSymMatrix result( nSelectedRows, 0 );
  for (int i=0; i<nSelectedRows; i++) 
    for (int j=0; j<nSelectedRows; j++)
      result[i][j] = m[ rowvec[i] ][ rowvec[j] ];

  return result;

}
AlgebraicVector AlignmentParameters::collapseVector ( const AlgebraicVector m,
const std::vector< bool > &  sel 
) const [protected]

Definition at line 227 of file AlignmentParameters.cc.

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

Referenced by selectedParameters().

{

  int nRows = m.num_row();
  int size  = sel.size();

  // Check size matching
  if ( nRows != size ) 
    throw cms::Exception("LogicError") << "Size mismatch in parameters";

  // If OK, continue
  std::vector<int> rowvec;
  for ( int i=0; i<nRows; i++ ) 
    if ( sel[i] ) rowvec.push_back(i);

  int nSelectedRows=rowvec.size();
  AlgebraicVector result( nSelectedRows, 0 );
  for ( int i=0; i<nSelectedRows; i++ )
    result[i] = m[ (int)rowvec[i] ];

  return result;

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

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

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

{

  int nRows = m.num_row();
  int size  = sel.size();

  std::vector<int> rowvec;
  for ( int i=0; i<size; i++ ) 
    if ( sel[i] ) rowvec.push_back(i);

  // Check size matching
  if( nRows != static_cast<int>(rowvec.size()) ) 
    throw cms::Exception("LogicError") << "Size mismatch in parameters";

  // If OK, continue
  AlgebraicSymMatrix result(size,0);
  for ( int i=0; i<nRows; i++ )
    for (int j=0; j<nRows; j++)
      result[ rowvec[i] ][ rowvec[j] ] = m[i][j];

  return result;
}
AlgebraicVector AlignmentParameters::expandVector ( const AlgebraicVector m,
const std::vector< bool > &  sel 
) const [protected]

Definition at line 280 of file AlignmentParameters.cc.

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

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

{

  int nRows = m.num_row();
  int size  = sel.size();

  std::vector<int> rowvec;
  for ( int i=0; i<size; i++ ) 
    if (sel[i]==true) rowvec.push_back(i);

  // Check size matching
  if( nRows != static_cast<int>(rowvec.size()) ) 
    throw cms::Exception("LogicError") << "Size mismatch in parameters";

  // If OK, continue
  AlgebraicVector result(size,0);
  for (int i=0; i<nRows; i++) result[ rowvec[i] ] = m[i];
  return result;

}
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().

{
  if (!theAlignable) {
    edm::LogError("Alignment") << "@SUB=AlignmentParameters::hierarchyLevel"
                               << "Called for AlignmentParameters without pointer to Alignable";
    return 0;
  }

  std::vector<Alignable*> comps;
  theAlignable->firstCompsWithParams(comps);
  if (comps.empty()) return 0;

  unsigned int maxLevelOfComp = 0;
  for (std::vector<Alignable*>::const_iterator iAli = comps.begin(), iAliEnd = comps.end();
       iAli != iAliEnd; ++iAli) {// firstCompsWithParams guaranties that alignmentParameters() != 0:
    const unsigned int compResult = (*iAli)->alignmentParameters()->hierarchyLevel();
    // levels might be different for components, get largest:
    if (maxLevelOfComp < compResult) maxLevelOfComp = compResult;
  }

  return maxLevelOfComp + 1;
}
bool AlignmentParameters::isValid ( void  ) const
int AlignmentParameters::numSelected ( void  ) const
const AlgebraicVector & AlignmentParameters::parameters ( void  ) const
AlgebraicSymMatrix AlignmentParameters::selectedCovariance ( void  ) 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(), numSelected(), and selector().

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

{
  const AlgebraicMatrix dev(this->derivatives(tsos, alignableDet));

  const int ncols  = dev.num_col();
  const int nrows  = dev.num_row();
  const int nsel   = numSelected();

  AlgebraicMatrix seldev(nsel, ncols);

  int ir2 = 0;
  for (int irow = 0; irow < nrows; ++irow) {
    if (this->selector()[irow]) {
      for (int icol = 0; icol < ncols; ++icol) {
        seldev[ir2][icol] = dev[irow][icol];
      }
      ++ir2;
    }
  }

  return seldev;
}
AlgebraicVector AlignmentParameters::selectedParameters ( void  ) 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().

Definition at line 134 of file AlignmentParameters.h.

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