]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/src/AliL3ConfMapFit.cxx
Introduction of the online monitoring code into the alimdc package. Fixed some memory...
[u/mrichter/AliRoot.git] / HLT / src / AliL3ConfMapFit.cxx
index a7381632377910d194bac9a3479f6e2d34307fb3..a1f8d0290a2857b7747a9d102acadaa37b57d4e3 100644 (file)
@@ -1,35 +1,39 @@
-// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
-//*-- Copyright &copy ASV 
+// @(#) $Id$
 
-#include <math.h>
+// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
+//*-- Copyright &copy ALICE HLT Group
 
+#include "AliL3StandardIncludes.h"
+#include "AliL3RootTypes.h"
 #include "AliL3Logging.h"
-#include "AliL3ConfMapFit.h"
 #include "AliL3Vertex.h"
 #include "AliL3ConfMapTrack.h"
 #include "AliL3ConfMapPoint.h"
+#include "AliL3Transform.h"
+#include "AliL3ConfMapFit.h"
 
+/** \class AliL3ConfMapFit
+<pre>
 //_____________________________________________________________
 // AliL3ConfMapFit
 //
 // Fit class for conformal mapping tracking
+</pre>
+*/
 
 ClassImp(AliL3ConfMapFit)
 
-Double_t AliL3ConfMapFit::pi=3.14159265358979323846;
 
 AliL3ConfMapFit::AliL3ConfMapFit(AliL3ConfMapTrack *track,AliL3Vertex *vertex)
 {
   //constructor
   fTrack = track;
   fVertex = vertex;
-  BFACT = 0.0029980;
-  bField = 0.2;
-  
 }
 
 Int_t AliL3ConfMapFit::FitHelix()
 {
+  //fit the helix
   if(FitCircle())
     {
       LOG(AliL3Log::kError,"AliL3ConfMapFit::FitHelix","TrackFit")<<AliL3Log::kDec<<
@@ -69,7 +73,7 @@ Int_t AliL3ConfMapFit::FitCircle()
   for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit())
     {
       co++;
-      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->currentHit;
+      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->GetCurrentHit();
       cHit->SetXYWeight( 1./ (Double_t)(cHit->GetXerr()*cHit->GetXerr() + cHit->GetYerr()*cHit->GetYerr()) );
       wsum      += cHit->GetXYWeight() ;
       xav       += cHit->GetXYWeight() * cHit->GetX() ;
@@ -98,7 +102,7 @@ Int_t AliL3ConfMapFit::FitCircle()
   for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit())
     { 
       //AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint *)hits->At(hit_counter);
-      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->currentHit;
+      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->GetCurrentHit();
       xi        = cHit->GetX() - xav ;
       yi        = cHit->GetY() - yav ;
       xxav     += xi * xi * cHit->GetXYWeight() ;
@@ -182,7 +186,7 @@ Int_t AliL3ConfMapFit::FitCircle()
   for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit())  
     { 
       //AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)hits->At(hit_counter);  
-      AliL3ConfMapPoint* cHit = (AliL3ConfMapPoint*)fTrack->currentHit;
+      AliL3ConfMapPoint* cHit = (AliL3ConfMapPoint*)fTrack->GetCurrentHit();
 
       xold = cHit->GetX() - xav ;
       yold = cHit->GetY() - yav ;
@@ -339,41 +343,26 @@ Int_t AliL3ConfMapFit::FitCircle()
 
   fTrack->SetCharge(q);
   
-//
-//    Get other track parameters
-//
-  Double_t x0, y0,phi0,r0,psi,pt ;
-  if ( fTrack->ComesFromMainVertex() == true ) 
-    {
-      //flag = 1 ; // primary track flag
-      x0   = fVertex->GetX() ;
-      y0   = fVertex->GetY() ;
-      phi0 = fVertex->GetPhi() ;
-      r0   = fVertex->GetR() ;
-      fTrack->SetPhi0(phi0);
-      fTrack->SetR0(r0);
-    } 
-  else 
-    {
-      //AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)hits->Last();
-      AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)fTrack->lastHit;
-      //flag =  0 ; // primary track flag
-      x0   =  lHit->GetX()  ;
-      y0   =  lHit->GetY()  ;
-      phi0 =  atan2(lHit->GetY(),lHit->GetX());
-      if ( phi0 < 0 ) phi0 += 2*pi;
-      r0   =  sqrt ( lHit->GetX() * lHit->GetX() + lHit->GetY() * lHit->GetY() )  ;
-      fTrack->SetPhi0(phi0);
-      fTrack->SetR0(r0);
-    }
-  //
+  
+  //Set the first point on the track to the space point coordinates of the innermost track
+  //This will be updated to lie on the fit later on (AliL3Track::UpdateToFirstPoint).
+  Double_t x0,y0,psi,pt ;
+  AliL3ConfMapPoint *lHit = (AliL3ConfMapPoint*)fTrack->GetLastHit();
+  x0 = lHit->GetX();
+  y0 = lHit->GetY();
+  fTrack->SetFirstPoint(x0,y0,0); //Z-value is set in FitLine
+
   psi  = (Double_t)atan2(bcent-y0,acent-x0) ;
-  psi  = psi + q * 0.5F * pi ;
-  if ( psi < 0 ) psi = psi + 2*pi;
+  psi  = psi + q * AliL3Transform::PiHalf();
+  if ( psi < 0 ) psi = psi + AliL3Transform::TwoPi();
+  pt   = (Double_t)(AliL3Transform::GetBFieldValue() * radius ) ;
   
-  pt   = (Double_t)(BFACT * bField * radius ) ;
+  //Update the track parameters with the parameters from this fit:
   fTrack->SetPsi(psi);
   fTrack->SetPt(pt);
+  fTrack->SetRadius(radius);
+  fTrack->SetCenterX(acent);
+  fTrack->SetCenterY(bcent);
 
   //
 //    Get errors from fast fit
@@ -401,20 +390,20 @@ Int_t AliL3ConfMapFit::FitLine ( )
   //find sum , sums ,sumz, sumss 
   // 
   Double_t dx, dy ;
-  Double_t radius = (Double_t)(fTrack->GetPt() / ( BFACT * bField ) ) ;
+  Double_t radius = (Double_t)(fTrack->GetPt() / AliL3Transform::GetBFieldValue() ) ;
 
   //TObjArray *hits = fTrack->GetHits();
   //Int_t num_of_hits = fTrack->GetNumberOfPoints();
 
-  if ( fTrack->ComesFromMainVertex() == true ) 
+  if (0)// fTrack->ComesFromMainVertex() == true ) 
     {
-      dx = ((AliL3ConfMapPoint*)fTrack->firstHit)->GetX() - fVertex->GetX();
-      dy = ((AliL3ConfMapPoint*)fTrack->firstHit)->GetY() - fVertex->GetY() ;
+      dx = ((AliL3ConfMapPoint*)fTrack->GetFirstHit())->GetX() - fVertex->GetX();
+      dy = ((AliL3ConfMapPoint*)fTrack->GetFirstHit())->GetY() - fVertex->GetY() ;
     }
   else 
     {
-      dx = ((AliL3ConfMapPoint *)fTrack->firstHit)->GetX() - ((AliL3ConfMapPoint *)fTrack->lastHit)->GetX() ;
-      dy = ((AliL3ConfMapPoint *)fTrack->firstHit)->GetY() - ((AliL3ConfMapPoint *)fTrack->lastHit)->GetY() ;
+      dx = ((AliL3ConfMapPoint *)fTrack->GetFirstHit())->GetX() - ((AliL3ConfMapPoint *)fTrack->GetLastHit())->GetX() ;
+      dy = ((AliL3ConfMapPoint *)fTrack->GetFirstHit())->GetY() - ((AliL3ConfMapPoint *)fTrack->GetLastHit())->GetY() ;
       //dx = ((AliL3ConfMapPoint *)hits->First())->GetX() - ((AliL3ConfMapPoint *)hits->Last())->GetX() ;
       //dy = ((AliL3ConfMapPoint *)hits->First())->GetY() - ((AliL3ConfMapPoint *)hits->Last())->GetY() ;
     }
@@ -428,7 +417,7 @@ Int_t AliL3ConfMapFit::FitLine ( )
     } 
   else 
     { 
-      total_s = 2.0 * radius * pi ;
+      total_s = 2.0 * radius * AliL3Transform::Pi() ;
     } 
   
   AliL3ConfMapPoint *previousHit = NULL;
@@ -442,9 +431,9 @@ Int_t AliL3ConfMapFit::FitLine ( )
   for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit())  
     {
       // AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)hits->At(hit_counter);
-      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->currentHit;
-      // if ( currentHit != firstHit ) 
-      if(cHit != fTrack->firstHit)//  hits->First())
+      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->GetCurrentHit();
+      // if ( GetCurrentHit() != GetFirstHit() ) 
+      if(cHit != fTrack->GetFirstHit())//  hits->First())
        {
          dx   = cHit->GetX() - previousHit->GetX() ;
          dy   = cHit->GetY() - previousHit->GetY() ;
@@ -491,7 +480,7 @@ Int_t AliL3ConfMapFit::FitLine ( )
   for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit())  
     {
       //AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)hits->At(hit_counter);
-      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->currentHit;
+      AliL3ConfMapPoint *cHit = (AliL3ConfMapPoint*)fTrack->GetCurrentHit();
       r1   = cHit->GetZ() - tanl * cHit->GetS() - z0 ;
       chi2 += (Double_t) ( (Double_t)cHit->GetZWeight() * (r1 * r1) );
     }