CMS 3D CMS Logo

OptOModifiedRhomboidPrism.cc

Go to the documentation of this file.
00001 //  COCOA class implementation file
00002 //Id:  OptOMOdifiedRhomboidPrism.cc
00003 //CAT: Model
00004 //
00005 //   History: v0.9 Dec 1999 
00006 //   Pedro Arce
00007 
00008 #include "Alignment/CocoaModel/interface/OptOModifiedRhomboidPrism.h"
00009 #include "Alignment/CocoaModel/interface/LightRay.h"
00010 #include "Alignment/CocoaModel/interface/ALIPlane.h" 
00011 #include "Alignment/CocoaModel/interface/Measurement.h"
00012 #include <iostream>
00013 #include <iomanip>
00014 #ifdef COCOA_VIS
00015 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
00016 #include "Alignment/CocoaVisMgr/interface/ALIColour.h"
00017 #endif
00018 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeBox.h"
00019 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00020 
00021 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00022 //@@ Detailed simulation of Reflection in Plate Splitter
00023 //@@ The software gets the plane of reflection as the forward splitter plane
00024 //@@ Then the beam is reflected in this plane.
00025 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00026 void OptOModifiedRhomboidPrism::detailedDeviatesLightRay( LightRay& lightray )
00027 {
00028   if (ALIUtils::debug >= 2) std::cout << "$$$$$ LR: DETAILED DEVIATION IN MODIFIED RHOMBOID PRISM " << name() << std::endl;
00029 
00030   CLHEP::Hep3Vector XAxis(1.,0.,0.);
00031   CLHEP::HepRotation rmt = rmGlob();
00032   XAxis = rmt*XAxis;
00033   CLHEP::Hep3Vector YAxis(0.,1.,0.);
00034   YAxis = rmt*YAxis;
00035   CLHEP::Hep3Vector ZAxis(0.,0.,1.);
00036   ZAxis = rmt*ZAxis;
00037 
00038   ALIUtils::dump3v( XAxis , " x axis ");
00039   ALIUtils::dump3v( YAxis , " y axis ");
00040   ALIUtils::dump3v( ZAxis , " z axis ");
00041   if (ALIUtils::debug >= 5) {
00042     ALIUtils::dump3v( centreGlob(), " centre ");
00043   }
00044 
00045   if (ALIUtils::debug >= 2) std::cout << "$$$ LR: REFRACTION IN FORWARD PLATE " << std::endl;
00046   //---------- Get forward plate
00047   ALIPlane plate = getPlate( 1, 1 );
00048   //---------- Refract in plate while entering
00049   ALIdouble refra_ind1 = 1.;
00050   ALIdouble refra_ind2 = findExtraEntryValueMustExist("refra_ind");
00051   lightray.refract( plate, refra_ind1, refra_ind2 );
00052   if (ALIUtils::debug >= 2) {
00053     lightray.dumpData("LightRay after Refraction at entering: "); 
00054   }
00055 
00056   if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFLECTION IN FIRST PLATE " << std::endl;
00057   //---------- Get up plate rotated
00058   plate = getRotatedPlate( 1 );
00059   //---------- Reflect in plate
00060   lightray.reflect( plate );
00061 
00062   if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFLECTION IN SECOND PLATE " << std::endl;
00063   //---------- Get up plate rotated
00064   plate = getRotatedPlate( 0 );
00065   //---------- Reflect in plate
00066   lightray.reflect( plate );
00067 
00068   if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFRACTION IN BACKWARD PLATE " << std::endl;
00069   //---------- Get backward plate
00070   plate = getPlate( 0, 1 );
00071   //---------- Refract in plate while exiting
00072   lightray.refract( plate, refra_ind2, refra_ind1 );
00073 
00074 }
00075 
00076 
00077 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00078 //@@ Detailed simulation of the light ray traversing
00079 //@@  The beam enters the prism, is refracted, traverses the prism and finally is again refracted when it exits:
00080 //@@ Get the intersection with the forward prism plane
00081 //@@ Refract the beam and propagate until it intersects the backward plane.
00082 //@@ Finally the beam is refracted again.
00083 //@@
00084 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00085 void OptOModifiedRhomboidPrism::detailedTraversesLightRay( LightRay& lightray )
00086 {
00087   if (ALIUtils::debug >= 2) std::cout << "LR: DETAILED TRAVERSE MODIFIED RHOMBOID PRISM " << name() << std::endl;
00088 
00089   //---------- Get forward plate
00090   ALIPlane plate = getPlate(1, 1);
00091   //---------- Refract while entering splitter
00092   ALIdouble refra_ind1 = 1.;
00093   ALIdouble refra_ind2 = findExtraEntryValueMustExist("refra_ind");
00094   lightray.refract( plate, refra_ind1, refra_ind2 );
00095   if (ALIUtils::debug >= 2) {
00096     lightray.dumpData("Refracted in first plate"); 
00097   }
00098 
00099   //---------- Get back ward plate (of triangular piiece)
00100   plate = getPlate(1, 0);
00101   //---------- Refract while exiting prism
00102   lightray.refract( plate, refra_ind2, refra_ind1 );
00103   if (ALIUtils::debug >= 2) {
00104     lightray.dumpData("Refracted in first plate"); 
00105   }
00106 
00107 }
00108 
00109 
00110 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00111 //@@ Fast simulation of deviation of the light ray:
00112 //@@ Reflect in a Plate Splitter
00113 //@@ The beam is reflected in the first plate of the plate splitter, which is obtained without applying the rotation by 'wedge'. 
00114 //@@ After the beam is reflected, it is rotated around the splitter X axis by 'deviX' and around the Y axis by 'deviY'.
00115 //@@
00116 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00117 void OptOModifiedRhomboidPrism::fastDeviatesLightRay( LightRay& lightray ) 
00118 {
00119   if (ALIUtils::debug >= 2) std::cout << "LR: FAST REFLECTION IN MODIFIED RHOMBOID PRISM " << name() << std::endl;
00120 
00121   //---------- Get backward plate
00122   ALIPlane plate = getPlate(0, 0);
00123   //---------- Intersect with plate
00124   lightray.intersect( plate );
00125   if (ALIUtils::debug >= 2) {
00126     lightray.dumpData("Intersected in plate"); 
00127   }
00128   //---------- Deviate Lightray 
00129   lightray.shiftAndDeviateWhileTraversing( this, 'R');
00130   /*  ALIdouble deviRX = findExtraEntryValue("deviRX");
00131   ALIdouble deviRY = findExtraEntryValue("deviRY");
00132   ALIdouble shiftRX = findExtraEntryValue("shiftRX");
00133   ALIdouble shiftRY = findExtraEntryValue("shiftRY");
00134   lightray.shiftAndDeviateWhileTraversing( this, shiftRX, shiftRY, deviRX, deviRY);
00135   */
00136 
00137   if (ALIUtils::debug >= 2) {
00138     //    std::cout << " shiftRX " << shiftRX << " shiftRY " << shiftRY << std::endl;
00139     //   std::cout << " deviRX " << deviRX << " deviRY " << deviRY << std::endl;
00140     lightray.dumpData("Deviated ");
00141   }
00142   
00143 }
00144 
00145 
00146 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00147 //@@ Fast simulation of the light ray traversing
00148 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00149 //@@ Traverse Plane Parallel Plate 
00150 //@@ Traslated to the backward plate of the plate splitter
00151 //@@ Shifted in the splitter X direction by 'shiftX', and in the Y direction by 'shiftY' 
00152 //@@ and  rotated around the splitter X axis by 'deviX' and around the Y axis by 'deviY'.
00153 //@@
00154 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00155 void OptOModifiedRhomboidPrism::fastTraversesLightRay( LightRay& lightray )
00156 {
00157   if (ALIUtils::debug >= 2) std::cout << "LR: FAST TRAVERSE MODIFIED RHOMBOID PRISM " << name() << std::endl;
00158   
00159   //---------- Get backward plate
00160   ALIPlane plate = getPlate(0, 0);
00161   lightray.intersect( plate );
00162   if (ALIUtils::debug >= 2) {
00163     lightray.dumpData("Intersected with plate"); 
00164   }
00165   //---------- Shift and Deviate
00166   lightray.shiftAndDeviateWhileTraversing( this, 'T');
00167   /*  ALIdouble shiftTX = findExtraEntryValue("shiftTX");
00168   ALIdouble shiftTY = findExtraEntryValue("shiftTY");
00169   ALIdouble deviTX = findExtraEntryValue("deviTX");
00170   ALIdouble deviTY = findExtraEntryValue("deviTY");
00171   lightray.shiftAndDeviateWhileTraversing( this, shiftTX, shiftTY, deviTX, deviTY);*/
00172 
00173   if (ALIUtils::debug >= 2) {
00174     lightray.dumpData("Shifted and Deviated");
00175   }
00176 
00177 }
00178 
00179 
00180 
00181 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00182 //@@ Get one of the rotated plates of an OptO
00183 //@@ 
00184 //@@ The point is defined taking the centre of the prism, 
00185 //@@ and traslating it by +/-1/2 'shift' in the direction of the splitter Z.
00186 //@@ The normal of this plane is obtained as the splitter Z, 
00187 //@@ and then it is rotated around X by 'angle' and with the global rotation matrix. 
00188 //@@ It is also rotated around the splitter X and Y axis by +/-1/2 of the 'wedgeR'. 
00189 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00190 ALIPlane OptOModifiedRhomboidPrism::getRotatedPlate(const ALIbool forwardPlate)
00191 {
00192   if (ALIUtils::debug >= 4) std::cout << "% LR: GET ROTATED PLATE " << name() << std::endl;
00193   //---------- Get OptO variables
00194   const ALIdouble shift = (findExtraEntryValue("shiftRY"));
00195   ALIdouble wedgeR = findExtraEntryValue("wedgeR");
00196 
00197   //---------- Get centre of plate
00198   //----- plate centre = OptO centre +/- 1/2 shift
00199   CLHEP::Hep3Vector plate_point = centreGlob();
00200   //--- Add to it half of the shift following the direction of the prism Y. -1/2 if it is forward plate, +1/2 if it is backward plate
00201   ALIdouble normal_sign = -forwardPlate*2 + 1;
00202   CLHEP::Hep3Vector YAxis(0.,1.,0.);
00203   CLHEP::HepRotation rmt = rmGlob();
00204   YAxis = rmt*YAxis;
00205   plate_point += normal_sign * shift/2. * YAxis;
00206 
00207   //---------- Get normal of plate
00208   //----- Plate normal before wedgeR (Z axis of OptO rotated 'angle' around X)
00209   CLHEP::Hep3Vector ZAxis(0.,0.,1.);
00210   ALIdouble anglePlanes;
00211   ALIbool we = findExtraEntryValueIfExists("anglePlanes", anglePlanes);
00212   if( !we ) { 
00213     anglePlanes = 45.*ALIUtils::deg;
00214   }
00215   ZAxis.rotateX( anglePlanes );
00216 
00217   //----- Rotate with global rotation matrix
00218   CLHEP::Hep3Vector plate_normal = rmt*ZAxis;
00219   if (ALIUtils::debug >= 3) { 
00220     ALIUtils::dump3v( plate_point, "plate_point");
00221     ALIUtils::dump3v( plate_normal, "plate_normal before wedge");
00222     ALIUtils::dumprm( rmt, "rmt before wedge angles" );
00223   }
00224 
00225   //----- Rotate plate normal by 1/2 wedgeR angles
00226   //--- Around X axis
00227   CLHEP::Hep3Vector XAxis(0.,0.,1.);
00228   XAxis = rmt*XAxis;
00229   plate_normal.rotate( normal_sign * wedgeR/2., XAxis );
00230   if (ALIUtils::debug >= 3) ALIUtils::dump3v( plate_normal, "plate_normal after wedgeR around X ");
00231   //--- Around the axis obtained rotating the prism Y axis by 'anglePlanes' around the prism X axis
00232   YAxis = CLHEP::Hep3Vector(0.,1.,0.);
00233   YAxis.rotateX( anglePlanes );
00234   YAxis = rmt*YAxis;
00235   plate_normal.rotate( normal_sign * wedgeR/2., YAxis );
00236   if (ALIUtils::debug >= 3) ALIUtils::dump3v( plate_normal, "plate_normal after wedgeR around Y ");
00237 
00238   //---------- Return plate plane
00239   return ALIPlane(plate_point, plate_normal);
00240 
00241 }
00242 
00243 
00244 
00245 #ifdef COCOA_VIS
00246 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00247 void OptOModifiedRhomboidPrism::fillIguana()
00248 {
00249   ALIColour* col = new ALIColour( 0., 0., 1., 0. );
00250   ALIdouble width;
00251   ALIbool wexists = findExtraEntryValueIfExists("width",width);
00252   if( !wexists ) width = 1.;
00253   ALIdouble shift;
00254   wexists = findExtraEntryValueIfExists("shift",shift);
00255   if( !wexists ) shift = 4.;
00256   std::vector<ALIdouble> spar;
00257   spar.push_back(shift);
00258   spar.push_back(shift);
00259   spar.push_back(width);
00260   spar.push_back(0.);
00261   spar.push_back(45.);
00262   spar.push_back(0.);
00263   IgCocoaFileMgr::getInstance().addSolid( *this, "PARAL", spar, col);
00264   //add a triangle
00265   std::vector<ALIdouble> spar2;
00266   spar2.push_back(width);
00267   spar2.push_back(width);
00268   spar2.push_back(0.);
00269   spar2.push_back(width);
00270   spar2.push_back(width);
00271   IgCocoaFileMgr::getInstance().addSolid( *this, "TRD", spar2, col);
00272 
00273 }
00274 
00275 #endif
00276 
00277 
00278 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00279 void OptOModifiedRhomboidPrism::constructSolidShape()
00280 {
00281   ALIdouble go;
00282   GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00283   gomgr->getGlobalOptionValue("VisScale", go );
00284 
00285   theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*5.*cm/m ); //COCOA internal units are meters
00286 }

Generated on Tue Jun 9 17:23:39 2009 for CMSSW by  doxygen 1.5.4