Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Alignment_CommonAlignmentAlgorithm_AlignmentParameterStore_h
0002 #define Alignment_CommonAlignmentAlgorithm_AlignmentParameterStore_h
0003 
0004 #include "Alignment/CommonAlignment/interface/Utilities.h"
0005 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignableData.h"
0006 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentCorrelationsStore.h"
0007 #include "Alignment/CommonAlignmentParametrization/interface/CompositeAlignmentParameters.h"
0008 
0009 /// \class AlignmentParameterStore
0010 ///
0011 /// Basic class for management of alignment parameters and correlations
0012 ///
0013 ///  $Date: 2011/05/23 20:50:31 $
0014 ///  $Revision: 1.19 $
0015 /// (last update by $Author: mussgill $)
0016 
0017 namespace edm {
0018   class ParameterSet;
0019 }
0020 class AlignmentUserVariables;
0021 class TrackerTopology;
0022 
0023 class AlignmentParameterStore {
0024 public:
0025   typedef std::vector<AlignmentParameters*> Parameters;
0026   typedef std::map<std::pair<Alignable*, Alignable*>, AlgebraicMatrix> Correlations;
0027   typedef std::vector<unsigned int> DetIds;
0028 
0029   /// constructor
0030   AlignmentParameterStore(const align::Alignables& alis, const edm::ParameterSet& config);
0031 
0032   /// destructor
0033   virtual ~AlignmentParameterStore();
0034 
0035   /// select parameters
0036   /// (for backward compatibility, use with vector<AlignableDetOrUnitPtr> as argument instead)
0037   CompositeAlignmentParameters selectParameters(const std::vector<AlignableDet*>& alignabledets) const;
0038   /// select parameters
0039   CompositeAlignmentParameters selectParameters(const std::vector<AlignableDetOrUnitPtr>& alignabledets) const;
0040   /// select parameters
0041   CompositeAlignmentParameters selectParameters(const align::Alignables&) const;
0042 
0043   /// update parameters
0044   void updateParameters(const CompositeAlignmentParameters& aap, bool updateCorrelations = true);
0045 
0046   /// get all alignables
0047   const align::Alignables& alignables(void) const { return theAlignables; }
0048 
0049   /// get all alignables with valid parameters
0050   align::Alignables validAlignables(void) const;
0051 
0052   /// returns number of alignables
0053   int numObjects(void) const { return theAlignables.size(); }
0054 
0055   /// get full correlation map
0056   AlignmentCorrelationsStore* correlationsStore(void) const { return theCorrelationsStore; }
0057 
0058   /// get number of correlations between alignables
0059   const unsigned int numCorrelations(void) const { return theCorrelationsStore->size(); }
0060 
0061   /// Obsolete: Use AlignableNavigator::alignableDetFromGeomDet and alignableFromAlignableDet
0062   /*   Alignable* alignableFromGeomDet( const GeomDet* geomDet ) const; */
0063 
0064   /// get Alignable corresponding to given AlignableDet (non-const ref. argument since might be returned)
0065   Alignable* alignableFromAlignableDet(const AlignableDetOrUnitPtr& alignableDet) const;
0066 
0067   /// Obsolete: Use AlignableNavigator::alignableDetFromDetId and alignableFromAlignableDet
0068   /*   Alignable* alignableFromDetId(const unsigned int& detId) const; */
0069 
0070   /// apply all valid parameters to their alignables
0071   void applyParameters(void);
0072 
0073   /// apply parameters of a given alignable
0074   void applyParameters(Alignable* alignable);
0075 
0076   /// reset parameters, correlations, user variables
0077   void resetParameters(void);
0078 
0079   /// reset parameters of a given alignable
0080   void resetParameters(Alignable* ali);
0081 
0082   /// cache the current position, rotation and other parameters
0083   void cacheTransformations(void);
0084 
0085   /// cache for the given run the current position, rotation and other parameters
0086   void cacheTransformations(const align::RunNumber&);
0087 
0088   /// restore the previously cached position, rotation and other parameters
0089   void restoreCachedTransformations(void);
0090 
0091   /// restore for the given run the previously cached position, rotation and other parameters
0092   void restoreCachedTransformations(const align::RunNumber&);
0093 
0094   /// acquire shifts/rotations from alignables of the store and copy into
0095   ///  alignment parameters (local frame)
0096   void acquireRelativeParameters(void);
0097 
0098   /// apply absolute positions to alignables
0099   void applyAlignableAbsolutePositions(const align::Alignables& alis, const AlignablePositions& newpos, int& ierr);
0100 
0101   /// apply relative shifts to alignables
0102   void applyAlignableRelativePositions(const align::Alignables& alivec, const AlignableShifts& shifts, int& ierr);
0103 
0104   /// Attach alignment parameters to given alignables
0105   void attachAlignmentParameters(const align::Alignables& alivec, const Parameters& parvec, int& ierr);
0106 
0107   /// Attach alignment parameters to alignables
0108   void attachAlignmentParameters(const Parameters& parvec, int& ierr);
0109 
0110   /// Attach correlations to given alignables
0111   void attachCorrelations(const align::Alignables& alivec, const Correlations& cormap, bool overwrite, int& ierr);
0112 
0113   /// Attach correlations to alignables
0114   void attachCorrelations(const Correlations& cormap, bool overwrite, int& ierr);
0115 
0116   /// Attach User Variables to given alignables
0117   void attachUserVariables(const align::Alignables& alivec,
0118                            const std::vector<AlignmentUserVariables*>& uvarvec,
0119                            int& ierr);
0120 
0121   /// Set Alignment position error
0122   void setAlignmentPositionError(const align::Alignables& alivec, double valshift, double valrot);
0123 
0124   /// Obtain type and layer from Alignable
0125   std::pair<int, int> typeAndLayer(const Alignable* ali, const TrackerTopology* tTopo) const;
0126 
0127   /// a single alignable parameter of an Alignable
0128   typedef std::pair<Alignable*, unsigned int> ParameterId;
0129   /// Assuming aliMaster has (sub-)components aliComps with alignment parameters
0130   /// (cf. Alignable::firstParamComponents), paramIdsVecOut and factorsVecOut will be filled
0131   /// (in parallel) with constraints on the selected alignment parameters of aliMaster to
0132   /// get rid of the additionally introduced degrees of freedom:
0133   /// The 'vector product' of the parameters identified by ParameterId in std::vector<ParameterId>
0134   /// and the factors in std::vector<double> has to vanish (i.e. == 0.),
0135   /// |factor| < epsilon will be treated as 0.
0136   /// If all == false, skip constraint on aliMaster's degree of freedom 'i' if 'i'th alignment
0137   /// parameter of aliMaster is not selected, i.e. constrain only for otherwise doubled d.o.f.
0138   /// If all == true, produce one constraint for each of the aliMaster's parameters
0139   /// irrespective of whether they are selecte dor not.
0140   /// paramIdsVecOut and factorsVecOut contain exactly one std::vector per selected alignment
0141   /// parameter of aliMaster, but in principle these can be empty...
0142   /// Note that not all combinations of AlignmentParameters classes ar supported.
0143   /// If not there will be an exception (and false returned...)
0144   bool hierarchyConstraints(const Alignable* aliMaster,
0145                             const align::Alignables& aliComps,
0146                             std::vector<std::vector<ParameterId> >& paramIdsVecOut,
0147                             std::vector<std::vector<double> >& factorsVecOut,
0148                             bool all,
0149                             double epsilon) const;
0150 
0151 protected:
0152   // storage for correlations
0153   AlignmentCorrelationsStore* theCorrelationsStore;
0154 
0155 private:
0156   enum TypeOfConstraints { NONE, HIERARCHY_CONSTRAINTS, APPROX_AVERAGING_CONSTRAINTS };
0157 
0158   // data members
0159 
0160   /// alignables
0161   align::Alignables theAlignables;
0162 
0163   /// type of constraints
0164   TypeOfConstraints theTypeOfConstraints;
0165 };
0166 
0167 #endif