]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDpid.cxx
In PointSetArray: added member for default daughter PointSet capacity (fDefPointSetCa...
[u/mrichter/AliRoot.git] / TRD / AliTRDpid.cxx
index c6a2105164b9cb713e510fb36791cca6011f3074..090ce93203167661b653d7dd4e89063e07cf6c2b 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.1  2001/05/07 08:08:05  cblume
-Update of TRD code
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -41,12 +36,12 @@ Update of TRD code
 #include <TParticle.h>
 
 #include "AliRun.h"
-#include "AliTRD.h"
 #include "AliTRDpid.h"
 #include "AliTRDcluster.h"
 #include "AliTRDtrack.h"
 #include "AliTRDtracker.h"
 #include "AliTRDgeometry.h"
+#include "AliMC.h"
 
 ClassImp(AliTRDpid)
 
@@ -67,6 +62,8 @@ AliTRDpid::AliTRDpid():TNamed()
   fPIDindexMin   = 0;
   fPIDindexMax   = 0;
 
+  fEvent         = 0;
+
   fThreePadOnly  = kFALSE;
 
 }
@@ -83,12 +80,14 @@ AliTRDpid::AliTRDpid(const char* name, const char* title):TNamed(name,title)
   fGeometry     = NULL;
   fFileKine     = NULL;
 
+  fEvent        = 0;
+
   Init();
 
 }
 
 //_____________________________________________________________________________
-AliTRDpid::AliTRDpid(const AliTRDpid &p)
+AliTRDpid::AliTRDpid(const AliTRDpid &p):TNamed(p)
 {
   //
   // AliTRDpid copy constructor
@@ -108,14 +107,19 @@ AliTRDpid::~AliTRDpid()
   if (fClusterArray) {
     fClusterArray->Delete();
     delete fClusterArray;
+    fClusterArray = NULL;
   }
 
   if (fTrackArray) {
     fTrackArray->Delete();
     delete fTrackArray;
+    fTrackArray = NULL;
   }
 
-  fFileKine->Close();
+  if (fFileKine) {
+    delete fFileKine;
+    fFileKine = NULL;
+  }
 
 }
 
@@ -132,7 +136,7 @@ AliTRDpid &AliTRDpid::operator=(const AliTRDpid &p)
 }
 
 //_____________________________________________________________________________
-void AliTRDpid::Copy(TObject &p)
+void AliTRDpid::Copy(TObject &p) const
 {
   //
   // Copy function
@@ -147,6 +151,7 @@ void AliTRDpid::Copy(TObject &p)
   ((AliTRDpid &) p).fPIDindexMin   = fPIDindexMin;
   ((AliTRDpid &) p).fPIDindexMax   = fPIDindexMax;
   ((AliTRDpid &) p).fThreePadOnly  = fThreePadOnly;
+  ((AliTRDpid &) p).fEvent         = fEvent;
 
 }
 
@@ -306,20 +311,15 @@ Bool_t AliTRDpid::ReadKine(const Char_t *name, Int_t event)
   }
   gAlice->GetEvent(event);
 
-  AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD");
-  if (!trd) {
-    printf("AliTRDpid::ReadKine -- ");
-    printf("No TRD object found\n");    
-    return kFALSE;
-  }
-
-  fGeometry = trd->GetGeometry();
+  fGeometry = AliTRDgeometry::GetGeometry(gAlice->GetRunLoader());
   if (!fGeometry) {
     printf("AliTRDpid::ReadKine -- ");
     printf("No TRD geometry found\n");
     return kFALSE;
   }
 
+  fEvent = event;
+
   return kTRUE;
 
 }
@@ -343,8 +343,13 @@ Bool_t AliTRDpid::ReadCluster(const Char_t *name)
   printf("AliTRDpid::ReadCluster -- ");
   printf("Open file %s\n",name);
 
-  AliTRDtracker *tracker = new AliTRDtracker("dummy","dummy");
-  tracker->ReadClusters(fClusterArray,name);
+  AliTRDtracker *tracker = new AliTRDtracker();
+  TFile* file = TFile::Open(name);
+  file->cd("Event0");
+  TTree* tree = (TTree*) file->Get("TreeD");
+  tracker->ReadClusters(fClusterArray,tree);
+  file->Close();
+  delete file;
 
   if (!fClusterArray) {
     printf("AliTRDpid::ReadCluster -- ");
@@ -388,7 +393,9 @@ Bool_t AliTRDpid::ReadTracks(const Char_t *name)
     }
   }
 
-  TTree   *trackTree   = (TTree *) file->Get("TreeT");
+  Char_t treeName[12];
+  sprintf(treeName,"TreeT%d_TRD",fEvent);
+  TTree   *trackTree   = (TTree *) file->Get(treeName);
   TBranch *trackBranch = trackTree->GetBranch("tracks");
 
   Int_t nEntry = ((Int_t) trackTree->GetEntries());
@@ -438,7 +445,7 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t)
   }
   
   // Loop through all clusters associated to this track
-  Int_t nCluster = t->GetNclusters();
+  Int_t nCluster = t->GetNumberOfClusters();
   for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
 
     // Get a cluster
@@ -448,8 +455,8 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t)
     } 
 
     // Get the first two MC track indices
-    Int_t track0 = cluster->GetTrackIndex(0);
-    Int_t track1 = cluster->GetTrackIndex(1);
+    Int_t track0 = cluster->GetLabel(0);
+    Int_t track1 = cluster->GetLabel(1);
 
     // Check on the track index to find the right primaries
     if ((track0 >  fPIDindexMin) && 
@@ -462,7 +469,7 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t)
       }
       if (accept) {
 
-        particle = gAlice->Particle(track0);
+        particle = gAlice->GetMCApp()->Particle(track0);
         if (particle->GetFirstMother() == -1) {
           switch (TMath::Abs(particle->GetPdgCode())) {
           case kPdgEl:
@@ -554,7 +561,7 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t, Int_t *pdg
   }
 
   // Loop through all clusters associated to this track
-  Int_t nCluster = t->GetNclusters();
+  Int_t nCluster = t->GetNumberOfClusters();
   for (iCluster = 0; iCluster < nCluster; iCluster++) {
 
     // Get a cluster
@@ -566,9 +573,9 @@ Int_t AliTRDpid::MCpid(const AliTRDtrack *t, Int_t *pdg
     // Get the MC track indices
     for (iTrack = 0; iTrack < kNtrack; iTrack++) {
 
-      Int_t trackIndex = cluster->GetTrackIndex(iTrack);
+      Int_t trackIndex = cluster->GetLabel(iTrack);
       if (trackIndex >= 0) {
-        particle = gAlice->Particle(trackIndex);
+        particle = gAlice->GetMCApp()->Particle(trackIndex);
         Int_t  pdgCode = particle->GetPdgCode(); 
         Bool_t newPart = kTRUE;
         for (iPart = 0; iPart < nPart; iPart++) {
@@ -635,7 +642,7 @@ Bool_t AliTRDpid::SumCharge(const AliTRDtrack *t
   }
   
   // Loop through all clusters associated to this track
-  Int_t nClus = t->GetNclusters();
+  Int_t nClus = t->GetNumberOfClusters();
   for (Int_t iClus = 0; iClus < nClus; iClus++) {
 
     // Get a cluster