Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:05

0001 #ifndef Alignment_CommonAlignment_AlignmentParameters_H
0002 #define Alignment_CommonAlignment_AlignmentParameters_H
0003 
0004 #include <vector>
0005 
0006 #include "Alignment/CommonAlignment/interface/AlignmentParametersData.h"
0007 #include "Alignment/CommonAlignment/interface/AlignmentUserVariables.h"
0008 
0009 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0010 
0011 /// \class AlignmentParameters
0012 ///
0013 /// Base class for alignment parameters
0014 ///
0015 /// It contains a parameter vector of size N and a covariance matrix of size NxN.
0016 /// There is a pointer to the Alignable to which the parameters belong.
0017 /// There is also a pointer to UserVariables.
0018 /// Parameters can be enabled/disabled using theSelector.
0019 /// bValid declares if the parameters are 'valid'.
0020 /// The methods *selected* set/return only the active
0021 /// parameters/derivatives/covariance as subvector/submatrix
0022 /// of reduced size.
0023 ///
0024 ///  $Date: 2010/10/26 19:50:21 $
0025 ///  $Revision: 1.9 $
0026 /// (last update by $Author: flucke $)
0027 
0028 // include and not forward declare to ensure automatic conversion from AlignableDet(Unit):
0029 // NO: include problems... #include "Alignment/CommonAlignment/interface/AlignableDetOrUnitPtr.h"
0030 class AlignableDetOrUnitPtr;
0031 class Alignable;
0032 class TrajectoryStateOnSurface;
0033 class RecHit;
0034 
0035 class AlignmentParameters {
0036 public:
0037   typedef AlignmentParametersData::DataContainer DataContainer;
0038 
0039   /// Default constructor
0040   AlignmentParameters();
0041 
0042   /// Constructor from given input
0043   AlignmentParameters(Alignable* object, const AlgebraicVector& par, const AlgebraicSymMatrix& cov);
0044 
0045   /// Constructor including selection of active parameters
0046   AlignmentParameters(Alignable* object,
0047                       const AlgebraicVector& par,
0048                       const AlgebraicSymMatrix& cov,
0049                       const std::vector<bool>& sel);
0050 
0051   /// Constructor
0052   AlignmentParameters(Alignable* object, const DataContainer& data);
0053 
0054   /// Destructor
0055   virtual ~AlignmentParameters();
0056 
0057   /// apply parameters to alignable
0058   virtual void apply() = 0;
0059   /// tell type (AlignmentParametersFactory::ParametersType - but no circular dependency)
0060   virtual int type() const = 0;
0061 
0062   /// Enforce clone methods in derived classes
0063   virtual AlignmentParameters* clone(const AlgebraicVector& par, const AlgebraicSymMatrix& cov) const = 0;
0064   virtual AlignmentParameters* cloneFromSelected(const AlgebraicVector& par, const AlgebraicSymMatrix& cov) const = 0;
0065 
0066   /// Get alignment parameter selector vector
0067   const std::vector<bool>& selector(void) const;
0068 
0069   /// Get number of selected parameters
0070   int numSelected(void) const;
0071 
0072   /// Get selected parameters
0073   AlgebraicVector selectedParameters(void) const;
0074 
0075   /// Get covariance matrix of selected parameters
0076   AlgebraicSymMatrix selectedCovariance(void) const;
0077 
0078   /// Get alignment parameters
0079   const AlgebraicVector& parameters(void) const;
0080 
0081   /// Get parameter covariance matrix
0082   const AlgebraicSymMatrix& covariance(void) const;
0083 
0084   /// Get derivatives of selected parameters
0085   virtual AlgebraicMatrix derivatives(const TrajectoryStateOnSurface& tsos,
0086                                       const AlignableDetOrUnitPtr& alidet) const = 0;
0087   virtual AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface& tsos,
0088                                               const AlignableDetOrUnitPtr& alidet) const;
0089 
0090   /// Set pointer to user variables
0091   void setUserVariables(AlignmentUserVariables* auv);
0092   /// Get pointer to user variables
0093   AlignmentUserVariables* userVariables(void) const;
0094 
0095   /// Get pointer to corresponding alignable
0096   Alignable* alignable(void) const;
0097 
0098   /// How many levels of Alignables with parameters can be found in the
0099   /// substructures of the Alignable of these parameters? E.g.
0100   /// 0: lowest level, i.e. no components of hte Alignable have parameters,
0101   /// n: up to n generations of components have parameters (some 'branches' may have less)
0102   virtual unsigned int hierarchyLevel() const;
0103 
0104   /// Get number of parameters
0105   int size(void) const;
0106 
0107   /// Get validity flag
0108   bool isValid(void) const;
0109   /// Set validity flag
0110   void setValid(bool v);
0111 
0112 protected:
0113   // private helper methods
0114   AlgebraicSymMatrix collapseSymMatrix(const AlgebraicSymMatrix& m, const std::vector<bool>& sel) const;
0115   AlgebraicVector collapseVector(const AlgebraicVector& m, const std::vector<bool>& sel) const;
0116   AlgebraicSymMatrix expandSymMatrix(const AlgebraicSymMatrix& m, const std::vector<bool>& sel) const;
0117   AlgebraicVector expandVector(const AlgebraicVector& m, const std::vector<bool>& sel) const;
0118 
0119   // data members
0120 
0121   Alignable* theAlignable;
0122 
0123   DataContainer theData;
0124 
0125   AlignmentUserVariables* theUserVariables;
0126 
0127   bool bValid;  ///< True if parameters are valid
0128 };
0129 
0130 #endif