CMS 3D CMS Logo

OptOCOPS.cc

Go to the documentation of this file.
00001 //   COCOA class implementation file
00002 //Id:  OptOCops.cc
00003 //CAT: Model
00004 //
00005 //   History: v1.0 
00006 //   Pedro Arce
00007 
00008 #include "Alignment/CocoaModel/interface/OptOCOPS.h"
00009 #include "Alignment/CocoaModel/interface/LightRay.h"
00010 #include "Alignment/CocoaModel/interface/Measurement.h"
00011 #ifdef COCOA_VIS
00012 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
00013 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
00014 #endif
00015 #include "Alignment/CocoaModel/interface/ALIPlane.h"
00016 #include "Alignment/CocoaDDLObjects/interface/CocoaSolidShapeBox.h"
00017 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00018 
00019 #include <iostream>
00020 #include <iomanip>
00021 #include <fstream>
00022 #include <math.h>               // I have added a new library for isnan() function
00023 
00024 
00025 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00026 //@@  Make measurement as distance to previous object 'screen'
00027 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00028 void OptOCOPS::defaultBehaviour( LightRay& lightray, Measurement& meas )
00029 {
00030   if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::defaultBehaviour" <<std::endl;
00031   makeMeasurement( lightray, meas);
00032 }
00033 
00034 
00035 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00036 //@@  Make measurement as distance to previous object 'screen'
00037 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00038 void OptOCOPS::makeMeasurement( LightRay& lightray, Measurement& meas ) 
00039 {
00040 
00041   if (ALIUtils::debug >= 4) std::cout << "***** OptOCOPS::makeMeasurement(lightray, meas) " << std::endl; 
00042   //---------- Centre of COPS is at dowel point 2 
00043   CLHEP::Hep3Vector dowel2 = centreGlob();
00044   //---------- Coordinates of dowel point 1 are given with respect to dowel point 2 (in local reference frame)
00045   ALIdouble posx12 = findExtraEntryValue("dowel1X");
00046 // Changed default value to .045 from .03
00047   if(posx12 == 0. ) posx12 = 0.045;
00048   CLHEP::Hep3Vector dowel1(posx12,findExtraEntryValue("dowel1Y"), 0.);
00049   CLHEP::HepRotation rmt = rmGlob(); 
00050   dowel1 = rmt*dowel1;
00051   dowel1 += dowel2;  
00052   if (ALIUtils::debug >= 3) {
00053     ALIUtils::dump3v(dowel2, " dowel2");
00054     ALIUtils::dump3v(dowel1, " dowel1");
00055   }
00056 
00057   //---------- Get line joining dowel1-dowel2 and perpendicular to it inside cops
00058   CLHEP::Hep3Vector line_dowel21 = - (dowel1-dowel2 ); 
00059   CLHEP::Hep3Vector ZAxis(0.,0,1.); 
00060   ZAxis = rmt * ZAxis; 
00061   CLHEP::Hep3Vector line_dowel21_perp = ZAxis.cross( line_dowel21 ); 
00062   if (ALIUtils::debug >= 3) {
00063     ALIUtils::dump3v(line_dowel21," line_dowel21");
00064     ALIUtils::dump3v(line_dowel21_perp," line_dowel21_perp");
00065   }
00066  
00067   //---------- Position four CCDs (locally, i.e. with respect to centre)
00068   //----- Get first CCD length, that will be used to give a default placement to the CCDs
00069   ALIdouble CCDlength = findExtraEntryValue("CCDlength");
00070   if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6; // (in meters, the default unit)
00071 
00072 
00073 
00074   //  global / local output of ccd location in RF was reversed, I am swapping
00075 
00076 
00077   //----- Upper CCD (leftmost point & direction dowel1-dowel2)
00078   if(ALIUtils::debug>= 3) std::cout << std::endl << "***** UP CCD *****" << std::endl
00079                             << "******************" << std::endl << std::endl;
00080   ALIdouble posX = findExtraEntryValue("upCCDXtoDowel2");
00081   ALIdouble posY;
00082   ALIbool eexists = findExtraEntryValueIfExists("upCCDYtoDowel2", posY);
00083   if(!eexists) posY = CCDlength + 0.004;
00084   CLHEP::Hep3Vector posxy( posX, posY, 0);
00085   if(ALIUtils::debug>= 3) std::cout << " %%%% CCD distances to Dowel2: " << std::endl;
00086   if(ALIUtils::debug>= 3) std::cout << "   up ccd in local RF " << posxy << std::endl; 
00087   posxy = rmt * posxy;
00088   if(ALIUtils::debug>= 3) std::cout << "   up ccd in global RF " << posxy << std::endl; 
00089   ALILine upCCD( dowel2 + posxy, -line_dowel21 ); 
00090   ccds[0] = ALILine( posxy, -line_dowel21 );
00091 
00092   //----- Lower CCD (leftmost point & direction dowel2-dowel1)
00093   if(ALIUtils::debug>= 3) std::cout << std::endl << "***** DOWN CCD *****" << std::endl 
00094                             << "********************" << std::endl << std::endl ;
00095   posX = findExtraEntryValue("downCCDXtoDowel2");
00096   eexists = findExtraEntryValueIfExists("downCCDYtoDowel2", posY);
00097   if(!eexists) posY = 0.002;
00098   posxy = CLHEP::Hep3Vector( posX, posY, 0);
00099   if(ALIUtils::debug>= 3) std::cout << "   down ccd in local RF " << posxy << std::endl; 
00100   posxy = rmt * posxy;
00101   if(ALIUtils::debug>= 3) std::cout << "   down ccd in global RF " << posxy << std::endl; 
00102   ALILine downCCD( dowel2 + posxy, -line_dowel21 );
00103   ccds[1] = ALILine( posxy, -line_dowel21 );
00104 
00105   //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
00106 
00107   if(ALIUtils::debug>= 3) std::cout << std::endl << "***** LEFT CCD *****" << std::endl
00108                             << "********************" << std::endl << std::endl;
00109   eexists = findExtraEntryValueIfExists("leftCCDXtoDowel2", posX);
00110   if(!eexists) posX = -0.002;
00111   posY = findExtraEntryValue("leftCCDYtoDowel2");
00112   posxy = CLHEP::Hep3Vector( posX, posY, 0);
00113   if(ALIUtils::debug>= 3) std::cout << "   left ccd in local RF " << posxy << std::endl; 
00114   posxy = rmt * posxy;
00115   if(ALIUtils::debug>= 3) std::cout << "   left ccd in global RF " << posxy << std::endl; 
00116   ALILine leftCCD( dowel2 + posxy, line_dowel21_perp );
00117   ccds[2] = ALILine(  posxy, line_dowel21_perp );
00118 
00119   //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
00120   if(ALIUtils::debug>= 3) std::cout << std::endl << "***** RIGHT CCD *****" << std::endl 
00121                             << "*********************" << std::endl<< std::endl ;
00122   eexists = findExtraEntryValueIfExists("rightCCDXtoDowel2", posX);
00123   if(!eexists) posX = -CCDlength - 0.004;
00124   posY = findExtraEntryValue("rightCCDYtoDowel2");
00125   posxy = CLHEP::Hep3Vector( posX, posY, 0);
00126   if(ALIUtils::debug>= 3) std::cout << "   right ccd in local RF " << posxy << std::endl; 
00127   posxy = rmt * posxy;
00128   if(ALIUtils::debug>= 3) std::cout << "   right ccd in global RF " << posxy  << std::endl << std::endl; 
00129   ALILine rightCCD( dowel2 + posxy, line_dowel21_perp );
00130   ccds[3] = ALILine(  posxy, line_dowel21_perp );
00131 
00132   if (ALIUtils::debug >= 3) {
00133     std::cout << " %%%  Positions of CCDs in global RF: " << std::endl<< std::endl;
00134     std::cout << "     upCCD: " << upCCD << std::endl;
00135     std::cout << "     downCCD: " << downCCD << std::endl;
00136     std::cout << "     leftCCD: " << leftCCD << std::endl;
00137     std::cout << "     rightCCD: " << rightCCD << std::endl << std::endl;
00138   }
00139 
00140   //---------- Intersect x-hair laser with COPS
00141   if (ALIUtils::debug >= 3) std::cout << " %%%  Intersecting x-hair laser with COPS: " << std::endl;
00142   ALIPlane copsPlane(centreGlob(), ZAxis);
00143   lightray.intersect( *this ); 
00144   CLHEP::Hep3Vector inters = lightray.point();
00145   if (ALIUtils::debug >= 3) {
00146      ALIUtils::dump3v(inters, " Intersection of x-hair laser with COPS ");
00147   }
00148 
00149   //---------- Get cross of x-hair laser:
00150    if (ALIUtils::debug >= 5) std::cout << "1. Get the OptO x-hair laser from the measurement list of OptOs" << std::endl;
00151    
00152   OpticalObject* xhairOptO = *(meas.OptOList().begin());
00153 
00154   if (ALIUtils::debug >= 35) std::cout << "2. Get the Y of the laser and project it on the COPS" << std::endl;
00155   CLHEP::Hep3Vector YAxis_xhair(0.,1.,0.);
00156   CLHEP::HepRotation rmtx = xhairOptO->rmGlob(); 
00157   YAxis_xhair = rmtx * YAxis_xhair;
00158   ALILine Yline_xhair( inters, copsPlane.project( YAxis_xhair ));
00159   if (ALIUtils::debug >= 3) {
00160     std::cout << "  %%%% Projecting x-hair laser on COPS: " << std::endl;
00161      ALIUtils::dump3v(YAxis_xhair, " Y direction of laser ");
00162     std::cout << " Y line of laser projected on COPS " <<  Yline_xhair << std::endl;
00163   }
00164 
00165   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;
00166   
00167   ALIdouble anglebx;
00168   eexists = xhairOptO->findExtraEntryValueIfExists("angleBetweenAxis", anglebx);
00169   if(!eexists) anglebx = PI/2.;
00170   CLHEP::Hep3Vector XAxis_xhair = YAxis_xhair;
00171 
00172  //   if (ALIUtils::debug >= 3) ALIUtils::dump3v(XAxis_xhair," X of laser1 ");
00173   ZAxis = CLHEP::Hep3Vector(0.,0.,1.);
00174   ZAxis = rmtx * ZAxis;
00175   XAxis_xhair.rotate(anglebx, ZAxis );
00176   ALILine Xline_xhair( inters, copsPlane.project( XAxis_xhair ) );
00177   if (ALIUtils::debug >= 3) {
00178     std::cout << "angleBetweenAxis = " << anglebx << std::endl;
00179     ALIUtils::dump3v(XAxis_xhair," X direction of laser ");
00180     std::cout << " X line of laser projected on COPS " <<  Xline_xhair << std::endl;
00181   }
00182  
00183 
00184   //---------- Get measurement as intersection with four CCDs 
00185   if(ALIUtils::debug >= 3) std::cout << "  Getting measurements as intersection with four CCDs: " << std::endl;
00186 
00187   if(ALIUtils::debug >= 4)std::cout << "intersecting with upCCD " << std::endl;
00188   ALIdouble measv[4][2];
00189 
00190 // swap Y and X line_xhair by exchanging second index
00191 
00192   if(ALIUtils::debug >= 5)std::cout << "$@S@ measv[0][0] upccd " << std::endl;
00193   measv[0][0] = getMeasFromInters( Yline_xhair, upCCD, line_dowel21 );
00194   if(ALIUtils::debug >= 5)std::cout << "$@$@ measv[0][1] upccd " << std::endl;
00195   measv[0][1] = getMeasFromInters( Xline_xhair, upCCD, line_dowel21 );
00196   
00197   //---- check if postive or negative: 
00198   if(ALIUtils::debug >= 4) std::cout << "intersecting with downCCD " << std::endl;
00199   measv[1][0] = getMeasFromInters(Yline_xhair, downCCD, line_dowel21 );
00200   measv[1][1] = getMeasFromInters(Xline_xhair, downCCD, line_dowel21 );
00201   
00202 //  
00203   
00204   if(ALIUtils::debug >= 4) std::cout << "intersecting with leftCCD " << std::endl;
00205   measv[2][0] = getMeasFromInters(Xline_xhair, leftCCD, line_dowel21_perp );
00206   measv[2][1] = getMeasFromInters(Yline_xhair, leftCCD, line_dowel21_perp );
00207   if(ALIUtils::debug >= 4) std::cout << "intersecting with rightCCD " << std::endl;
00208   measv[3][0] = getMeasFromInters(Xline_xhair, rightCCD, line_dowel21_perp );
00209   measv[3][1] = getMeasFromInters(Yline_xhair, rightCCD, line_dowel21_perp );
00210 
00211   /* Both X and Y axis of the x-laser are intersected with each CCD and it checks that one of 
00212   the two is inside the CCD(less than CCDlength/2). If no one is inside, it will give an 
00213   exception. If both are inside (a strange case where, for example, the laser centre is very 
00214   close and forms 45 degrees with the CCD) it will also make an exception (if you prefer, I can
00215   put a warning saying that you have two measurements, but I guess this should never happen for
00216   you, so I better give an exception and you don't risk to overpass this warning).
00217 
00218   Then it is mandatory that you put the CCDlength parameter (I could put a default one if 
00219   you prefer). 
00220   
00221 
00222   ALIbool measInCCD[2];
00223   uint ii,jj;
00224   for( ii = 0; ii < 4; ii++ ) {
00225     for( jj = 0; jj < 2; jj++ ) {
00226       measInCCD[jj] =  fabs( measv[ii][jj] ) < CCDlength/2;
00227     }
00228     if (ALIUtils::debug >= 2) std::cout << "$@$@ CHECK CCD = " << ii << std::endl; 
00229     if( measInCCD[0] && measInCCD[1] ){
00230       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;
00231       exit(1);
00232     } else if( !(measInCCD[0] || measInCCD[1]) ){
00233       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;
00234       exit(1);
00235     } else {
00236       measInCCD[0] ?  meas.setValueSimulated( ii, measv[ii][0] ) :
00237         meas.setValueSimulated( ii, measv[ii][1] );
00238     }
00239   }
00240   */
00241 
00242   ALIstring measNames[4] ={"up","down","left","right"};
00243   ALIbool laserLine; 
00244   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; 
00245      
00246   uint ii;
00247   for( ii = 0; ii < 4; ii++ ) {
00248     if (ALIUtils::debug >= 2) std::cout << "\tmeas CCD " << measNames[ii] << " ii=(" << ii << ") \t Values: "
00249      //<< (fabs( measv[ii][0] ) <  fabs( measv[ii][1]) 
00250        << " " << fabs( measv[ii][0] ) << " " <<  fabs( measv[ii][1] ) << "  isnan() = " <<
00251        isnan(measv[ii][1]) << std::endl;
00252 
00253     if( meas.xlaserLine( ii ) != -1 ) { 
00254       laserLine = ALIbool( meas.xlaserLine( ii ) );
00255     } else { 
00256     
00257     //  Problem here !!!
00258     //
00259     //  Somehow measv[][1] can occasionally return value of 'nan'
00260     //  which is interpretted as less than any real value
00261     //
00262       if(isnan(measv[ii][1]) != 0){
00263                 measv[ii][1] = 1e99;
00264                 if (ALIUtils::debug >= 2) std::cout << "  --> Swapping for " << measv[ii][1] << "(inf)" << std::endl;
00265                                   }
00266                                    
00267       laserLine = fabs( measv[ii][0] ) <  fabs( measv[ii][1] );
00268       
00269       meas.setXlaserLine( ii, int(laserLine) );
00270     }
00271     laserLine ? meas.setValueSimulated( ii, measv[ii][0] ) 
00272       : meas.setValueSimulated( ii, measv[ii][1] );
00273   }
00274   
00275     if (ALIUtils::debug >= 2) std::cout << std::endl;   //Keep format of debug output reasonable
00276 
00277   // try to identify pathological cases: up and down CCD are intersected by the same 
00278   // laser line (say X) and the same for the left and right CCD
00279 
00280   if(ALIUtils::debug >= 2) std::cout << "***** OptOCOPS::makeMeasurement  - identify pathological cases U and D intersected by same line" <<std::endl;
00281   ALIbool xlaserDir[4];
00282   for( ii = 0; ii < 4; ii++ ) {
00283     //    xlaserDir[ii] = fabs( measv[ii][0] ) <  fabs( measv[ii][1] );
00284     xlaserDir[ii] = ALIbool( meas.xlaserLine( ii ) ); 
00285   }
00286   if( xlaserDir[0] ^ xlaserDir[1] ) {
00287     std::cerr << "!!EXITING up and down CCDs intersected by different x-laser line " << xlaserDir[0] << " " <<  xlaserDir[1] << std::endl;
00288     exit(1);
00289   }
00290   if( xlaserDir[2] ^ xlaserDir[3] ) {
00291     std::cerr << "!!EXITING right and left CCDs intersected by different x-laser line " << xlaserDir[0] << " " <<  xlaserDir[1] << std::endl;
00292     exit(1);
00293   }
00294 
00295   if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::makeMeasurement - now output sim values" << std::endl;
00296 
00297   if (ALIUtils::debug >= 1) {
00298     ALIstring chrg = "";
00299     std::cout << "REAL value: " << chrg <<"U: " << 1000*meas.value()[0] << chrg 
00300          << " D: " << 1000*meas.value()[1] 
00301          << " L: " << 1000*meas.value()[2] 
00302          << " R: " << 1000*meas.value()[3]  
00303          << " (mm)  " << (this)->name() << std::endl;
00304     ALIdouble detU =  1000*meas.valueSimulated(0); if(fabs(detU) <= 1.e-9 ) detU = 0.;
00305     ALIdouble detD =  1000*meas.valueSimulated(1); if(fabs(detD) <= 1.e-9 ) detD = 0.;
00306     ALIdouble detL =  1000*meas.valueSimulated(2); if(fabs(detL) <= 1.e-9 ) detL = 0.;
00307     ALIdouble detR =  1000*meas.valueSimulated(3); if(fabs(detR) <= 1.e-9 ) detR = 0.;
00308     std::cout << "SIMU value: " << chrg << "U: "
00309       // << setprecision(3) << setw(4)
00310          << detU
00311          << chrg << " D: " << detD
00312          << chrg << " L: " << detL
00313          << chrg << " R: " << detR
00314          << " (mm)  " << (this)->name() << std::endl;
00315   }
00316   
00317 
00318 }
00319 
00320 
00321 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00322 //@@ Fast simulation of Light Ray traverses
00323 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00324 void OptOCOPS::fastTraversesLightRay( LightRay& lightray )
00325 {
00326 
00327   if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::fastTraversesLightRay" <<std::endl;
00328   if (ALIUtils::debug >= 2) std::cout << "LR: FAST TRAVERSES COPS  " << name() << std::endl;
00329 
00330   //---------- Get intersection 
00331   CLHEP::Hep3Vector ZAxis(0.,0,1.);
00332   CLHEP::HepRotation rmt = rmGlob();
00333   ZAxis = rmt * ZAxis;
00334   lightray.intersect( ALIPlane(centreGlob(), ZAxis) );
00335   CLHEP::Hep3Vector inters = lightray.point();
00336   lightray.setPoint( inters );
00337 
00338   if (ALIUtils::debug >= 2) {
00339     lightray.dumpData(" after COPS ");
00340   }
00341 
00342 }     
00343 
00344 
00345 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00346 ALIdouble* OptOCOPS::convertPointToLocalCoordinates( const CLHEP::Hep3Vector& point)
00347 {
00348   if(ALIUtils::debug >= 1) std::cout << "***** OptOCOPS::convertPointToLocalCoordinates" <<std::endl;
00349   ALIdouble interslc[2];
00350 
00351   //----- X value
00352   CLHEP::HepRotation rmt = rmGlob();
00353   CLHEP::Hep3Vector XAxism(1.,0.,0.);
00354   XAxism*=rmt;
00355   if( ALIUtils::debug >= 5) ALIUtils::dump3v( (this)->centreGlob(),  "centre glob sensor2D" );
00356   if( ALIUtils::debug >= 5) ALIUtils::dumprm( rmt,  "rotation matrix sensor2D" );
00357   //t  ALIUtils::dump3v(point - (this)->centreGlob() , "inters - (this)->centreGlob()");
00358   //t  ALIUtils::dump3v(XAxism , "XAxism");
00359   interslc[0] = (point - (this)->centreGlob() ) * XAxism;
00360   
00361   //----- Y value
00362   CLHEP::Hep3Vector YAxism(0.,1.,0.);
00363   YAxism*=rmt;
00364   //t  ALIUtils::dump3v(YAxism , "YAxism");
00365   interslc[1] = (point - (this)->centreGlob() ) * YAxism;
00366 
00367   if( ALIUtils::debug >=5 ) {
00368     std::cout << " intersection in local coordinates: X= " << interslc[0] << "  Y= " << interslc[1] << std::endl;
00369   }
00370   return interslc;
00371 }
00372 
00373 
00374 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00375 ALIdouble OptOCOPS::getMeasFromInters( ALILine& line_xhair, ALILine& ccd, CLHEP::Hep3Vector& cops_line )
00376 {
00377 
00378   if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::getMeasFromInters" <<std::endl;
00379   CLHEP::Hep3Vector inters = line_xhair.intersect( ccd, 0 ) - ccd.pt(); 
00380   ALIdouble sign = inters*ccd.vec(); 
00381   if( sign != 0 ){
00382     sign = fabs(sign)/sign;
00383     //    std::cout << "  @@@@@@@@@@@@ sign = " << sign << std::endl;
00384     //   ALIUtils::dump3v(inters, " intersection " );
00385     //   ALIUtils::dump3v( ccd.vec(), " cops_line ");
00386   } //sign can be zero only if inters is 0, because they are parallel
00387   return sign*inters.mag();
00388 }
00389 
00390 
00391 #ifdef COCOA_VIS
00392 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00393 void OptOCOPS::fillVRML()
00394 {
00395  
00396   ALIVRMLMgr& vrmlmgr = ALIVRMLMgr::getInstance();
00397 
00398   //---------- Position four CCDs (locally, i.e. with respect to centre)
00399   //----- Get first CCD length, that will be used to give a default placement to the CCDs
00400   ALIdouble CCDlength = findExtraEntryValue("CCDlength");
00401   if( CCDlength == 0. ) CCDlength = 2048*14 * 1.E-6; // (in meters, the default unit)
00402   //Original CCDdim value was 10; .05 works well
00403 //  ALIdouble CCDdim = .040;
00404     ALIdouble CCDdim = 2048*14 * 1.E-6;
00405   //Original was divided by 10
00406 //  ALIdouble CCDwidth = CCDdim/10.;
00407   ALIdouble CCDwidth = .005;
00408 
00409   if(ALIUtils::debug >= 4) std::cout << " ccds0 " << ccds[0] << "ccds1 " << ccds[1] << std::endl;
00410   ALIColour colup( 1.,0.,0., 0.);
00411   ALIColour coldown( 0.,1.,0., 0.);
00412   ALIColour colleft( 0.,0.,1., 0.);
00413   ALIColour colright( 0.,1.,1., 0.);
00414   //----- Upper CCD (leftmost point & direction dowel1-dowel2)
00415   //original ccdsize was 50; 1 works ok
00416   ALIdouble ccdsize = 1.;
00417 
00418   // VRML objects are drawn 'after rotation into system'; so to make all CCDs look the
00419   //  same in the drawing, CCDwidth parameters must be the same
00420   // x, y , z , color
00421 
00422   //----- Upper CCD 
00423   vrmlmgr.AddBoxDisplaced( *this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[0].pt()+0.5*CCDlength*ccds[0].vec()), &colup);
00424   //----- Lower CCD (leftmost point & direction dowel2-dowel1)
00425   vrmlmgr.AddBoxDisplaced( *this, CCDdim, CCDwidth, CCDwidth, ccdsize*(ccds[1].pt()+0.5*CCDlength*ccds[1].vec()), &coldown );
00426   //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
00427   vrmlmgr.AddBoxDisplaced( *this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[2].pt()+0.5*CCDlength*ccds[2].vec()), &colleft );
00428   //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
00429   vrmlmgr.AddBoxDisplaced( *this, CCDwidth, CCDdim, CCDwidth, ccdsize*(ccds[3].pt()+0.5*CCDlength*ccds[3].vec()), &colright );
00430 
00431   vrmlmgr.SendReferenceFrame( *this, CCDdim); 
00432   vrmlmgr.SendName( *this, 0.01 );
00433 
00434 }
00435 
00436 
00437 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00438 void OptOCOPS::fillIguana()
00439 {
00440   //---------- Position four CCDs (locally, i.e. with respect to centre)
00441   //----- Get first CCD length, that will be used to give a default placement to the CCDs
00442   ALIdouble CCDlength;
00443   ALIbool pexists = findExtraEntryValueIfExists("CCDlength",CCDlength);
00444   if( !pexists ) CCDlength = 2048*14 * 1.E-6;
00445   ALIdouble CCDdim = 2048*14 * 1.E-6;
00446   ALIdouble CCDwidth = .005;
00447 
00448   if(ALIUtils::debug >= 4) std::cout << " ccds0 " << ccds[0] << "ccds1 " << ccds[1] << std::endl;
00449   ALIColour colup( 0.2,1.,0., 0.);
00450   ALIColour coldown( 0.3,1.,0., 0.);
00451   ALIColour colleft( 0.4,1.,0., 0.);
00452   ALIColour colright( 0.5,1.,0., 0.);
00453   //----- Upper CCD (leftmost point & direction dowel1-dowel2)
00454   //original ccdsize was 50; 1 works ok
00455   ALIdouble ccdsize = 1;
00456 
00457   // VRML objects are drawn 'after rotation into system'; so to make all CCDs look the
00458   //  same in the drawing, CCDwidth parameters must be the same
00459   // x, y , z , color
00460 
00461   std::vector<ALIdouble> spar;
00462   spar.push_back(CCDdim);
00463   spar.push_back(CCDwidth);
00464   spar.push_back(CCDwidth);
00465   //----- Upper CCD 
00466  IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar, &colup, ccdsize*(ccds[0].pt()+0.5*CCDlength*ccds[0].vec()));
00467   //----- Lower CCD (leftmost point & direction dowel2-dowel1)
00468  IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar, &coldown, ccdsize*(ccds[1].pt()+0.5*CCDlength*ccds[1].vec()) );
00469   //----- left CCD (uppermost point & direction perpendicular to dowel2-dowel1)
00470   std::vector<ALIdouble> spar2;
00471   spar2.push_back(CCDwidth);
00472   spar2.push_back(CCDdim);
00473   spar2.push_back(CCDwidth);
00474   IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar2, &colleft, ccdsize*(ccds[2].pt()+0.5*CCDlength*ccds[2].vec()));
00475   //----- right CCD (uppermost point & direction perpendicular to dowel2-dowel1)
00476   IgCocoaFileMgr::getInstance().addSolid( *this, "BOX", spar2, &colright, ccdsize*(ccds[3].pt()+0.5*CCDlength*ccds[3].vec()));
00477 
00478 }
00479 #endif
00480 
00481 
00482 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00483 void OptOCOPS::constructSolidShape()
00484 {
00485   ALIdouble go;
00486   GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00487   gomgr->getGlobalOptionValue("VisScale", go );
00488 
00489   theSolidShape = new CocoaSolidShapeBox( "Box", go*5.*cm/m, go*5.*cm/m, go*1.*cm/m ); //COCOA internal units are meters
00490 }

Generated on Tue Jun 9 17:23:39 2009 for CMSSW by  doxygen 1.5.4