Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "Alignment/CocoaModel/interface/OptOMirror.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 void OptOMirror::defaultBehaviour( LightRay& lightray, Measurement& meas )
00025 {
00026 detailedDeviatesLightRay( lightray );
00027 }
00028
00029
00030
00031
00032
00033 void OptOMirror::detailedDeviatesLightRay( LightRay& lightray )
00034 {
00035 if (ALIUtils::debug >= 2) std::cout << "LR: DETAILED REFLECTION IN MIRROR " << name() << std::endl;
00036 if (ALIUtils::debug >= 3) ALIUtils::dump3v( centreGlob(), " centre Global ");
00037
00038
00039 ALIPlane plate = getPlate(1, 0);
00040 lightray.intersect( plate );
00041 CLHEP::Hep3Vector inters = lightray.point( );
00042
00043
00044
00045 CLHEP::Hep3Vector ZAxis = getZAxis();
00046 CLHEP::HepRotation rmt = rmGlob();
00047 ZAxis = rmt * ZAxis;
00048
00049 ALIdouble width = findExtraEntryValue("width");
00050 CLHEP::Hep3Vector plate_centre = centreGlob() - 0.5 * width * ZAxis;
00051
00052
00053
00054 ALIdouble distance = ( plate_centre - inters ).mag();
00055
00056
00057
00058 ALIdouble flatness = findExtraEntryValue("flatness");
00059
00060 flatness *= 632.E-9;
00061 ALIdouble length = 0.;
00062
00063 ALIdouble curvature_radius;
00064 ALIdouble angFlatness;
00065 if( flatness != 0) {
00066 length = findExtraEntryValueMustExist("length");
00067 curvature_radius = (flatness*flatness + length*length) / (2*flatness);
00068 angFlatness = asin( distance / curvature_radius);
00069 } else {
00070 curvature_radius = ALI_DBL_MAX;
00071 angFlatness = 0;
00072 }
00073
00074 if (ALIUtils::debug >= 3) {
00075 std::cout << " intersection with plate " << inters << std::endl;
00076 std::cout << " plate_centre " << plate_centre << std::endl;
00077 std::cout << " distance plate_centre - intersection " << distance << std::endl;
00078 std::cout << " flatness " << flatness << ", length " << length;
00079 std::cout << ", curvature radius " << curvature_radius << " angle of flatness " << angFlatness << std::endl;
00080 }
00081
00082
00083 CLHEP::Hep3Vector ipcV = inters - plate_centre;
00084 if( ipcV.mag() != 0) ipcV *= 1./ipcV.mag();
00085 CLHEP::HepRotation rtm = rmGlob();
00086 ipcV = rtm*ipcV;
00087 CLHEP::Hep3Vector rotationAxis = ipcV.cross(ZAxis);
00088
00089 CLHEP::Hep3Vector inters_normal = CLHEP::Hep3Vector(0.,0.,1.);
00090 inters_normal.rotate( angFlatness, rotationAxis );
00091 inters_normal = rmt * inters_normal;
00092
00093 if (ALIUtils::debug >= 2) {
00094 ALIUtils::dump3v( ipcV, " intersection - plate_centre std::vector ");
00095 std::cout << "rotation Axis " << rotationAxis << std::endl;
00096 std::cout << " plate normal at intersection point " << inters_normal << std::endl;
00097 }
00098
00099 ALIdouble cosang = -( inters_normal * lightray.direction() ) /
00100 inters_normal.mag() / lightray.direction().mag();
00101 CLHEP::Hep3Vector lrold = lightray.direction();
00102 lightray.setDirection( lightray.direction() + inters_normal*2*cosang );
00103
00104 if (ALIUtils::debug >= 2) {
00105 lightray.dumpData("Reflected in mirror");
00106 }
00107
00108 }
00109
00110
00111
00112
00113
00114 void OptOMirror::fastDeviatesLightRay( LightRay& lightray )
00115 {
00116 if (ALIUtils::debug >= 2) std::cout << "LR: FAST REFLECTION IN MIRROR " << name() << std::endl;
00117
00118
00119 ALIPlane plate = getPlate(1, 0);
00120
00121
00122 lightray.reflect( plate );
00123 if (ALIUtils::debug >= 2) {
00124 lightray.dumpData("Reflected in plate");
00125 }
00126
00127
00128
00129
00130 lightray.shiftAndDeviateWhileTraversing( this, 'R' );
00131 if (ALIUtils::debug >= 2) {
00132 lightray.dumpData("Deviated ");
00133 }
00134
00135 }
00136
00137
00138 void OptOMirror::detailedTraversesLightRay( LightRay& lightray )
00139 {
00140 if (ALIUtils::debug >= 2) std::cout << "LR: DETAILED TRAVERSE IN MIRROR " << name() << std::endl;
00141
00142
00143 ALIPlane plate = getPlate(1, 1);
00144
00145 ALIdouble width = findExtraEntryValue("width");
00146 if( width == 0 ) {
00147 if(ALIUtils::debug >= 3) lightray.dumpData("Traversed with 0 width");
00148 return;
00149 }
00150
00151
00152 ALIdouble refra_ind1 = 1.;
00153 ALIdouble refra_ind2 = findExtraEntryValue("refra_ind");
00154 lightray.refract( plate, refra_ind1, refra_ind2 );
00155 if (ALIUtils::debug >= 2) {
00156 lightray.dumpData("Refracted in first plate");
00157 }
00158
00159
00160 plate = getPlate(0, 1);
00161
00162 lightray.refract( plate, refra_ind2, refra_ind1 );
00163 if (ALIUtils::debug >= 2) {
00164 lightray.dumpData("Refracted in first plate");
00165 }
00166
00167 }
00168
00169
00170
00171 void OptOMirror::fastTraversesLightRay( LightRay& lightray )
00172 {
00173 if (ALIUtils::debug >= 2) std::cout << "LR: TRAVERSE MIRROR " << name() << std::endl;
00174
00175
00176 ALIPlane plate = getPlate(0, 0);
00177 lightray.intersect( plate );
00178 if (ALIUtils::debug >= 2) {
00179 lightray.dumpData("Intersected with plate");
00180 }
00181
00182 lightray.shiftAndDeviateWhileTraversing( this, 'T' );
00183 if (ALIUtils::debug >= 2) {
00184 lightray.dumpData("Shifted and Deviated");
00185 }
00186
00187 }
00188
00189
00190
00191 #ifdef COCOA_VIS
00192
00193 void OptOMirror::fillIguana()
00194 {
00195 ALIdouble width;
00196 ALIbool wexists = findExtraEntryValueIfExists("width",width);
00197 if( !wexists ) width = 1.;
00198 ALIdouble length;
00199 wexists = findExtraEntryValueIfExists("length",length);
00200 if( !wexists ) length = 4.;
00201
00202 ALIColour* col = new ALIColour( 0., 0., 1., 0. );
00203 std::vector<ALIdouble> spar;
00204 spar.push_back(length);
00205 spar.push_back(length);
00206 spar.push_back(width);
00207 IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar, col);
00208 }
00209 #endif
00210
00211
00212
00213 void OptOMirror::constructSolidShape()
00214 {
00215 ALIdouble go;
00216 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00217 gomgr->getGlobalOptionValue("VisScale", go );
00218
00219 theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*1.*cm/m );
00220 }