]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSTrackerV1.cxx
Coding conventions
[u/mrichter/AliRoot.git] / ITS / AliITSTrackerV1.cxx
index 98c8e7e320bb82a5ee4d60f19ff01cc457d50dfe..30b44ac2910fc1cca3bc5672dbd5d7594193aad8 100644 (file)
 // imposition respectively. The authors thank Mariana Bondila to have help 
 // them to resolve some problems.  July-2000
 
-#include <Riostream.h>
 #include <Riostream.h>
 #include <TMath.h>
 #include <TBranch.h>
 #include <TVector.h>
 #include <TFile.h>
+#include <TRandom.h>
 #include <TTree.h>
-#include <TStopwatch.h>
 
 #include "TParticle.h"
 #include "AliRun.h"
-#include "AliLoader.h"
-#include "AliITS.h"
-#include "AliITSsegmentationSSD.h"
+#include "AliITSDetTypeRec.h"
 #include "AliITSgeomSPD.h"
 #include "AliITSgeomSDD.h"
 #include "AliITSgeomSSD.h"
 #include "AliITSgeom.h"
 #include "AliITSRecPoint.h"
-#include "stdlib.h"
 #include "AliKalmanTrack.h" 
 #include "AliMagF.h"
 #include "AliITSTrackV1.h"
 #include "AliITSIOTrack.h"
 #include "AliITSRad.h"   
-#include "../TPC/AliTPCtracker.h"
+#include "AliTPCtracker.h"
 #include "AliITSTrackerV1.h"
-#include "AliITSVertex.h"
 #include "AliITSPid.h"
