13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
28 using namespace CLHEP;
35 std::cout <<
"***** OptOCOPS::defaultBehaviour" << std::endl;
36 makeMeasurement(lightray, meas);
44 std::cout <<
"***** OptOCOPS::makeMeasurement(lightray, meas) " << std::endl;
46 CLHEP::Hep3Vector dowel2 = centreGlob();
48 ALIdouble posx12 = findExtraEntryValue(
"dowel1X");
52 CLHEP::Hep3Vector dowel1(posx12, findExtraEntryValue(
"dowel1Y"), 0.);
53 CLHEP::HepRotation rmt = rmGlob();
54 dowel1 = rmt * dowel1;
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");
76 CCDlength = 2048 * 14 * 1.E-6;
82 std::cout << std::endl <<
"***** UP CCD *****" << std::endl <<
"******************" << std::endl << std::endl;
85 ALIbool eexists = findExtraEntryValueIfExists(
"upCCDYtoDowel2",
posY);
87 posY = CCDlength + 0.004;
89 CLHEP::Hep3Vector posxy(
posX,
posY, 0);
91 std::cout <<
" %%%% CCD distances to Dowel2: " << std::endl;
93 std::cout <<
" up ccd in local RF " << posxy << std::endl;
96 std::cout <<
" up ccd in global RF " << posxy << std::endl;
99 ALILine upCCD(dowel2 + posxy, line_dowel21);
100 ccds[0] =
ALILine(posxy, line_dowel21);
103 std::cout << std::endl <<
"***** DOWN CCD *****" << std::endl <<
"********************" << std::endl << std::endl;
104 posX = findExtraEntryValue(
"downCCDXtoDowel2");
105 eexists = findExtraEntryValueIfExists(
"downCCDYtoDowel2",
posY);
108 posxy = CLHEP::Hep3Vector(
posX,
posY, 0);
110 std::cout <<
" down ccd in local RF " << posxy << std::endl;
113 std::cout <<
" down ccd in global RF " << posxy << std::endl;
117 ALILine downCCD(dowel2 + posxy, line_dowel21);
118 ccds[1] =
ALILine(posxy, line_dowel21);
123 std::cout << std::endl <<
"***** LEFT CCD *****" << std::endl <<
"********************" << std::endl << std::endl;
124 eexists = findExtraEntryValueIfExists(
"leftCCDXtoDowel2",
posX);
127 posX = -CCDlength - 0.002;
128 posY = findExtraEntryValue(
"leftCCDYtoDowel2");
129 posxy = CLHEP::Hep3Vector(
posX,
posY, 0);
131 std::cout <<
" left ccd in local RF " << posxy << std::endl;
134 std::cout <<
" left ccd in global RF " << posxy << std::endl;
138 ALILine leftCCD(dowel2 + posxy, -line_dowel21_perp);
139 ccds[2] =
ALILine(posxy, -line_dowel21_perp);
143 std::cout << std::endl <<
"***** RIGHT CCD *****" << std::endl <<
"*********************" << std::endl << std::endl;
144 eexists = findExtraEntryValueIfExists(
"rightCCDXtoDowel2",
posX);
148 posY = findExtraEntryValue(
"rightCCDYtoDowel2");
149 posxy = CLHEP::Hep3Vector(
posX,
posY, 0);
151 std::cout <<
" right ccd in local RF " << posxy << std::endl;
154 std::cout <<
" right ccd in global RF " << posxy << std::endl << std::endl;
158 ALILine rightCCD(dowel2 + posxy, -line_dowel21_perp);
159 ccds[3] =
ALILine(posxy, -line_dowel21_perp);
162 std::cout <<
" %%% Positions of CCDs in global RF: " << std::endl << std::endl;
163 std::cout <<
" upCCD: " << upCCD << std::endl;
164 std::cout <<
" downCCD: " << downCCD << std::endl;
165 std::cout <<
" leftCCD: " << leftCCD << std::endl;
166 std::cout <<
" rightCCD: " << rightCCD << std::endl << std::endl;
171 std::cout <<
" %%% Intersecting x-hair laser with COPS: " << std::endl;
172 ALIPlane copsPlane(centreGlob(), ZAxis);
174 CLHEP::Hep3Vector inters = lightray.
point();
181 std::cout <<
"1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
186 std::cout <<
"2. Get the Y of the laser and project it on the COPS" << std::endl;
187 CLHEP::Hep3Vector YAxis_xhair(0., 1., 0.);
188 const CLHEP::HepRotation& rmtx = xhairOptO->
rmGlob();
189 YAxis_xhair = rmtx * YAxis_xhair;
192 std::cout <<
" %%%% Projecting x-hair laser on COPS: " << std::endl;
194 std::cout <<
" Y line of laser projected on COPS " << Yline_xhair << std::endl;
198 std::cout <<
" 3. Get the X of the laser (correct it if cross is not 90o) and project it on the COPS" << std::endl;
204 CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
207 ZAxis = CLHEP::Hep3Vector(0., 0., 1.);
208 ZAxis = rmtx * ZAxis;
209 XAxis_xhair.rotate(anglebx, ZAxis);
212 std::cout <<
"angleBetweenAxis = " << anglebx << std::endl;
214 std::cout <<
" X line of laser projected on COPS " << Xline_xhair << std::endl;
219 std::cout <<
" Getting measurements as intersection with four CCDs: " << std::endl;
222 std::cout <<
"intersecting with upCCD " << std::endl;
228 std::cout <<
"$@S@ measv[0][0] upccd " << std::endl;
229 measv[0][0] = getMeasFromInters(Yline_xhair, upCCD, line_dowel21);
231 std::cout <<
"$@$@ measv[0][1] upccd " << std::endl;
232 measv[0][1] = getMeasFromInters(Xline_xhair, upCCD, line_dowel21);
236 std::cout <<
"intersecting with downCCD " << std::endl;
237 measv[1][0] = getMeasFromInters(Yline_xhair, downCCD, line_dowel21);
238 measv[1][1] = getMeasFromInters(Xline_xhair, downCCD, line_dowel21);
243 std::cout <<
"intersecting with leftCCD " << std::endl;
244 measv[2][0] = getMeasFromInters(Xline_xhair, leftCCD, line_dowel21_perp);
245 measv[2][1] = getMeasFromInters(Yline_xhair, leftCCD, line_dowel21_perp);
247 std::cout <<
"intersecting with rightCCD " << std::endl;
248 measv[3][0] = getMeasFromInters(Xline_xhair, rightCCD, line_dowel21_perp);
249 measv[3][1] = getMeasFromInters(Yline_xhair, rightCCD, line_dowel21_perp);
282 ALIstring measNames[4] = {
"up",
"down",
"left",
"right"};
286 <<
"--> Now comparing measurement in ccds by x and y laser lines (will always choose the smaller one) "
290 for (
ii = 0;
ii < 4;
ii++) {
309 std::cout <<
" --> Swapping for " << measv[
ii][1] <<
"(inf)" << std::endl;
326 std::cout <<
"***** OptOCOPS::makeMeasurement - identify pathological cases U and D intersected by same line"
329 for (
ii = 0;
ii < 4;
ii++) {
333 if (xlaserDir[0] ^ xlaserDir[1]) {
334 std::cerr <<
"!!EXITING up and down CCDs intersected by different x-laser line " << xlaserDir[0] <<
" "
335 << xlaserDir[1] << std::endl;
338 if (xlaserDir[2] ^ xlaserDir[3]) {
339 std::cerr <<
"!!EXITING right and left CCDs intersected by different x-laser line " << xlaserDir[0] <<
" "
340 << xlaserDir[1] << std::endl;
345 std::cout <<
"***** OptOCOPS::makeMeasurement - now output sim values" << std::endl;
349 std::cout <<
"REAL value: " << chrg <<
"U: " << 1000 * meas.
value()[0] << chrg <<
" D: " << 1000 * meas.
value()[1]
350 <<
" L: " << 1000 * meas.
value()[2] <<
" R: " << 1000 * meas.
value()[3] <<
" (mm) " << (
this)->
name()
367 << detU << chrg <<
" D: " << detD << chrg <<
" L: " << detL << chrg <<
" R: " << detR <<
" (mm) "
368 << (
this)->
name() << std::endl;
377 std::cout <<
"***** OptOCOPS::fastTraversesLightRay" << std::endl;
379 std::cout <<
"LR: FAST TRAVERSES COPS " <<
name() << std::endl;
382 CLHEP::Hep3Vector ZAxis(0., 0, 1.);
383 CLHEP::HepRotation rmt = rmGlob();
386 CLHEP::Hep3Vector inters = lightray.
point();
397 std::cout <<
"***** OptOCOPS::convertPointToLocalCoordinates" << std::endl;
401 CLHEP::HepRotation rmt = rmGlob();
402 CLHEP::Hep3Vector XAxism(1., 0., 0.);
410 interslc[0] = (
point - (
this)->centreGlob()) * XAxism;
413 CLHEP::Hep3Vector YAxism(0., 1., 0.);
416 interslc[1] = (
point - (
this)->centreGlob()) * YAxism;
419 std::cout <<
" intersection in local coordinates: X= " << interslc[0] <<
" Y= " << interslc[1] << std::endl;
427 std::cout <<
"***** OptOCOPS::getMeasFromInters" << std::endl;
428 CLHEP::Hep3Vector inters = line_xhair.
intersect(ccd,
false) - ccd.
pt();
436 return sign * inters.mag();
442 ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
446 ALIdouble CCDlength = findExtraEntryValue(
"CCDlength");
448 CCDlength = 2048 * 14 * 1.E-6;
457 std::cout <<
" ccds0 " << ccds[0] <<
"ccds1 " << ccds[1] << std::endl;
458 ALIColour colup(1., 0., 0., 0.);
459 ALIColour coldown(0., 1., 0., 0.);
460 ALIColour colleft(0., 0., 1., 0.);
461 ALIColour colright(0., 1., 1., 0.);
471 vrmlmgr.AddBoxDisplaced(
472 *
this, CCDdim, CCDwidth, CCDwidth, ccdsize * (ccds[0].
pt() + 0.5 * CCDlength * ccds[0].vec()), &colup);
474 vrmlmgr.AddBoxDisplaced(
475 *
this, CCDdim, CCDwidth, CCDwidth, ccdsize * (ccds[1].
pt() + 0.5 * CCDlength * ccds[1].vec()), &coldown);
477 vrmlmgr.AddBoxDisplaced(
478 *
this, CCDwidth, CCDdim, CCDwidth, ccdsize * (ccds[2].
pt() + 0.5 * CCDlength * ccds[2].vec()), &colleft);
480 vrmlmgr.AddBoxDisplaced(
481 *
this, CCDwidth, CCDdim, CCDwidth, ccdsize * (ccds[3].
pt() + 0.5 * CCDlength * ccds[3].vec()), &colright);
483 vrmlmgr.SendReferenceFrame(*
this, CCDdim);
484 vrmlmgr.SendName(*
this, 0.01);
492 ALIbool pexists = findExtraEntryValueIfExists(
"CCDlength", CCDlength);
494 CCDlength = 2048 * 14 * 1.E-6;
499 std::cout <<
" ccds0 " << ccds[0] <<
"ccds1 " << ccds[1] << std::endl;
500 ALIColour colup(0.2, 1., 0., 0.);
501 ALIColour coldown(0.3, 1., 0., 0.);
502 ALIColour colleft(0.4, 1., 0., 0.);
503 ALIColour colright(0.5, 1., 0., 0.);
512 std::vector<ALIdouble> spar;
513 spar.push_back(CCDdim);
514 spar.push_back(CCDwidth);
515 spar.push_back(CCDwidth);
517 IgCocoaFileMgr::getInstance().addSolid(
518 *
this,
"BOX", spar, &colup, ccdsize * (ccds[0].
pt() + 0.5 * CCDlength * ccds[0].vec()));
520 IgCocoaFileMgr::getInstance().addSolid(
521 *
this,
"BOX", spar, &coldown, ccdsize * (ccds[1].
pt() + 0.5 * CCDlength * ccds[1].vec()));
523 std::vector<ALIdouble> spar2;
524 spar2.push_back(CCDwidth);
525 spar2.push_back(CCDdim);
526 spar2.push_back(CCDwidth);
527 IgCocoaFileMgr::getInstance().addSolid(
528 *
this,
"BOX", spar2, &colleft, ccdsize * (ccds[2].
pt() + 0.5 * CCDlength * ccds[2].vec()));
530 IgCocoaFileMgr::getInstance().addSolid(
531 *
this,
"BOX", spar2, &colright, ccdsize * (ccds[3].
pt() + 0.5 * CCDlength * ccds[3].vec()));
542 "Box", go * 5. * cm /
m, go * 5. * cm /
m, go * 1. * cm /
m);