Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:14

0001 //   COCOA class implementation file

0002 //Id:  OptOCubeSplitter.cc

0003 //CAT: Model

0004 //

0005 //   History: v1.0

0006 //   Pedro Arce

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 //@@ Fast simulation of deviation of the light ray:

0022 //@@ Reflect in a Cube Splitter

0023 //@@ The beam is reflected in the first plate of the Cube splitter, which is obtained without applying the rotation by 'wedge'.

0024 //@@ After the beam is reflected, it is rotated around the splitter X axis by 'deviX' and around the Y axis by 'deviY'.

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   //---------- Get forward plate

0032   ALIPlane plate = getMiddlePlate();
0033   //---------- Reflect in plate (including intersection with it)

0034   lightray.reflect(plate);
0035   if (ALIUtils::debug >= 2) {
0036     lightray.dumpData("Reflected in plate");
0037   }
0038   //---------- Deviate Lightray

0039   //  ALIdouble deviRX = findExtraEntryValue("deviRX");

0040   // ALIdouble deviRY = findExtraEntryValue("deviRY");

0041   //  lightray.shiftAndDeviateWhileTraversing( this, 0., 0., 0., deviRX, deviRY, 0.);

0042   lightray.shiftAndDeviateWhileTraversing(this, 'R');
0043   if (ALIUtils::debug >= 2) {
0044     lightray.dumpData("Deviated ");
0045   }
0046 }
0047 
0048 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0049 //@@ Fast simulation of the light ray traversing

0050 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0051 //@@ Traverse Plane Parallel Plate

0052 //@@ Traslated to the backward plate of the plate splitter

0053 //@@ Shifted in the splitter X direction by 'shiftX', and in the Y direction by 'shiftY'

0054 //@@ and  rotated around the splitter X axis by 'deviX' and around the Y axis by 'deviY'.

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   //---------- Get backward plate

0062   ALIPlane plate = getPlate(false, false);
0063   lightray.intersect(plate);
0064   if (ALIUtils::debug >= 2) {
0065     lightray.dumpData("Intersected with plate");
0066   }
0067   //---------- Shift and Deviate

0068   lightray.shiftAndDeviateWhileTraversing(this, 'T');
0069   /*  ALIdouble shiftX = findExtraEntryValue("shiftX");

0070   ALIdouble shiftY = findExtraEntryValue("shiftY");

0071   ALIdouble deviTX = findExtraEntryValue("deviTX");

0072   ALIdouble deviTY = findExtraEntryValue("deviTY");

0073   lightray.shiftAndDeviateWhileTraversing( this, shiftX, shiftY, deviTX, deviTY);*/
0074 
0075   if (ALIUtils::debug >= 2) {
0076     lightray.dumpData("Shifted and Deviated");
0077   }
0078 }
0079 
0080 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0081 //@@ Detailed simulation of deviation of the light ray (reflection, shift, ...)

0082 
0083 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0084 //@@ Detailed simulation of Reflection in Cube Splitter

0085 //@@ The software gets the plane of entering as the forward splitter plane and the beam is refracted

0086 //@@ The software gets the plane of reflection as the middle splitter plane

0087 //@@ The beam is reflected in this plane.

0088 //@@ The beam is refracted at exiting

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   //---------- Get first plate

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   //---------- Refract

0104   ALIdouble refra_ind1 = 1.;
0105   ALIdouble refra_ind2 = findExtraEntryValue("refra_ind");
0106   lightray.refract(plate, refra_ind1, refra_ind2);
0107 
0108   //---------- Get middle plate

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   //---------- Reflect

0116   lightray.reflect(plate);
0117   if (ALIUtils::debug >= 2) {
0118     lightray.dumpData("Reflected in plate");
0119   }
0120 
0121   //--------- Get upper plate

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 //@@ Detailed simulation of the light ray traversing

0136 //@@  The beam enters the splitter, is refracted, traverses the splitter and finally is again refracted when it exits:

0137 //@@ Get the intersection with the forward splitter plane

0138 //@@ Refract the beam and propagate until it intersects the backward splitter plane.

0139 //@@ Finally the beam is refracted again.

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   //---------- Get forward plate

0147   ALIPlane plate = getPlate(true, true);
0148 
0149   //---------- Refract while entering splitter

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   //---------- Get backward plate

0158   plate = getPlate(false, true);
0159   //---------- Refract while exiting splitter

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 //@@ Get the middle semitransparent plate of a Cube Splittter

0168 //@@ The point is defined taking the centre of the splitter,

0169 //@@ The normal of this plane is obtained as the splitter Z rotated 45o around X

0170 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0171 ALIPlane OptOCubeSplitter::getMiddlePlate() {
0172   if (ALIUtils::debug >= 4)
0173     std::cout << "%%% LR: GET MIDDLE PLATE " << name() << std::endl;
0174   //---------- Get centre and normal of plate

0175   //----- plate normal before wedge (Z axis of OptO)

0176   ALIdouble anglePlanes;
0177   ALIbool angpl = findExtraEntryValueIfExists("anglePlanes", anglePlanes);
0178   if (!angpl) {
0179     anglePlanes =
0180         acos(0.) /
0181         2.;  //default is 45o  !!! this creates problem in 'isr_medidas_globales.txt': laser goes along X and does not intersect cube if angles Y 0, anglePlanes 45

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   //----- plate centre = OptO

0195   CLHEP::Hep3Vector plate_point = centreGlob();
0196 
0197   //---------- Return plate plane

0198   return ALIPlane(plate_point, plate_normal);
0199 }
0200 
0201 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0202 //@@ Get the upper plate of a Cube Splittter

0203 //@@ The point is defined taking the centre of the splitter,

0204 //@@ The normal of this plane is obtained as the splitter Z rotated 45o around X

0205 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0206 ALIPlane OptOCubeSplitter::getUpperPlate() {
0207   if (ALIUtils::debug >= 4)
0208     std::cout << "LR: GET UPPER PLATE " << name() << std::endl;
0209   //---------- Get centre and normal of plate

0210   ALIdouble width = findExtraEntryValue("width");
0211   //----- plate normal before wedge (Y axis of OptO)

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   //----- plate centre = OptO centre +1/2 width in Y direction

0220   CLHEP::Hep3Vector plate_point = centreGlob();
0221   plate_point += width / 2. * plate_normal;
0222 
0223   //---------- Return plate plane

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);  //COCOA internal units are meters

0254 }