CMS 3D CMS Logo

ALILine Class Reference

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

List of all members.

Public Member Functions

 ALILine (const Hep3Vector &point, const Hep3Vector &direction)
 ALILine ()
Hep3Vector intersect (const ALIPlane &plane, bool notParallel=1)
Hep3Vector intersect (const ALILine &l2, bool notParallel=0)
const Hep3Vector & pt () const
const Hep3Vector & vec () const
 ~ALILine ()

Private Attributes

Hep3Vector _direction
Hep3Vector _point

Friends

std::ostream & operator<< (std::ostream &, const ALILine &li)


Detailed Description

Definition at line 16 of file ALILine.h.


Constructor & Destructor Documentation

ALILine::ALILine (  )  [inline]

Definition at line 19 of file ALILine.h.

00019 { };  

ALILine::~ALILine (  )  [inline]

Definition at line 20 of file ALILine.h.

00020 { };  

ALILine::ALILine ( const Hep3Vector &  point,
const Hep3Vector &  direction 
)


Member Function Documentation

CLHEP::Hep3Vector ALILine::intersect ( const ALIPlane plane,
bool  notParallel = 1 
)

Definition at line 199 of file ALILine.cc.

References _direction, _point, TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), lat::endl(), cmsRelvalreport::exit, ALIPlane::normal(), and ALIPlane::point().

00200 {
00201   if(ALIUtils::debug >= 5) std::cout << "***** ALILine::intersect WITH PLANE" << std::endl;
00202   if(ALIUtils::debug >= 4) {
00203     ALIUtils::dump3v( plane.point(), "plane point"); 
00204     ALIUtils::dump3v( plane.normal(), "plane normal"); 
00205   }
00206   
00207   //---------- Check that they intersect
00208   if( fabs( plane.normal()*_direction ) < 1.E-10 ) {
00209     std::cerr << " !!!! INTERSECTION NOT POSSIBLE: LightRay is perpendicular to plane " << std::endl;
00210     std::cerr << " plane.normal()*direction() = " << plane.normal()*_direction << std::endl;
00211     ALIUtils::dump3v( _direction, "LightRay direction ");
00212     ALIUtils::dump3v( plane.normal(), "plane normal ");
00213     exit(1);
00214   }
00215 
00216   //---------- Get intersection point between LightRay and plane
00217   //-   if(ALIUtils::debug >= 4) std::cout << " ALILine::intersect WITH LightRay" << std::endl;
00218         
00219   CLHEP::Hep3Vector vtemp = plane.point() - _point;
00220         if(ALIUtils::debug >= 4) ALIUtils::dump3v( vtemp, "n_r = point  - point_plane"); 
00221         
00222   ALIdouble dtemp = _direction * plane.normal();
00223         if(ALIUtils::debug >= 4) std::cout << " lightray* plate normal" << dtemp << std::endl;
00224         
00225   if ( dtemp != 0. ) {
00226       dtemp = (vtemp * plane.normal()) / dtemp;
00227       if(ALIUtils::debug >= 4)  std::cout << " n_r*plate normal (dtemp) : " << dtemp << std::endl;
00228       if(ALIUtils::debug >= 4)  std::cout << " Old vtemp : " << vtemp << std::endl;
00229         } else std::cerr << "!!! LightRay: Intersect With Plane: plane and light ray parallel: no intersection" << std::endl;     
00230                 
00231   vtemp = _direction * dtemp;
00232         if(ALIUtils::debug >= 4) ALIUtils::dump3v( vtemp, "n_r scaled (vtemp) : "); 
00233         if(ALIUtils::debug >= 4) ALIUtils::dump3v( dtemp, "dtemp analog to vtemp : "); 
00234     
00235   CLHEP::Hep3Vector inters = vtemp + _point;
00236         if(ALIUtils::debug >= 4) ALIUtils::dump3v( inters, "intersection point = vtemp + _point"); 
00237         if(ALIUtils::debug >= 4) ALIUtils::dump3v( vtemp, "vtemp =  "); 
00238         if(ALIUtils::debug >= 4) ALIUtils::dump3v( _point, "_point =  "); 
00239 
00240   return inters;
00241 }

CLHEP::Hep3Vector ALILine::intersect ( const ALILine l2,
bool  notParallel = 0 
)

Definition at line 28 of file ALILine.cc.

References ALI_DBL_MAX, TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, ALIUtils::dump3v(), e, lat::endl(), cmsRelvalreport::exit, pt(), vec(), x, and z.

Referenced by OptODistancemeter::makeMeasurement().

