File indexing completed on 2024-04-06 11:56:03
0001
0002
0003
0004
0005
0006
0007
0008 #include "Alignment/CocoaModel/interface/OptOModifiedRhomboidPrism.h"
0009 #include "Alignment/CocoaModel/interface/LightRay.h"
0010 #include "Alignment/CocoaModel/interface/ALIPlane.h"
0011 #include "Alignment/CocoaModel/interface/Measurement.h"
0012 #include <iostream>
0013 #include <iomanip>
0014 #ifdef COCOA_VIS
0015 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
0016 #include "Alignment/CocoaVisMgr/interface/ALIColour.h"
0017 #endif
0018 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeBox.h"
0019 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0020
0021 using namespace CLHEP;
0022
0023
0024
0025
0026
0027
0028 void OptOModifiedRhomboidPrism::detailedDeviatesLightRay(LightRay& lightray) {
0029 if (ALIUtils::debug >= 2)
0030 std::cout << "$$$$$ LR: DETAILED DEVIATION IN MODIFIED RHOMBOID PRISM " << name() << std::endl;
0031
0032 CLHEP::Hep3Vector XAxis(1., 0., 0.);
0033 CLHEP::HepRotation rmt = rmGlob();
0034 XAxis = rmt * XAxis;
0035 CLHEP::Hep3Vector YAxis(0., 1., 0.);
0036 YAxis = rmt * YAxis;
0037 CLHEP::Hep3Vector ZAxis(0., 0., 1.);
0038 ZAxis = rmt * ZAxis;
0039
0040 ALIUtils::dump3v(XAxis, " x axis ");
0041 ALIUtils::dump3v(YAxis, " y axis ");
0042 ALIUtils::dump3v(ZAxis, " z axis ");
0043 if (ALIUtils::debug >= 5) {
0044 ALIUtils::dump3v(centreGlob(), " centre ");
0045 }
0046
0047 if (ALIUtils::debug >= 2)
0048 std::cout << "$$$ LR: REFRACTION IN FORWARD PLATE " << std::endl;
0049
0050 ALIPlane plate = getPlate(true, true);
0051
0052 ALIdouble refra_ind1 = 1.;
0053 ALIdouble refra_ind2 = findExtraEntryValueMustExist("refra_ind");
0054 lightray.refract(plate, refra_ind1, refra_ind2);
0055 if (ALIUtils::debug >= 2) {
0056 lightray.dumpData("LightRay after Refraction at entering: ");
0057 }
0058
0059 if (ALIUtils::debug >= 2)
0060 std::cout << std::endl << "$$$ LR: REFLECTION IN FIRST PLATE " << std::endl;
0061
0062 plate = getRotatedPlate(true);
0063
0064 lightray.reflect(plate);
0065
0066 if (ALIUtils::debug >= 2)
0067 std::cout << std::endl << "$$$ LR: REFLECTION IN SECOND PLATE " << std::endl;
0068
0069 plate = getRotatedPlate(false);
0070
0071 lightray.reflect(plate);
0072
0073 if (ALIUtils::debug >= 2)
0074 std::cout << std::endl << "$$$ LR: REFRACTION IN BACKWARD PLATE " << std::endl;
0075
0076 plate = getPlate(false, true);
0077
0078 lightray.refract(plate, refra_ind2, refra_ind1);
0079 }
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089 void OptOModifiedRhomboidPrism::detailedTraversesLightRay(LightRay& lightray) {
0090 if (ALIUtils::debug >= 2)
0091 std::cout << "LR: DETAILED TRAVERSE MODIFIED RHOMBOID PRISM " << name() << std::endl;
0092
0093
0094 ALIPlane plate = getPlate(true, true);
0095
0096 ALIdouble refra_ind1 = 1.;
0097 ALIdouble refra_ind2 = findExtraEntryValueMustExist("refra_ind");
0098 lightray.refract(plate, refra_ind1, refra_ind2);
0099 if (ALIUtils::debug >= 2) {
0100 lightray.dumpData("Refracted in first plate");
0101 }
0102
0103
0104 plate = getPlate(true, false);
0105
0106 lightray.refract(plate, refra_ind2, refra_ind1);
0107 if (ALIUtils::debug >= 2) {
0108 lightray.dumpData("Refracted in first plate");
0109 }
0110 }
0111
0112
0113
0114
0115
0116
0117
0118
0119 void OptOModifiedRhomboidPrism::fastDeviatesLightRay(LightRay& lightray) {
0120 if (ALIUtils::debug >= 2)
0121 std::cout << "LR: FAST REFLECTION IN MODIFIED RHOMBOID PRISM " << name() << std::endl;
0122
0123
0124 ALIPlane plate = getPlate(false, false);
0125
0126 lightray.intersect(plate);
0127 if (ALIUtils::debug >= 2) {
0128 lightray.dumpData("Intersected in plate");
0129 }
0130
0131 lightray.shiftAndDeviateWhileTraversing(this, 'R');
0132
0133
0134
0135
0136
0137
0138
0139 if (ALIUtils::debug >= 2) {
0140
0141
0142 lightray.dumpData("Deviated ");
0143 }
0144 }
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 void OptOModifiedRhomboidPrism::fastTraversesLightRay(LightRay& lightray) {
0156 if (ALIUtils::debug >= 2)
0157 std::cout << "LR: FAST TRAVERSE MODIFIED RHOMBOID PRISM " << name() << std::endl;
0158
0159
0160 ALIPlane plate = getPlate(false, false);
0161 lightray.intersect(plate);
0162 if (ALIUtils::debug >= 2) {
0163 lightray.dumpData("Intersected with plate");
0164 }
0165
0166 lightray.shiftAndDeviateWhileTraversing(this, 'T');
0167
0168
0169
0170
0171
0172
0173 if (ALIUtils::debug >= 2) {
0174 lightray.dumpData("Shifted and Deviated");
0175 }
0176 }
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187 ALIPlane OptOModifiedRhomboidPrism::getRotatedPlate(const ALIbool forwardPlate) {
0188 if (ALIUtils::debug >= 4)
0189 std::cout << "% LR: GET ROTATED PLATE " << name() << std::endl;
0190
0191 const ALIdouble shift = (findExtraEntryValue("shiftRY"));
0192 ALIdouble wedgeR = findExtraEntryValue("wedgeR");
0193
0194
0195
0196 CLHEP::Hep3Vector plate_point = centreGlob();
0197
0198 ALIdouble normal_sign = -forwardPlate * 2 + 1;
0199 CLHEP::Hep3Vector YAxis(0., 1., 0.);
0200 CLHEP::HepRotation rmt = rmGlob();
0201 YAxis = rmt * YAxis;
0202 plate_point += normal_sign * shift / 2. * YAxis;
0203
0204
0205
0206 CLHEP::Hep3Vector ZAxis(0., 0., 1.);
0207 ALIdouble anglePlanes;
0208 ALIbool we = findExtraEntryValueIfExists("anglePlanes", anglePlanes);
0209 if (!we) {
0210 anglePlanes = 45. * ALIUtils::deg;
0211 }
0212 ZAxis.rotateX(anglePlanes);
0213
0214
0215 CLHEP::Hep3Vector plate_normal = rmt * ZAxis;
0216 if (ALIUtils::debug >= 3) {
0217 ALIUtils::dump3v(plate_point, "plate_point");
0218 ALIUtils::dump3v(plate_normal, "plate_normal before wedge");
0219 ALIUtils::dumprm(rmt, "rmt before wedge angles");
0220 }
0221
0222
0223
0224 CLHEP::Hep3Vector XAxis(0., 0., 1.);
0225 XAxis = rmt * XAxis;
0226 plate_normal.rotate(normal_sign * wedgeR / 2., XAxis);
0227 if (ALIUtils::debug >= 3)
0228 ALIUtils::dump3v(plate_normal, "plate_normal after wedgeR around X ");
0229
0230 YAxis = CLHEP::Hep3Vector(0., 1., 0.);
0231 YAxis.rotateX(anglePlanes);
0232 YAxis = rmt * YAxis;
0233 plate_normal.rotate(normal_sign * wedgeR / 2., YAxis);
0234 if (ALIUtils::debug >= 3)
0235 ALIUtils::dump3v(plate_normal, "plate_normal after wedgeR around Y ");
0236
0237
0238 return ALIPlane(plate_point, plate_normal);
0239 }
0240
0241 #ifdef COCOA_VIS
0242
0243 void OptOModifiedRhomboidPrism::fillIguana() {
0244 ALIColour* col = new ALIColour(0., 0., 1., 0.);
0245 ALIdouble width;
0246 ALIbool wexists = findExtraEntryValueIfExists("width", width);
0247 if (!wexists)
0248 width = 1.;
0249 ALIdouble shift;
0250 wexists = findExtraEntryValueIfExists("shift", shift);
0251 if (!wexists)
0252 shift = 4.;
0253 std::vector<ALIdouble> spar;
0254 spar.push_back(shift);
0255 spar.push_back(shift);
0256 spar.push_back(width);
0257 spar.push_back(0.);
0258 spar.push_back(45.);
0259 spar.push_back(0.);
0260 IgCocoaFileMgr::getInstance().addSolid(*this, "PARAL", spar, col);
0261
0262 std::vector<ALIdouble> spar2;
0263 spar2.push_back(width);
0264 spar2.push_back(width);
0265 spar2.push_back(0.);
0266 spar2.push_back(width);
0267 spar2.push_back(width);
0268 IgCocoaFileMgr::getInstance().addSolid(*this, "TRD", spar2, col);
0269 }
0270
0271 #endif
0272
0273
0274 void OptOModifiedRhomboidPrism::constructSolidShape() {
0275 ALIdouble go;
0276 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0277 gomgr->getGlobalOptionValue("VisScale", go);
0278
0279 theSolidShape = new CocoaSolidShapeBox(
0280 "Box", go * 5. * cm / m, go * 5. * cm / m, go * 5. * cm / m);
0281 }