Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef PEDESTEERERWEAKMODECONSTRAINTS_H
0002 #define PEDESTEERERWEAKMODECONSTRAINTS_H
0003 
0004 /**
0005  * \class PedeSteererWeakModeConstraints
0006  *
0007  * Provides steering of weak mode constraints for Pede according to configuration
0008  *
0009  * \author    : Joerg Behr
0010  * date       : February 2013
0011  */
0012 
0013 #include <list>
0014 #include <vector>
0015 #include <map>
0016 #include <set>
0017 #include <string>
0018 // forward ofstream:
0019 #include <iosfwd>
0020 
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 #include "Alignment/CommonAlignment/interface/Utilities.h"
0023 #include "Alignment/MillePedeAlignmentAlgorithm/src/PedeSteerer.h"
0024 
0025 #include <DataFormats/GeometryVector/interface/GlobalPoint.h>
0026 #include <CondFormats/Alignment/interface/Definitions.h>
0027 
0028 class Alignable;
0029 class PedeLabelerBase;
0030 
0031 /***************************************
0032 ****************************************/
0033 
0034 //FIXME: move GeometryConstraintConfigData to PedeSteererWeakModeConstraints?
0035 class GeometryConstraintConfigData {
0036 public:
0037   GeometryConstraintConfigData(const std::vector<double> &co,
0038                                const std::string &c,
0039                                const std::vector<std::pair<Alignable *, std::string> > &alisFile,
0040                                const int sd,
0041                                const align::Alignables &ex,
0042                                const int instance,
0043                                const bool downToLowestLevel);
0044   const std::vector<double> coefficients_;
0045   const std::string constraintName_;
0046   const std::vector<std::pair<Alignable *, std::string> > levelsFilenames_;
0047   const align::Alignables excludedAlignables_;
0048   std::map<std::string, std::ofstream *> mapFileName_;
0049   std::list<std::pair<Alignable *, std::list<Alignable *> > >
0050       HLSsubdets_;  //first pointer to HLS object, second list is the list of pointers to the lowest components
0051   const int sysdeformation_;
0052   const int instance_;
0053   const bool downToLowestLevel_;
0054 };
0055 
0056 class PedeSteererWeakModeConstraints {
0057 public:
0058   ~PedeSteererWeakModeConstraints();
0059   PedeSteererWeakModeConstraints(AlignableTracker *aliTracker,
0060                                  const PedeLabelerBase *labels,
0061                                  const std::vector<edm::ParameterSet> &config,
0062                                  std::string sf);
0063 
0064   //FIXME: split the code of the method into smaller pieces/submethods
0065   // Main method that configures everything and calculates also the constraints
0066   unsigned int constructConstraints(const align::Alignables &);
0067 
0068   // Returns a references to the container in which the configuration is stored
0069   std::list<GeometryConstraintConfigData> &getConfigData() { return ConstraintsConfigContainer_; }
0070 
0071 private:
0072   // Method creates the data structures with the full configuration
0073   unsigned int createAlignablesDataStructure();
0074 
0075   // Write the calculated constraints to the output files
0076   void writeOutput(const std::list<std::pair<unsigned int, double> > &output,
0077                    const GeometryConstraintConfigData &it,
0078                    const Alignable *iHLS,
0079                    double sum_xi_x0);
0080 
0081   // find the out file stream for a given constraint and high-level structure
0082   std::ofstream *getFile(const GeometryConstraintConfigData &it, const Alignable *iHLS) const;
0083 
0084   // Close the output files
0085   void closeOutputfiles();
0086 
0087   // Checks whether lowleveldet is a daugther of HLS
0088   bool checkMother(const Alignable *const lowleveldet, const Alignable *const HLS) const;
0089 
0090   std::pair<align::GlobalPoint, align::GlobalPoint> getDoubleSensorPosition(const Alignable *ali) const;
0091 
0092   double getPhase(const std::vector<double> &coefficients) const;
0093 
0094   // The function for the geometry deformation is defined as f(x).
0095   // The methods returns x depending on the type of deformation
0096   double getX(const int sysdeformation, const align::GlobalPoint &pos, const double phase) const;
0097 
0098   double getX0(const std::pair<Alignable *, std::list<Alignable *> > &iHLS,
0099                const GeometryConstraintConfigData &it) const;
0100 
0101   // Calculates and returns the coefficient for alignment parameter iParameter
0102   // for an alignable at position pos.
0103   double getCoefficient(const int sysdeformation,
0104                         const align::GlobalPoint &pos,
0105                         const GlobalPoint gUDirection,
0106                         const GlobalPoint gVDirection,
0107                         const GlobalPoint gWDirection,
0108                         const int iParameter,
0109                         const double &x0,
0110                         const std::vector<double> &constraintparameters) const;
0111 
0112   //returns true if iParameter of Alignable is selected in configuration file
0113   bool checkSelectionShiftParameter(const Alignable *ali, unsigned int iParameter) const;
0114 
0115   // Method used to test the provided configuration for unknown parameters
0116   void verifyParameterNames(const edm::ParameterSet &pset, unsigned int psetnr) const;
0117 
0118   // Method which creates the associative map between levels and coefficient file names
0119   const std::vector<std::pair<Alignable *, std::string> > makeLevelsFilenames(
0120       std::set<std::string> &steerFilePrefixContainer,
0121       const align::Alignables &alis,
0122       const std::string &steerFilePrefix) const;
0123 
0124   // Verify that the name of the configured deformation is known and that the number of coefficients has been correctly configured
0125   int verifyDeformationName(const std::string &name, const std::vector<double> &coefficients) const;
0126 
0127   //list of dead modules which are not used in any constraint
0128   std::list<align::ID> deadmodules_;
0129 
0130   //the data structure that holds all needed informations for the constraint configuration
0131   std::list<GeometryConstraintConfigData> ConstraintsConfigContainer_;
0132 
0133   const PedeLabelerBase *myLabels_;  //PedeLabeler needed to get for the alignables the corresponding Pede label
0134 
0135   const std::vector<edm::ParameterSet> myConfig_;  //the VPSet with the configurations for all constraints
0136 
0137   const std::string steerFile_;  // the name of the PedeSteerer steering file
0138 
0139   const AlignableObjectId alignableObjectId_;
0140 
0141   enum SystematicDeformations {
0142     kUnknown = 0,
0143     kTwist,
0144     kZexpansion,
0145     kSagitta,
0146     kRadial,
0147     kTelescope,
0148     kLayerRotation,
0149     kElliptical,
0150     kBowing,
0151     kSkew
0152   };
0153 };
0154 
0155 #endif