File indexing completed on 2024-09-07 04:34:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _OPTICALOBJECT_HH
0011 #define _OPTICALOBJECT_HH
0012
0013 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
0014 #include <cstdint>
0015
0016 class LightRay;
0017 class Measurement;
0018 class Entry;
0019 class ALIFileIn;
0020 class Measurement;
0021 class ALIPlane;
0022
0023 class CocoaMaterialElementary;
0024 class CocoaSolidShape;
0025
0026 #include "CLHEP/Vector/ThreeVector.h"
0027 #include "CLHEP/Vector/Rotation.h"
0028 #include <fstream>
0029 #include <vector>
0030 class OpticalAlignInfo;
0031 class OpticalAlignParam;
0032
0033 enum XYZcoor { XCoor, YCoor, ZCoor };
0034
0035 class OpticalObject {
0036 friend std::ostream& operator<<(std::ostream& os, const OpticalObject& c);
0037
0038 public:
0039
0040 OpticalObject() {}
0041 OpticalObject(OpticalObject* parent, const ALIstring& type, const ALIstring& name, const ALIbool copy_data);
0042 virtual ~OpticalObject();
0043
0044
0045 void construct();
0046
0047 void constructFromOptAligInfo(const OpticalAlignInfo& oaInfo);
0048 std::vector<ALIstring> getCoordinateFromOptAlignParam(const OpticalAlignParam& oaParam);
0049 void createComponentOptOsFromOptAlignInfo();
0050
0051 virtual void constructMaterial();
0052 virtual void constructSolidShape();
0053
0054 virtual void fillVRML() {}
0055 virtual void fillIguana() {}
0056
0057
0058 const ALIstring& name() const { return theName; };
0059 const ALIstring& type() const { return theType; };
0060 const OpticalObject* parent() const { return theParent; };
0061
0062
0063 const std::vector<Entry*>& CoordinateEntryList() const { return theCoordinateEntryVector; }
0064
0065 const std::vector<Entry*>& ExtraEntryList() const { return theExtraEntryVector; }
0066
0067 std::vector<ALIdouble>& ExtraEntryValueList() { return theExtraEntryValueVector; }
0068
0069 const std::vector<ALIdouble>& ExtraEntryValueOriginalList() { return theExtraEntryValueOriginalVector; }
0070 const std::vector<ALIdouble>& ExtraEntryValueOriginalOriginalList() {
0071 return theExtraEntryValueOriginalOriginalVector;
0072 }
0073
0074
0075 const CLHEP::Hep3Vector& centreGlob() const { return theCentreGlob; }
0076
0077 const CLHEP::Hep3Vector& centreGlobal() const { return centreGlob(); }
0078
0079 const CLHEP::Hep3Vector centreLocal() const;
0080
0081 const CLHEP::Hep3Vector& centreGlobOriginal() const { return theCentreGlobOriginal; }
0082 const CLHEP::Hep3Vector& centreGlobOriginalOriginal() const { return theCentreGlobOriginalOriginal; }
0083 const CLHEP::HepRotation& rmGlob() const { return theRmGlob; }
0084
0085 const CLHEP::HepRotation rmLocal() const;
0086
0087 const CLHEP::HepRotation& rmGlobOriginal() const { return theRmGlobOriginal; }
0088 const CLHEP::HepRotation& rmGlobOriginalOriginal() const { return theRmGlobOriginalOriginal; }
0089
0090 const double getEntryCentre(const XYZcoor coor) const;
0091 const double getEntryCentre(const ALIstring& coor) const;
0092
0093 const double getEntryRMangle(const XYZcoor coor) const;
0094 const double getEntryRMangle(const ALIstring& coor) const;
0095
0096 const ALIuint ID() const { return theCmsswID; }
0097 const ALIuint getCmsswID() const { return theCmsswID; }
0098 void setCmsswID(ALIuint id) { theCmsswID = id; }
0099 void setID(ALIuint id) { theCmsswID = id; }
0100
0101
0102 void setRmGlobalOriginal(const CLHEP::HepRotation& rm) { theRmGlobOriginal = rm; }
0103 void setGlobalRMOriginalOriginal(const CLHEP::HepRotation& rmoriori);
0104 void propagateGlobalRMOriginalOriginalChangeToChildren(const CLHEP::HepRotation& rmorioriold,
0105 const CLHEP::HepRotation& rmoriorinew);
0106 CLHEP::HepRotation buildRmFromEntryValuesOriginalOriginal();
0107
0108 void setRmGlobal(const CLHEP::HepRotation& rm) { theRmGlob = rm; }
0109
0110 void setType(const ALIstring& type) { theType = type; }
0111 void addCoordinateEntryToList(Entry* entry) { theCoordinateEntryVector.push_back(entry); }
0112 void addExtraEntryToList(Entry* entry) { theExtraEntryVector.push_back(entry); }
0113 void addExtraEntryValueToList(ALIdouble entry_value) { theExtraEntryValueVector.push_back(entry_value); }
0114 void addExtraEntryValueOriginalToList(ALIdouble entry_value) {
0115 theExtraEntryValueOriginalVector.push_back(entry_value);
0116 }
0117 void addExtraEntryValueOriginalOriginalToList(ALIdouble entry_value) {
0118 theExtraEntryValueOriginalOriginalVector.push_back(entry_value);
0119 }
0120
0121
0122
0123
0124 virtual void participateInMeasurement(LightRay& lightray, Measurement& meas, const ALIstring& behav);
0125
0126 virtual void defaultBehaviour(LightRay& lightray, Measurement& meas);
0127
0128 virtual void fastDeviatesLightRay(LightRay& lightray);
0129
0130 virtual void fastTraversesLightRay(LightRay& lightray);
0131
0132 virtual void detailedDeviatesLightRay(LightRay& lightray);
0133
0134 virtual void detailedTraversesLightRay(LightRay& lightray);
0135
0136
0137 virtual void makeMeasurement(LightRay& lightray, Measurement& meas);
0138
0139
0140 virtual void userDefinedBehaviour(LightRay& lightray, Measurement& meas, const ALIstring& behav);
0141
0142
0143 CLHEP::Hep3Vector getZAxis() {
0144 CLHEP::Hep3Vector ZAxis(0., 0., 1.);
0145 CLHEP::HepRotation rmt = rmGlob();
0146 ZAxis = rmt * ZAxis;
0147 return ZAxis;
0148 }
0149
0150 ALIPlane getPlate(const ALIbool forwardPlate, const ALIbool applyWedge);
0151
0152
0153
0154 void displaceCentreGlob(const XYZcoor coor, const ALIdouble disp);
0155 CLHEP::Hep3Vector getDisplacementInLocalCoordinates(const XYZcoor coor, const ALIdouble disp);
0156 void displaceCentreGlob(const CLHEP::Hep3Vector& dispVec);
0157
0158 void displaceRmGlobAroundGlobal(OpticalObject* opto1stRotated, const XYZcoor coor, const ALIdouble disp);
0159 void displaceRmGlobAroundLocal(OpticalObject* opto1stRotated, const XYZcoor coor, const ALIdouble disp);
0160
0161 void displaceExtraEntry(const ALIuint entryNo, const ALIdouble disp);
0162 void setExtraEntryValue(const ALIuint entryNo, const ALIdouble disp);
0163
0164
0165
0166
0167 void displaceCentreGlobOriginal(const XYZcoor coor, const ALIdouble disp);
0168 void displaceCentreGlobOriginal(const CLHEP::Hep3Vector& dispVec);
0169 void displaceCentreGlobOriginalOriginal(const XYZcoor coor, const ALIdouble disp);
0170 void displaceCentreGlobOriginalOriginal(const CLHEP::Hep3Vector& dispVec);
0171
0172 void displaceRmGlobOriginal(const OpticalObject* opto1stRotated, const XYZcoor coor, const ALIdouble disp);
0173 void displaceRmGlobOriginalOriginal(const OpticalObject* opto1stRotated, const XYZcoor coor, const ALIdouble disp);
0174
0175 void displaceExtraEntryOriginal(const ALIuint entryNo, const ALIdouble disp);
0176 void displaceExtraEntryOriginalOriginal(const ALIuint entryNo, const ALIdouble disp);
0177
0178
0179 void resetGlobalCoordinates();
0180 void resetOriginalOriginalCoordinates();
0181
0182
0183 const ALIint extraEntryNo(const ALIstring& entry_name) const;
0184
0185
0186 const ALIdouble findExtraEntryValueMustExist(const ALIstring& eename) const;
0187
0188 const ALIdouble findExtraEntryValue(const ALIstring& eename) const;
0189
0190
0191 const ALIbool findExtraEntryValueIfExists(const ALIstring& eename, ALIdouble& value) const;
0192
0193
0194 const ALIstring shortName() const;
0195
0196 const ALIstring longName() const { return name(); }
0197
0198
0199 void setMeas(Measurement* meas) { theCurrentMeas = meas; }
0200 Measurement* meas() { return theCurrentMeas; }
0201
0202 std::vector<double> getRotationAnglesInOptOFrame(const OpticalObject* optoAncestor,
0203 const std::vector<Entry*>& entries) const;
0204 std::vector<double> getLocalRotationAngles(const std::vector<Entry*>& entries) const;
0205 std::vector<double> getRotationAnglesFromMatrix(CLHEP::HepRotation& rmLocal,
0206 const std::vector<Entry*>& entries) const;
0207 double diff2pi(double ang1, double ang2);
0208 bool eq2ang(double ang1, double ang2);
0209 double approxTo0(double val);
0210 double addPii(double val);
0211 int checkMatrixEquations(double angleX, double angleY, double angleZ, CLHEP::HepRotation* rot = nullptr);
0212
0213
0214 void setGlobalCoordinates();
0215 void setOriginalEntryValues();
0216
0217 CocoaMaterialElementary* getMaterial() const { return theMaterial; }
0218 CocoaSolidShape* getSolidShape() const { return theSolidShape; }
0219
0220
0221 private:
0222
0223 void readData(ALIFileIn& filein);
0224
0225 void copyData();
0226
0227
0228 void readExtraEntries(ALIFileIn& filein);
0229
0230 protected:
0231
0232 virtual void fillExtraEntry(std::vector<ALIstring>& wordlist);
0233
0234 private:
0235
0236 void readCoordinates(const ALIstring& coor_type_read, const ALIstring& coor_type_expected, ALIFileIn& filein);
0237
0238 void fillCoordinateEntry(const ALIstring& coor_name, const std::vector<ALIstring>& wordlist);
0239
0240 void setAnglesNull();
0241
0242
0243 void buildWordList(const Entry* entry, std::vector<ALIstring>& wordlist);
0244
0245
0246 void createComponentOptOs(ALIFileIn& filein);
0247
0248 OpticalObject* createNewOptO(OpticalObject* parent, ALIstring optoType, ALIstring optoName, ALIbool fcopyComponents);
0249
0250
0251 void setGlobalCentre();
0252 void setGlobalRM();
0253 void setGlobalCoordinatesOfComponents();
0254
0255 void SetCentreLocalFromEntryValues();
0256 void SetCentreGlobFromCentreLocal();
0257 void SetRMLocalFromEntryValues();
0258 void SetRMGlobFromRMLocal();
0259 void SetRMGlobFromRMLocalOriginalOriginal(const CLHEP::HepRotation& rmoriori);
0260
0261 void calculateLocalRotationAxisInGlobal();
0262
0263 void transformCylindrical2Cartesian();
0264 void transformSpherical2Cartesian();
0265 void transformGlobal2Local();
0266
0267 template <class T>
0268 void rotateItAroundGlobal(T& object, const XYZcoor coor, const double disp);
0269
0270 CLHEP::Hep3Vector getDispVec(const XYZcoor coor, const ALIdouble disp);
0271
0272 void SetCentreIsGlobal(ALIbool isG) { centreIsGlobal = isG; }
0273 void SetAnglesIsGlobal(ALIbool isG) { anglesIsGlobal = isG; }
0274
0275 private:
0276
0277 OpticalObject* theParent;
0278 ALIstring theType;
0279 ALIstring theName;
0280
0281 ALIbool fcopyData;
0282
0283
0284 CLHEP::Hep3Vector theCentreGlob;
0285 CLHEP::HepRotation theRmGlob;
0286
0287 CLHEP::Hep3Vector theCentreGlobOriginal;
0288 CLHEP::HepRotation theRmGlobOriginal;
0289 CLHEP::Hep3Vector theCentreGlobOriginalOriginal;
0290 CLHEP::HepRotation theRmGlobOriginalOriginal;
0291
0292
0293 std::vector<Entry*> theCoordinateEntryVector;
0294 std::vector<Entry*> theExtraEntryVector;
0295
0296
0297 std::vector<ALIdouble> theExtraEntryValueVector;
0298 std::vector<ALIdouble> theExtraEntryValueOriginalVector;
0299 std::vector<ALIdouble> theExtraEntryValueOriginalOriginalVector;
0300
0301
0302 ALIbool centreIsGlobal;
0303 ALIbool anglesIsGlobal;
0304
0305 Measurement* theCurrentMeas;
0306
0307 CLHEP::Hep3Vector axisXLocalInGlobal;
0308 CLHEP::Hep3Vector axisYLocalInGlobal;
0309 CLHEP::Hep3Vector axisZLocalInGlobal;
0310
0311 ALIuint theCmsswID;
0312
0313 protected:
0314 CocoaMaterialElementary* theMaterial;
0315 CocoaSolidShape* theSolidShape;
0316
0317 ALIint verbose;
0318 };
0319
0320 #endif