Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Alignment_TrackerAlignment_AlignableModifier_H
0002 #define Alignment_TrackerAlignment_AlignableModifier_H
0003 
0004 #include <vector>
0005 #include <string>
0006 #include <utility>
0007 
0008 #include "CondFormats/Alignment/interface/Definitions.h"
0009 
0010 /// AlignableModifier is a helper class to modify the Alignables.
0011 ///
0012 /// Configuration parameters are defined in this class.
0013 
0014 class Alignable;
0015 
0016 namespace CLHEP {
0017   class DRand48Engine;
0018 }
0019 namespace edm {
0020   class ParameterSet;
0021 }
0022 
0023 class AlignableModifier {
0024 public:
0025   /// Constructor
0026   AlignableModifier();
0027 
0028   /// Destructor
0029   ~AlignableModifier();
0030 
0031   /// Modify given set of alignables according to parameters
0032   bool modify(Alignable* alignable, const edm::ParameterSet& pSet);
0033 
0034   /// Check if given parameter should be propagated
0035   bool isPropagated(const std::string& parameterName) const;
0036 
0037   /// Move alignable in global space according to parameters
0038   void moveAlignable(Alignable* alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ);
0039 
0040   /// Move alignable in local space according to parameters
0041   void moveAlignableLocal(Alignable* alignable, bool random, bool gaussian, float sigmaX, float sigmaY, float sigmaZ);
0042 
0043   /// Rotate alignable in global space according to parameters
0044   void rotateAlignable(
0045       Alignable* alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ);
0046 
0047   /// Rotate alignable in local space according to parameters
0048   void rotateAlignableLocal(
0049       Alignable* alignable, bool random, bool gaussian, float sigmaPhiX, float sigmaPhiY, float sigmaPhiZ);
0050 
0051   /// Add the AlignmentPositionError (in global frame) to Alignable
0052   void addAlignmentPositionError(Alignable* alignable, float dx, float dy, float dz);
0053 
0054   /// Add the AlignmentPositionError (in local frame) to Alignable
0055   void addAlignmentPositionErrorLocal(Alignable* alignable, float dx, float dy, float dz);
0056 
0057   /// Add alignment position error resulting from rotation in global frame
0058   void addAlignmentPositionErrorFromRotation(Alignable* alignable, float phiX, float phiY, float phiZ);
0059 
0060   /// Add alignment position error resulting from rotation in local frame
0061   void addAlignmentPositionErrorFromLocalRotation(Alignable* alignable, float phiX, float phiY, float phiZ);
0062 
0063   /// Add alignment position error resulting from rotation in global frame
0064   void addAlignmentPositionErrorFromRotation(Alignable* alignable, align::RotationType&);
0065 
0066   /// Add alignment position error resulting from rotation in local frame
0067   void addAlignmentPositionErrorFromLocalRotation(Alignable* alignable, align::RotationType&);
0068 
0069   /// Decodes string and sets distribution accordingly ('fixed', 'flat' or 'gaussian').
0070   void setDistribution(const std::string& distr);
0071 
0072   /// Resets the generator seed according to the argument.
0073   void setSeed(long seed);
0074 
0075   /// Return a vector of random numbers (gaussian distribution)
0076   const std::vector<float> gaussianRandomVector(float sigmaX, float sigmaY, float sigmaZ) const;
0077   /// Return a vector of random numbers (flat distribution)
0078   const std::vector<float> flatRandomVector(float sigmaX, float sigmaY, float sigmaZ) const;
0079   /// Randomise all entries in 'rnd':
0080   /// - either from gaussian with width rnd[i]
0081   /// - or from flat distribution between -rnd[i] and rnd[i]
0082   void randomise(std::vector<double>& rnd, bool gaussian) const;
0083 
0084 private:
0085   typedef std::pair<std::string, std::vector<double> > DeformationMemberType;
0086   void addDeformation(
0087       Alignable* alignable, const DeformationMemberType& deformation, bool random, bool gaussian, double scale);
0088 
0089   /// Unique random number generator
0090   CLHEP::DRand48Engine* theDRand48Engine;
0091 
0092   /// Initialisation of all parameters
0093   void init_();
0094 
0095   int m_modified;  // Indicates if a modification was performed
0096 
0097   // All parameters (see AlignableModifier::init() for definitions)
0098   std::string distribution_;
0099   bool random_, gaussian_, setError_;
0100   bool setRotations_, setTranslations_;
0101   long seed_;
0102   double scaleError_, scale_;
0103   double phiX_, phiY_, phiZ_;
0104   double phiXlocal_, phiYlocal_, phiZlocal_;
0105   double dX_, dY_, dZ_;
0106   double dXlocal_, dYlocal_, dZlocal_;
0107   DeformationMemberType deformation_;
0108   double twist_, shear_;
0109 };
0110 
0111 #endif  //AlignableModifier_H