CMS 3D CMS Logo

OptOCOPS Class Reference

#include <Alignment/CocoaModel/interface/OptOCOPS.h>

Inheritance diagram for OptOCOPS:

OpticalObject

List of all members.

Public Member Functions

void constructSolidShape ()
ALIdoubleconvertPointToLocalCoordinates (const Hep3Vector &point)
virtual void defaultBehaviour (LightRay &lightray, Measurement &meas)
virtual void fastTraversesLightRay (LightRay &lightray)
virtual void makeMeasurement (LightRay &lightray, Measurement &meas)
 OptOCOPS (OpticalObject *parent, const ALIstring &type, const ALIstring &name, const ALIbool copy_data)
 OptOCOPS ()
 ~OptOCOPS ()

Private Member Functions

ALIdouble getMeasFromInters (ALILine &line_xhair, ALILine &ccd, Hep3Vector &cops_line)

Private Attributes

ALILine ccds [4]
DeviationsFromFileSensor2DdeviFromFile
ALIbool fdevi_from_file


Detailed Description

Definition at line 20 of file OptOCOPS.h.


Constructor & Destructor Documentation

OptOCOPS::OptOCOPS (  )  [inline]

Definition at line 25 of file OptOCOPS.h.

00025 { };

OptOCOPS::OptOCOPS ( OpticalObject parent,
const ALIstring type,
const ALIstring name,
const ALIbool  copy_data 
) [inline]

Definition at line 26 of file OptOCOPS.h.

00026                                                                                                          : 
00027   OpticalObject( parent, type, name, copy_data), fdevi_from_file(0){ };

OptOCOPS::~OptOCOPS (  )  [inline]

Definition at line 28 of file OptOCOPS.h.

00028 { };


Member Function Documentation

void OptOCOPS::constructSolidShape (  )  [virtual]

Reimplemented from OpticalObject.

Definition at line 483 of file OptOCOPS.cc.

References GlobalOptionMgr::getGlobalOptionValue(), GlobalOptionMgr::getInstance(), m, and OpticalObject::theSolidShape.

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 }

ALIdouble* OptOCOPS::convertPointToLocalCoordinates ( const Hep3Vector &  point  ) 

void OptOCOPS::defaultBehaviour ( LightRay lightray,
Measurement meas 
) [virtual]

Reimplemented from OpticalObject.

Definition at line 28 of file OptOCOPS.cc.

References GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, lat::endl(), and makeMeasurement().

00029 {
00030   if(ALIUtils::debug >= 5) std::cout << "***** OptOCOPS::defaultBehaviour" <<std::endl;
00031   makeMeasurement( lightray, meas);
00032 }

void OptOCOPS::fastTraversesLightRay ( LightRay lightray  )  [virtual]

Reimplemented from OpticalObject.

Definition at line 324 of file OptOCOPS.cc.

References OpticalObject::centreGlob(), GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, LightRay::dumpData(), lat::endl(), LightRay::intersect(), OpticalObject::name(), LightRay::point(), OpticalObject::rmGlob(), rmt, and LightRay::setPoint().

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 }     

ALIdouble OptOCOPS::getMeasFromInters ( ALILine line_xhair,
ALILine ccd,
Hep3Vector &  cops_line 
) [private]

Referenced by makeMeasurement().

void OptOCOPS::makeMeasurement ( LightRay lightray,
Measurement meas 
) [virtual]

Reimplemented from OpticalObject.

Definition at line 38 of file OptOCOPS.cc.

References ccds, OpticalObject::centreGlob(), TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), e, lat::endl(), cmsRelvalreport::exit, OpticalObject::findExtraEntryValue(), OpticalObject::findExtraEntryValueIfExists(), getMeasFromInters(), LightRay::intersect(), edm::isnan(), OpticalObject::name(), Measurement::OptOList(), PI, LightRay::point(), ALIPlane::project(), OpticalObject::rmGlob(), rmt, Measurement::setValueSimulated(), Measurement::setXlaserLine(), Measurement::value(), Measurement::valueSimulated(), and Measurement::xlaserLine().

Referenced by defaultBehaviour().

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 }


Member Data Documentation

ALILine OptOCOPS::ccds[4] [private]

Definition at line 51 of file OptOCOPS.h.

Referenced by makeMeasurement().

DeviationsFromFileSensor2D* OptOCOPS::deviFromFile [private]

Definition at line 49 of file OptOCOPS.h.

ALIbool OptOCOPS::fdevi_from_file [private]

Definition at line 50 of file OptOCOPS.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:29:18 2009 for CMSSW by  doxygen 1.5.4