13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
27 using namespace CLHEP;
35 makeMeasurement( lightray, meas);
47 CLHEP::Hep3Vector dowel2 = centreGlob();
49 ALIdouble posx12 = findExtraEntryValue(
"dowel1X");
51 if(posx12 == 0. ) posx12 = -0.045;
52 CLHEP::Hep3Vector dowel1(posx12,findExtraEntryValue(
"dowel1Y"), 0.);
53 CLHEP::HepRotation rmt = rmGlob();
63 CLHEP::Hep3Vector line_dowel21 = (dowel1-dowel2 );
64 CLHEP::Hep3Vector ZAxis(0.,0,1.);
66 CLHEP::Hep3Vector line_dowel21_perp = ZAxis.cross( line_dowel21 );
74 ALIdouble CCDlength = findExtraEntryValue(
"CCDlength");
75 if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6;
84 <<
"******************" << std::endl << std::endl;
85 ALIdouble posX = findExtraEntryValue(
"upCCDXtoDowel2");
87 ALIbool eexists = findExtraEntryValueIfExists(
"upCCDYtoDowel2", posY);
88 if(!eexists) posY = CCDlength + 0.004;
90 CLHEP::Hep3Vector posxy( posX, posY, 0);
97 ALILine upCCD( dowel2 + posxy, line_dowel21 );
98 ccds[0] =
ALILine( posxy, line_dowel21 );
101 <<
"********************" << std::endl << std::endl ;
102 posX = findExtraEntryValue(
"downCCDXtoDowel2");
103 eexists = findExtraEntryValueIfExists(
"downCCDYtoDowel2", posY);
104 if(!eexists) posY = 0.002;
105 posxy = CLHEP::Hep3Vector( posX, posY, 0);
112 ALILine downCCD( dowel2 + posxy, line_dowel21 );
113 ccds[1] =
ALILine( posxy, line_dowel21 );
118 <<
"********************" << std::endl << std::endl;
119 eexists = findExtraEntryValueIfExists(
"leftCCDXtoDowel2", posX);
121 if(!eexists) posX = -CCDlength - 0.002;
122 posY = findExtraEntryValue(
"leftCCDYtoDowel2");
123 posxy = CLHEP::Hep3Vector( posX, posY, 0);
130 ALILine leftCCD( dowel2 + posxy, -line_dowel21_perp );
131 ccds[2] =
ALILine( posxy, -line_dowel21_perp );
135 <<
"*********************" << std::endl<< std::endl ;
136 eexists = findExtraEntryValueIfExists(
"rightCCDXtoDowel2", posX);
138 if(!eexists) posX = - 0.004;
139 posY = findExtraEntryValue(
"rightCCDYtoDowel2");
140 posxy = CLHEP::Hep3Vector( posX, posY, 0);
147 ALILine rightCCD( dowel2 + posxy, -line_dowel21_perp );
148 ccds[3] =
ALILine( posxy, -line_dowel21_perp );
151 std::cout <<
" %%% Positions of CCDs in global RF: " << std::endl<< std::endl;
152 std::cout <<
" upCCD: " << upCCD << std::endl;
153 std::cout <<
" downCCD: " << downCCD << std::endl;
154 std::cout <<
" leftCCD: " << leftCCD << std::endl;
155 std::cout <<
" rightCCD: " << rightCCD << std::endl << std::endl;
160 ALIPlane copsPlane(centreGlob(), ZAxis);
162 CLHEP::Hep3Vector inters = lightray.
point();
168 if (
ALIUtils::debug >= 5)
std::cout <<
"1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
173 CLHEP::Hep3Vector YAxis_xhair(0.,1.,0.);
174 CLHEP::HepRotation rmtx = xhairOptO->
rmGlob();
175 YAxis_xhair = rmtx * YAxis_xhair;
178 std::cout <<
" %%%% Projecting x-hair laser on COPS: " << std::endl;
180 std::cout <<
" Y line of laser projected on COPS " << Yline_xhair << std::endl;
183 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;
187 if(!eexists) anglebx =
PI/2.;
188 CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
191 ZAxis = CLHEP::Hep3Vector(0.,0.,1.);
192 ZAxis = rmtx * ZAxis;
193 XAxis_xhair.rotate(anglebx, ZAxis );
196 std::cout <<
"angleBetweenAxis = " << anglebx << std::endl;
198 std::cout <<
" X line of laser projected on COPS " << Xline_xhair << std::endl;
211 measv[0][0] = getMeasFromInters( Yline_xhair, upCCD, line_dowel21 );
213 measv[0][1] = getMeasFromInters( Xline_xhair, upCCD, line_dowel21 );
217 measv[1][0] = getMeasFromInters(Yline_xhair, downCCD, line_dowel21 );
218 measv[1][1] = getMeasFromInters(Xline_xhair, downCCD, line_dowel21 );
223 measv[2][0] = getMeasFromInters(Xline_xhair, leftCCD, line_dowel21_perp );
224 measv[2][1] = getMeasFromInters(Yline_xhair, leftCCD, line_dowel21_perp );
226 measv[3][0] = getMeasFromInters(Xline_xhair, rightCCD, line_dowel21_perp );
227 measv[3][1] = getMeasFromInters(Yline_xhair, rightCCD, line_dowel21_perp );
260 ALIstring measNames[4] ={
"up",
"down",
"left",
"right"};
262 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;
265 for( ii = 0; ii < 4; ii++ ) {
268 <<
" " << fabs( measv[ii][0] ) <<
" " << fabs( measv[ii][1] ) <<
" isnan() = " <<
285 laserLine = fabs( measv[ii][0] ) < fabs( measv[ii][1] );
298 if(
ALIUtils::debug >= 2)
std::cout <<
"***** OptOCOPS::makeMeasurement - identify pathological cases U and D intersected by same line" <<std::endl;
300 for( ii = 0; ii < 4; ii++ ) {
304 if( xlaserDir[0] ^ xlaserDir[1] ) {
305 std::cerr <<
"!!EXITING up and down CCDs intersected by different x-laser line " << xlaserDir[0] <<
" " << xlaserDir[1] << std::endl;
308 if( xlaserDir[2] ^ xlaserDir[3] ) {
309 std::cerr <<
"!!EXITING right and left CCDs intersected by different x-laser line " << xlaserDir[0] <<
" " << xlaserDir[1] << std::endl;
317 std::cout <<
"REAL value: " << chrg <<
"U: " << 1000*meas.
value()[0] << chrg
318 <<
" D: " << 1000*meas.
value()[1]
319 <<
" L: " << 1000*meas.
value()[2]
320 <<
" R: " << 1000*meas.
value()[3]
321 <<
" (mm) " << (
this)->
name() << std::endl;
326 std::cout <<
"SIMU value: " << chrg <<
"U: "
329 << chrg <<
" D: " << detD
330 << chrg <<
" L: " << detL
331 << chrg <<
" R: " << detR
332 <<
" (mm) " << (
this)->
name() << std::endl;
349 CLHEP::Hep3Vector ZAxis(0.,0,1.);
350 CLHEP::HepRotation rmt = rmGlob();
353 CLHEP::Hep3Vector inters = lightray.
point();
370 CLHEP::HepRotation rmt = rmGlob();
371 CLHEP::Hep3Vector XAxism(1.,0.,0.);
377 interslc[0] = (point - (
this)->centreGlob() ) * XAxism;
380 CLHEP::Hep3Vector YAxism(0.,1.,0.);
383 interslc[1] = (point - (
this)->centreGlob() ) * YAxism;
386 std::cout <<
" intersection in local coordinates: X= " << interslc[0] <<
" Y= " << interslc[1] << std::endl;
397 CLHEP::Hep3Vector inters = line_xhair.
intersect( ccd, 0 ) - ccd.
pt();
400 sign = fabs(sign)/sign;
405 return sign*inters.mag();
414 ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
418 ALIdouble CCDlength = findExtraEntryValue(
"CCDlength");
419 if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6;
428 ALIColour colup( 1.,0.,0., 0.);
429 ALIColour coldown( 0.,1.,0., 0.);
430 ALIColour colleft( 0.,0.,1., 0.);
431 ALIColour colright( 0.,1.,1., 0.);
441 vrmlmgr.AddBoxDisplaced( *
this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[0].pt()+0.5*CCDlength*ccds[0].vec()), &colup);
443 vrmlmgr.AddBoxDisplaced( *
this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[1].pt()+0.5*CCDlength*ccds[1].vec()), &coldown );
445 vrmlmgr.AddBoxDisplaced( *
this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[2].pt()+0.5*CCDlength*ccds[2].vec()), &colleft );
447 vrmlmgr.AddBoxDisplaced( *
this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[3].pt()+0.5*CCDlength*ccds[3].vec()), &colright );
449 vrmlmgr.SendReferenceFrame( *
this, CCDdim);
450 vrmlmgr.SendName( *
this, 0.01 );
461 ALIbool pexists = findExtraEntryValueIfExists(
"CCDlength",CCDlength);
462 if( !pexists ) CCDlength = 2048*14 * 1.E-6;
467 ALIColour colup( 0.2,1.,0., 0.);
468 ALIColour coldown( 0.3,1.,0., 0.);
469 ALIColour colleft( 0.4,1.,0., 0.);
470 ALIColour colright( 0.5,1.,0., 0.);
479 std::vector<ALIdouble> spar;
480 spar.push_back(CCDdim);
481 spar.push_back(CCDwidth);
482 spar.push_back(CCDwidth);
484 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar, &colup, ccdsize*(ccds[0].pt()+0.5*CCDlength*ccds[0].vec()));
486 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar, &coldown, ccdsize*(ccds[1].pt()+0.5*CCDlength*ccds[1].vec()) );
488 std::vector<ALIdouble> spar2;
489 spar2.push_back(CCDwidth);
490 spar2.push_back(CCDdim);
491 spar2.push_back(CCDwidth);
492 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar2, &colleft, ccdsize*(ccds[2].pt()+0.5*CCDlength*ccds[2].vec()));
494 IgCocoaFileMgr::getInstance().addSolid( *
this,
"BOX", spar2, &colright, ccdsize*(ccds[3].pt()+0.5*CCDlength*ccds[3].vec()));
virtual void defaultBehaviour(LightRay &lightray, Measurement &meas)
virtual void makeMeasurement(LightRay &lightray, Measurement &meas)
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
std::vector< OpticalObject * > & OptOList()
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
void setValueSimulated(ALIint coor, ALIdouble value)
CLHEP::Hep3Vector project(const CLHEP::Hep3Vector &vec)
virtual int xlaserLine(ALIuint ii)
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
void intersect(const ALIPlane &plane)
void constructSolidShape()
virtual void fillIguana()
const ALIdouble * value() const
CLHEP::Hep3Vector intersect(const ALILine &l2, bool notParallel=0)
void dumpData(const ALIstring &str) const
const ALIdouble valueSimulated(ALIuint ii) const
ALIdouble getMeasFromInters(ALILine &line_xhair, ALILine &ccd, CLHEP::Hep3Vector &cops_line)
*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
virtual void fastTraversesLightRay(LightRay &lightray)
const CLHEP::Hep3Vector & vec() const