Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Alignment_MillePedeAlignmentAlgorithm_PedeLabelerBase_h
0002 #define Alignment_MillePedeAlignmentAlgorithm_PedeLabelerBase_h
0003 
0004 /** \class PedeLabelerBase
0005  *
0006  * Baseclass for pede labelers
0007  *
0008  *  Original author: Andreas Mussgiller, January 2011
0009  *
0010  *  $Date: 2011/02/18 17:08:13 $
0011  *  $Revision: 1.2 $
0012  *  (last update by $Author: mussgill $)
0013  */
0014 
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 
0017 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
0018 #include "Alignment/CommonAlignment/interface/Utilities.h"
0019 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentAlgorithmBase.h"
0020 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0021 
0022 #include "CondFormats/Common/interface/Time.h"
0023 
0024 #include <vector>
0025 
0026 class Alignable;
0027 class AlignableTracker;
0028 class AlignableMuon;
0029 class AlignableExtras;
0030 class IntegratedCalibrationBase;
0031 
0032 /***************************************
0033 ****************************************/
0034 class PedeLabelerBase {
0035 public:
0036   using RunNumber = align::RunNumber;
0037   using RunRange = align::RunRange;
0038   using RunRanges = align::RunRanges;
0039 
0040   class TopLevelAlignables {
0041   public:
0042     TopLevelAlignables(AlignableTracker *aliTracker, AlignableMuon *aliMuon, AlignableExtras *extras)
0043         : aliTracker_(aliTracker), aliMuon_(aliMuon), aliExtras_(extras) {}
0044     AlignableTracker *aliTracker_;
0045     AlignableMuon *aliMuon_;
0046     AlignableExtras *aliExtras_;
0047   };
0048 
0049   /// constructor from three Alignables (null pointers allowed )
0050   PedeLabelerBase(const TopLevelAlignables &alignables, const edm::ParameterSet &config);
0051   virtual ~PedeLabelerBase() {}
0052   /// tell labeler to treat also integrated calibrations
0053   virtual void addCalibrations(const std::vector<IntegratedCalibrationBase *> &iCals);
0054 
0055   /// uniqueId of Alignable, 0 if alignable not known
0056   /// between this ID and the next there is enough 'space' to add parameter
0057   /// numbers 0...nPar-1 to make unique IDs for the labels of active parameters
0058   virtual unsigned int alignableLabel(const Alignable *alignable) const = 0;
0059   /// uniqueId of Alignable for a given parameter index and instance,
0060   /// 0 if alignable not known between this ID and the next there is enough
0061   /// 'space' to add parameter numbers 0...nPar-1 to make unique IDs for the
0062   /// labels of active parameters
0063   virtual unsigned int alignableLabelFromParamAndInstance(const Alignable *alignable,
0064                                                           unsigned int param,
0065                                                           unsigned int instance) const = 0;
0066   virtual unsigned int lasBeamLabel(unsigned int lasBeamId) const = 0;
0067   /// returns the label for a given alignable parameter number combination
0068   virtual unsigned int parameterLabel(unsigned int aliLabel, unsigned int parNum) const = 0;
0069   /// returns the label for a given alignable parameter number combination
0070   /// in case the parameters are split into various instances
0071   virtual unsigned int parameterLabel(Alignable *alignable,
0072                                       unsigned int parNum,
0073                                       const AlignmentAlgorithmBase::EventInfo &eventInfo,
0074                                       const TrajectoryStateOnSurface &tsos) const = 0;
0075   /// returns true if the alignable has parameters that are split into various bins
0076   virtual bool hasSplitParameters(Alignable *alignable) const = 0;
0077   /// returns the number of instances for a given parameter
0078   virtual unsigned int numberOfParameterInstances(Alignable *alignable, int param = -1) const = 0;
0079   /// returns the maximum number of instances for any parameter of an Alignable*
0080   virtual unsigned int maxNumberOfParameterInstances() const = 0;
0081   /// offset in labels between consecutive parameter instances of Alignable*s
0082   unsigned int parameterInstanceOffset() const { return theParamInstanceOffset; }
0083 
0084   /// parameter number, 0 <= .. < theMaxNumParam, belonging to unique parameter label
0085   virtual unsigned int paramNumFromLabel(unsigned int paramLabel) const = 0;
0086   /// alignable label from parameter label (works also for alignable label...)
0087   virtual unsigned int alignableLabelFromLabel(unsigned int label) const = 0;
0088   /// Alignable from alignable or parameter label,
0089   /// null if no alignable (but error only if not las beam, either!)
0090   virtual Alignable *alignableFromLabel(unsigned int label) const = 0;
0091   /// las beam id from las beam or parameter label
0092   /// zero and error if not a valid las beam label
0093   virtual unsigned int lasBeamIdFromLabel(unsigned int label) const = 0;
0094   /// calibration and its parameter number from label,
0095   /// if label does not belong to any calibration return nullptr as pair.first
0096   virtual std::pair<IntegratedCalibrationBase *, unsigned int> calibrationParamFromLabel(unsigned int label) const;
0097 
0098   virtual const RunRange &runRangeFromLabel(unsigned int label) const { return theOpenRunRange; }
0099   /// first free label not yet used (for hacks within millepede...)
0100   /// valid only after last call to addCalibrations(..)
0101   virtual unsigned int firstFreeLabel() const;
0102 
0103   /// label for parameter 'paramNum' (counted from 0) of an integrated calibration
0104   virtual unsigned int calibrationLabel(const IntegratedCalibrationBase *calib, unsigned int paramNum) const;
0105   const AlignableTracker *alignableTracker() const { return topLevelAlignables_.aliTracker_; }
0106   const AlignableMuon *alignableMuon() const { return topLevelAlignables_.aliMuon_; }
0107   const AlignableExtras *alignableExtras() const { return topLevelAlignables_.aliExtras_; }
0108 
0109   static const unsigned int theMaxNumParam;
0110   static const unsigned int theParamInstanceOffset;
0111   static const unsigned int theMinLabel;
0112 
0113 protected:
0114   /// first free label after everything about Alignables and LAS beams
0115   /// (to be used for calibrations)
0116   virtual unsigned int firstNonAlignableLabel() const;
0117 
0118   /// Return tracker alignable object ID provider derived from the tracker's geometry
0119   const AlignableObjectId &objectIdProvider() const { return alignableObjectId_; }
0120 
0121   const RunRange theOpenRunRange;
0122 
0123 private:
0124   const TopLevelAlignables topLevelAlignables_;
0125   const AlignableObjectId alignableObjectId_;
0126 
0127   /// pairs of calibrations and their first label
0128   std::vector<std::pair<IntegratedCalibrationBase *, unsigned int> > theCalibrationLabels;
0129 };
0130 
0131 struct AlignableComparator {
0132   using is_transparent = void;  // needs to be defined, actual type is not relevant
0133   bool operator()(Alignable *a, Alignable *b) const { return a < b; }
0134   bool operator()(Alignable *a, const Alignable *b) const { return a < b; }
0135   bool operator()(const Alignable *a, Alignable *b) const { return a < b; }
0136 };
0137 
0138 #endif