Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "Alignment/CocoaModel/interface/OptODistancemeter.h"
00009 #include "Alignment/CocoaModel/interface/ALIPlane.h"
00010 #include "Alignment/CocoaModel/interface/Measurement.h"
00011 #include <iostream>
00012 #include <iomanip>
00013 #ifdef COCOA_VIS
00014 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
00015 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
00016 #endif
00017 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00018 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeTubs.h"
00019 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00020
00021
00022
00023
00024 void OptODistancemeter::defaultBehaviour( LightRay& lightray, Measurement& meas )
00025 {
00026 makeMeasurement( lightray, meas);
00027
00028 }
00029
00030
00031
00032
00033
00034 void OptODistancemeter::makeMeasurement( LightRay& lightray, Measurement& meas )
00035 {
00036 const OpticalObject* opto_prev = meas.getPreviousOptO( this );
00037 CLHEP::Hep3Vector dm_centre = centreGlob();
00038 CLHEP::Hep3Vector ZAxis(0.,0.,1.);
00039 CLHEP::HepRotation rmt = rmGlob();
00040 ZAxis = rmt * ZAxis;
00041
00042
00043 ALILine dm_line( centreGlob(), ZAxis );
00044
00045 CLHEP::Hep3Vector ZAxisdt(0.,0.,1.);
00046 CLHEP::HepRotation rmtdt = opto_prev->rmGlob();
00047 ZAxisdt = rmtdt * ZAxisdt;
00048 ALIPlane dt_plane( opto_prev->centreGlob(), ZAxisdt );
00049
00050 if(ALIUtils::debug >= 3) {
00051 ALIUtils::dump3v( dm_centre, "distancemeter centre");
00052 ALIUtils::dump3v( ZAxis, "distancemeter direc");
00053 ALIUtils::dump3v( opto_prev->centreGlob(),"distance_target centre");
00054 ALIUtils::dump3v( ZAxisdt,"distance_target direc");
00055 }
00056
00057 CLHEP::Hep3Vector inters = dm_line.intersect( dt_plane );
00058
00059 dm_centre = inters - dm_centre;
00060 if (ALIUtils::debug >= 4) {
00061 std::cout << "OptO dm" << name() << dm_line << std::endl;
00062
00063 std::cout << "OptO dt" << opto_prev->name() << std::endl;
00064 ALIUtils::dump3v( opto_prev->centreGlob(), " previous OptO centre Glob ");
00065 ALIUtils::dump3v( inters, " intersection with target ");
00066 ALIUtils::dump3v( dm_centre, " distance std::vector");
00067 }
00068 ALIdouble proj = dm_centre*ZAxis;
00069
00070
00071
00072
00073 meas.setValueSimulated (0 , proj );
00074 if (ALIUtils::debug >= 1) {
00075 std::cout << "SIMU value: D: " << meas.valueSimulated(0)*1000.
00076 << " (mm) " << (this)->name() << std::endl;
00077 std::cout << "REAL value: D: " << meas.value()[0]*1000.
00078 << " (mm) " << (this)->name() << std::endl;
00079 }
00080 }
00081
00082
00083 #ifdef COCOA_VIS
00084 void OptODistancemeter::fillVRML()
00085 {
00086
00087 ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
00088 ALIColour* col = new ALIColour( 1., 0., 1., 0. );
00089 vrmlmgr.AddBox( *this, .2, .2, 1., col);
00090 vrmlmgr.SendReferenceFrame( *this, 1.2);
00091 vrmlmgr.SendName( *this, 0.1 );
00092 }
00093
00094
00095
00096 void OptODistancemeter::fillIguana()
00097 {
00098 ALIColour* col = new ALIColour( 1., 0., 0.5, 0. );
00099 std::vector<ALIdouble> spar;
00100 spar.push_back(1.);
00101 spar.push_back(3.);
00102 CLHEP::HepRotation rm;
00103 rm.rotateX( 90.*deg);
00104 IgCocoaFileMgr::getInstance().addSolid( *this, "CYLINDER", spar, col, CLHEP::Hep3Vector(), rm);
00105 }
00106 #endif
00107
00108
00109
00110 void OptODistancemeter::constructSolidShape()
00111 {
00112 ALIdouble go;
00113 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00114 gomgr->getGlobalOptionValue("VisScale", go );
00115
00116 theSolidShape = new CocoaSolidShapeTubs( "Tubs", go*0.*cm/m, go*2.*cm/m, go*5.*cm/m );
00117 }