+#include "AliMC.h"
 
 ClassImp(AliITSTrackerV1)
  //______________________________________________________________________
 AliITSTrackerV1::AliITSTrackerV1() {
   //Default constructor
-  fITS = 0;
+  //fITS = 0;
   fresult = 0;
   fPtref=0.;
   fChi2max=0.;
@@ -91,60 +87,69 @@ AliITSTrackerV1::AliITSTrackerV1() {
   fRecCylPhi=0;
   fRecCylZ=0;
   fFieldFactor=0;
+  fDetTypeRec = 0;
 }
 //______________________________________________________________________
-AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
+AliITSTrackerV1::AliITSTrackerV1(Int_t evnumber, Bool_t flag) {
     //Origin   A. Badala' and G.S. Pappalardo:  
     // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
     // Class constructor. It does some initializations.
 
   //PH Initialisation taken from the default constructor
-    fITS      = IITTSS;
-    fresult = 0;
-    fPtref    = 0.;
-    fChi2max  =0.; 
-    frecPoints = 0;             
-    fvettid = 0;
-    fflagvert = flag;   
-    frl = 0;
-    fzmin = 0;
-    fzmax = 0;
-    fphimin = 0;
-    fphimax = 0;
-    fphidet = 0;
+  //fITS      = IITTSS;
+  fresult = 0;
+  fPtref    = 0.;
+  fChi2max  =0.; 
+  frecPoints = 0;               
+  fvettid = 0;
+  fflagvert = flag;     
+  frl = 0;
+  fzmin = 0;
+  fzmax = 0;
+  fphimin = 0;
+  fphimax = 0;
+  fphidet = 0;
   
-    Int_t imax = 200,jmax = 450;
-    frl       = new AliITSRad(imax,jmax);
-
-    //////////  gets information on geometry /////////////////////////////
-        AliITSgeom *g1 = fITS->GetITSgeom();  
-    Int_t ll=1, dd=1;
-    TVector det(9);
-
-    Int_t ia;
-    for(ia=0; ia<6; ia++) {
-       fNlad[ia]=g1->GetNladders(ia+1);
-       fNdet[ia]=g1->GetNdetectors(ia+1);
-       //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n"; 
-    } // end for ia
+  Int_t imax = 200,jmax = 450;
+  frl       = new AliITSRad(imax,jmax);
+  
+  //////////  gets information on geometry /////////////////////////////
+  AliRunLoader* rl = AliRunLoader::Open("galice.root");
+  AliITSLoader* loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
+  if (!loader) {
+    Error("AliITSTrackerV1", "ITS loader not found");
+    return;
+  }
+  fDetTypeRec = new AliITSDetTypeRec(loader);
+  AliITSgeom* g1 = loader->GetITSgeom();
 
+  Int_t ll=1, dd=1;
+  TVector det(9);
+  
+  Int_t ia;
+  for(ia=0; ia<6; ia++) {
+    fNlad[ia]=g1->GetNladders(ia+1);
+    fNdet[ia]=g1->GetNdetectors(ia+1);
+    //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n"; 
+  } // end for ia
+  
     //cout<<" mean radius = ";
-    Int_t ib;
-    for(ib=0; ib<6; ib++) {  
-       g1->GetCenterThetaPhi(ib+1,ll,dd,det);
-       Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
-       g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
-       Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
-       fAvrad[ib]=(r1+r2)/2.;
-       //cout<<fAvrad[ib]<<" ";
-    } // end for ib
+  Int_t ib;
+  for(ib=0; ib<6; ib++) {  
+    g1->GetCenterThetaPhi(ib+1,ll,dd,det);
+    Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
+    g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
+    Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
+    fAvrad[ib]=(r1+r2)/2.;
+    //cout<<fAvrad[ib]<<" ";
+  } // end for ib
     //cout<<"\n"; getchar();
-
-    fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
-    fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
-
-    fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
-    fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
+  
+  fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
+  fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
+  
+  fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
+  fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
 
     fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
     fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
@@ -235,17 +240,17 @@ AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
        gAlice->GetEvent(evnumber);
-  Int_t NumOfModules = g1->GetIndexMax();
-  fRecCylR = new Double_t *[NumOfModules];
-  fRecCylPhi = new Double_t *[NumOfModules]; 
-  fRecCylZ = new Double_t *[NumOfModules];
+  Int_t numOfModules = g1->GetIndexMax();
+  fRecCylR = new Double_t *[numOfModules];
+  fRecCylPhi = new Double_t *[numOfModules]; 
+  fRecCylZ = new Double_t *[numOfModules];
   AliITSRecPoint *recp;
-  fNRecPoints = new Int_t[NumOfModules];
+  fNRecPoints = new Int_t[numOfModules];
    
-                for(Int_t module=0; module<NumOfModules; module++) {                           
-                 fITS->ResetRecPoints();                    
-        gAlice->TreeR()->GetEvent(module);               
-                 frecPoints=fITS->RecPoints();
+                for(Int_t module=0; module<numOfModules; module++) {                           
+                 fDetTypeRec->ResetRecPoints();                     
+                 gAlice->TreeR()->GetEvent(module);              
+                 frecPoints=fDetTypeRec->RecPoints();
                  Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
                  fRecCylR[module] = new Double_t[nRecPoints];
                  fRecCylPhi[module] = new Double_t[nRecPoints];
@@ -280,14 +285,16 @@ AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
    // fFieldFactor = (Double_t)fieldPointer->Factor();
     fFieldFactor =(Double_t)fieldPointer-> SolenoidField()/10/.2;
    // cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
+    delete rl;
+    
 }
 //______________________________________________________________________
-AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
+AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) : TObject(cobj) {
     // Origin  A. Badala' and G.S. Pappalardo:
     // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
     // copy constructor
         
-        *fITS = *cobj.fITS;
+  //    *fITS = *cobj.fITS;
     *fresult = *cobj.fresult;
     fPtref = cobj.fPtref;
     fChi2max = cobj.fChi2max;    
@@ -340,18 +347,21 @@ AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
     } // end for im2
 
 
-       AliITSgeom *g1 = fITS->GetITSgeom();  
-   Int_t NumOfModules = g1->GetIndexMax();
+    AliRunLoader* rl = AliRunLoader::Open("galice.root");
+    rl->CdGAFile();
+    AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+
+   Int_t numOfModules = g1->GetIndexMax();
        /*
-  fRecCylR = new Float_t *[NumOfModules];
-  fRecCylPhi = new Float_t *[NumOfModules]; 
-  fRecCylZ = new Float_t *[NumOfModules];
+  fRecCylR = new Float_t *[numOfModules];
+  fRecCylPhi = new Float_t *[numOfModules]; 
+  fRecCylZ = new Float_t *[numOfModules];
   */
-  fRecCylR = new Double_t *[NumOfModules];
-  fRecCylPhi = new Double_t *[NumOfModules]; 
-  fRecCylZ = new Double_t *[NumOfModules];  
-  fNRecPoints = new Int_t[NumOfModules];       
-               for(Int_t module=0; module<NumOfModules; module++) {            
+  fRecCylR = new Double_t *[numOfModules];
+  fRecCylPhi = new Double_t *[numOfModules]; 
+  fRecCylZ = new Double_t *[numOfModules];  
+  fNRecPoints = new Int_t[numOfModules];       
+               for(Int_t module=0; module<numOfModules; module++) {            
                  Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
                  /*
                  fRecCylR[module] = new Float_t[nRecPoints];
@@ -368,10 +378,14 @@ AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
                         fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];                       
                  }             
                }        
+               delete rl;
  
 }
-void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) { 
-  for(Int_t mod=0; mod<NumOfModules; mod++) {
+/*
+//______________________________________________________________________
+void AliITSTrackerV1::DelMatrix(Int_t numOfModules) {
+  // cleanup of some data members
+  for(Int_t mod=0; mod<numOfModules; mod++) {
     delete fRecCylR[mod];
         delete fRecCylPhi[mod];
         delete fRecCylZ[mod];
@@ -380,6 +394,7 @@ void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) {
         delete fRecCylPhi;
         delete fRecCylZ;
 }
+*/
 //______________________________________________________________________
 AliITSTrackerV1::~AliITSTrackerV1(){
     // Origin  A. Badala' and G.S. Pappalardo:
@@ -403,12 +418,12 @@ AliITSTrackerV1::~AliITSTrackerV1(){
         
 }
 //______________________________________________________________________
-AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
+AliITSTrackerV1 &AliITSTrackerV1::operator=(const AliITSTrackerV1 &obj) {
     // Origin  A. Badala' and G.S. Pappalardo:
     // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it  
     // assignement operator
 
-        *fITS = *obj.fITS;
+  //    *fITS = *obj.fITS;
     *fresult = *obj.fresult;
     fPtref = obj.fPtref;
     fChi2max = obj.fChi2max;      
@@ -461,13 +476,16 @@ AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
        } // end for im2
     } // end for im1
 
-       AliITSgeom *g1 = fITS->GetITSgeom();  
-   Int_t NumOfModules = g1->GetIndexMax();
-  fRecCylR = new Double_t *[NumOfModules];
-  fRecCylPhi = new Double_t *[NumOfModules]; 
-  fRecCylZ = new Double_t *[NumOfModules];  
-  fNRecPoints = new Int_t[NumOfModules];  
-         for(Int_t module=0; module<NumOfModules; module++) {            
+    AliRunLoader* rl = AliRunLoader::Open("galice.root");
+    rl->CdGAFile();
+    AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+    // AliITSgeom *g1 = fITS->GetITSgeom();  
+   Int_t numOfModules = g1->GetIndexMax();
+  fRecCylR = new Double_t *[numOfModules];
+  fRecCylPhi = new Double_t *[numOfModules]; 
+  fRecCylZ = new Double_t *[numOfModules];  
+  fNRecPoints = new Int_t[numOfModules];  
+         for(Int_t module=0; module<numOfModules; module++) {            
                  Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
                  fRecCylR[module] = new Double_t[nRecPoints];
                  fRecCylPhi[module] = new Double_t[nRecPoints];
@@ -481,6 +499,7 @@ AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
                }        
          
         
+         delete rl;
     return *this;
 }
 //______________________________________________________________________
@@ -495,11 +514,11 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
     // The method can be called by a macro. It preforms the tracking for
     // all good TPC tracks
 
-    printf("begin DoTracking - file %p\n",file);
+    printf("begin DoTracking - file %p\n",(void*)file);
 
     gAlice->GetEvent(evNumber);  //modificato per gestire hbt
  
-    AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
+    AliKalmanTrack::SetFieldMap(gAlice->Field());
    // cout<<" field = "<<gAlice->Field()->SolenoidField()<<endl;
 
 
@@ -508,16 +527,20 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
     if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
 
     cf->cd();
-    TString foldname(fITS->GetLoader()->GetEventFolder()->GetName());
-    
-    AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber,foldname);  
-    //PH    AliTPCtracker *tracker = new AliTPCtracker(digp);            //I.B.
+    AliRunLoader* rl = AliRunLoader::Open("galice.root");
+    AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
+    TString foldname(itsl->GetEventFolder()->GetName());
+    //TString foldname(fITS->GetLoader()->GetEventFolder()->GetName());
+    delete rl;   
+    printf("This method is not converted to the NewIO !\n");  //I.B.
+    return; //I.B.
+    AliTPCtracker *tracker = new AliTPCtracker(digp);            //I.B.
     //PH    tracker->SetEventNumber(evNumber);                           //I.B.
 
     // Load clusters
-    //tracker->LoadInnerSectors(); //I.B.
-    //tracker->LoadOuterSectors(); //I.B.  
-    tracker->LoadClusters();       //I.B.
+    printf("This method is not converted to the NewIO !\n");  //I.B.
+    return; //I.B.
+    tracker->LoadClusters(0);       //I.B.
 
     // Load tracks
     TFile *tf=TFile::Open("AliTPCtracksSorted.root");  
@@ -553,7 +576,7 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
     TVector vec(5);
     TTree *tr=gAlice->TreeR();
     Int_t nent=(Int_t)tr->GetEntries();  
-    frecPoints = fITS->RecPoints();
+    frecPoints = fDetTypeRec->RecPoints();
 
     Int_t numbpoints;
     Int_t totalpoints=0;
@@ -563,7 +586,7 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
 
     for (mod=0; mod<nent; mod++) {
        fvettid[mod]=0;
-       fITS->ResetRecPoints();  
+       fDetTypeRec->ResetRecPoints();  
        gAlice->TreeR()->GetEvent(mod); 
        numbpoints = frecPoints->GetEntries();
        totalpoints+=numbpoints;
@@ -678,7 +701,7 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
        primaryTrack.SetZv(zv);
        primaryTrack.SetsigmaDv(sigmaDv);
        primaryTrack.SetsigmaZv(sigmaZv);
-       primaryTrack.PrimaryTrack(frl);
+       primaryTrack.PrimaryTrack();
        TVector  d2=primaryTrack.Getd2();
        TVector  tgl2=primaryTrack.Gettgl2();
        TVector  dtgl=primaryTrack.Getdtgl();
@@ -719,7 +742,7 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
            for(k=0; k<3; k++){  
                Int_t lpp=(Int_t)vecLabRef(k);
                if(lpp>=0) {
-                   TParticle *p=(TParticle*) gAlice->Particle(lpp);
+                   TParticle *p=(TParticle*) gAlice->GetMCApp()->Particle(lpp);
                    Int_t pcode=p->GetPdgCode();
                    if(pcode==11) vecLabRef(k)=p->GetFirstMother();
                } // end if
@@ -827,7 +850,7 @@ void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
                ////  for q definition
                if(il>1){
                  if(idmodule>0.){                      
-                   fITS->ResetRecPoints();
+                   fDetTypeRec->ResetRecPoints();
                    gAlice->TreeR()->GetEvent(idmodule);
                    recp=(AliITSRecPoint*)frecPoints->UncheckedAt(idpoint);
                    q[il-2]=recp->GetQ()*(*fresult).Getfcor(il-2);
@@ -928,7 +951,10 @@ void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
     sigmazl[5]=0.6889; 
     ///////////////////////////////////////////////////////////
     Int_t index; 
-    AliITSgeom *g1 = fITS->GetITSgeom();
+    AliRunLoader* rl = AliRunLoader::Open("galice.root");
+    rl->CdGAFile();
+    AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
+
     AliITSRecPoint *recp;        
     for(index =0; index<trackITSlist->GetSize(); index++) {
        AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
@@ -1135,7 +1161,7 @@ void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
                Int_t indexmod;       
                indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
                                              (Int_t)toucDet(iriv)); 
-               fITS->ResetRecPoints();   
+               fDetTypeRec->ResetRecPoints();   
                gAlice->TreeR()->GetEvent(indexmod); 
                Int_t npoints=frecPoints->GetEntries();
        
@@ -1210,9 +1236,9 @@ void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
                    // cout<<" chi2pred = "<<chi2pred<<"\n";
                    // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
                    if(iriv == 0) flaghit=1;
-                   (*newTrack).AddMS(frl);  // add the multiple scattering 
+                   (*newTrack).AddMS();  // add the multiple scattering 
                                             //matrix to the covariance matrix 
-                   (*newTrack).AddEL(frl,1.,0);
+                   (*newTrack).AddEL(1.,0);
 
                    if(fflagvert){
                        KalmanFilterVert(newTrack,cluster,sigmanew);
@@ -1231,9 +1257,9 @@ void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
            AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
            (*newTrack).Setfnoclust();           
            //(*newTrack).SetLayer((*trackITS).GetLayer()-1); 
-           (*newTrack).AddMS(frl);  // add the multiple scattering matrix
+           (*newTrack).AddMS();  // add the multiple scattering matrix
                                     // to the covariance matrix  
-           (*newTrack).AddEL(frl,1.,0);
+           (*newTrack).AddEL(1.,0);
            listoftrack.AddLast(newTrack);
        } // end if
 
@@ -1244,6 +1270,8 @@ void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
     } // end of for on tracks (index)
 
     //gObjectTable->Print();   // stampa memoria
+     delete rl;
+    
 }
 //______________________________________________________________________
 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
@@ -1691,3 +1719,4 @@ void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
     newTrack->SetChi2(newTrack->GetChi2()+chi2);   
     //   newTrack->SetChi2(newTrack->GetChi2()+chi2pred);
 }
+