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