]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFtrackerMI.cxx
A small change in histogram names
[u/mrichter/AliRoot.git] / TOF / AliTOFtrackerMI.cxx
index 49e8907b4878acfd3fb1309405f59c1e7bb0e4a1..6fdea19ed9c4ebcc404f64faf5b312b7cdafc2bc 100644 (file)
 #include <Rtypes.h>
 
 #include "TClonesArray.h"
-//#include "TGeoManager.h"
 #include "TTree.h"
 #include "TTreeStream.h"
 
-//#include "AliRun.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 
 #include "AliTOFRecoParam.h"
-#include "AliTOFcalib.h"
+#include "AliTOFReconstructor.h"
 #include "AliTOFcluster.h"
 #include "AliTOFGeometry.h"
 #include "AliTOFtrackerMI.h"
@@ -58,99 +56,22 @@ AliTOFtrackerMI::AliTOFtrackerMI():
   fnbadmatch(0),
   fnunmatch(0),
   fnmatch(0),
-  fR(378.), 
+  fR(379.), 
   fTOFHeigth(15.3),  
   fdCut(3.), 
   fDx(1.5), 
   fDy(0), 
   fDz(0), 
-  fTracks(0x0),
-  fSeeds(0x0),
+  fTracks(new TClonesArray("AliTOFtrack")),
+  fSeeds(new TClonesArray("AliESDtrack")),
   fDebugStreamer(0x0)
  { 
   //AliTOFtrackerMI main Ctor
 
-   fRecoParam=new AliTOFRecoParam();
-   fGeom=new AliTOFGeometry();
-   Double_t parPID[2];   
-   parPID[0]=fRecoParam->GetTimeResolution();
-   parPID[1]=fRecoParam->GetTimeNSigma();
-   fPid=new AliTOFpidESD(parPID);
    fDy=AliTOFGeometry::XPad(); 
    fDz=AliTOFGeometry::ZPad(); 
    fDebugStreamer = new TTreeSRedirector("TOFdebug.root");   
 }
