CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
20 
21 #include <iostream>
22 #include <iomanip>
23 #include <fstream>
24 #include <math.h> // I have added a new library for isnan() function
25 #include <cstdlib>
26 
27 using namespace CLHEP;
28 
29 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
30 //@@ Make measurement as distance to previous object 'screen'
31 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
33 {
34  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::defaultBehaviour" <<std::endl;
35  makeMeasurement( lightray, meas);
36 }
37 
38 
39 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
40 //@@ Make measurement as distance to previous object 'screen'
41 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
43 {
44 
45  if (ALIUtils::debug >= 4) std::cout << "***** OptOCOPS::makeMeasurement(lightray, meas) " << std::endl;
46  //---------- Centre of COPS is at dowel point 2
47  CLHEP::Hep3Vector dowel2 = centreGlob();
48  //---------- Coordinates of dowel point 1 are given with respect to dowel point 2 (in local reference frame)
49  ALIdouble posx12 = findExtraEntryValue("dowel1X");
50 // Changed default value to .045 from .03
51  if(posx12 == 0. ) 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. ) CCDlength = 2048*14 * 1.E-6; // (in meters, the default unit)
76 
77 
78 
79  // global / local output of ccd location in RF was reversed, I am swapping
80 
81 
82  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
83  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** UP CCD *****" << std::endl
84  << "******************" << std::endl << std::endl;
85  ALIdouble posX = findExtraEntryValue("upCCDXtoDowel2");
86  ALIdouble posY;
87  ALIbool eexists = findExtraEntryValueIfExists("upCCDYtoDowel2", posY);
88  if(!eexists) posY = CCDlength + 0.004;
89  //if(!eexists) posY = 0.004;
90  CLHEP::Hep3Vector posxy( posX, posY, 0);
91  if(ALIUtils::debug>= 3) std::cout << " %%%% CCD distances to Dowel2: " << std::endl;
92  if(ALIUtils::debug>= 3) std::cout << " up ccd in local RF " << posxy << std::endl;
93  posxy = rmt * posxy;
94  if(ALIUtils::debug>= 3) std::cout << " up ccd in global RF " << posxy << std::endl;
95  // ALILine upCCD( dowel2 + posxy, -line_dowel21 );
96  // ccds[0] = ALILine( posxy, -line_dowel21 );
97  ALILine upCCD( dowel2 + posxy, line_dowel21 );// Samir changed sign to correct the dowel 1st pixel
98  ccds[0] = ALILine( posxy, line_dowel21 ); // samir changed sign to correct the dowel 1st pixel
99  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
100  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** DOWN CCD *****" << std::endl
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);
106  if(ALIUtils::debug>= 3) std::cout << " down ccd in local RF " << posxy << std::endl;
107  posxy = rmt * posxy;
108  if(ALIUtils::debug>= 3) std::cout << " down ccd in global RF " << posxy << std::endl;
109 // ALILine downCCD( dowel2 + posxy, -line_dowel21 );
110  // ccds[1] = ALILine( posxy, -line_dowel21 );
111 
112 ALILine downCCD( dowel2 + posxy, line_dowel21 );//samir changed signto correct the dowel 1st pixel
113  ccds[1] = ALILine( posxy, line_dowel21 ); // samir changed sign to correct the dowel 1st pixel
114 
115  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
116 
117  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** LEFT CCD *****" << std::endl
118  << "********************" << std::endl << std::endl;
119  eexists = findExtraEntryValueIfExists("leftCCDXtoDowel2", posX);
120 // if(!eexists) posX = -0.002;
121  if(!eexists) posX = -CCDlength - 0.002; // Samir changed sign to correct the dowel 1st pixel
122  posY = findExtraEntryValue("leftCCDYtoDowel2");
123  posxy = CLHEP::Hep3Vector( posX, posY, 0);
124  if(ALIUtils::debug>= 3) std::cout << " left ccd in local RF " << posxy << std::endl;
125  posxy = rmt * posxy;
126  if(ALIUtils::debug>= 3) std::cout << " left ccd in global RF " << posxy << std::endl;
127  // ALILine leftCCD( dowel2 + posxy, line_dowel21_perp );
128  // ccds[2] = ALILine( posxy, line_dowel21_perp );
129 
130  ALILine leftCCD( dowel2 + posxy, -line_dowel21_perp );//samir changed sign to correct the dowel 1st pixel
131  ccds[2] = ALILine( posxy, -line_dowel21_perp );//samir changed sign to correct the dowel 1st pixel
132 
133  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
134  if(ALIUtils::debug>= 3) std::cout << std::endl << "***** RIGHT CCD *****" << std::endl
135  << "*********************" << std::endl<< std::endl ;
136  eexists = findExtraEntryValueIfExists("rightCCDXtoDowel2", posX);
137  // if(!eexists) posX = -CCDlength - 0.004;
138  if(!eexists) posX = - 0.004; // samir tried to change in order to adjust the position of 1 st pixel.
139  posY = findExtraEntryValue("rightCCDYtoDowel2");
140  posxy = CLHEP::Hep3Vector( posX, posY, 0);
141  if(ALIUtils::debug>= 3) std::cout << " right ccd in local RF " << posxy << std::endl;
142  posxy = rmt * posxy;
143  if(ALIUtils::debug>= 3) std::cout << " right ccd in global RF " << posxy << std::endl << std::endl;
144  // ALILine rightCCD( dowel2 + posxy, line_dowel21_perp );
145  // ccds[3] = ALILine( posxy, line_dowel21_perp );
146 
147 ALILine rightCCD( dowel2 + posxy, -line_dowel21_perp ); //samir changed sign to correct the dowel 1st pixel
148  ccds[3] = ALILine( posxy, -line_dowel21_perp ); //samir changed sign to correct the dowel 1st pixel
149 
150  if (ALIUtils::debug >= 3) {
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;
156  }
157 
158  //---------- Intersect x-hair laser with COPS
159  if (ALIUtils::debug >= 3) std::cout << " %%% Intersecting x-hair laser with COPS: " << std::endl;
160  ALIPlane copsPlane(centreGlob(), ZAxis);
161  lightray.intersect( *this );
162  CLHEP::Hep3Vector inters = lightray.point();
163  if (ALIUtils::debug >= 3) {
164  ALIUtils::dump3v(inters, " Intersection of x-hair laser with COPS ");
165  }
166 
167  //---------- Get cross of x-hair laser:
168  if (ALIUtils::debug >= 5) std::cout << "1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
169 
170  OpticalObject* xhairOptO = *(meas.OptOList().begin());
171 
172  if (ALIUtils::debug >= 35) std::cout << "2. Get the Y of the laser and project it on the COPS" << std::endl;
173  CLHEP::Hep3Vector YAxis_xhair(0.,1.,0.);
174  CLHEP::HepRotation rmtx = xhairOptO->rmGlob();
175  YAxis_xhair = rmtx * YAxis_xhair;
176  ALILine Yline_xhair( inters, copsPlane.project( YAxis_xhair ));
177  if (ALIUtils::debug >= 3) {
178  std::cout << " %%%% Projecting x-hair laser on COPS: " << std::endl;
179  ALIUtils::dump3v(YAxis_xhair, " Y direction of laser ");
180  std::cout << " Y line of laser projected on COPS " << Yline_xhair << std::endl;
181  }
182 
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;
184 
185  ALIdouble anglebx;
186  eexists = xhairOptO->findExtraEntryValueIfExists("angleBetweenAxis", anglebx);
187  if(!eexists) anglebx = PI/2.;
188  CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
189 
190  // if (ALIUtils::debug >= 3) ALIUtils::dump3v(XAxis_xhair," X of laser1 ");
191  ZAxis = CLHEP::Hep3Vector(0.,0.,1.);
192  ZAxis = rmtx * ZAxis;
193  XAxis_xhair.rotate(anglebx, ZAxis );
194  ALILine Xline_xhair( inters, copsPlane.project( XAxis_xhair ) );
195  if (ALIUtils::debug >= 3) {
196  std::cout << "angleBetweenAxis = " << anglebx << std::endl;
197  ALIUtils::dump3v(XAxis_xhair," X direction of laser ");
198  std::cout << " X line of laser projected on COPS " << Xline_xhair << std::endl;
199  }
200 
201 
202  //---------- Get measurement as intersection with four CCDs
203  if(ALIUtils::debug >= 3) std::cout << " Getting measurements as intersection with four CCDs: " << std::endl;
204 
205  if(ALIUtils::debug >= 4)std::cout << "intersecting with upCCD " << std::endl;
206  ALIdouble measv[4][2];
207 
208 // swap Y and X line_xhair by exchanging second index
209 
210  if(ALIUtils::debug >= 5)std::cout << "$@S@ measv[0][0] upccd " << std::endl;
211  measv[0][0] = getMeasFromInters( Yline_xhair, upCCD, line_dowel21 );
212  if(ALIUtils::debug >= 5)std::cout << "$@$@ measv[0][1] upccd " << std::endl;
213  measv[0][1] = getMeasFromInters( Xline_xhair, upCCD, line_dowel21 );
214 
215  //---- check if postive or negative:
216  if(ALIUtils::debug >= 4) std::cout << "intersecting with downCCD " << std::endl;
217  measv[1][0] = getMeasFromInters(Yline_xhair, downCCD, line_dowel21 );
218  measv[1][1] = getMeasFromInters(Xline_xhair, downCCD, line_dowel21 );
219 
220 //
221 
222  if(ALIUtils::debug >= 4) std::cout << "intersecting with leftCCD " << std::endl;
223  measv[2][0] = getMeasFromInters(Xline_xhair, leftCCD, line_dowel21_perp );
224  measv[2][1] = getMeasFromInters(Yline_xhair, leftCCD, line_dowel21_perp );
225  if(ALIUtils::debug >= 4) std::cout << "intersecting with rightCCD " << std::endl;
226  measv[3][0] = getMeasFromInters(Xline_xhair, rightCCD, line_dowel21_perp );
227  measv[3][1] = getMeasFromInters(Yline_xhair, rightCCD, line_dowel21_perp );
228 
229  /* Both X and Y axis of the x-laser are intersected with each CCD and it checks that one of
230  the two is inside the CCD(less than CCDlength/2). If no one is inside, it will give an
231  exception. If both are inside (a strange case where, for example, the laser centre is very
232  close and forms 45 degrees with the CCD) it will also make an exception (if you prefer, I can
233  put a warning saying that you have two measurements, but I guess this should never happen for
234  you, so I better give an exception and you don't risk to overpass this warning).
235 
236  Then it is mandatory that you put the CCDlength parameter (I could put a default one if
237  you prefer).
238 
239 
240  ALIbool measInCCD[2];
241  ALIuint ii,jj;
242  for( ii = 0; ii < 4; ii++ ) {
243  for( jj = 0; jj < 2; jj++ ) {
244  measInCCD[jj] = fabs( measv[ii][jj] ) < CCDlength/2;
245  }
246  if (ALIUtils::debug >= 2) std::cout << "$@$@ CHECK CCD = " << ii << std::endl;
247  if( measInCCD[0] && measInCCD[1] ){
248  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;
249  exit(1);
250  } else if( !(measInCCD[0] || measInCCD[1]) ){
251  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;
252  exit(1);
253  } else {
254  measInCCD[0] ? meas.setValueSimulated( ii, measv[ii][0] ) :
255  meas.setValueSimulated( ii, measv[ii][1] );
256  }
257  }
258  */
259 
260  ALIstring measNames[4] ={"up","down","left","right"};
261  ALIbool laserLine;
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;
263 
264  unsigned int ii;
265  for( ii = 0; ii < 4; ii++ ) {
266  if (ALIUtils::debug >= 2) std::cout << "\tmeas CCD " << measNames[ii] << " ii=(" << ii << ") \t Values: "
267  //<< (fabs( measv[ii][0] ) < fabs( measv[ii][1])
268  << " " << fabs( measv[ii][0] ) << " " << fabs( measv[ii][1] ) << " isnan() = " <<
269  std::isnan(measv[ii][1]) << std::endl;
270 
271  if( meas.xlaserLine( ii ) != -1 ) {
272  laserLine = ALIbool( meas.xlaserLine( ii ) );
273  } else {
274 
275  // Problem here !!!
276  //
277  // Somehow measv[][1] can occasionally return value of 'nan'
278  // which is interpretted as less than any real value
279  //
280  if(std::isnan(measv[ii][1]) != 0){
281  measv[ii][1] = 1e99;
282  if (ALIUtils::debug >= 2) std::cout << " --> Swapping for " << measv[ii][1] << "(inf)" << std::endl;
283  }
284 
285  laserLine = fabs( measv[ii][0] ) < fabs( measv[ii][1] );
286 
287  meas.setXlaserLine( ii, int(laserLine) );
288  }
289  laserLine ? meas.setValueSimulated( ii, measv[ii][0] )
290  : meas.setValueSimulated( ii, measv[ii][1] );
291  }
292 
293  if (ALIUtils::debug >= 2) std::cout << std::endl; //Keep format of debug output reasonable
294 
295  // try to identify pathological cases: up and down CCD are intersected by the same
296  // laser line (say X) and the same for the left and right CCD
297 
298  if(ALIUtils::debug >= 2) std::cout << "***** OptOCOPS::makeMeasurement - identify pathological cases U and D intersected by same line" <<std::endl;
299  ALIbool xlaserDir[4];
300  for( ii = 0; ii < 4; ii++ ) {
301  // xlaserDir[ii] = fabs( measv[ii][0] ) < fabs( measv[ii][1] );
302  xlaserDir[ii] = ALIbool( meas.xlaserLine( ii ) );
303  }
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;
306  exit(1);
307  }
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;
310  exit(1);
311  }
312 
313  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::makeMeasurement - now output sim values" << std::endl;
314 
315  if (ALIUtils::debug >= 1) {
316  ALIstring chrg = "";
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;
322  ALIdouble detU = 1000*meas.valueSimulated(0); if(fabs(detU) <= 1.e-9 ) detU = 0.;
323  ALIdouble detD = 1000*meas.valueSimulated(1); if(fabs(detD) <= 1.e-9 ) detD = 0.;
324  ALIdouble detL = 1000*meas.valueSimulated(2); if(fabs(detL) <= 1.e-9 ) detL = 0.;
325  ALIdouble detR = 1000*meas.valueSimulated(3); if(fabs(detR) <= 1.e-9 ) detR = 0.;
326  std::cout << "SIMU value: " << chrg << "U: "
327  // << setprecision(3) << setw(4)
328  << detU
329  << chrg << " D: " << detD
330  << chrg << " L: " << detL
331  << chrg << " R: " << detR
332  << " (mm) " << (this)->name() << std::endl;
333  }
334 
335 
336 }
337 
338 
339 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
340 //@@ Fast simulation of Light Ray traverses
341 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
343 {
344 
345  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::fastTraversesLightRay" <<std::endl;
346  if (ALIUtils::debug >= 2) std::cout << "LR: FAST TRAVERSES COPS " << name() << std::endl;
347 
348  //---------- Get intersection
349  CLHEP::Hep3Vector ZAxis(0.,0,1.);
350  CLHEP::HepRotation rmt = rmGlob();
351  ZAxis = rmt * ZAxis;
352  lightray.intersect( ALIPlane(centreGlob(), ZAxis) );
353  CLHEP::Hep3Vector inters = lightray.point();
354  lightray.setPoint( inters );
355 
356  if (ALIUtils::debug >= 2) {
357  lightray.dumpData(" after COPS ");
358  }
359 
360 }
361 
362 
363 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
365 {
366  if(ALIUtils::debug >= 1) std::cout << "***** OptOCOPS::convertPointToLocalCoordinates" <<std::endl;
367  ALIdouble* interslc = new ALIdouble[2];
368 
369  //----- X value
370  CLHEP::HepRotation rmt = rmGlob();
371  CLHEP::Hep3Vector XAxism(1.,0.,0.);
372  XAxism*=rmt;
373  if( ALIUtils::debug >= 5) ALIUtils::dump3v( (this)->centreGlob(), "centre glob sensor2D" );
374  if( ALIUtils::debug >= 5) ALIUtils::dumprm( rmt, "rotation matrix sensor2D" );
375  //t ALIUtils::dump3v(point - (this)->centreGlob() , "inters - (this)->centreGlob()");
376  //t ALIUtils::dump3v(XAxism , "XAxism");
377  interslc[0] = (point - (this)->centreGlob() ) * XAxism;
378 
379  //----- Y value
380  CLHEP::Hep3Vector YAxism(0.,1.,0.);
381  YAxism*=rmt;
382  //t ALIUtils::dump3v(YAxism , "YAxism");
383  interslc[1] = (point - (this)->centreGlob() ) * YAxism;
384 
385  if( ALIUtils::debug >=5 ) {
386  std::cout << " intersection in local coordinates: X= " << interslc[0] << " Y= " << interslc[1] << std::endl;
387  }
388  return interslc;
389 }
390 
391 
392 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
393 ALIdouble OptOCOPS::getMeasFromInters( ALILine& line_xhair, ALILine& ccd, CLHEP::Hep3Vector& cops_line )
394 {
395 
396  if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::getMeasFromInters" <<std::endl;
397  CLHEP::Hep3Vector inters = line_xhair.intersect( ccd, 0 ) - ccd.pt();
398  ALIdouble sign = inters*ccd.vec();
399  if( sign != 0 ){
400  sign = fabs(sign)/sign;
401  // std::cout << " @@@@@@@@@@@@ sign = " << sign << std::endl;
402  // ALIUtils::dump3v(inters, " intersection " );
403  // ALIUtils::dump3v( ccd.vec(), " cops_line ");
404  } //sign can be zero only if inters is 0, because they are parallel
405  return sign*inters.mag();
406 }
407 
408 
409 #ifdef COCOA_VIS
410 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
411 void OptOCOPS::fillVRML()
412 {
413 
414  ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
415 
416  //---------- Position four CCDs (locally, i.e. with respect to centre)
417  //----- Get first CCD length, that will be used to give a default placement to the CCDs
418  ALIdouble CCDlength = findExtraEntryValue("CCDlength");
419  if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6; // (in meters, the default unit)
420  //Original CCDdim value was 10; .05 works well
421 // ALIdouble CCDdim = .040;
422  ALIdouble CCDdim = 2048*14 * 1.E-6;
423  //Original was divided by 10
424 // ALIdouble CCDwidth = CCDdim/10.;
425  ALIdouble CCDwidth = .005;
426 
427  if(ALIUtils::debug >= 4) std::cout << " ccds0 " << ccds[0] << "ccds1 " << ccds[1] << std::endl;
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.);
432  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
433  //original ccdsize was 50; 1 works ok
434  ALIdouble ccdsize = 1.;
435 
436  // VRML objects are drawn 'after rotation into system'; so to make all CCDs look the
437  // same in the drawing, CCDwidth parameters must be the same
438  // x, y , z , color
439 
440  //----- Upper CCD
441  vrmlmgr.AddBoxDisplaced( *this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[0].pt()+0.5*CCDlength*ccds[0].vec()), &colup);
442  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
443  vrmlmgr.AddBoxDisplaced( *this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[1].pt()+0.5*CCDlength*ccds[1].vec()), &coldown );
444  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
445  vrmlmgr.AddBoxDisplaced( *this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[2].pt()+0.5*CCDlength*ccds[2].vec()), &colleft );
446  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
447  vrmlmgr.AddBoxDisplaced( *this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[3].pt()+0.5*CCDlength*ccds[3].vec()), &colright );
448 
449  vrmlmgr.SendReferenceFrame( *this, CCDdim);
450  vrmlmgr.SendName( *this, 0.01 );
451 
452 }
453 
454 
455 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
457 {
458  //---------- Position four CCDs (locally, i.e. with respect to centre)
459  //----- Get first CCD length, that will be used to give a default placement to the CCDs
460  ALIdouble CCDlength;
461  ALIbool pexists = findExtraEntryValueIfExists("CCDlength",CCDlength);
462  if( !pexists ) CCDlength = 2048*14 * 1.E-6;
463  ALIdouble CCDdim = 2048*14 * 1.E-6;
464  ALIdouble CCDwidth = .005;
465 
466  if(ALIUtils::debug >= 4) std::cout << " ccds0 " << ccds[0] << "ccds1 " << ccds[1] << std::endl;
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.);
471  //----- Upper CCD (leftmost point & direction dowel1-dowel2)
472  //original ccdsize was 50; 1 works ok
473  ALIdouble ccdsize = 1;
474 
475  // VRML objects are drawn 'after rotation into system'; so to make all CCDs look the
476  // same in the drawing, CCDwidth parameters must be the same
477  // x, y , z , color
478 
479  std::vector<ALIdouble> spar;
480  spar.push_back(CCDdim);
481  spar.push_back(CCDwidth);
482  spar.push_back(CCDwidth);
483  //----- Upper CCD
484  IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar, &colup, ccdsize*(ccds[0].pt()+0.5*CCDlength*ccds[0].vec()));
485  //----- Lower CCD (leftmost point & direction dowel2-dowel1)
486  IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar, &coldown, ccdsize*(ccds[1].pt()+0.5*CCDlength*ccds[1].vec()) );
487  //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
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()));
493  //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
494  IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar2, &colright, ccdsize*(ccds[3].pt()+0.5*CCDlength*ccds[3].vec()));
495 
496 }
497 #endif
498 
499 
500 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
502 {
503  ALIdouble go;
505  gomgr->getGlobalOptionValue("VisScale", go );
506 
507  theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*1.*cm/m ); //COCOA internal units are meters
508 }
long double ALIdouble
Definition: CocoaGlobals.h:11
virtual void defaultBehaviour(LightRay &lightray, Measurement &meas)
Definition: OptOCOPS.cc:32
#define PI
virtual void makeMeasurement(LightRay &lightray, Measurement &meas)
Definition: OptOCOPS.cc:42
virtual void fillVRML()
Definition: OpticalObject.h:55
static void dumprm(const CLHEP::HepRotation &rm, const std::string &msg, std::ostream &out=std::cout)
Definition: ALIUtils.cc:77
std::vector< OpticalObject * > & OptOList()
Definition: Measurement.h:109
const ALIbool findExtraEntryValueIfExists(const ALIstring &eename, ALIdouble &value) const
static ALIint debug
Definition: ALIUtils.h:35
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
bool ALIbool
Definition: CocoaGlobals.h:19
void setPoint(const CLHEP::Hep3Vector &point)
Definition: LightRay.h:64
ALIdouble * convertPointToLocalCoordinates(const CLHEP::Hep3Vector &point)
Definition: OptOCOPS.cc:364
bool isnan(float x)
Definition: math.h:13
virtual void setXlaserLine(ALIuint ii, int val)
Definition: Measurement.h:209
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:52
const CLHEP::Hep3Vector & pt() const
Definition: ALILine.h:27
void setValueSimulated(ALIint coor, ALIdouble value)
Definition: Measurement.h:196
CLHEP::Hep3Vector project(const CLHEP::Hep3Vector &vec)
Definition: ALIPlane.cc:30
virtual int xlaserLine(ALIuint ii)
Definition: Measurement.h:199
static void dump3v(const CLHEP::Hep3Vector &vec, const std::string &msg)
Definition: ALIUtils.cc:61
void intersect(const ALIPlane &plane)
Definition: LightRay.cc:100
void constructSolidShape()
Definition: OptOCOPS.cc:501
virtual void fillIguana()
Definition: OpticalObject.h:56
const ALIdouble * value() const
Definition: Measurement.h:125
CLHEP::Hep3Vector intersect(const ALILine &l2, bool notParallel=0)
Definition: ALILine.cc:29
std::string ALIstring
Definition: CocoaGlobals.h:9
void dumpData(const ALIstring &str) const
Definition: LightRay.cc:381
const ALIdouble valueSimulated(ALIuint ii) const
Definition: Measurement.h:117
ALIdouble getMeasFromInters(ALILine &line_xhair, ALILine &ccd, CLHEP::Hep3Vector &cops_line)
Definition: OptOCOPS.cc:393
tuple cout
Definition: gather_cfg.py:41
*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
virtual void fastTraversesLightRay(LightRay &lightray)
Definition: OptOCOPS.cc:342
const CLHEP::Hep3Vector & vec() const
Definition: ALILine.h:28