00001
00002
00003
00004
00005
00006
00007
00008 #include "Alignment/CocoaModel/interface/OptODistancemeter3dim.h"
00009 #include "Alignment/CocoaModel/interface/Measurement.h"
00010 #include <iostream>
00011 #include <iomanip>
00012 #ifdef COCOA_VIS
00013 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
00014 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
00015 #endif
00016 #include "CLHEP/Units/SystemOfUnits.h"
00017 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeTubs.h"
00018 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00019
00020
00021
00022
00023
00024 void OptODistancemeter3dim::defaultBehaviour( LightRay& lightray, Measurement& meas )
00025 {
00026 makeMeasurement( lightray, meas);
00027
00028 }
00029
00030
00031
00032
00033
00034 void OptODistancemeter3dim::makeMeasurement( LightRay& lightray, Measurement& meas )
00035 {
00036 const OpticalObject* opto_prev = meas.getPreviousOptO( this );
00037 CLHEP::Hep3Vector dm_centre = centreGlob();
00038 dm_centre -= opto_prev->centreGlob();
00039 if (ALIUtils::debug >= 4) {
00040 std::cout << "OptO " << name() << std::endl;
00041 ALIUtils::dump3v( centreGlob(), " centre Glob ");
00042 std::cout << "OptO " << opto_prev->name() << std::endl;
00043 ALIUtils::dump3v( opto_prev->centreGlob(), " previous OptO centre Glob ");
00044 ALIUtils::dump3v( dm_centre, " distance std::vector");
00045 }
00046
00047 meas.setValueSimulated (0 , dm_centre.mag() );
00048 if (ALIUtils::debug >= 1) {
00049 std::cout << "SIMU value: D: " << meas.valueSimulated(0)*1000.
00050 << " (mm) " << (this)->name() << std::endl;
00051 std::cout << "REAL value: D: " << meas.value()[0]*1000.
00052 << " (mm) " << (this)->name() << std::endl;
00053 }
00054 }
00055
00056
00057 #ifdef COCOA_VIS
00058
00059 void OptODistancemeter3dim::fillVRML()
00060 {
00061
00062 ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
00063 vrmlmgr.AddBox( *this, 1., .2, .2);
00064 vrmlmgr.SendReferenceFrame( *this, 1.);
00065 vrmlmgr.SendName( *this, 0.01 );
00066 }
00067
00068
00069
00070 void OptODistancemeter3dim::fillIguana()
00071 {
00072 ALIColour* col = new ALIColour( 1., 0., 1., 0. );
00073 std::vector<ALIdouble> spar;
00074 spar.push_back(1.);
00075 spar.push_back(3.);
00076 CLHEP::HepRotation rm;
00077 rm.rotateX( 90.*deg);
00078 IgCocoaFileMgr::getInstance().addSolid( *this, "CYLINDER", spar, col, CLHEP::Hep3Vector(), rm);
00079 }
00080 #endif
00081
00082
00083
00084 void OptODistancemeter3dim::constructSolidShape()
00085 {
00086 ALIdouble go;
00087 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00088 gomgr->getGlobalOptionValue("VisScale", go );
00089
00090 theSolidShape = new CocoaSolidShapeTubs( "Tubs", go*0.*cm/m, go*2.*cm/m, go*5.*cm/m );
00091 }