]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRD.cxx
Bugfix for calculation of cluster widths.
[u/mrichter/AliRoot.git] / TRD / AliTRD.cxx
index f1afa7b6bf2736307fbc93d2a4623ca36a2bc548..736a417d3d64bf058ff56057a2022eae86158059 100644 (file)
@@ -43,8 +43,6 @@
 #include "AliMagF.h"
 #include "AliRun.h"
 #include "AliTRD.h"
-#include "AliTRDcluster.h"
-#include "AliTRDclusterizer.h"
 #include "AliTRDdigit.h"
 #include "AliTRDdigitizer.h"
 #include "AliTRDdigitsManager.h"
 #include "AliTRDgeometryHole.h"
 #include "AliTRDhit.h"
 #include "AliTRDpoints.h"
-#include "AliTRDrecPoint.h"
 #include "AliTRDtrackHits.h"  
+#include "AliTRDrawData.h"
 #include "AliTrackReference.h"
 #include "AliMC.h"
-#include "AliTRDclusterizerV1.h"
-#include "AliTRDparameter.h"
-#include "AliTRDtracker.h"
 
 ClassImp(AliTRD)
  
@@ -74,9 +69,6 @@ AliTRD::AliTRD()
   fHits          = 0;
   fDigits        = 0;
 
-  fRecPoints     = 0;
-  fNRecPoints    = 0;
-
   fGeometry      = 0;
 
   fGasDensity    = 0;
@@ -106,13 +98,9 @@ AliTRD::AliTRD(const char *name, const char *title)
     exit(1);
   } 
 
-  // Define the TRD geometry according to the FRAME geometry
-  if      (frame->IsVersion() == 0) {
-    // Geometry with hole
-    fGeometry = new AliTRDgeometryHole();
-  }
-  else if (frame->IsVersion() == 1) {
-    // Geometry without hole
+  // Define the TRD geometry
+  if ((frame->IsVersion() == 0) ||
+      (frame->IsVersion() == 1)) {
     fGeometry = new AliTRDgeometryFull();
   }
   else {
@@ -120,6 +108,12 @@ AliTRD::AliTRD(const char *name, const char *title)
     exit(1);
   }
 
+  // Save the geometry
+  TDirectory* saveDir = gDirectory;
+  gAlice->GetRunLoader()->CdGAFile();
+  fGeometry->Write("TRDgeometry");
+  saveDir->cd();
+
   // Allocate the hit array
   fHits           = new TClonesArray("AliTRDhit"     ,405);
   gAlice->GetMCApp()->AddHitList(fHits);
@@ -127,10 +121,6 @@ AliTRD::AliTRD(const char *name, const char *title)
   // Allocate the digits array
   fDigits         = 0;
 
-  // Allocate the rec point array
-  fRecPoints     = new TObjArray(400);
-  fNRecPoints    = 0;
-   
   fIshunt        = 0;
   fGasMix        = 1;
 
@@ -175,10 +165,10 @@ AliTRD::~AliTRD()
     delete fHits;
     fHits      = 0;
   }
-  if (fRecPoints) {
-    delete fRecPoints;
-    fRecPoints = 0;
-  }
+//  if (fRecPoints) {
+//    delete fRecPoints;
+//    fRecPoints = 0;
+//  }
   if (fTrackHits) {
     delete fTrackHits;
     fTrackHits = 0;
@@ -186,47 +176,6 @@ AliTRD::~AliTRD()
 
 }
 
-//_____________________________________________________________________________
-void AliTRD::AddCluster(Float_t *pos, Int_t det, Float_t amp
-                      , Int_t *tracks, Float_t *sig, Int_t iType)
-{
-  //
-  // Add a cluster for the TRD
-  //
-
-  AliTRDcluster *c = new AliTRDcluster();
-
-  c->SetDetector(det);
-  c->AddTrackIndex(tracks);
-  c->SetQ(amp);
-  c->SetY(pos[0]);
-  c->SetZ(pos[1]);
-  c->SetSigmaY2(sig[0]);   
-  c->SetSigmaZ2(sig[1]);
-  c->SetLocalTimeBin(((Int_t) pos[2]));
-
-  switch (iType) {
-  case 0:
-    c->Set2pad();
-    break;
-  case 1:
-    c->Set3pad();
-    break;
-  case 2:
-    c->Set4pad();
-    break;
-  case 3:
-    c->Set5pad();
-    break;
-  case 4:
-    c->SetLarge();
-    break;
-  };
-
-  fRecPoints->Add(c);
-
-}
-
 //_____________________________________________________________________________
 void AliTRD::Hits2Digits()
 {
@@ -335,6 +284,30 @@ void AliTRD::SDigits2Digits()
 
 }
 
