CMS 3D CMS Logo

OptOCOPS.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 //Id: OptOCops.cc
3 //CAT: Model
4 //
5 // History: v1.0
6 // Pedro Arce
7 
12 #ifdef COCOA_VIS
13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
15 #endif
21 
22 #include <iostream>
23 #include <iomanip>
24 #include <fstream>
25 #include <cmath> // among others include also floating-point std::abs functions
26 #include <cstdlib>
27 
28 using namespace CLHEP;
29 
30 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
31 //@@ Make measurement as distance to previous object 'screen'
32 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
34  if (ALIUtils::debug >= 5)
35  std::cout << "***** OptOCOPS::defaultBehaviour" << std::endl;
36  makeMeasurement(lightray, meas);
37 }
38 
39 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
40 //@@ Make measurement as distance to previous object 'screen'
41 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
43  if (ALIUtils::debug >= 4)
44  std::cout << "***** OptOCOPS::makeMeasurement(lightray, meas) " << std::endl;
45  //---------- Centre of COPS is at dowel point 2
46  CLHEP::Hep3Vector dowel2 = centreGlob();
47  //---------- Coordinates of dowel point 1 are given with respect to dowel point 2 (in local reference frame)
48  ALIdouble posx12 = findExtraEntryValue("dowel1X");
49  // Changed default value to .045 from .03
50  if (posx12 == 0.)
51  posx12 = -0.045; //samir changed sign to correct the dowel 1st pixel
52  CLHEP::Hep3Vector dowel1(posx12, findExtraEntryValue("dowel1Y"), 0.);
53  CLHEP::HepRotation rmt = rmGlob();
54  dowel1 = rmt * dowel1;
55  dowel1 += dowel2;
56  if (ALIUtils::debug >= 3) {
57  ALIUtils::dump3v(dowel2, " dowel2");
58  ALIUtils::dump3v(dowel1, " dowel1");
59  }
60 
61  //---------- Get line joining dowel1-dowel2 and perpendicular to it inside cops
62  // CLHEP::Hep3Vector line_dowel21 = - (dowel1-dowel2 ); //////
63  CLHEP::Hep3Vector line_dowel21 = (dowel1 - dowel2); // samir changed sign to correct the dowel 1st pixel
64  CLHEP::Hep3Vector ZAxis(0., 0, 1.);
65  ZAxis = rmt * ZAxis;
66  CLHEP::Hep3Vector line_dowel21_perp = ZAxis.cross(line_dowel21);
67  if (ALIUtils::debug >= 3) {
68  ALIUtils::dump3v(line_dowel21, " line_dowel21");
69  ALIUtils::dump3v(line_dowel21_perp, " line_dowel21_perp");
70  }
71 
72  //---------- Position four CCDs (locally, i.e. with respect to centre)
73  //----- Get first CCD length, that will be used to give a default placement to the CCDs
74  ALIdouble CCDlength = findExtraEntryValue("CCDlength");
75  if (CCDlength == 0.)
76  CCDlength = 2048 * 14 * 1.E-6; // (in meters, the default unit)
77 
78  // global / local output of ccd location in RF was reversed, I am swapping
79 
80  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
81  if (ALIUtils::debug >= 3)
82  std::cout << std::endl << "***** UP CCD *****" << std::endl << "******************" << std::endl << std::endl;
83  ALIdouble posX = findExtraEntryValue("upCCDXtoDowel2");
85  ALIbool eexists = findExtraEntryValueIfExists("upCCDYtoDowel2", posY);
86  if (!eexists)
87  posY = CCDlength + 0.004;
88  //if(!eexists) posY = 0.004;
89  CLHEP::Hep3Vector posxy(posX, posY, 0);
90  if (ALIUtils::debug >= 3)
91  std::cout << " %%%% CCD distances to Dowel2: " << std::endl;
92  if (ALIUtils::debug >= 3)
93  std::cout << " up ccd in local RF " << posxy << std::endl;
94  posxy = rmt * posxy;
95  if (ALIUtils::debug >= 3)
96  std::cout << " up ccd in global RF " << posxy << std::endl;
97  // ALILine upCCD( dowel2 + posxy, -line_dowel21 );
98  // ccds[0] = ALILine( posxy, -line_dowel21 );
99  ALILine upCCD(dowel2 + posxy, line_dowel21); // Samir changed sign to correct the dowel 1st pixel
100  ccds[0] = ALILine(posxy, line_dowel21); // samir changed sign to correct the dowel 1st pixel
101  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
102  if (ALIUtils::debug >= 3)
103  std::cout << std::endl << "***** DOWN CCD *****" << std::endl << "********************" << std::endl << std::endl;
104  posX = findExtraEntryValue("downCCDXtoDowel2");
105  eexists = findExtraEntryValueIfExists("downCCDYtoDowel2", posY);
106  if (!eexists)
107  posY = 0.002;
108  posxy = CLHEP::Hep3Vector(posX, posY, 0);
109  if (ALIUtils::debug >= 3)
110  std::cout << " down ccd in local RF " << posxy << std::endl;
111  posxy = rmt * posxy;
112  if (ALIUtils::debug >= 3)
113  std::cout << " down ccd in global RF " << posxy << std::endl;
114  // ALILine downCCD( dowel2 + posxy, -line_dowel21 );
115  // ccds[1] = ALILine( posxy, -line_dowel21 );
116 
117  ALILine downCCD(dowel2 + posxy, line_dowel21); //samir changed signto correct the dowel 1st pixel
118  ccds[1] = ALILine(posxy, line_dowel21); // samir changed sign to correct the dowel 1st pixel
119 
120  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
121 
122  if (ALIUtils::debug >= 3)
123  std::cout << std::endl << "***** LEFT CCD *****" << std::endl << "********************" << std::endl << std::endl;
124  eexists = findExtraEntryValueIfExists("leftCCDXtoDowel2", posX);
125  // if(!eexists) posX = -0.002;
126  if (!eexists)
127  posX = -CCDlength - 0.002; // Samir changed sign to correct the dowel 1st pixel
128  posY = findExtraEntryValue("leftCCDYtoDowel2");
129  posxy = CLHEP::Hep3Vector(posX, posY, 0);
130  if (ALIUtils::debug >= 3)
131  std::cout << " left ccd in local RF " << posxy << std::endl;
132  posxy = rmt * posxy;
133  if (ALIUtils::debug >= 3)
134  std::cout << " left ccd in global RF " << posxy << std::endl;
135  // ALILine leftCCD( dowel2 + posxy, line_dowel21_perp );
136  // ccds[2] = ALILine( posxy, line_dowel21_perp );
137 
138  ALILine leftCCD(dowel2 + posxy, -line_dowel21_perp); //samir changed sign to correct the dowel 1st pixel
139  ccds[2] = ALILine(posxy, -line_dowel21_perp); //samir changed sign to correct the dowel 1st pixel
140 
141  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
142  if (ALIUtils::debug >= 3)
143  std::cout << std::endl << "***** RIGHT CCD *****" << std::endl << "*********************" << std::endl << std::endl;
144  eexists = findExtraEntryValueIfExists("rightCCDXtoDowel2", posX);
145  // if(!eexists) posX = -CCDlength - 0.004;
146  if (!eexists)
147  posX = -0.004; // samir tried to change in order to adjust the position of 1 st pixel.
148  posY = findExtraEntryValue("rightCCDYtoDowel2");
149  posxy = CLHEP::Hep3Vector(posX, posY, 0);
150  if (ALIUtils::debug >= 3)
151  std::cout << " right ccd in local RF " << posxy << std::endl;
152  posxy = rmt * posxy;
153  if (ALIUtils::debug >= 3)
154  std::cout << " right ccd in global RF " << posxy << std::endl << std::endl;
155  // ALILine rightCCD( dowel2 + posxy, line_dowel21_perp );
156  // ccds[3] = ALILine( posxy, line_dowel21_perp );
157 
158  ALILine rightCCD(dowel2 + posxy, -line_dowel21_perp); //samir changed sign to correct the dowel 1st pixel
159  ccds[3] = ALILine(posxy, -line_dowel21_perp); //samir changed sign to correct the dowel 1st pixel
160 
161  if (ALIUtils::debug >= 3) {
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;
167  }
168 
169  //---------- Intersect x-hair laser with COPS
170  if (ALIUtils::debug >= 3)
171  std::cout << " %%% Intersecting x-hair laser with COPS: " << std::endl;
172  ALIPlane copsPlane(centreGlob(), ZAxis);
173  lightray.intersect(*this);
174  CLHEP::Hep3Vector inters = lightray.point();
175  if (ALIUtils::debug >= 3) {
176  ALIUtils::dump3v(inters, " Intersection of x-hair laser with COPS ");
177  }
178 
179  //---------- Get cross of x-hair laser:
180  if (ALIUtils::debug >= 5)
181  std::cout << "1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
182 
183  OpticalObject* xhairOptO = *(meas.OptOList().begin());
184 
185  if (ALIUtils::debug >= 35)
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;
190  ALILine Yline_xhair(inters, copsPlane.project(YAxis_xhair));
191  if (ALIUtils::debug >= 3) {
192  std::cout << " %%%% Projecting x-hair laser on COPS: " << std::endl;
193  ALIUtils::dump3v(YAxis_xhair, " Y direction of laser ");
194  std::cout << " Y line of laser projected on COPS " << Yline_xhair << std::endl;
195  }
196 
197  if (ALIUtils::debug >= 5)
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;
199 
200  ALIdouble anglebx;
201  eexists = xhairOptO->findExtraEntryValueIfExists("angleBetweenAxis", anglebx);
202  if (!eexists)
203  anglebx = PI / 2.;
204  CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
205 
206  // if (ALIUtils::debug >= 3) ALIUtils::dump3v(XAxis_xhair," X of laser1 ");
207  ZAxis = CLHEP::Hep3Vector(0., 0., 1.);
208  ZAxis = rmtx * ZAxis;
209  XAxis_xhair.rotate(anglebx, ZAxis);
210  ALILine Xline_xhair(inters, copsPlane.project(XAxis_xhair));
211  if (ALIUtils::debug >= 3) {
212  std::cout << "angleBetweenAxis = " << anglebx << std::endl;
213  ALIUtils::dump3v(XAxis_xhair, " X direction of laser ");
214  std::cout << " X line of laser projected on COPS " << Xline_xhair << std::endl;
215  }
216 
217  //---------- Get measurement as intersection with four CCDs
218  if (ALIUtils::debug >= 3)
219  std::cout << " Getting measurements as intersection with four CCDs: " << std::endl;
220 
221  if (ALIUtils::debug >= 4)
222  std::cout << "intersecting with upCCD " << std::endl;
223  ALIdouble measv[4][2];
224 
225  // swap Y and X line_xhair by exchanging second index
226 
227  if (ALIUtils::debug >= 5)
228  std::cout << "$@S@ measv[0][0] upccd " << std::endl;
229  measv[0][0] = getMeasFromInters(Yline_xhair, upCCD, line_dowel21);
230  if (ALIUtils::debug >= 5)
231  std::cout << "$@$@ measv[0][1] upccd " << std::endl;
232  measv[0][1] = getMeasFromInters(Xline_xhair, upCCD, line_dowel21);
233 
234  //---- check if postive or negative:
235  if (ALIUtils::debug >= 4)
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);
239 
240  //
241 
242  if (ALIUtils::debug >= 4)
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);
246  if (ALIUtils::debug >= 4)
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);
250 
251  /* Both X and Y axis of the x-laser are intersected with each CCD and it checks that one of
252  the two is inside the CCD(less than CCDlength/2). If no one is inside, it will give an
253  exception. If both are inside (a strange case where, for example, the laser centre is very
254  close and forms 45 degrees with the CCD) it will also make an exception (if you prefer, I can
255  put a warning saying that you have two measurements, but I guess this should never happen for
256  you, so I better give an exception and you don't risk to overpass this warning).
257 
258  Then it is mandatory that you put the CCDlength parameter (I could put a default one if
259  you prefer).
260 
261 
262  ALIbool measInCCD[2];
263  ALIuint ii,jj;
264  for( ii = 0; ii < 4; ii++ ) {
265  for( jj = 0; jj < 2; jj++ ) {
266  measInCCD[jj] = std::abs( measv[ii][jj] ) < CCDlength/2;
267  }
268  if (ALIUtils::debug >= 2) std::cout << "$@$@ CHECK CCD = " << ii << std::endl;
269  if( measInCCD[0] && measInCCD[1] ){
270  std::cerr << "!!!EXITING: both lasers lines of x-hair laser intersect with same CCD " << measNames[ii] << " one at " << measv[ii][0] << " another one at " << measv[ii][1] << "CCDhalfLegth " << CCDlength/2 << std::endl;
271  exit(1);
272  } else if( !(measInCCD[0] || measInCCD[1]) ){
273  std::cerr << "!!!EXITING: none of the lasers lines of x-hair laser intersect with CCD " << measNames[ii] << ", one at " << measv[ii][0] << " another one at " << measv[ii][1] << "CCDhalfLegth " << CCDlength/2 << std::endl;
274  exit(1);
275  } else {
276  measInCCD[0] ? meas.setValueSimulated( ii, measv[ii][0] ) :
277  meas.setValueSimulated( ii, measv[ii][1] );
278  }
279  }
280  */
281 
282  ALIstring measNames[4] = {"up", "down", "left", "right"};
283  ALIbool laserLine;
284  if (ALIUtils::debug >= 2)
285  std::cout << std::endl
286  << "--> Now comparing measurement in ccds by x and y laser lines (will always choose the smaller one) "
287  << std::endl;
288 
289  unsigned int ii;
290  for (ii = 0; ii < 4; ii++) {
291  if (ALIUtils::debug >= 2)
292  std::cout << "\tmeas CCD " << measNames[ii] << " ii=(" << ii
293  << ") \t Values: "
294  //<< (std::abs( measv[ii][0] ) < std::abs( measv[ii][1])
295  << " " << std::abs(measv[ii][0]) << " " << std::abs(measv[ii][1])
296  << " edm::isNotFinite() = " << edm::isNotFinite(measv[ii][1]) << std::endl;
297 
298  if (meas.xlaserLine(ii) != -1) {
299  laserLine = ALIbool(meas.xlaserLine(ii));
300  } else {
301  // Problem here !!!
302  //
303  // Somehow measv[][1] can occasionally return value of 'nan'
304  // which is interpretted as less than any real value
305  //
306  if (edm::isNotFinite(measv[ii][1]) != 0) {
307  measv[ii][1] = 1e99;
308  if (ALIUtils::debug >= 2)
309  std::cout << " --> Swapping for " << measv[ii][1] << "(inf)" << std::endl;
310  }
311 
312  laserLine = std::abs(measv[ii][0]) < std::abs(measv[ii][1]);
313 
314  meas.setXlaserLine(ii, int(laserLine));
315  }
316  laserLine ? meas.setValueSimulated(ii, measv[ii][0]) : meas.setValueSimulated(ii, measv[ii][1]);
317  }
318 
319  if (ALIUtils::debug >= 2)
320  std::cout << std::endl; //Keep format of debug output reasonable
321 
322  // try to identify pathological cases: up and down CCD are intersected by the same
323  // laser line (say X) and the same for the left and right CCD
324 
325  if (ALIUtils::debug >= 2)
326  std::cout << "***** OptOCOPS::makeMeasurement - identify pathological cases U and D intersected by same line"
327  << std::endl;
328  ALIbool xlaserDir[4];
329  for (ii = 0; ii < 4; ii++) {
330  // xlaserDir[ii] = std::abs( measv[ii][0] ) < std::abs( measv[ii][1] );
331  xlaserDir[ii] = ALIbool(meas.xlaserLine(ii));
332  }
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;
336  exit(1);
337  }
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;
341  exit(1);
342  }
343 
344  if (ALIUtils::debug >= 5)
345  std::cout << "***** OptOCOPS::makeMeasurement - now output sim values" << std::endl;
346 
347  if (ALIUtils::debug >= 1) {
348  ALIstring chrg = "";
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()
351  << std::endl;
352  ALIdouble detU = 1000 * meas.valueSimulated(0);
353  if (std::abs(detU) <= 1.e-9)
354  detU = 0.;
355  ALIdouble detD = 1000 * meas.valueSimulated(1);
356  if (std::abs(detD) <= 1.e-9)
357  detD = 0.;
358  ALIdouble detL = 1000 * meas.valueSimulated(2);
359  if (std::abs(detL) <= 1.e-9)
360  detL = 0.;
361  ALIdouble detR = 1000 * meas.valueSimulated(3);
362  if (std::abs(detR) <= 1.e-9)
363  detR = 0.;
364  std::cout << "SIMU value: " << chrg
365  << "U: "
366  // << setprecision(3) << setw(4)
367  << detU << chrg << " D: " << detD << chrg << " L: " << detL << chrg << " R: " << detR << " (mm) "
368  << (this)->name() << std::endl;
369  }
370 }
371 
372 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
373 //@@ Fast simulation of Light Ray traverses
374 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
376  if (ALIUtils::debug >= 5)
377  std::cout << "***** OptOCOPS::fastTraversesLightRay" << std::endl;
378  if (ALIUtils::debug >= 2)
379  std::cout << "LR: FAST TRAVERSES COPS " << name() << std::endl;
380 
381  //---------- Get intersection
382  CLHEP::Hep3Vector ZAxis(0., 0, 1.);
383  CLHEP::HepRotation rmt = rmGlob();
384  ZAxis = rmt * ZAxis;
385  lightray.intersect(ALIPlane(centreGlob(), ZAxis));
386  CLHEP::Hep3Vector inters = lightray.point();
387  lightray.setPoint(inters);
388 
389  if (ALIUtils::debug >= 2) {
390  lightray.dumpData(" after COPS ");
391  }
392 }
393 
394 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
396  if (ALIUtils::debug >= 1)
397  std::cout << "***** OptOCOPS::convertPointToLocalCoordinates" << std::endl;
398  ALIdouble* interslc = new ALIdouble[2];
399 
400  //----- X value
401  CLHEP::HepRotation rmt = rmGlob();
402  CLHEP::Hep3Vector XAxism(1., 0., 0.);
403  XAxism *= rmt;
404  if (ALIUtils::debug >= 5)
405  ALIUtils::dump3v((this)->centreGlob(), "centre glob sensor2D");
406  if (ALIUtils::debug >= 5)
407  ALIUtils::dumprm(rmt, "rotation matrix sensor2D");
408  //t ALIUtils::dump3v(point - (this)->centreGlob() , "inters - (this)->centreGlob()");
409  //t ALIUtils::dump3v(XAxism , "XAxism");
410  interslc[0] = (point - (this)->centreGlob()) * XAxism;
411 
412  //----- Y value
413  CLHEP::Hep3Vector YAxism(0., 1., 0.);
414  YAxism *= rmt;
415  //t ALIUtils::dump3v(YAxism , "YAxism");
416  interslc[1] = (point - (this)->centreGlob()) * YAxism;
417 
418  if (ALIUtils::debug >= 5) {
419  std::cout << " intersection in local coordinates: X= " << interslc[0] << " Y= " << interslc[1] << std::endl;
420  }
421  return interslc;
422 }
423 
424 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
425 ALIdouble OptOCOPS::getMeasFromInters(ALILine& line_xhair, ALILine& ccd, CLHEP::Hep3Vector& cops_line) {
426  if (ALIUtils::debug >= 5)
427  std::cout << "***** OptOCOPS::getMeasFromInters" << std::endl;
428  CLHEP::Hep3Vector inters = line_xhair.intersect(ccd, false) - ccd.pt();
429  ALIdouble sign = inters * ccd.vec();
430  if (sign != 0) {
431  sign = std::abs(sign) / sign;
432  // std::cout << " @@@@@@@@@@@@ sign = " << sign << std::endl;
433  // ALIUtils::dump3v(inters, " intersection " );
434  // ALIUtils::dump3v( ccd.vec(), " cops_line ");
435  } //sign can be zero only if inters is 0, because they are parallel
436  return sign * inters.mag();
437 }
438 
439 #ifdef COCOA_VIS
440 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
441 void OptOCOPS::fillVRML() {
442  ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
443 
444  //---------- Position four CCDs (locally, i.e. with respect to centre)
445  //----- Get first CCD length, that will be used to give a default placement to the CCDs
446  ALIdouble CCDlength = findExtraEntryValue("CCDlength");
447  if (CCDlength == 0.)
448  CCDlength = 2048 * 14 * 1.E-6; // (in meters, the default unit)
449  //Original CCDdim value was 10; .05 works well
450  // ALIdouble CCDdim = .040;
451  ALIdouble CCDdim = 2048 * 14 * 1.E-6;
452  //Original was divided by 10
453  // ALIdouble CCDwidth = CCDdim/10.;
454  ALIdouble CCDwidth = .005;
455 
456  if (ALIUtils::debug >= 4)
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.);
462  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
463  //original ccdsize was 50; 1 works ok
464  ALIdouble ccdsize = 1.;
465 
466  // VRML objects are drawn 'after rotation into system'; so to make all CCDs look the
467  // same in the drawing, CCDwidth parameters must be the same
468  // x, y , z , color
469 
470  //----- Upper CCD
471  vrmlmgr.AddBoxDisplaced(
472  *this, CCDdim, CCDwidth, CCDwidth, ccdsize * (ccds[0].pt() + 0.5 * CCDlength * ccds[0].vec()), &colup);
473  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
474  vrmlmgr.AddBoxDisplaced(
475  *this, CCDdim, CCDwidth, CCDwidth, ccdsize * (ccds[1].pt() + 0.5 * CCDlength * ccds[1].vec()), &coldown);
476  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
477  vrmlmgr.AddBoxDisplaced(
478  *this, CCDwidth, CCDdim, CCDwidth, ccdsize * (ccds[2].pt() + 0.5 * CCDlength * ccds[2].vec()), &colleft);
479  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
480  vrmlmgr.AddBoxDisplaced(
481  *this, CCDwidth, CCDdim, CCDwidth, ccdsize * (ccds[3].pt() + 0.5 * CCDlength * ccds[3].vec()), &colright);
482 
483  vrmlmgr.SendReferenceFrame(*this, CCDdim);
484  vrmlmgr.SendName(*this, 0.01);
485 }
486 
487 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
488 void OptOCOPS::fillIguana() {
489  //---------- Position four CCDs (locally, i.e. with respect to centre)
490  //----- Get first CCD length, that will be used to give a default placement to the CCDs
491  ALIdouble CCDlength;
492  ALIbool pexists = findExtraEntryValueIfExists("CCDlength", CCDlength);
493  if (!pexists)
494  CCDlength = 2048 * 14 * 1.E-6;
495  ALIdouble CCDdim = 2048 * 14 * 1.E-6;
496  ALIdouble CCDwidth = .005;
497 
498  if (ALIUtils::debug >= 4)
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.);
504  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
505  //original ccdsize was 50; 1 works ok
506  ALIdouble ccdsize = 1;
507 
508  // VRML objects are drawn 'after rotation into system'; so to make all CCDs look the
509  // same in the drawing, CCDwidth parameters must be the same
510  // x, y , z , color
511 
512  std::vector<ALIdouble> spar;
513  spar.push_back(CCDdim);
514  spar.push_back(CCDwidth);
515  spar.push_back(CCDwidth);
516  //----- Upper CCD
517  IgCocoaFileMgr::getInstance().addSolid(
518  *this, "BOX", spar, &colup, ccdsize * (ccds[0].pt() + 0.5 * CCDlength * ccds[0].vec()));
519  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
520  IgCocoaFileMgr::getInstance().addSolid(
521  *this, "BOX", spar, &coldown, ccdsize * (ccds[1].pt() + 0.5 * CCDlength * ccds[1].vec()));
522  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
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()));
529  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
530  IgCocoaFileMgr::getInstance().addSolid(
531  *this, "BOX", spar2, &colright, ccdsize * (ccds[3].pt() + 0.5 * CCDlength * ccds[3].vec()));
532 }
533 #endif
534 
535 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
537  ALIdouble go;
539  gomgr->getGlobalOptionValue("VisScale", go);
540 
541  theSolidShape = new CocoaSolidShapeBox(
542  "Box", go * 5. * cm / m, go * 5. * cm / m, go * 1. * cm / m); //COCOA internal units are meters
543 }
LightRay::dumpData
void dumpData(const ALIstring &str) const
Definition: LightRay.cc:374
PI
Definition: PayloadInspector.h:21
ALIbool
bool ALIbool
Definition: CocoaGlobals.h:19
Model.h
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
OptOCOPS::makeMeasurement
void makeMeasurement(LightRay &lightray, Measurement &meas) override
Definition: OptOCOPS.cc:42
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
ALILine::intersect
CLHEP::Hep3Vector intersect(const ALILine &l2, bool notParallel=false)
Definition: ALILine.cc:27
GlobalOptionMgr
Definition: GlobalOptionMgr.h:18
OptOCOPS::getMeasFromInters
ALIdouble getMeasFromInters(ALILine &line_xhair, ALILine &ccd, CLHEP::Hep3Vector &cops_line)
Definition: OptOCOPS.cc:425
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
OpticalObject::findExtraEntryValueIfExists
const ALIbool findExtraEntryValueIfExists(const ALIstring &eename, ALIdouble &value) const
Definition: OpticalObject.cc:1563
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
OptOCOPS::constructSolidShape
void constructSolidShape() override
Definition: OptOCOPS.cc:536
GlobalOptionMgr.h
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
GlobalOptionMgr::getGlobalOptionValue
int getGlobalOptionValue(const ALIstring &sstr, ALIdouble &val)
--— Search a string in theGlobalOptions and return 1 if found
Definition: GlobalOptionMgr.cc:115
ALIPlane::project
CLHEP::Hep3Vector project(const CLHEP::Hep3Vector &vec)
Definition: ALIPlane.cc:27
OptOCOPS::convertPointToLocalCoordinates
ALIdouble * convertPointToLocalCoordinates(const CLHEP::Hep3Vector &point)
Definition: OptOCOPS.cc:395
OpticalObject
Definition: OpticalObject.h:35
Measurement::setXlaserLine
virtual void setXlaserLine(ALIuint ii, int val)
Definition: Measurement.h:158
LightRay.h
CocoaSolidShapeBox
Definition: CocoaSolidShapeBox.h:13
Measurement::setValueSimulated
void setValueSimulated(ALIint coor, ALIdouble value)
Definition: Measurement.h:146
OptOCOPS.h
OptOCOPS::defaultBehaviour
void defaultBehaviour(LightRay &lightray, Measurement &meas) override
Definition: OptOCOPS.cc:33
OpticalObject::rmGlob
const CLHEP::HepRotation & rmGlob() const
Definition: OpticalObject.h:83
LightRay::intersect
void intersect(const ALIPlane &plane)
Definition: LightRay.cc:93
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
LightRay::point
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:57
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
Measurement
Definition: Measurement.h:27
ALILine
Definition: ALILine.h:16
RecoTauValidation_cfi.posX
posX
Definition: RecoTauValidation_cfi.py:287
ALIPlane.h
OpticalObject::fillIguana
virtual void fillIguana()
Definition: OpticalObject.h:55
CLHEP
Definition: CocoaGlobals.h:27
Measurement.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
ALILine::pt
const CLHEP::Hep3Vector & pt() const
Definition: ALILine.h:26
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
OptOCOPS::fastTraversesLightRay
void fastTraversesLightRay(LightRay &lightray) override
Definition: OptOCOPS.cc:375
LightRay::setPoint
void setPoint(const CLHEP::Hep3Vector &point)
Definition: LightRay.h:63
Measurement::OptOList
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:101
ALIPlane
Definition: ALIPlane.h:15
ALILine::vec
const CLHEP::Hep3Vector & vec() const
Definition: ALILine.h:27
ALILine.h
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
isFinite.h
Measurement::xlaserLine
virtual int xlaserLine(ALIuint ii)
Definition: Measurement.h:147
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
OpticalObject::fillVRML
virtual void fillVRML()
Definition: OpticalObject.h:54
Measurement::value
const ALIdouble * value() const
Definition: Measurement.h:109
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:52
point
*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
Definition: invegas.h:5
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
CocoaSolidShapeBox.h
cuy.ii
ii
Definition: cuy.py:589
RecoTauValidation_cfi.posY
posY
Definition: RecoTauValidation_cfi.py:288
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37