CMS 3D CMS Logo

OptOTiltmeter.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 //Id: OptOTiltmeter.cc
3 //CAT: Model
4 //
5 // History: v1.0
6 // Pedro Arce
7 
10 #include <iostream>
11 #include <iomanip>
12 #ifdef COCOA_VIS
13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
15 #endif
18 
19 using namespace CLHEP;
20 
21 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
22 //@@ Default behaviour: make measurement
23 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
24 void OptOTiltmeter::defaultBehaviour(LightRay& lightray, Measurement& meas) { makeMeasurement(lightray, meas); }
25 
26 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
27 //@@ Make measurement as angle with the horizontal plane = angle between local Z axis and its projection on the global XZ plane
28 //-Make measurement as rotations around X axis: difference between current Z axis and Z axis (0,0,1)
29 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
31  //---------- Get local Z axix
32  CLHEP::HepRotation rmt = rmGlob();
33  CLHEP::Hep3Vector ZAxisl(0., 0., 1.);
34  ZAxisl *= rmt;
35 
36  //--------- Get projection in a global XZ plane
37  /*-plane parallel to global Y (gravity) and to tiltmeter Z
38  CLHEP::Hep3Vector plane_point(0.,0.,0.);
39  CLHEP::Hep3Vector plane_normal = ZAxisl.cross( CLHEP::Hep3Vector(0.,1.,0.) );
40  CLHEP::Hep3Vector ZAxis_proj = (ALIPlane( plane_point, plane_normal)).project( ZAxisl );
41  */
42  CLHEP::Hep3Vector XAxisg(1., 0., 0.);
43  CLHEP::Hep3Vector ZAxisg(0., 0., 1.);
44  CLHEP::Hep3Vector ZAxis_proj = (ZAxisl * XAxisg) * XAxisg + (ZAxisl * ZAxisg) * ZAxisg;
45  ZAxis_proj *= (1. / ZAxis_proj.mag());
46 
47  //--------- Get measurement
48  ALIdouble measvalue = acos(ZAxisl * ZAxis_proj / ZAxisl.mag() / ZAxis_proj.mag());
49  //----- get sign of angle as sign of y component of ZAxis
50  if (ZAxisl.y() != 0)
51  measvalue *= (ZAxisl.y() / fabs(ZAxisl.y()));
52  meas.setValueSimulated(0, measvalue);
53 
54  if (ALIUtils::debug >= 3) {
55  ALIUtils::dump3v(ZAxisl, " OptOTiltmeter: Local Z axis ");
56  ALIUtils::dumprm(rmt, " tiltmeter rotation matrix");
57  ALIUtils::dump3v(ZAxis_proj, " Projection of Local Z axis on global XZ plane ");
58  std::cout << "SIMU value: TA: " << std::setprecision(8) << 1000 * meas.valueSimulated(0) << " (mrad) "
59  << (this)->name() << std::endl;
60  std::cout << "REAL value: TA: " << std::setprecision(8) << 1000 * meas.value()[0] << " (mrad) " << (this)->name()
61  << std::endl;
62  }
63 
64  /*- //---------- Get simulated value:
65  CLHEP::HepRotation rmtori = rmGlobOriginal();
66  CLHEP::Hep3Vector ZAxism(0.,0.,1.);
67  CLHEP::Hep3Vector ZAxism_ori = ZAxism;
68  ZAxism_ori *= rmtori;
69 
70  //---------- Measure rotation with respect to original position, around the X axis defined by the original position, in the original YZ plane
71  CLHEP::Hep3Vector ZAxism_rot = ZAxism;
72  CLHEP::HepRotation rmt = rmGlob();
73  ZAxism_rot *= rmt;
74  //----- Project on original YZ plane
75  CLHEP::Hep3Vector YAxism_ori(0.,1.,0.);
76  YAxism_ori *= rmtori;
77  //--- create original YZ plane
78  CLHEP::Hep3Vector YZplanePoint = centreGlob();
79  CLHEP::Hep3Vector YZplaneNormal = YAxism_ori.cross( ZAxism_ori );
80  ALIPlane yzorig( YZplanePoint, YZplaneNormal );
81  CLHEP::Hep3Vector ZAxism_proj = yzorig.project( ZAxism_rot);
82  //- ALIUtils::dump3v( YAxism_ori, "YAxism_ori");
83  //- ALIUtils::dump3v( ZAxism_ori, "ZAxism_ori");
84  //- ALIUtils::dump3v( ZAxism_rot, "ZAxism_rot");
85  //- ALIUtils::dump3v( ZAxism_proj, "ZAxism_proj");
86  ALIdouble measValue = acos( ZAxism.dot(ZAxism_proj)/ZAxism_proj.mag() );
87  if( ZAxism_proj.x() < 0) measValue *= -1.;
88  meas.setValueSimulated(0 , measValue );
89 
90  if (ALIUtils::debug >= 3) {
91  std::cout << " OptOTiltmeter: Original Z axis " << ZAxism_ori << std::endl;
92  ALIUtils::dumprm(rmt," tiltmeter original rotation matrix");
93  std::cout << " OptOTiltmeter: current Z axis " << ZAxism_rot << std::endl;
94  ALIUtils::dumprm(rmt," tiltmeter current rotation matrix");
95  std::cout << "SIMU value; TA: " << std::setprecision(8) << meas.valueSimulated(0)
96  << " (rad) " << (this)->name() << std::endl;
97  std::cout << "REAL value: TA: " << std::setprecision(8) << meas.value()[0]
98  << " (rad) " << (this)->name() << std::endl;
99 
100  }
101  */
102 }
103 
104 #ifdef COCOA_VIS
105 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
107  //- std::cout << " filling optosensor " << std::endl;
108  ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
109  ALIColour* col = new ALIColour(1., 1., 0., 0.);
110  vrmlmgr.AddBox(*this, .2, .2, 1., col);
111  vrmlmgr.SendReferenceFrame(*this, 0.6);
112  vrmlmgr.SendName(*this, 0.01);
113 }
114 
115 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
117  ALIColour* col = new ALIColour(1., 0., 0.9, 0.);
118  std::vector<ALIdouble> spar;
119  spar.push_back(1.);
120  spar.push_back(1.);
121  spar.push_back(4.);
122  IgCocoaFileMgr::getInstance().addSolid(*this, "BOX", spar, col);
123 }
124 #endif
125 
126 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
128  ALIdouble go;
130  gomgr->getGlobalOptionValue("VisScale", go);
131 
132  theSolidShape = new CocoaSolidShapeBox(
133  "Box", go * 2. * cm / m, go * 2. * cm / m, go * 5. * cm / m); //COCOA internal units are meters
134 }
GlobalOptionMgr
Definition: GlobalOptionMgr.h:18
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
cuy.col
col
Definition: cuy.py:1010
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GlobalOptionMgr.h
GlobalOptionMgr::getGlobalOptionValue
int getGlobalOptionValue(const ALIstring &sstr, ALIdouble &val)
--— Search a string in theGlobalOptions and return 1 if found
Definition: GlobalOptionMgr.cc:115
CocoaSolidShapeBox
Definition: CocoaSolidShapeBox.h:13
Measurement::setValueSimulated
void setValueSimulated(ALIint coor, ALIdouble value)
Definition: Measurement.h:146
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
Measurement
Definition: Measurement.h:27
OptOTiltmeter::defaultBehaviour
void defaultBehaviour(LightRay &lightray, Measurement &meas) override
Definition: OptOTiltmeter.cc:24
OpticalObject::fillIguana
virtual void fillIguana()
Definition: OpticalObject.h:55
CLHEP
Definition: CocoaGlobals.h:27
Measurement.h
OptOTiltmeter.h
ALIUtils::dumprm
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
Definition: ALIUtils.cc:71
LightRay
Definition: LightRay.h:20
OptOTiltmeter::makeMeasurement
void makeMeasurement(LightRay &lightray, Measurement &meas) override
Definition: OptOTiltmeter.cc:30
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
Measurement::valueSimulated
const ALIdouble valueSimulated(ALIuint ii) const
Definition: Measurement.h:105
ALIUtils::dump3v
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:58
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
OptOTiltmeter::constructSolidShape
void constructSolidShape() override
Definition: OptOTiltmeter.cc:127
OpticalObject::fillVRML
virtual void fillVRML()
Definition: OpticalObject.h:54
Measurement::value
const ALIdouble * value() const
Definition: Measurement.h:109
CocoaSolidShapeBox.h