Reconstruction of raw data (T.Kuhr)
[u/mrichter/AliRoot.git] / TPC / AliTPCReconstructor.cxx
index b0923e8ba153e4cacb0e9526812bc180ab84b7bd..a491a174359bb40e9549e515aa8f1c787cd872de 100644 (file)
@@ -25,7 +25,7 @@
 #include "AliTPCReconstructor.h"
 #include "AliRunLoader.h"
 #include "AliRun.h"
-#include "AliTPC.h"
+#include "AliRawReader.h"
 #include "AliTPCclustererMI.h"
 #include "AliTPCtrackerMI.h"
 #include "AliTPCpidESD.h"
@@ -33,6 +33,7 @@
 
 ClassImp(AliTPCReconstructor)
 
+Double_t AliTPCReconstructor::fgCtgRange = 1.05;
 
 //_____________________________________________________________________________
 void AliTPCReconstructor::Reconstruct(AliRunLoader* runLoader) const
@@ -77,6 +78,42 @@ void AliTPCReconstructor::Reconstruct(AliRunLoader* runLoader) const
   loader->UnloadDigits();
 }
 
+//_____________________________________________________________________________
+void AliTPCReconstructor::Reconstruct(AliRunLoader* runLoader,
+                                     AliRawReader* rawReader) const
+{
+// reconstruct clusters from raw data
+
+  AliLoader* loader = runLoader->GetLoader("TPCLoader");
+  if (!loader) {
+    Error("Reconstruct", "TPC loader not found");
+    return;
+  }
+  loader->LoadRecPoints("recreate");
+
+  AliTPCParam* param = GetTPCParam(runLoader);
+  if (!param) return;
+  AliTPCclustererMI clusterer(param);
+
+  Int_t iEvent = 0;
+  while (rawReader->NextEvent()) {
+    runLoader->GetEvent(iEvent++);
+
+    TTree* treeClusters = loader->TreeR();
+    if (!treeClusters) {
+      loader->MakeTree("R");
+      treeClusters = loader->TreeR();
+    }
+
+    clusterer.SetOutput(treeClusters);
+    clusterer.Digits2Clusters(rawReader);
+         
+    loader->WriteRecPoints("OVERWRITE");
+  }
+
+  loader->UnloadRecPoints();
+}
+
 //_____________________________________________________________________________
 AliTracker* AliTPCReconstructor::CreateTracker(AliRunLoader* runLoader) const
 {
@@ -104,19 +141,12 @@ AliTPCParam* AliTPCReconstructor::GetTPCParam(AliRunLoader* runLoader) const
 {
 // get the TPC parameters
 
-  if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
-  if (!runLoader->GetAliRun()) {
-    Error("GetTPCParam", "couldn't get AliRun object");
-    return NULL;
-  }
-  AliTPC* tpc = (AliTPC*) runLoader->GetAliRun()->GetDetector("TPC");
-  if (!tpc) {
-    Error("GetTPCParam", "couldn't get TPC detector");
-    return NULL;
-  }
-  if (!tpc->GetParam()) {
-    Error("GetTPCParam", "no TPC parameters available");
-    return NULL;
-  }
-  return tpc->GetParam();
+  TDirectory* saveDir = gDirectory;
+  runLoader->CdGAFile();
+
+  AliTPCParam* param = (AliTPCParam*) gDirectory->Get("75x40_100x60_150x60");
+  if (!param) Error("GetTPCParam", "no TPC parameters found");
+
+  saveDir->cd();
+  return param;
 }