00029 { 
00030   
00031   if(ALIUtils::debug >= 3 ){
00032     std::cout << "***** ALILine::intersect (constructor) two lines: " << std::endl 
00033                         << " line1: " << *this << std::endl
00034                         << " line2: " << l2 << std::endl;
00035   }
00036   CLHEP::Hep3Vector inters; 
00037   //--- Check that they are not parallel 
00038   double acosvec = vec().dot(l2.vec()) / vec().mag() / l2.vec().mag();
00039   
00040   if(ALIUtils::debug >= 5 ){
00041   
00042         std::cout << "\t Determination of acosvec = vec().dot(l2.vec()) / vec().mag() / l2.vec().mag() "
00043         << std::endl << std::endl;
00044 //      std::cout << "\t vec().dot = " << vec().dot << std::endl; 
00045         std::cout << "\t l2.vec() = " << l2.vec() << std::endl;
00046 
00047         std::cout << "\t vec().mag() = " << vec().mag() << std::endl;
00048         std::cout << "\t l2.vec().mag() = " << l2.vec().mag() << std::endl << std::endl;
00049   
00050                         }
00051   
00052   if(ALIUtils::debug >= 5 ) std::cout << " acosvec = " << acosvec << std::endl;
00053   if( 1 - fabs(acosvec) < 1E-8 ) {
00054     if( notParallel ) {
00055       std::cerr << " !!!EXITING ALILine::intersect: two lines are parallel"
00056         << std::endl;
00057       exit(1);
00058     } else {
00059       if(ALIUtils::debug >= 5 ) std::cout << " !!! ALILine::intersect: two lines are parallel (no errors)" << std::endl;
00060       //gcc2952      inters = CLHEP::Hep3Vector( DBL_MAX, DBL_MAX, DBL_MAX );
00061       inters = CLHEP::Hep3Vector( ALI_DBL_MAX, ALI_DBL_MAX, ALI_DBL_MAX );
00062     }
00063   } else { 
00064 
00065     
00066  //     ****************************************************************        //  
00067  //     ****************************************************************        //
00068  //     ****************************************************************        //
00069  //                          Determination of Fact                              //
00070  //                                                                             //
00071  //     Problem :  3D quantity was determined by doing calculation with         //
00072  //                the 2D projections of the std::vectors.  It is possible              //
00073  //                for projection in a particular plane to be 0                 //
00074  //                                                                             //
00075  //     Solution : Test for problem and redo calculation if necessary by        //
00076  //                projecting into a different plane                            //
00077  //     ****************************************************************        //  
00078  //     ****************************************************************        //
00079  //     ****************************************************************        //
00080   
00081  
00082         
00083     ALIdouble fact = ( vec().y() * l2.pt().x() - vec().x() * l2.pt().y()
00084        - vec().y() * pt().x() + vec().x() * pt().y() )
00085       / ( vec().x() * l2.vec().y() - vec().y() * l2.vec().x() );
00086 
00087 
00088 
00089   if(ALIUtils::debug >= 2 ){
00090        std::cout << std::endl << std::endl << "*** START CALC OF FACT ***" << std::endl;
00091        std::cout << "    ==================" << std::endl << std::endl;            
00092        std::cout << "*** Determination of fact ->";      
00093        std::cout << "\t fact = (" << vec().y() * l2.pt().x() - vec().x() * l2.pt().y()
00094        - vec().y() * pt().x() + vec().x() * pt().y() << "/";
00095        
00096        std::cout <<  vec().x() * l2.vec().y() - vec().y() * l2.vec().x() << ") = " << fact << std::endl;
00097  
00098                                 }
00099         
00100   //    ALIdouble old_fact = fact;
00101     ALIdouble old_fact_denominator = vec().x() * l2.vec().y() - vec().y() * l2.vec().x();                               
00102     //-    ALIdouble old_fact2 = 0.;
00103     ALIdouble old_fact_denominator2 = 999;
00104                
00105 
00106    if(fabs(fact) > 1e8 || fabs(old_fact_denominator) < 1.e-10)
00107     {
00108       
00109       // do calculation by rotating 90 degrees into xy plane
00110       // Z-> X
00111       // X-> -Z
00112       
00113        if(ALIUtils::debug >= 2 && fabs(old_fact_denominator) < 1.e-10) std::cout << " ** Problem:  old_fact_denominator -> " << old_fact_denominator << std::endl;
00114        
00115        if(ALIUtils::debug >= 2 && fabs(fact) > 1e8) std::cout << " ** Problem: fact -> " << fact << std::endl;
00116        
00117        if(ALIUtils::debug >= 2 && (vec().x() * l2.vec().y() - vec().y() * l2.vec().x()) == 0) std::cout << " ** Division by 0 !!! " << std::endl;       
00118        if(ALIUtils::debug >= 2 ) std::cout << " ** Must rotate to yz plane for calculation (X-> Z) ";
00119  
00120     
00121         fact = ( -1 * vec().y() * l2.pt().z() + vec().z() * l2.pt().y()
00122         + vec().y() * pt().z() - vec().z() * pt().y() )
00123         / ( -1*vec().z() * l2.vec().y() + vec().y() * l2.vec().z() );
00124       
00125         if(ALIUtils::debug >= 2 ) std::cout << "\t -- 1st Recalculation of fact in yz plane = " << fact << std::endl;  
00126 
00127         old_fact_denominator2 = -1*vec().z() * l2.vec().y() + vec().y() * l2.vec().z();
00128 
00129         
00130         if(fabs(-1*vec().z() * l2.vec().y() + vec().y() * l2.vec().z())< 1.e-10)
00131         {
00132           
00133           if(ALIUtils::debug >= 2 ) std::cout << " ** Must rotate to xz plane for calculation (Y-> -Z) ";
00134             if(ALIUtils::debug >= 2 && fabs(old_fact_denominator2) < 1.e-10) std::cout << " ** Problem: old_fact_denominator2 -> " << old_fact_denominator2 << std::endl;       
00135           //-              if(ALIUtils::debug >= 2 && fabs(old_fact2) > 1.e8) std::cout << " ** Problem: old_fact2 -> " << old_fact2 << std::endl;
00136           
00137           fact = ( -1*vec().z() * l2.pt().x() + vec().x() * l2.pt().z()
00138                    + vec().z() * pt().x() - vec().x() * pt().z() )
00139             / ( -1*vec().x() * l2.vec().z() + vec().z() * l2.vec().x() );
00140           
00141            if(ALIUtils::debug >= 2 ) std::cout << "\t -- 2nd Recalculation of fact in xz plane = " << fact << std::endl;  
00142 
00143 
00144         }
00145         else {
00146           if(ALIUtils::debug >= 2 ) std::cout << "*!* 2nd calculation sufficient" << std::endl;
00147         }
00148        
00149     }    
00150     else
00151     {
00152 
00153      if(ALIUtils::debug >= 2 ) std::cout << "*!* Standard calculation - things are fine" << std::endl;
00154      if(ALIUtils::debug >= 2 ) std::cout << "\t ----> fact = ( " << vec().y() * l2.pt().x() - vec().x() *
00155      l2.pt().y() - vec().y() * pt().x() + vec().x() * pt().y() << " / " << vec().x() * l2.vec().y() 
00156      - vec().y()* l2.vec().x() << " ) = " << fact << std::endl;    
00157     }
00158 
00159           
00160           
00161  //     ****************************************************************        //  
00162  //     ****************************************************************        //
00163  //     ****************************************************************        //
00164  //                             Finished With Fact                                      //
00165  //     ****************************************************************        //  
00166  //     ****************************************************************        //
00167  //     ****************************************************************        //        
00168           
00169           
00170      inters =  l2.pt() + fact * l2.vec();
00171      
00172      if(ALIUtils::debug >= 2 ){           
00173         std::cout << "Determination of intersection = l2.pt() + fact * l2.vec()" << std::endl << std::endl;
00174         ALIUtils::dump3v( l2.pt(), "\t --> l2.pt() = ");
00175         std::cout << "\t --> fact = " << fact << std::endl;
00176         std::cout << "\t --> l2.vec() = " << l2.vec() << std::endl;
00177         ALIUtils::dump3v( inters, "***\t --> ALILine::intersection at: ");
00178      }
00179 
00180   }
00181  
00182   return inters;
00183  
00184 }

const Hep3Vector& ALILine::pt (  )  const [inline]

Definition at line 27 of file ALILine.h.

References _point.

Referenced by intersect().

00027 {return _point;};

const Hep3Vector& ALILine::vec (  )  const [inline]

Definition at line 28 of file ALILine.h.

References _direction.

Referenced by intersect().

00028 {return _direction;};


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const ALILine li 
) [friend]

Definition at line 186 of file ALILine.cc.

00187 {
00188   out << " ALILine point " << li._point << std::endl;
00189   out << " ALILine direc " << li._direction;
00190 
00191   return out;  
00192 }


Member Data Documentation

Hep3Vector ALILine::_direction [private]

Definition at line 34 of file ALILine.h.

Referenced by intersect(), operator<<(), and vec().

Hep3Vector ALILine::_point [private]

Definition at line 33 of file ALILine.h.

Referenced by intersect(), operator<<(), and pt().


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