+//_____________________________________________________________________________
+void AliTRD::Digits2Raw() 
+{
+  //
+  // convert digits of the current event to raw data
+  //
+
+  fLoader->LoadDigits();
+  TTree* digits = fLoader->TreeD();
+  if (!digits) {
+    Error("Digits2Raw", "no digits tree");
+    return;
+  }
+
+  AliTRDrawData rawWriter;
+//  rawWriter.SetDebug(2);
+  if (!rawWriter.Digits2Raw(digits)) {
+    Error("AliTRD::Digits2Raw","The raw writer could not load the digits tree");
+  }
+
+  fLoader->UnloadDigits();
+
+}
+
 //_____________________________________________________________________________
 void AliTRD::AddHit(Int_t track, Int_t det, Float_t *hits, Int_t q
                   , Bool_t inDrift)
@@ -468,8 +441,6 @@ void AliTRD::Copy(TObject &trd)
 
   ((AliTRD &) trd).fGasMix      = fGasMix;
   ((AliTRD &) trd).fGeometry    = fGeometry;       
-  ((AliTRD &) trd).fRecPoints   = fRecPoints;
-  ((AliTRD &) trd).fNRecPoints  = fNRecPoints;
   ((AliTRD &) trd).fGasDensity  = fGasDensity;
   ((AliTRD &) trd).fFoilDensity = fFoilDensity;
   ((AliTRD &) trd).fDrawTR      = fDrawTR;
@@ -792,16 +763,16 @@ void AliTRD::Init()
     printf("\n");
   }
 
-  if      (fGeometry->IsVersion() == 0) {
-    printf("%s: Geometry for spaceframe with holes initialized\n",ClassName());
-  }
-  else if (fGeometry->IsVersion() == 1) {
-    printf("%s: Geometry for spaceframe without holes initialized\n",ClassName());
+  if (fGeometry->IsVersion() == 1) {
+    printf("%s: Full geometry version initialized\n",ClassName());
     if (fGeometry->GetPHOShole())
       printf("%s: Leave space in front of PHOS free\n",ClassName());
     if (fGeometry->GetRICHhole())
       printf("%s: Leave space in front of RICH free\n",ClassName());
   }
+  else {
+    printf("%s: Not a valid geometry\n",ClassName());
+  }
   
   if (fGasMix == 1) {
     printf("%s: Gas Mixture: 85%% Xe + 15%% CO2\n",ClassName());
@@ -992,21 +963,6 @@ void AliTRD::ResetDigits()
 
 }
 
-//_____________________________________________________________________________
-void AliTRD::ResetRecPoints()
-{
-  //
-  // Reset number of reconstructed points and the point array
-  //
-
-  if (fRecPoints) {
-    fNRecPoints = 0;
-    Int_t nentr = fRecPoints->GetEntriesFast();
-    for (Int_t i = 0; i < nentr; i++) delete fRecPoints->RemoveAt(i);
-  }
-
-}
-
 //_____________________________________________________________________________
 void AliTRD::SetTreeAddress()
 {
@@ -1014,25 +970,9 @@ void AliTRD::SetTreeAddress()
   // Set the branch addresses for the trees.
   //
 
-  Char_t branchname[15];
-
   if ( fLoader->TreeH() && (fHits == 0x0))  fHits = new TClonesArray("AliTRDhit",405);
   AliDetector::SetTreeAddress();
 
-  TBranch *branch;
-  TTree   *treeR = fLoader->TreeR();
-
-  if (treeR) {
-    sprintf(branchname,"%scluster",GetName());
-    if (fRecPoints == 0x0) fRecPoints  = new TObjArray(400);
-    if (fRecPoints) {
-      branch = treeR->GetBranch(branchname);
-      if (branch) {
-        branch->SetAddress(&fRecPoints);
-      }
-    }
-  }
-
   if (fHitType > 0) {
     SetTreeAddress2();    
   }
@@ -1300,41 +1240,6 @@ void AliTRD::AddHit2(Int_t track, Int_t det, Float_t *hits, Int_t q
 }
 
 
-//_____________________________________________________________________________
-void AliTRD::Reconstruct() const
-{
-// reconstruct clusters
-
-  AliTRDclusterizerV1 clusterer("clusterer", "TRD clusterizer");
-  AliRunLoader* runLoader = GetLoader()->GetRunLoader();
-  runLoader->CdGAFile();
-  AliTRDparameter* trdParam = (AliTRDparameter*) gFile->Get("TRDparameter"); 
-  if (!trdParam) {
-    Error("Reconstruct", "no TRD parameters found");
-    return;
-  }
-  trdParam->ReInit();
-  clusterer.SetParameter(trdParam);
-  Int_t nEvents = runLoader->GetNumberOfEvents();
-
-  for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
-    clusterer.Open(runLoader->GetFileName(), iEvent);
-    clusterer.ReadDigits();
-    clusterer.MakeClusters();
-    clusterer.WriteClusters(-1);
-  }
-}
-
-//_____________________________________________________________________________
-AliTracker* AliTRD::CreateTracker() const
-{
-// create a TRD tracker
-
-  GetLoader()->GetRunLoader()->CdGAFile();
-  return new AliTRDtracker(gFile);
-}
-
-