Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:38:43

0001 //   COCOA class implementation file

0002 //Id:  OptODistancemeter.cc

0003 //CAT: Model

0004 //

0005 //   History: v1.0

0006 //   Pedro Arce

0007 
0008 #include "Alignment/CocoaModel/interface/OptODistancemeter.h"
0009 #include "Alignment/CocoaModel/interface/ALIPlane.h"
0010 #include "Alignment/CocoaModel/interface/Measurement.h"
0011 #include <iostream>
0012 #include <iomanip>
0013 #ifdef COCOA_VIS
0014 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
0015 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
0016 #endif
0017 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0018 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeTubs.h"
0019 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0020 
0021 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0022 //@@  Default behaviour: make measurement

0023 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0024 void OptODistancemeter::defaultBehaviour(LightRay& lightray, Measurement& meas) { makeMeasurement(lightray, meas); }
0025 
0026 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0027 //@@  Make measurement as distance to previous object 'screen'

0028 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0029 void OptODistancemeter::makeMeasurement(LightRay& lightray, Measurement& meas) {
0030   const OpticalObject* opto_prev = meas.getPreviousOptO(this);
0031   CLHEP::Hep3Vector dm_centre = centreGlob();
0032   CLHEP::Hep3Vector ZAxis(0., 0., 1.);
0033   CLHEP::HepRotation rmt = rmGlob();
0034   ZAxis = rmt * ZAxis;
0035 
0036   //----- intersect z of distancemeter with distance target

0037   ALILine dm_line(centreGlob(), ZAxis);
0038 
0039   CLHEP::Hep3Vector ZAxisdt(0., 0., 1.);
0040   const CLHEP::HepRotation& rmtdt = opto_prev->rmGlob();
0041   ZAxisdt = rmtdt * ZAxisdt;
0042   ALIPlane dt_plane(opto_prev->centreGlob(), ZAxisdt);
0043 
0044   if (ALIUtils::debug >= 3) {
0045     ALIUtils::dump3v(dm_centre, "distancemeter centre");
0046     ALIUtils::dump3v(ZAxis, "distancemeter direc");
0047     ALIUtils::dump3v(opto_prev->centreGlob(), "distance_target centre");
0048     ALIUtils::dump3v(ZAxisdt, "distance_target direc");
0049   }
0050 
0051   CLHEP::Hep3Vector inters = dm_line.intersect(dt_plane);
0052 
0053   dm_centre = inters - dm_centre;
0054   if (ALIUtils::debug >= 4) {
0055     std::cout << "OptO dm" << name() << dm_line << std::endl;
0056     //    ALIUtils::dump3v( centreGlob(), " centre Glob ");

0057     std::cout << "OptO dt" << opto_prev->name() << std::endl;
0058     ALIUtils::dump3v(opto_prev->centreGlob(), " previous OptO centre Glob ");
0059     ALIUtils::dump3v(inters, " intersection with target ");
0060     ALIUtils::dump3v(dm_centre, " distance std::vector");
0061   }
0062   ALIdouble proj = dm_centre * ZAxis;
0063 
0064   //- ALIUtils::dump3v( ZAxis, " zaxis ");

0065   //-  std::cout << " proj " << proj << std::endl;

0066 
0067   meas.setValueSimulated(0, proj);
0068   if (ALIUtils::debug >= 1) {
0069     std::cout << "SIMU value: D: " << meas.valueSimulated(0) * 1000. << " (mm)  " << (this)->name() << std::endl;
0070     std::cout << "REAL value: D: " << meas.value()[0] * 1000. << " (mm)  " << (this)->name() << std::endl;
0071   }
0072 }
0073 
0074 #ifdef COCOA_VIS
0075 void OptODistancemeter::fillVRML() {
0076   //-  std::cout << " filling optosensor " << std::endl;

0077   ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
0078   ALIColour* col = new ALIColour(1., 0., 1., 0.);
0079   vrmlmgr.AddBox(*this, .2, .2, 1., col);
0080   vrmlmgr.SendReferenceFrame(*this, 1.2);
0081   vrmlmgr.SendName(*this, 0.1);
0082 }
0083 
0084 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0085 void OptODistancemeter::fillIguana() {
0086   ALIColour* col = new ALIColour(1., 0., 0.5, 0.);
0087   std::vector<ALIdouble> spar;
0088   spar.push_back(1.);
0089   spar.push_back(3.);
0090   CLHEP::HepRotation rm;
0091   rm.rotateX(90. * deg);
0092   IgCocoaFileMgr::getInstance().addSolid(*this, "CYLINDER", spar, col, CLHEP::Hep3Vector(), rm);
0093 }
0094 #endif
0095 
0096 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0097 void OptODistancemeter::constructSolidShape() {
0098   ALIdouble go;
0099   GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0100   gomgr->getGlobalOptionValue("VisScale", go);
0101 
0102   theSolidShape = new CocoaSolidShapeTubs(
0103       "Tubs", go * 0. * cm / m, go * 2. * cm / m, go * 5. * cm / m);  //COCOA internal units are meters

0104 }