Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:43

0001 #ifndef Alignment_CommonAlignmentParametrization_CompositeAlignmentParameters_h
0002 #define Alignment_CommonAlignmentParametrization_CompositeAlignmentParameters_h
0003 
0004 #include "Alignment/CommonAlignment/interface/AlignableDetOrUnitPtr.h"
0005 #include "Alignment/CommonAlignment/interface/AlignmentParametersData.h"
0006 #include "Alignment/CommonAlignment/interface/Utilities.h"
0007 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0008 
0009 #include <map>
0010 #include <vector>
0011 
0012 /// \class CompositeAlignmentParameters
0013 ///
0014 /// Class for 'concatenated' alignment parameters and associated
0015 /// Quantities for a set of Alignables. Provided by AlignmentParameterStore.
0016 /// It does not inherit from AligmentParameters since it does not need to be
0017 /// attached to an Alignable, so it does not need to have implementations of the
0018 /// apply(..) method. It neither needs AlignmentUservariables attached.
0019 ///
0020 ///  $Date: 2007/10/08 15:56:00 $
0021 ///  $Revision: 1.12 $
0022 /// (last update by $Author: cklae $)
0023 
0024 class AlignableDet;
0025 class Alignable;
0026 
0027 class CompositeAlignmentParameters {
0028 public:
0029   /// vector of alignable components
0030   typedef align::Alignables Components;
0031 
0032   typedef std::map<AlignableDetOrUnitPtr, Alignable *> AlignableDetToAlignableMap;
0033   typedef std::map<Alignable *, int> Aliposmap;
0034   typedef std::map<Alignable *, int> Alilenmap;
0035 
0036   typedef AlignmentParametersData::DataContainer DataContainer;
0037 
0038   /// constructors
0039 
0040   CompositeAlignmentParameters(const AlgebraicVector &par, const AlgebraicSymMatrix &cov, const Components &comp);
0041 
0042   CompositeAlignmentParameters(const AlgebraicVector &par,
0043                                const AlgebraicSymMatrix &cov,
0044                                const Components &comp,
0045                                const AlignableDetToAlignableMap &alimap,
0046                                const Aliposmap &aliposmap,
0047                                const Alilenmap &alilenmap);
0048 
0049   CompositeAlignmentParameters(const DataContainer &data,
0050                                const Components &comp,
0051                                const AlignableDetToAlignableMap &alimap,
0052                                const Aliposmap &aliposmap,
0053                                const Alilenmap &alilenmap);
0054 
0055   /// destructor
0056   virtual ~CompositeAlignmentParameters();
0057 
0058   /// Get alignment parameters
0059   const AlgebraicVector &parameters() const { return theData->parameters(); }
0060 
0061   /// Get parameter covariance matrix
0062   const AlgebraicSymMatrix &covariance() const { return theData->covariance(); }
0063 
0064   /// Clone parameters
0065   CompositeAlignmentParameters *clone(const AlgebraicVector &par, const AlgebraicSymMatrix &cov) const;
0066 
0067   /// Clone parameters
0068   CompositeAlignmentParameters *clone(const AlgebraicVector &par,
0069                                       const AlgebraicSymMatrix &cov,
0070                                       const AlignableDetToAlignableMap &alimap,
0071                                       const Aliposmap &aliposmap,
0072                                       const Alilenmap &alilenmap) const;
0073 
0074   /// Get vector of alignable components
0075   Components components() const;
0076 
0077   /// Get derivatives
0078   AlgebraicMatrix derivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const;
0079   /// Get derivatives for selected alignables
0080   AlgebraicMatrix selectedDerivatives(const TrajectoryStateOnSurface &tsos, const AlignableDetOrUnitPtr &alidet) const;
0081   /// for backward compatibility, use std::vector<AlignableDetOrUnitPtr>
0082   AlgebraicMatrix derivatives(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0083                               const std::vector<AlignableDet *> &alidetvec) const;
0084   AlgebraicMatrix derivatives(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0085                               const std::vector<AlignableDetOrUnitPtr> &alidetvec) const;
0086   /// for backward compatibility, use std::vector<AlignableDetOrUnitPtr>
0087   AlgebraicMatrix selectedDerivatives(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0088                                       const std::vector<AlignableDet *> &alidetvec) const;
0089   AlgebraicMatrix selectedDerivatives(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0090                                       const std::vector<AlignableDetOrUnitPtr> &alidetvec) const;
0091 
0092   /// for backward compatibility, use std::vector<AlignableDetOrUnitPtr>
0093   AlgebraicVector correctionTerm(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0094                                  const std::vector<AlignableDet *> &alidetvec) const;
0095   AlgebraicVector correctionTerm(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0096                                  const std::vector<AlignableDetOrUnitPtr> &alidetvec) const;
0097   /// deprecated due to 'AlignableDet*' interface (legacy code should not be
0098   /// needed anymore)
0099   AlgebraicMatrix derivativesLegacy(const TrajectoryStateOnSurface &tsos, AlignableDet *alidet) const;
0100   /// deprecated due to 'AlignableDet*' interface (legacy code should not be
0101   /// needed anymore)
0102   AlgebraicMatrix selectedDerivativesLegacy(const TrajectoryStateOnSurface &tsos, AlignableDet *alidet) const;
0103   /// deprecated due to 'AlignableDet*' interface (legacy code should not be
0104   /// needed anymore)
0105   AlgebraicMatrix derivativesLegacy(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0106                                     const std::vector<AlignableDet *> &alidetvec) const;
0107   /// deprecated due to 'AlignableDet*' interface (legacy code should not be
0108   /// needed anymore)
0109   AlgebraicMatrix selectedDerivativesLegacy(const std::vector<TrajectoryStateOnSurface> &tsosvec,
0110                                             const std::vector<AlignableDet *> &alidetvec) const;
0111 
0112   /// Get relevant Alignable from AlignableDet
0113   Alignable *alignableFromAlignableDet(const AlignableDetOrUnitPtr &adet) const;
0114 
0115   /// Extract parameters for subset of alignables
0116   AlgebraicVector parameterSubset(const align::Alignables &) const;
0117 
0118   /// Extract covariance matrix for subset of alignables
0119   AlgebraicSymMatrix covarianceSubset(const align::Alignables &) const;
0120 
0121   /// Extract covariance matrix elements between two subsets of alignables
0122   AlgebraicMatrix covarianceSubset(const align::Alignables &, const align::Alignables &) const;
0123 
0124 protected:
0125   DataContainer theData;
0126 
0127 private:
0128   /// Extract position and length of parameters for a subset of Alignables.
0129   bool extractPositionAndLength(const align::Alignables &alignables,
0130                                 std::vector<int> &posvec,
0131                                 std::vector<int> &lenvec,
0132                                 int &length) const;
0133 
0134   /// Return vector of alignables without multiple occurences.
0135   align::Alignables extractAlignables(const align::Alignables &) const;
0136 
0137   /// backward compatibility method to convert vectors from specific
0138   /// AlignableDet to more general AlignableDetOrUnitPtr
0139   void convert(const std::vector<AlignableDet *> &input, std::vector<AlignableDetOrUnitPtr> &output) const;
0140 
0141   /// Vector of alignable components
0142   Components theComponents;
0143 
0144   /// Relate Alignable's and AlignableDet's
0145   AlignableDetToAlignableMap theAlignableDetToAlignableMap;
0146 
0147   /// Maps to find parameters/covariance elements for given alignable
0148   Aliposmap theAliposmap;
0149   Alilenmap theAlilenmap;
0150 };
0151 
0152 #endif