File indexing completed on 2024-09-07 04:34:26
0001 #ifndef Alignment_CommonAlignment_Alignable_H
0002 #define Alignment_CommonAlignment_Alignable_H
0003
0004 #include "Alignment/CommonAlignment/interface/AlignableSurface.h"
0005 #include "Alignment/CommonAlignment/interface/StructureType.h"
0006 #include "Alignment/CommonAlignment/interface/Utilities.h"
0007 #include "DataFormats/DetId/interface/DetId.h"
0008
0009 class AlignmentErrorsExtended;
0010 class AlignmentParameters;
0011 class AlignmentPositionError;
0012 class Alignments;
0013 class AlignmentSurfaceDeformations;
0014 class SurfaceDeformation;
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 class AlignmentParameters;
0025 class SurveyDet;
0026
0027 class Alignable {
0028 public:
0029 typedef align::Scalar Scalar;
0030 typedef align::PositionType PositionType;
0031 typedef align::RotationType RotationType;
0032 typedef align::GlobalVector GlobalVector;
0033 typedef align::LocalVector LocalVector;
0034 typedef align::Alignables Alignables;
0035 typedef align::StructureType StructureType;
0036
0037 enum class CompConstraintType { NONE, POSITION, POSITION_Z };
0038
0039
0040
0041 Alignable(align::ID, const AlignableSurface&);
0042
0043
0044
0045 Alignable(align::ID, const RotationType&);
0046
0047
0048 virtual ~Alignable();
0049
0050
0051
0052 void update(align::ID, const AlignableSurface&);
0053
0054
0055 void setAlignmentParameters(AlignmentParameters* dap);
0056
0057
0058 AlignmentParameters* alignmentParameters() const { return theAlignmentParameters; }
0059
0060
0061
0062 virtual void addComponent(Alignable*) = 0;
0063
0064
0065 virtual const Alignables& components() const = 0;
0066
0067
0068 int size() const { return components().size(); }
0069
0070
0071
0072 const Alignables& deepComponents() const { return theDeepComponents; }
0073
0074
0075
0076
0077
0078 virtual void recursiveComponents(Alignables& result) const = 0;
0079
0080
0081
0082
0083 bool firstCompsWithParams(Alignables& paramComps) const;
0084
0085
0086
0087
0088 bool lastCompsWithParams(Alignables& paramComps) const;
0089
0090
0091 Alignable* mother() const { return theMother; }
0092
0093
0094 void setMother(Alignable* mother) { theMother = mother; }
0095
0096
0097 virtual void move(const GlobalVector& displacement) = 0;
0098
0099
0100
0101
0102 virtual void rotateInGlobalFrame(const RotationType& rotation) = 0;
0103
0104
0105 virtual void rotateInLocalFrame(const RotationType& rotation);
0106
0107
0108 virtual void rotateAroundGlobalAxis(const GlobalVector& axis, Scalar radians);
0109
0110
0111 virtual void rotateAroundLocalAxis(const LocalVector& axis, Scalar radians);
0112
0113
0114 virtual void rotateAroundGlobalX(Scalar radians);
0115
0116
0117 virtual void rotateAroundLocalX(Scalar radians);
0118
0119
0120 virtual void rotateAroundGlobalY(Scalar radians);
0121
0122
0123 virtual void rotateAroundLocalY(Scalar radians);
0124
0125
0126 virtual void rotateAroundGlobalZ(Scalar radians);
0127
0128
0129 virtual void rotateAroundLocalZ(Scalar radians);
0130
0131
0132 const AlignableSurface& surface() const { return theSurface; }
0133
0134
0135 const PositionType& globalPosition() const { return surface().position(); }
0136
0137
0138 const RotationType& globalRotation() const { return surface().rotation(); }
0139
0140
0141 const GlobalVector& displacement() const { return theDisplacement; }
0142
0143
0144 const RotationType& rotation() const { return theRotation; }
0145
0146
0147 virtual void setAlignmentPositionError(const AlignmentPositionError& ape, bool propagateDown) = 0;
0148
0149
0150
0151 virtual void addAlignmentPositionError(const AlignmentPositionError& ape, bool propagateDown) = 0;
0152
0153
0154
0155
0156
0157 virtual void addAlignmentPositionErrorFromRotation(const RotationType& rotation, bool propagateDown) = 0;
0158
0159
0160
0161
0162
0163 virtual void addAlignmentPositionErrorFromLocalRotation(const RotationType& rotation, bool propagateDown) = 0;
0164
0165
0166 virtual void setSurfaceDeformation(const SurfaceDeformation* deformation, bool propagateDown) = 0;
0167
0168
0169
0170 virtual void addSurfaceDeformation(const SurfaceDeformation* deformation, bool propagateDown) = 0;
0171
0172
0173 virtual StructureType alignableObjectId() const = 0;
0174
0175
0176
0177 const DetId& geomDetId() const { return theDetId; }
0178
0179
0180 align::ID id() const { return theId; }
0181
0182
0183 virtual CompConstraintType compConstraintType() const { return compConstraintType_; }
0184
0185
0186 virtual void dump() const = 0;
0187
0188
0189 virtual Alignments* alignments() const = 0;
0190
0191
0192 virtual AlignmentErrorsExtended* alignmentErrors() const = 0;
0193
0194
0195 AlignmentSurfaceDeformations* surfaceDeformations() const;
0196
0197
0198
0199 virtual int surfaceDeformationIdPairs(std::vector<std::pair<int, SurfaceDeformation*> >&) const = 0;
0200
0201
0202 virtual void cacheTransformation();
0203
0204
0205
0206 virtual void cacheTransformation(const align::RunNumber&);
0207
0208
0209 virtual void restoreCachedTransformation();
0210
0211
0212
0213 virtual void restoreCachedTransformation(const align::RunNumber&);
0214
0215
0216 const SurveyDet* survey() const { return theSurvey; }
0217
0218
0219 void setSurvey(const SurveyDet*);
0220
0221
0222 virtual void recenterSurface();
0223
0224 protected:
0225 template <class T>
0226 using Cache = std::map<align::RunNumber, T>;
0227
0228 void addDisplacement(const GlobalVector& displacement);
0229 void addRotation(const RotationType& rotation);
0230 virtual void updateMother(const GlobalVector& shift);
0231
0232 DetId theDetId;
0233
0234
0235 align::ID theId;
0236
0237 AlignableSurface theSurface;
0238
0239 GlobalVector theDisplacement;
0240 RotationType theRotation;
0241
0242 AlignableSurface theCachedSurface;
0243 GlobalVector theCachedDisplacement;
0244 RotationType theCachedRotation;
0245
0246 CompConstraintType compConstraintType_{CompConstraintType::NONE};
0247
0248 Alignables theDeepComponents;
0249
0250
0251 Cache<AlignableSurface> surfacesCache_;
0252 Cache<GlobalVector> displacementsCache_;
0253 Cache<RotationType> rotationsCache_;
0254
0255 private:
0256
0257 Alignable() {}
0258
0259 AlignmentParameters* theAlignmentParameters;
0260
0261 Alignable* theMother;
0262
0263 const SurveyDet* theSurvey;
0264 };
0265
0266 #endif