File indexing completed on 2023-03-17 10:38:40
0001
0002
0003
0004
0005
0006
0007
0008 #include "Alignment/CocoaModel/interface/EntryAngleAffAngles.h"
0009 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0010 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0011
0012
0013 EntryAngleAffAngles::EntryAngleAffAngles(const ALIstring& type) : EntryAngle(type) {}
0014
0015
0016 void EntryAngleAffAngles::FillName(const ALIstring& name) {
0017 ALIstring nn = "Angles ";
0018 nn += name;
0019 setName(nn);
0020 }
0021
0022
0023
0024
0025 void EntryAngleAffAngles::displace(ALIdouble disp) {
0026 XYZcoor coor = XCoor;
0027 ALIint namelength = name().length() - 1;
0028
0029 if (name_[namelength] == 'X') {
0030 coor = XCoor;
0031 } else if (name_[namelength] == 'Y') {
0032 coor = YCoor;
0033 } else if (name_[namelength] == 'Z') {
0034 coor = ZCoor;
0035 }
0036
0037 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0038 if (gomgr->GlobalOptions()["rotateAroundLocal"] == 0) {
0039 OptOCurrent()->displaceRmGlobAroundGlobal(OptOCurrent(), coor, disp);
0040 } else {
0041 OptOCurrent()->displaceRmGlobAroundLocal(OptOCurrent(), coor, disp);
0042 }
0043 }
0044
0045
0046 void EntryAngleAffAngles::displaceOriginal(ALIdouble disp) {
0047 ALIint namelength = name().length() - 1;
0048
0049 if (name_[namelength] == 'X') {
0050
0051 OptOCurrent()->displaceRmGlobOriginal(OptOCurrent(), XCoor, disp);
0052 } else if (name_[namelength] == 'Y') {
0053
0054 OptOCurrent()->displaceRmGlobOriginal(OptOCurrent(), YCoor, disp);
0055 } else if (name_[namelength] == 'Z') {
0056 OptOCurrent()->displaceRmGlobOriginal(OptOCurrent(), ZCoor, disp);
0057 }
0058 }
0059
0060
0061 void EntryAngleAffAngles::displaceOriginalOriginal(ALIdouble disp) {
0062 ALIint namelength = name().length() - 1;
0063 if (ALIUtils::debug >= 5)
0064 std::cout << this << "ENtryAnglesAffAngle displaceOriginalOriginal" << name_ << std::endl;
0065 if (name_[namelength] == 'X') {
0066
0067 OptOCurrent()->displaceRmGlobOriginalOriginal(OptOCurrent(), XCoor, disp);
0068 } else if (name_[namelength] == 'Y') {
0069
0070 OptOCurrent()->displaceRmGlobOriginalOriginal(OptOCurrent(), YCoor, disp);
0071 } else if (name_[namelength] == 'Z') {
0072 OptOCurrent()->displaceRmGlobOriginalOriginal(OptOCurrent(), ZCoor, disp);
0073 }
0074 }
0075
0076
0077 ALIdouble EntryAngleAffAngles::valueDisplaced() const {
0078
0079
0080 if (ALIUtils::debug >= 5) {
0081 std::cout << " EntryAngleAffAngles::valueDisplaced() parent opto " << OptOCurrent()->parent()->name()
0082 << std::endl;
0083 ALIUtils::dumprm(OptOCurrent()->rmGlob(), " RmGlob ");
0084 ALIUtils::dumprm(OptOCurrent()->rmGlobOriginal(), " RmGlobOriginal ");
0085 ALIUtils::dumprm(OptOCurrent()->parent()->rmGlobOriginal(), " parent RmGlobOriginal ");
0086 }
0087
0088 CLHEP::HepRotation diffRm = OptOCurrent()->rmGlob() * OptOCurrent()->rmGlobOriginal().inverse();
0089 CLHEP::HepRotation rmLocal = diffRm * OptOCurrent()->parent()->rmGlobOriginal().inverse();
0090 std::vector<double> localrot =
0091 OptOCurrent()->getRotationAnglesFromMatrix(rmLocal, OptOCurrent()->CoordinateEntryList());
0092 if (ALIUtils::debug >= 5) {
0093 ALIUtils::dumprm(diffRm, " diffRm ");
0094 ALIUtils::dumprm(rmLocal, " rmLocal ");
0095 std::cout << " localrot " << localrot[0] << " " << localrot[1] << " " << localrot[2] << std::endl;
0096 }
0097
0098 if (name() == "angles_X") {
0099 return localrot[0];
0100 } else if (name() == "angles_Y") {
0101 return localrot[1];
0102 } else if (name() == "angles_Z") {
0103 return localrot[2];
0104 }
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 return 0.;
0136 }
0137
0138
0139 ALIdouble EntryAngleAffAngles::checkDiff(const CLHEP::Hep3Vector& _axis,
0140 const CLHEP::Hep3Vector& _axisOrig,
0141 const std::vector<double>& localrot,
0142 const std::vector<double>& localrotorig) const {
0143 CLHEP::Hep3Vector axis = _axis;
0144 CLHEP::Hep3Vector axisOrig = _axisOrig;
0145 int inam = 0;
0146 if (name() == "angles_X") {
0147 inam = 1;
0148 } else if (name() == "angles_Y") {
0149 inam = 2;
0150 } else if (name() == "angles_Z") {
0151 inam = 3;
0152 }
0153 switch (inam) {
0154 case 1:
0155 axis.rotateX(localrot[0]);
0156 axisOrig.rotateX(localrotorig[0]);
0157 [[fallthrough]];
0158 case 2:
0159 axis.rotateY(localrot[1]);
0160 axisOrig.rotateY(localrotorig[1]);
0161 [[fallthrough]];
0162 case 3:
0163 axis.rotateZ(localrot[2]);
0164 axisOrig.rotateZ(localrotorig[2]);
0165 break;
0166 }
0167
0168 ALIdouble ang = axis.angle(axisOrig);
0169
0170
0171
0172
0173
0174
0175
0176 return ang;
0177 }