00001
00002
00003
00004
00005
00006
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
00025
00026
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
00049 ALIPlane plate = getPlate( 1, 1 );
00050
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
00060 plate = getRotatedPlate( 1 );
00061
00062 lightray.reflect( plate );
00063
00064 if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFLECTION IN SECOND PLATE " << std::endl;
00065
00066 plate = getRotatedPlate( 0 );
00067
00068 lightray.reflect( plate );
00069
00070 if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFRACTION IN BACKWARD PLATE " << std::endl;
00071
00072 plate = getPlate( 0, 1 );
00073
00074 lightray.refract( plate, refra_ind2, refra_ind1 );
00075
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
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
00092 ALIPlane plate = getPlate(1, 1);
00093
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
00102 plate = getPlate(1, 0);
00103
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
00114
00115
00116
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
00124 ALIPlane plate = getPlate(0, 0);
00125
00126 lightray.intersect( plate );
00127 if (ALIUtils::debug >= 2) {
00128 lightray.dumpData("Intersected in plate");
00129 }
00130
00131 lightray.shiftAndDeviateWhileTraversing( this, 'R');
00132
00133
00134
00135
00136
00137
00138
00139 if (ALIUtils::debug >= 2) {
00140
00141
00142 lightray.dumpData("Deviated ");
00143 }
00144
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
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
00162 ALIPlane plate = getPlate(0, 0);
00163 lightray.intersect( plate );
00164 if (ALIUtils::debug >= 2) {
00165 lightray.dumpData("Intersected with plate");
00166 }
00167
00168 lightray.shiftAndDeviateWhileTraversing( this, 'T');
00169
00170
00171
00172
00173
00174
00175 if (ALIUtils::debug >= 2) {
00176 lightray.dumpData("Shifted and Deviated");
00177 }
00178
00179 }
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 ALIPlane OptOModifiedRhomboidPrism::getRotatedPlate(const ALIbool forwardPlate)
00193 {
00194 if (ALIUtils::debug >= 4) std::cout << "% LR: GET ROTATED PLATE " << name() << std::endl;
00195
00196 const ALIdouble shift = (findExtraEntryValue("shiftRY"));
00197 ALIdouble wedgeR = findExtraEntryValue("wedgeR");
00198
00199
00200
00201 CLHEP::Hep3Vector plate_point = centreGlob();
00202
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
00210
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
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
00228
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
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
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
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 );
00288 }