CMS 3D CMS Logo

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