-//_____________________________________________________________________________
-AliTOFtrackerMI::AliTOFtrackerMI(const AliTOFtrackerMI &t):
-  AliTracker(),
-  fRecoParam(0x0),
-  fGeom(0x0),
-  fPid(0x0),
-  fN(0),
-  fNseeds(0),
-  fNseedsTOF(0),
-  fngoodmatch(0),
-  fnbadmatch(0),
-  fnunmatch(0),
-  fnmatch(0),
-  fR(378.), 
-  fTOFHeigth(15.3),  
-  fdCut(3.), 
-  fDx(1.5), 
-  fDy(0), 
-  fDz(0), 
-  fTracks(0x0),
-  fSeeds(0x0),
-  fDebugStreamer(0x0)
- { 
-  //AliTOFtrackerMI copy Ctor
-
-  fNseeds=t.fNseeds;
-  fNseedsTOF=t.fNseedsTOF;
-  fngoodmatch=t.fngoodmatch;
-  fnbadmatch=t.fnbadmatch;
-  fnunmatch=t.fnunmatch;
-  fnmatch=t.fnmatch;
-  fRecoParam = t.fRecoParam;
-  fGeom=t.fGeom;
-  fPid = t.fPid;
-  fR=t.fR; 
-  fTOFHeigth=t.fTOFHeigth;  
-  fdCut=t.fdCut; 
-  fDy=t.fDy; 
-  fDz=t.fDz; 
-  fDx=1.5; 
-  fSeeds=t.fSeeds;
-  fTracks=t.fTracks;
-  fN=t.fN;
-}
-
-//_________________________________________________________________________________
-AliTOFtrackerMI& AliTOFtrackerMI::operator=(const AliTOFtrackerMI &t)
-{ 
-  //AliTOFtrackerMI assignment operator
-
-  this->fNseeds=t.fNseeds;
-  this->fNseedsTOF=t.fNseedsTOF;
-  this->fngoodmatch=t.fngoodmatch;
-  this->fnbadmatch=t.fnbadmatch;
-  this->fnunmatch=t.fnunmatch;
-  this->fnmatch=t.fnmatch;
-  this->fRecoParam = t.fRecoParam;
-  this->fGeom = t.fGeom;
-  this->fPid = t.fPid;
-  this->fR=t.fR; 
-  this->fTOFHeigth=t.fTOFHeigth;  
-  this->fdCut=t.fdCut; 
-  this->fDy=t.fDy;
-  this->fDz=t.fDz;
-  this->fDx=t.fDx;
-  this->fSeeds=t.fSeeds;
-  this->fTracks=t.fTracks;
-  this->fN=t.fN;
-  return *this;
-
-}
 
 //_____________________________________________________________________________
 AliTOFtrackerMI::~AliTOFtrackerMI(){
@@ -164,6 +85,16 @@ AliTOFtrackerMI::~AliTOFtrackerMI(){
   delete fRecoParam;
   delete fGeom;
   delete fPid;
+  if (fTracks){
+    fTracks->Delete();
+    delete fTracks;
+    fTracks=0x0;
+  }
+  if (fSeeds){
+    fSeeds->Delete();
+    delete fSeeds;
+    fSeeds=0x0;
+  }
 }
 
 //_____________________________________________________________________________
@@ -172,6 +103,23 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
   // Gets seeds from ESD event and Match with TOF Clusters
   //
 
+  // initialize RecoParam for current event
+
+  AliInfo("Initializing params for TOF... ");
+
+  fRecoParam = AliTOFReconstructor::GetRecoParam();  // instantiate reco param from STEER...
+
+  if (fRecoParam == 0x0) { 
+    AliFatal("No Reco Param found for TOF!!!");
+  }
+  //fRecoParam->Dump();
+  //if(fRecoParam->GetApplyPbPbCuts())fRecoParam=fRecoParam->GetPbPbparam();
+  //fRecoParam->PrintParameters();
+
+  Double_t parPID[2];   
+  parPID[0]=fRecoParam->GetTimeResolution();
+  parPID[1]=fRecoParam->GetTimeNSigma();
+  fPid=new AliTOFpidESD(parPID);
 
   //Initialise some counters
 
@@ -184,7 +132,6 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
 
   Int_t ntrk=event->GetNumberOfTracks();
   fNseeds = ntrk;
-  fSeeds= new TClonesArray("AliESDtrack");
   TClonesArray &aESDTrack = *fSeeds;
 
 
@@ -215,25 +162,30 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
   for (Int_t i=0; i<ntrk; i++) {
     AliESDtrack *t=event->GetTrack(i);
     AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
-    if(seed->GetTOFsignal()>0){
-      t->SetTOFsignal(seed->GetTOFsignal());
-      t->SetTOFcluster(seed->GetTOFcluster());
-      Int_t tlab[3];
-      seed->GetTOFLabel(tlab);    
-      t->SetTOFLabel(tlab);
-      AliTOFtrack *track = new AliTOFtrack(*seed);
-      Float_t info[10];
-      Double_t times[10];
-      seed->GetTOFInfo(info);
-      seed->GetIntegratedTimes(times);
-      t->UpdateTrackParams(track,AliESDtrack::kTOFout);    
-      t->SetIntegratedLength(seed->GetIntegratedLength());
-      t->SetIntegratedTimes(times);
-      t->SetTOFsignalToT(seed->GetTOFsignalToT());
-      t->SetTOFCalChannel(seed->GetTOFCalChannel());
-      //
-      t->SetTOFInfo(info);
-      delete track;
+
+    if ( (seed->GetStatus()&AliESDtrack::kTOFin)!=0 ) {
+      t->SetStatus(AliESDtrack::kTOFin);
+      //if(seed->GetTOFsignal()>0){
+      if ( (seed->GetStatus()&AliESDtrack::kTOFout)!=0 ) {
+       t->SetTOFsignal(seed->GetTOFsignal());
+       t->SetTOFcluster(seed->GetTOFcluster());
+       Int_t tlab[3];
+       seed->GetTOFLabel(tlab);    
+       t->SetTOFLabel(tlab);
+       AliTOFtrack *track = new AliTOFtrack(*seed);
+       Float_t info[10];
+       Double_t times[10];
+       seed->GetTOFInfo(info);
+       seed->GetIntegratedTimes(times);
+       t->UpdateTrackParams(track,AliESDtrack::kTOFout);
+       t->SetIntegratedLength(seed->GetIntegratedLength());
+       t->SetIntegratedTimes(times);
+       t->SetTOFsignalToT(seed->GetTOFsignalToT());
+       t->SetTOFCalChannel(seed->GetTOFCalChannel());
+       //
+       t->SetTOFInfo(info);
+       delete track;
+      }
     }
   }
 
@@ -241,16 +193,8 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
   //Make TOF PID
   fPid->MakePID(event);
 
-  if (fSeeds) {
-    fSeeds->Delete();
-    delete fSeeds;
-    fSeeds = 0x0;
-  }
-  if (fTracks) {
-    fTracks->Delete();
-    delete fTracks;
-    fTracks = 0x0;
-  }
+  fSeeds->Clear();
+  fTracks->Clear();
   return 0;
   
 }
@@ -258,7 +202,6 @@ Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
 void AliTOFtrackerMI::CollectESD() {
    //prepare the set of ESD tracks to be matched to clusters in TOF
  
-  fTracks= new TClonesArray("AliTOFtrack");
   TClonesArray &aTOFTrack = *fTracks;
   Int_t c0=0;
   Int_t c1=0;
@@ -267,27 +210,27 @@ void AliTOFtrackerMI::CollectESD() {
     AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
     if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
 
-    // TRD good tracks, already propagated at 371 cm
-
     AliTOFtrack *track = new AliTOFtrack(*t); // New
-    Double_t x = track->GetX(); //New
-
-    if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) && 
-        ( x >= AliTOFGeometry::RinTOF()) ){
-      track->SetSeedIndex(i);
-      t->UpdateTrackParams(track,AliESDtrack::kTOFout);    
-      new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
-      fNseedsTOF++;
-      c0++;
-      delete track;
-    }
+    Float_t x = (Float_t)track->GetX(); //New
 
-    // Propagate the rest of TPCbp  
+    // TRD good tracks, already propagated at 371 cm
+    if ( ( (t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
+        ( x >= AliTOFGeometry::Rmin() ) ) {
+      if  ( track->PropagateToInnerTOF() ) {
+       track->SetSeedIndex(i);
+       t->UpdateTrackParams(track,AliESDtrack::kTOFin);
+       new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
+       fNseedsTOF++;
+       c0++;
+       delete track;
+      }
+    }
 
+    // Propagate the rest of TPCbp
     else {
-      if(track->PropagateToInnerTOF()){ // temporary solution
+      if ( track->PropagateToInnerTOF() ) { // temporary solution
        track->SetSeedIndex(i);
-       t->UpdateTrackParams(track,AliESDtrack::kTOFout);    
+       t->UpdateTrackParams(track,AliESDtrack::kTOFin);
        new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
        fNseedsTOF++;
        c1++;
@@ -322,10 +265,10 @@ void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){
 void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
 
   //Match ESD tracks to clusters in TOF
-  const Float_t kTofOffset = 26;  // time offset
-  const Float_t kMinQuality        = -6.; // minimal quality
-  const Float_t kMaxQualityD       = 1.;  // max delta quality if cluster used
-  const Float_t kForbiddenR        = 0.1;  // minimal PID according TPC
+  const Float_t kTofOffset   = 26;  // time offset
+  const Float_t kMinQuality  = -6.; // minimal quality
+  const Float_t kMaxQualityD = 1.;  // max delta quality if cluster used
+  const Float_t kForbiddenR  = 0.1; // minimal PID according TPC
 
   static const Double_t kMasses[]={
     0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613
@@ -333,24 +276,24 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
   
   Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
 
-  AliTOFcalib *calib = new AliTOFcalib();
+  //AliTOFcalib *calib = new AliTOFcalib(); // AdC
 
   //PH Arrays (moved outside of the loop)
   Float_t * trackPos[4];
   for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
-  Int_t * clind[6];
-  for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN];
+  Int_t * clind = new Int_t[fN];
 
   // Some init 
   
   Int_t         index[1000];
+  Float_t       quality[1000];
   Float_t       dist3D[1000][6];
   Double_t      times[1000][6];
   Float_t       mintimedist[1000];
   Float_t       likelihood[1000];
   Float_t       length[1000];
   AliTOFcluster *clusters[1000];
-  Double_t       tpcpid[5];
+  Double_t      tpcpid[5];
   dist3D[0][0]=1;
   
   for (Int_t i=0; i<fNseedsTOF; i++) {
@@ -380,12 +323,12 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
     //
     //propagat track to the middle of TOF
     //
-    Float_t xs = 378.2;  // should be defined in the TOF geometry
+    Float_t xs = 379.2;  // should be defined in the TOF geometry
     Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());  
     Bool_t skip=kFALSE;
     Double_t ysect=trackTOFin->GetYat(xs,skip);
     if (skip){
-      xs = 372.;
+      xs = 373.;
       ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
       ysect=trackTOFin->GetYat(xs,skip);
     }
@@ -411,10 +354,10 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
     Float_t scalefact=3.;    
     Double_t dphi=
       scalefact*
-      ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR); 
+      ((5*TMath::Sqrt(cov[0]) + 3.*fDy + 10.*TMath::Abs(par[2]))/fR); 
     Double_t dz=
       scalefact*
-      (5*TMath::Sqrt(cov[2]) + 3.*fDz  +10.*TMath::Abs(par[3]));
+      (5*TMath::Sqrt(cov[2]) + 3.*fDz 10.*TMath::Abs(par[3]));
     
     Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
     if (phi<-TMath::Pi())phi+=2*TMath::Pi();
@@ -433,13 +376,8 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
       Double_t dph=TMath::Abs(c->GetPhi()-phi);
       if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
       if (TMath::Abs(dph)>dphi) continue;
-    
-      clind[0][nc] = c->GetDetInd(0);
-      clind[1][nc] = c->GetDetInd(1);
-      clind[2][nc] = c->GetDetInd(2);
-      clind[3][nc] = c->GetDetInd(3);
-      clind[4][nc] = c->GetDetInd(4);
-      clind[5][nc] = k;      
+
+      clind[nc] = k;
       nc++;
     }
 
@@ -451,9 +389,9 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
     for (Int_t icl=0; icl<nc; icl++){
       Float_t distances[5];
       if (nfound>=1000) break;
-      index[nfound]=clind[5][icl];
-      AliTOFcluster *cluster = fClusters[clind[5][icl]];
-      GetLinearDistances(trackTOFin,cluster, distances);
+      index[nfound]=clind[icl];
+      AliTOFcluster *cluster = fClusters[clind[icl]];
+      GetLinearDistances(trackTOFin, cluster, distances);
       dist3D[nfound][0] = distances[4];
       dist3D[nfound][1] = distances[1];
       dist3D[nfound][2] = distances[2];
@@ -468,7 +406,7 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
       //
       clusters[nfound] = cluster;
       //
-      //length  and TOF updates 
+      //length and TOF updates 
       trackTOFin->GetIntegratedTimes(times[nfound]);
       length[nfound] = trackTOFin->GetIntegratedLength();
       length[nfound]+=distances[4];
@@ -502,8 +440,9 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
     //
     //choose the best cluster
     //
-    Float_t quality[1000];
-    Int_t   index[1000];
+    //Float_t quality[1000];
+    //Int_t   index[1000];
+    for (Int_t kk=0; kk<1000; kk++) quality[kk]=0;
     //
     AliTOFcluster * cgold=0;
     Int_t igold =-1;
@@ -583,8 +522,20 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
     t->SetTOFInfo(info);
     t->SetTOFsignal(tof2);
     t->SetTOFcluster(cgold->GetIndex());  
+
+    AliDebug(2, Form("%7i     %7i     %10i     %10i  %10i  %10i      %7i",
+                    i,
+                    fnmatch-1,
+                    TMath::Abs(trackTOFin->GetLabel()),
+                    tlab[0], tlab[1], tlab[2],
+                    igold)); // AdC
+
     AliTOFtrack *trackTOFout = new AliTOFtrack(*t); 
-    trackTOFout->PropagateTo(378.);
+    trackTOFout->PropagateTo(379.);
+
+    // Fill the track residual histograms.
+    FillResiduals(trackTOFout,cgold,kFALSE);
+
     t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);    
     t->SetIntegratedLength(length[igold]);
     t->SetIntegratedTimes(times[igold]);
@@ -598,66 +549,11 @@ void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
   //
   //
   for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
-  for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
-  delete calib;
+  delete [] clind;
+  //delete calib; // AdC
 }
-
-
-
-
-// //_________________________________________________________________________
-// Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
-//   //--------------------------------------------------------------------
-//   //This function loads the TOF clusters
-//   //--------------------------------------------------------------------
-
-//   TBranch *branch=dTree->GetBranch("TOF");
-//   if (!branch) { 
-//     AliError(" can't get the branch with the TOF digits !");
-//     return 1;
-//   }
-
-//   TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
-//   branch->SetAddress(&digits);
-
-//   dTree->GetEvent(0);
-//   Int_t nd=digits->GetEntriesFast();
-//   Info("LoadClusters","number of digits: %d",nd);
-
-//   for (Int_t i=0; i<nd; i++) {
-//     AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
-//     Int_t dig[5]; Float_t g[3];
-//     dig[0]=d->GetSector();
-//     dig[1]=d->GetPlate();
-//     dig[2]=d->GetStrip();
-//     dig[3]=d->GetPadz();
-//     dig[4]=d->GetPadx();
-
-//     fGeom->GetPos(dig,g);
-
-//     Double_t h[5];
-//     h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
-//     h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2]; 
-//     h[3]=d->GetTdc(); h[4]=d->GetAdc();
-
-//     AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
-//     InsertCluster(cl);
-//   }  
-
-//   return 0;
-// }
-// //_________________________________________________________________________
-// void AliTOFtrackerMI::UnloadClusters() {
-//   //--------------------------------------------------------------------
-//   //This function unloads TOF clusters
-//   //--------------------------------------------------------------------
-//   for (Int_t i=0; i<fN; i++) delete fClusters[i];
-//   fN=0;
-// }
-
-
-
 //_________________________________________________________________________
+
 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
   //--------------------------------------------------------------------
   //This function loads the TOF clusters
@@ -669,7 +565,9 @@ Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
     return 1;
   }
 
-  TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
+  static TClonesArray dummy("AliTOFcluster",10000);
+  dummy.Clear();
+  TClonesArray *clusters=&dummy;
   branch->SetAddress(&clusters);
 
   cTree->GetEvent(0);
@@ -678,23 +576,7 @@ Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
 
   for (Int_t i=0; i<nc; i++) {
     AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
-    /*
-    for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
-
-    Double_t h[5];
-    h[0]=c->GetR();
-    h[1]=c->GetPhi();
-    h[2]=c->GetZ();
-    h[3]=c->GetTDC();
-    h[4]=c->GetADC();
 
-    Int_t indexDig[3];
-    for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
-
-    AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
-    */
-
-    //    fClusters[i]=c; fN++;
     fClusters[i]=new AliTOFcluster(*c); fN++;
 
     //AliInfo(Form("%4i %4i  %f %f %f  %f %f   %2i %1i %2i %1i %2i",i, fClusters[i]->GetIndex(),fClusters[i]->GetZ(),fClusters[i]->GetR(),fClusters[i]->GetPhi(), fClusters[i]->GetTDC(),fClusters[i]->GetADC(),fClusters[i]->GetDetInd(0),fClusters[i]->GetDetInd(1),fClusters[i]->GetDetInd(2),fClusters[i]->GetDetInd(3),fClusters[i]->GetDetInd(4)));
@@ -910,3 +792,17 @@ void    AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *c
   p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));  
   pz+= 0.25*(p1-p0);
 }
+//_________________________________________________________________________
+
+void AliTOFtrackerMI::FillClusterArray(TObjArray* arr) const
+{
+  //
+  // Returns the TOF cluster array
+  //
+
+  if (fN==0)
+    arr = 0x0;
+  else
+    for (Int_t i=0; i<fN; ++i) arr->Add(fClusters[i]);
+
+}