File indexing completed on 2024-05-10 02:20:14
0001
0002
0003
0004
0005
0006
0007
0008 #include "Alignment/CocoaModel/interface/OptOCubeSplitter.h"
0009 #include "Alignment/CocoaModel/interface/LightRay.h"
0010 #include "Alignment/CocoaModel/interface/ALIPlane.h"
0011 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
0012 #include <CLHEP/Units/SystemOfUnits.h>
0013 #ifdef COCOA_VIS
0014 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
0015 #include "Alignment/CocoaVisMgr/interface/ALIColour.h"
0016 #endif
0017 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeBox.h"
0018 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0019
0020
0021
0022
0023
0024
0025
0026
0027 void OptOCubeSplitter::fastDeviatesLightRay(LightRay& lightray) {
0028 if (ALIUtils::debug >= 2)
0029 std::cout << "LR: FAST REFLECTION IN CUBE SPLITTER " << name() << std::endl;
0030
0031
0032 ALIPlane plate = getMiddlePlate();
0033
0034 lightray.reflect(plate);
0035 if (ALIUtils::debug >= 2) {
0036 lightray.dumpData("Reflected in plate");
0037 }
0038
0039
0040
0041
0042 lightray.shiftAndDeviateWhileTraversing(this, 'R');
0043 if (ALIUtils::debug >= 2) {
0044 lightray.dumpData("Deviated ");
0045 }
0046 }
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 void OptOCubeSplitter::fastTraversesLightRay(LightRay& lightray) {
0058 if (ALIUtils::debug >= 2)
0059 std::cout << "LR: FAST TRAVERSE CUBE SPLITTER " << name() << std::endl;
0060
0061
0062 ALIPlane plate = getPlate(false, false);
0063 lightray.intersect(plate);
0064 if (ALIUtils::debug >= 2) {
0065 lightray.dumpData("Intersected with plate");
0066 }
0067
0068 lightray.shiftAndDeviateWhileTraversing(this, 'T');
0069
0070
0071
0072
0073
0074
0075 if (ALIUtils::debug >= 2) {
0076 lightray.dumpData("Shifted and Deviated");
0077 }
0078 }
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 void OptOCubeSplitter::detailedDeviatesLightRay(LightRay& lightray) {
0091 if (ALIUtils::debug >= 2)
0092 std::cout << "LR: DETAILED REFLECTION IN CUBE SPLITTER " << name() << std::endl;
0093
0094 if (ALIUtils::debug >= 2)
0095 ALIUtils::dump3v(centreGlob(), "centreGlob");
0096
0097 if (ALIUtils::debug >= 3)
0098 std::cout << "%%%%% refracting at entering first plate " << std::endl;
0099 if (ALIUtils::debug >= 3)
0100 std::cout << "%%% getting first plate " << std::endl;
0101 ALIPlane plate = getPlate(true, true);
0102
0103
0104 ALIdouble refra_ind1 = 1.;
0105 ALIdouble refra_ind2 = findExtraEntryValue("refra_ind");
0106 lightray.refract(plate, refra_ind1, refra_ind2);
0107
0108
0109 if (ALIUtils::debug >= 3)
0110 std::cout << "%%%%% reflecting in middle plate " << std::endl;
0111 if (ALIUtils::debug >= 3)
0112 std::cout << "%%% getting middle plate " << std::endl;
0113 plate = getMiddlePlate();
0114
0115
0116 lightray.reflect(plate);
0117 if (ALIUtils::debug >= 2) {
0118 lightray.dumpData("Reflected in plate");
0119 }
0120
0121
0122 if (ALIUtils::debug >= 3)
0123 std::cout << "%%%%% getting second plate " << std::endl;
0124 plate = getUpperPlate();
0125 if (ALIUtils::debug >= 3)
0126 std::cout << "%%%%% refracting at exiting second plate " << std::endl;
0127 lightray.refract(plate, refra_ind2, refra_ind1);
0128
0129 if (ALIUtils::debug >= 2) {
0130 lightray.dumpData("After CubeSplitter");
0131 }
0132 }
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 void OptOCubeSplitter::detailedTraversesLightRay(LightRay& lightray) {
0143 if (ALIUtils::debug >= 2)
0144 std::cout << "LR: DETAILED TRAVERSE CUBE SPLITTER " << name() << std::endl;
0145
0146
0147 ALIPlane plate = getPlate(true, true);
0148
0149
0150 ALIdouble refra_ind1 = 1.;
0151 ALIdouble refra_ind2 = findExtraEntryValue("refra_ind");
0152 lightray.refract(plate, refra_ind1, refra_ind2);
0153 if (ALIUtils::debug >= 2) {
0154 lightray.dumpData("Refracted in first plate");
0155 }
0156
0157
0158 plate = getPlate(false, true);
0159
0160 lightray.refract(plate, refra_ind2, refra_ind1);
0161 if (ALIUtils::debug >= 2) {
0162 lightray.dumpData("Refracted in first plate");
0163 }
0164 }
0165
0166
0167
0168
0169
0170
0171 ALIPlane OptOCubeSplitter::getMiddlePlate() {
0172 if (ALIUtils::debug >= 4)
0173 std::cout << "%%% LR: GET MIDDLE PLATE " << name() << std::endl;
0174
0175
0176 ALIdouble anglePlanes;
0177 ALIbool angpl = findExtraEntryValueIfExists("anglePlanes", anglePlanes);
0178 if (!angpl) {
0179 anglePlanes =
0180 acos(0.) /
0181 2.;
0182 if (ALIUtils::debug >= 4)
0183 std::cout << "anglePlanes default = " << anglePlanes / CLHEP::deg << std::endl;
0184 }
0185 CLHEP::Hep3Vector Axis(0., 0., 1.);
0186 CLHEP::Hep3Vector XAxis(1., 0., 0.);
0187 Axis.rotate(anglePlanes, XAxis);
0188 CLHEP::HepRotation rmt = rmGlob();
0189 CLHEP::Hep3Vector plate_normal = rmt * Axis;
0190 if (ALIUtils::debug >= 3) {
0191 ALIUtils::dumprm(rmt, "rmt before wedge angles");
0192 ALIUtils::dump3v(plate_normal, "plate_normal before wedge");
0193 }
0194
0195 CLHEP::Hep3Vector plate_point = centreGlob();
0196
0197
0198 return ALIPlane(plate_point, plate_normal);
0199 }
0200
0201
0202
0203
0204
0205
0206 ALIPlane OptOCubeSplitter::getUpperPlate() {
0207 if (ALIUtils::debug >= 4)
0208 std::cout << "LR: GET UPPER PLATE " << name() << std::endl;
0209
0210 ALIdouble width = findExtraEntryValue("width");
0211
0212 CLHEP::Hep3Vector Axis(0., 1., 0.);
0213 CLHEP::HepRotation rmt = rmGlob();
0214 CLHEP::Hep3Vector plate_normal = rmt * Axis;
0215 if (ALIUtils::debug >= 3) {
0216 ALIUtils::dumprm(rmt, "rmt before wedge angles");
0217 ALIUtils::dump3v(plate_normal, "plate_normal before wedge");
0218 }
0219
0220 CLHEP::Hep3Vector plate_point = centreGlob();
0221 plate_point += width / 2. * plate_normal;
0222
0223
0224 return ALIPlane(plate_point, plate_normal);
0225 }
0226
0227 #ifdef COCOA_VIS
0228
0229 void OptOCubeSplitter::fillIguana() {
0230 ALIColour* col = new ALIColour(0., 0., 0., 0.);
0231 ALIdouble width;
0232 ALIbool wexists = findExtraEntryValueIfExists("width", width);
0233 if (!wexists)
0234 width = 4.;
0235
0236 std::vector<ALIdouble> spar;
0237 spar.push_back(width);
0238 spar.push_back(width);
0239 spar.push_back(width);
0240 IgCocoaFileMgr::getInstance().addSolid(*this, "BOX", spar, col);
0241 }
0242 #endif
0243
0244
0245 void OptOCubeSplitter::constructSolidShape() {
0246 ALIdouble go;
0247 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0248 gomgr->getGlobalOptionValue("VisScale", go);
0249
0250 theSolidShape = new CocoaSolidShapeBox("Box",
0251 go * 5. * CLHEP::cm / CLHEP::m,
0252 go * 5. * CLHEP::cm / CLHEP::m,
0253 go * 5. * CLHEP::cm / CLHEP::m);
0254 }