Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:42:28

0001 /****************************************************************************
0002 * Authors: 
0003 *  Jan Kašpar (jan.kaspar@gmail.com) 
0004 ****************************************************************************/
0005 
0006 #ifndef CalibPPS_AlignmentRelative_AlignmentTask_h
0007 #define CalibPPS_AlignmentRelative_AlignmentTask_h
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 #include "CalibPPS/AlignmentRelative/interface/AlignmentGeometry.h"
0012 class AlignmentConstraint;
0013 class CTPPSGeometry;
0014 
0015 #include <vector>
0016 
0017 /**
0018  *\brief Represents an alignment task.
0019  **/
0020 class AlignmentTask {
0021 public:
0022   // -------------------- config file parameters --------------------
0023 
0024   /// whether to resolve detector shifts in readout direction(s)
0025   bool resolveShR;
0026 
0027   /// whether to resolve detector shifts in z
0028   bool resolveShZ;
0029 
0030   /// whether to resolve detector rotations around z
0031   bool resolveRotZ;
0032 
0033   /// whether to resolve only 1 rot_z per RP
0034   bool oneRotZPerPot;
0035 
0036   /// whether to apply the constraint mean U = mean V RotZ for strips ("standard" set of constraints only)
0037   bool useEqualMeanUMeanVRotZConstraints;
0038 
0039   /// fixed detectors constraints from config file
0040   edm::ParameterSet fixedDetectorsConstraints;
0041 
0042   /// settings of "standard" constraints from config file
0043   edm::ParameterSet standardConstraints;
0044 
0045   // -------------------- geometry-related members --------------------
0046 
0047   /// the geometry for this task
0048   AlignmentGeometry geometry;
0049 
0050   /// builds the alignment geometry
0051   static void buildGeometry(const std::vector<unsigned int> &rpDecIds,
0052                             const std::vector<unsigned int> &excludedSensors,
0053                             const CTPPSGeometry *,
0054                             double z0,
0055                             AlignmentGeometry &geometry);
0056 
0057   // -------------------- quantity-class-related members --------------------
0058 
0059   /// quantity classes
0060   enum QuantityClass {
0061     qcShR1,  ///< detector shifts in first readout direction
0062     qcShR2,  ///< detector shifts in second readout direction
0063     qcShZ,   ///< detector shifts in z
0064     qcRotZ,  ///< detector rotations around z
0065   };
0066 
0067   /// list of quantity classes to be optimized
0068   std::vector<QuantityClass> quantityClasses;
0069 
0070   /// returns a string tag for the given quantity class
0071   std::string quantityClassTag(QuantityClass) const;
0072 
0073   struct DetIdDirIdxPair {
0074     unsigned int detId;
0075     unsigned int dirIdx;
0076 
0077     bool operator<(const DetIdDirIdxPair &other) const {
0078       if (detId < other.detId)
0079         return true;
0080       if (detId > other.detId)
0081         return false;
0082       if (dirIdx < other.dirIdx)
0083         return true;
0084 
0085       return false;
0086     }
0087   };
0088 
0089   /// for each quantity class contains mapping (detector id, direction) --> measurement index
0090   std::map<QuantityClass, std::map<DetIdDirIdxPair, unsigned int>> mapMeasurementIndeces;
0091 
0092   /// for each quantity class contains mapping detector id --> quantity index
0093   std::map<QuantityClass, std::map<unsigned int, unsigned int>> mapQuantityIndeces;
0094 
0095   /// builds "mapMatrixIndeces" from "geometry"
0096   void buildIndexMaps();
0097 
0098   /// returns the number of quantities of the given class
0099   unsigned int measurementsOfClass(QuantityClass) const;
0100 
0101   /// returns the number of quantities of the given class
0102   unsigned int quantitiesOfClass(QuantityClass) const;
0103 
0104   /// returns measurement index (if non-existent, returns -1)
0105   signed int getMeasurementIndex(QuantityClass cl, unsigned int detId, unsigned int dirIdx) const;
0106 
0107   /// returns measurement index (if non-existent, returns -1)
0108   signed int getQuantityIndex(QuantityClass cl, unsigned int detId) const;
0109 
0110   // -------------------- constraint-related members --------------------
0111 
0112   /// builds a set of fixed-detector constraints
0113   void buildFixedDetectorsConstraints(std::vector<AlignmentConstraint> &) const;
0114 
0115   /// builds the standard constraints
0116   void buildStandardConstraints(std::vector<AlignmentConstraint> &) const;
0117 
0118   /// adds constraints such that only 1 rot_z per RP is left
0119   void buildOneRotZPerPotConstraints(std::vector<AlignmentConstraint> &) const;
0120 
0121   /// adds constraints such that only mean-U and mean-V RotZ are equal for each strip RP
0122   void buildEqualMeanUMeanVRotZConstraints(std::vector<AlignmentConstraint> &constraints) const;
0123 
0124   // -------------------- constructors --------------------
0125 
0126   /// dummy constructor (not to be used)
0127   AlignmentTask() {}
0128 
0129   /// normal constructor
0130   AlignmentTask(const edm::ParameterSet &ps);
0131 };
0132 
0133 #endif