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
00022
00023
00024
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
00047 ALIPlane plate = getPlate( 1, 1 );
00048
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
00058 plate = getRotatedPlate( 1 );
00059
00060 lightray.reflect( plate );
00061
00062 if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFLECTION IN SECOND PLATE " << std::endl;
00063
00064 plate = getRotatedPlate( 0 );
00065
00066 lightray.reflect( plate );
00067
00068 if (ALIUtils::debug >= 2) std::cout << std::endl << "$$$ LR: REFRACTION IN BACKWARD PLATE " << std::endl;
00069
00070 plate = getPlate( 0, 1 );
00071
00072 lightray.refract( plate, refra_ind2, refra_ind1 );
00073
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
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
00090 ALIPlane plate = getPlate(1, 1);
00091
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
00100 plate = getPlate(1, 0);
00101
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
00112
00113
00114
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
00122 ALIPlane plate = getPlate(0, 0);
00123
00124 lightray.intersect( plate );
00125 if (ALIUtils::debug >= 2) {
00126 lightray.dumpData("Intersected in plate");
00127 }
00128
00129 lightray.shiftAndDeviateWhileTraversing( this, 'R');
00130
00131
00132
00133
00134
00135
00136
00137 if (ALIUtils::debug >= 2) {
00138
00139
00140 lightray.dumpData("Deviated ");
00141 }
00142
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
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
00160 ALIPlane plate = getPlate(0, 0);
00161 lightray.intersect( plate );
00162 if (ALIUtils::debug >= 2) {
00163 lightray.dumpData("Intersected with plate");
00164 }
00165
00166 lightray.shiftAndDeviateWhileTraversing( this, 'T');
00167
00168
00169
00170
00171
00172
00173 if (ALIUtils::debug >= 2) {
00174 lightray.dumpData("Shifted and Deviated");
00175 }
00176
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 ALIPlane OptOModifiedRhomboidPrism::getRotatedPlate(const ALIbool forwardPlate)
00191 {
00192 if (ALIUtils::debug >= 4) std::cout << "% LR: GET ROTATED PLATE " << name() << std::endl;
00193
00194 const ALIdouble shift = (findExtraEntryValue("shiftRY"));
00195 ALIdouble wedgeR = findExtraEntryValue("wedgeR");
00196
00197
00198
00199 CLHEP::Hep3Vector plate_point = centreGlob();
00200
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
00208
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
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
00226
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
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
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
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 );
00286 }