13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h" 14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h" 28 using namespace CLHEP;
36 makeMeasurement( lightray, meas);
48 CLHEP::Hep3Vector dowel2 = centreGlob();
50 ALIdouble posx12 = findExtraEntryValue(
"dowel1X");
52 if(posx12 == 0. ) posx12 = -0.045;
53 CLHEP::Hep3Vector dowel1(posx12,findExtraEntryValue(
"dowel1Y"), 0.);
54 CLHEP::HepRotation rmt = rmGlob();
64 CLHEP::Hep3Vector line_dowel21 = (dowel1-dowel2 );
65 CLHEP::Hep3Vector ZAxis(0.,0,1.);
67 CLHEP::Hep3Vector line_dowel21_perp = ZAxis.cross( line_dowel21 );
75 ALIdouble CCDlength = findExtraEntryValue(
"CCDlength");
76 if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6;
85 <<
"******************" << std::endl << std::endl;
88 ALIbool eexists = findExtraEntryValueIfExists(
"upCCDYtoDowel2", posY);
89 if(!eexists) posY = CCDlength + 0.004;
91 CLHEP::Hep3Vector posxy( posX, posY, 0);
98 ALILine upCCD( dowel2 + posxy, line_dowel21 );
99 ccds[0] =
ALILine( posxy, line_dowel21 );
102 <<
"********************" << std::endl << std::endl ;
103 posX = findExtraEntryValue(
"downCCDXtoDowel2");
104 eexists = findExtraEntryValueIfExists(
"downCCDYtoDowel2", posY);
105 if(!eexists) posY = 0.002;
106 posxy = CLHEP::Hep3Vector( posX, posY, 0);
113 ALILine downCCD( dowel2 + posxy, line_dowel21 );
114 ccds[1] =
ALILine( posxy, line_dowel21 );
119 <<
"********************" << std::endl << std::endl;
120 eexists = findExtraEntryValueIfExists(
"leftCCDXtoDowel2", posX);
122 if(!eexists) posX = -CCDlength - 0.002;
123 posY = findExtraEntryValue(
"leftCCDYtoDowel2");
124 posxy = CLHEP::Hep3Vector( posX, posY, 0);
131 ALILine leftCCD( dowel2 + posxy, -line_dowel21_perp );
132 ccds[2] =
ALILine( posxy, -line_dowel21_perp );
136 <<
"*********************" << std::endl<< std::endl ;
137 eexists = findExtraEntryValueIfExists(
"rightCCDXtoDowel2", posX);
139 if(!eexists) posX = - 0.004;
140 posY = findExtraEntryValue(
"rightCCDYtoDowel2");
141 posxy = CLHEP::Hep3Vector( posX, posY, 0);
148 ALILine rightCCD( dowel2 + posxy, -line_dowel21_perp );
149 ccds[3] =
ALILine( posxy, -line_dowel21_perp );
152 std::cout <<
" %%% Positions of CCDs in global RF: " << std::endl<< std::endl;
153 std::cout <<
" upCCD: " << upCCD << std::endl;
154 std::cout <<
" downCCD: " << downCCD << std::endl;
155 std::cout <<
" leftCCD: " << leftCCD << std::endl;
156 std::cout <<
" rightCCD: " << rightCCD << std::endl << std::endl;
161 ALIPlane copsPlane(centreGlob(), ZAxis);
163 CLHEP::Hep3Vector inters = lightray.
point();
169 if (
ALIUtils::debug >= 5)
std::cout <<
"1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
174 CLHEP::Hep3Vector YAxis_xhair(0.,1.,0.);
175 const CLHEP::HepRotation& rmtx = xhairOptO->
rmGlob();
176 YAxis_xhair = rmtx * YAxis_xhair;
179 std::cout <<
" %%%% Projecting x-hair laser on COPS: " << std::endl;
181 std::cout <<
" Y line of laser projected on COPS " << Yline_xhair << std::endl;
184 if (
ALIUtils::debug >= 5)
std::cout <<
" 3. Get the X of the laser (correct it if cross is not 90o) and project it on the COPS" << std::endl;
188 if(!eexists) anglebx =
PI/2.;
189 CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
192 ZAxis = CLHEP::Hep3Vector(0.,0.,1.);
193 ZAxis = rmtx * ZAxis;
194 XAxis_xhair.rotate(anglebx, ZAxis );
197 std::cout <<
"angleBetweenAxis = " << anglebx << std::endl;
199 std::cout <<
" X line of laser projected on COPS " << Xline_xhair << std::endl;
212 measv[0][0] = getMeasFromInters( Yline_xhair, upCCD, line_dowel21 );
214 measv[0][1] = getMeasFromInters( Xline_xhair, upCCD, line_dowel21 );
218 measv[1][0] = getMeasFromInters(Yline_xhair, downCCD, line_dowel21 );
219 measv[1][1] = getMeasFromInters(Xline_xhair, downCCD, line_dowel21 );
224 measv[2][0] = getMeasFromInters(Xline_xhair, leftCCD, line_dowel21_perp );
225 measv[2][1] = getMeasFromInters(Yline_xhair, leftCCD, line_dowel21_perp );
227 measv[3][0] = getMeasFromInters(Xline_xhair, rightCCD, line_dowel21_perp );
228 measv[3][1] = getMeasFromInters(Yline_xhair, rightCCD, line_dowel21_perp );
261 ALIstring measNames[4] ={
"up",
"down",
"left",
"right"};
263 if (
ALIUtils::debug >= 2)
std::cout << std::endl <<
"--> Now comparing measurement in ccds by x and y laser lines (will always choose the smaller one) " <<std::endl;
266 for( ii = 0; ii < 4; ii++ ) {
269 <<
" " <<
std::abs( measv[ii][0] ) <<
" " <<
std::abs( measv[ii][1] ) <<
" edm::isNotFinite() = " <<
299 if(
ALIUtils::debug >= 2)
std::cout <<
"***** OptOCOPS::makeMeasurement - identify pathological cases U and D intersected by same line" <<std::endl;
301 for( ii = 0; ii < 4; ii++ ) {
305 if( xlaserDir[0] ^ xlaserDir[1] ) {
306 std::cerr <<
"!!EXITING up and down CCDs intersected by different x-laser line " << xlaserDir[0] <<
" " << xlaserDir[1] << std::endl;
309 if( xlaserDir[2] ^ xlaserDir[3] ) {
310 std::cerr <<
"!!EXITING right and left CCDs intersected by different x-laser line " << xlaserDir[0] <<
" " << xlaserDir[1] << std::endl;
318 std::cout <<
"REAL value: " << chrg <<
"U: " << 1000*meas.
value()[0] << chrg
319 <<
" D: " << 1000*meas.
value()[1]
320 <<
" L: " << 1000*meas.
value()[2]
321 <<
" R: " << 1000*meas.
value()[3]
322 <<
" (mm) " << (
this)->
name() << std::endl;
327 std::cout <<
"SIMU value: " << chrg <<
"U: " 330 << chrg <<
" D: " << detD
331 << chrg <<
" L: " << detL
332 << chrg <<
" R: " << detR
333 <<
" (mm) " << (
this)->
name() << std::endl;
350 CLHEP::Hep3Vector ZAxis(0.,0,1.);
351 CLHEP::HepRotation rmt = rmGlob();
354 CLHEP::Hep3Vector inters = lightray.
point();
371 CLHEP::HepRotation rmt = rmGlob();
372 CLHEP::Hep3Vector XAxism(1.,0.,0.);
378 interslc[0] = (point - (
this)->centreGlob() ) * XAxism;
381 CLHEP::Hep3Vector YAxism(0.,1.,0.);
384 interslc[1] = (point - (
this)->centreGlob() ) * YAxism;
387 std::cout <<
" intersection in local coordinates: X= " << interslc[0] <<
" Y= " << interslc[1] << std::endl;
398 CLHEP::Hep3Vector inters = line_xhair.
intersect( ccd,
false ) - ccd.
pt();
406 return sign*inters.mag();
415 ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
419 ALIdouble CCDlength = findExtraEntryValue(
"CCDlength");
420 if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6;
429 ALIColour colup( 1.,0.,0., 0.);
430 ALIColour coldown( 0.,1.,0., 0.);
431 ALIColour colleft( 0.,0.,1., 0.);
432 ALIColour colright( 0.,1.,1., 0.);
442 vrmlmgr.AddBoxDisplaced( *
this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[0].
pt()+0.5*CCDlength*ccds[0].vec()), &colup);
444 vrmlmgr.AddBoxDisplaced( *
this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[1].
pt()+0.5*CCDlength*ccds[1].vec()), &coldown );
446 vrmlmgr.AddBoxDisplaced( *
this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[2].
pt()+0.5*CCDlength*ccds[2].vec()), &colleft );
448 vrmlmgr.AddBoxDisplaced( *
this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[3].
pt()+0.5*CCDlength*ccds[3].vec()), &colright );
450 vrmlmgr.SendReferenceFrame( *
this, CCDdim);
451 vrmlmgr.SendName( *
this, 0.01 );
462 ALIbool pexists = findExtraEntryValueIfExists(
"CCDlength",CCDlength);
463 if( !pexists ) CCDlength = 2048*14 * 1.E-6;
468 ALIColour colup( 0.2,1.,0., 0.);
469 ALIColour coldown( 0.3,1.,0., 0.);
470 ALIColour colleft( 0.4,1.,0., 0.);
471 ALIColour colright( 0.5,1.,0., 0.);
480 std::vector<ALIdouble> spar;
481 spar.push_back(CCDdim);
482 spar.push_back(CCDwidth);
483 spar.push_back(CCDwidth);
485 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar, &colup, ccdsize*(ccds[0].
pt()+0.5*CCDlength*ccds[0].vec()));
487 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar, &coldown, ccdsize*(ccds[1].
pt()+0.5*CCDlength*ccds[1].vec()) );
489 std::vector<ALIdouble> spar2;
490 spar2.push_back(CCDwidth);
491 spar2.push_back(CCDdim);
492 spar2.push_back(CCDwidth);
493 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar2, &colleft, ccdsize*(ccds[2].
pt()+0.5*CCDlength*ccds[2].vec()));
495 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar2, &colright, ccdsize*(ccds[3].
pt()+0.5*CCDlength*ccds[3].vec()));
void defaultBehaviour(LightRay &lightray, Measurement &meas) override
void makeMeasurement(LightRay &lightray, Measurement &meas) override
CLHEP::Hep3Vector intersect(const ALILine &l2, bool notParallel=false)
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
const ALIbool findExtraEntryValueIfExists(const ALIstring &eename, ALIdouble &value) const
static GlobalOptionMgr * getInstance()
const CLHEP::HepRotation & rmGlob() const
int getGlobalOptionValue(const ALIstring &sstr, ALIdouble &val)
--— Search a string in theGlobalOptions and return 1 if found
void setPoint(const CLHEP::Hep3Vector &point)
ALIdouble * convertPointToLocalCoordinates(const CLHEP::Hep3Vector &point)
virtual void setXlaserLine(ALIuint ii, int val)
const CLHEP::Hep3Vector & point() const
const CLHEP::Hep3Vector & pt() const
Abs< T >::type abs(const T &t)
void setValueSimulated(ALIint coor, ALIdouble value)
CLHEP::Hep3Vector project(const CLHEP::Hep3Vector &vec)
virtual int xlaserLine(ALIuint ii)
void constructSolidShape() override
const std::vector< OpticalObject * > & OptOList() const
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
void intersect(const ALIPlane &plane)
virtual void fillIguana()
const ALIdouble * value() const
void dumpData(const ALIstring &str) const
const ALIdouble valueSimulated(ALIuint ii) const
ALIdouble getMeasFromInters(ALILine &line_xhair, ALILine &ccd, CLHEP::Hep3Vector &cops_line)
void fastTraversesLightRay(LightRay &lightray) override
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
const CLHEP::Hep3Vector & vec() const