]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFReconstructor.cxx
Corrected t0spread stored in AliTOFHeader object and changed log infos
[u/mrichter/AliRoot.git] / TOF / AliTOFReconstructor.cxx
index 744180f32c760bb4d9ed1ea12baf8433624f4125..aba69870b99a69a95df989e1908bf62ccf2b8912 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-
-#include <TFile.h>
+#include <cstdlib>
+#include "TObjArray.h"
+#include "TString.h"
 
 #include "AliLog.h"
-#include "AliRun.h"
-#include "AliRunLoader.h"
+#include "AliESDEvent.h"
+#include "AliESDpid.h"
+#include "AliRawReader.h"
+#include "AliTOFHeader.h"
 
-#include "AliTOFGeometry.h"
-#include "AliTOFGeometryV4.h"
-#include "AliTOFGeometryV5.h"
-#include "AliTOFtracker.h"
-#include "AliTOFtrackerMI.h"
 #include "AliTOFClusterFinder.h"
+#include "AliTOFClusterFinderV1.h"
+#include "AliTOFcalib.h"
+#include "AliTOFtrackerMI.h"
+#include "AliTOFtracker.h"
+#include "AliTOFtrackerV1.h"
+#include "AliTOFT0maker.h"
 #include "AliTOFReconstructor.h"
 
+class TTree;
+
 ClassImp(AliTOFReconstructor)
 
-//_____________________________________________________________________________
-  void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader) const
+ //____________________________________________________________________
+AliTOFReconstructor::AliTOFReconstructor() 
+  : AliReconstructor(),
+    fTOFcalib(0)/*,
+                 fTOFT0maker(0)*/
 {
-// reconstruct clusters from digits
+//
+// ctor
+//
+  
+  //Retrieving the TOF calibration info  
+  fTOFcalib = new AliTOFcalib();
+  fTOFcalib->Init();
 
-  AliTOFClusterFinder *tofClus = new AliTOFClusterFinder(runLoader);
-  tofClus->Load();
-  for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++)
-    {
-      tofClus->Digits2RecPoints(iEvent);
-    }
-  tofClus->UnLoad();
+#if 0
+  fTOFcalib->CreateCalObjects();
+
+  if(!fTOFcalib->ReadParOnlineDelayFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+  if(!fTOFcalib->ReadParOnlineStatusFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+
+  if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+
+
+  if(!fTOFcalib->ReadDeltaBCOffsetFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+  if(!fTOFcalib->ReadCTPLatencyFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+  if(!fTOFcalib->ReadT0FillFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+  if(!fTOFcalib->ReadRunParamsFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
+#endif
 
 }
 
 //_____________________________________________________________________________
-void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader,
-                                      AliRawReader *rawReader) const
+AliTOFReconstructor::~AliTOFReconstructor() 
 {
-// reconstruct clusters from Raw Data
-
-  AliTOFClusterFinder tofClus(runLoader);
-  tofClus.LoadClusters();
-  Int_t iEvent = 0;
-  while (rawReader->NextEvent()) {
-    tofClus.Digits2RecPoints(iEvent,rawReader);
-    //tofClus.Raw2Digits(iEvent,rawReader); // temporary solution
-    iEvent++;
-  }
-  tofClus.UnLoadClusters();
+//
+// dtor
+//
+
+  delete fTOFcalib;
+
+  //delete fTOFT0maker;
 
 }
 
@@ -75,61 +92,181 @@ void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader,
 void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
                                       TTree *clustersTree) const
 {
-// reconstruct clusters from Raw Data
+  //
+  // reconstruct clusters from Raw Data
+  //
+
+  TString optionString = GetOption();
 
-  AliTOFClusterFinder tofClus;
-  tofClus.Digits2RecPoints(rawReader, clustersTree);
+  // use V1 cluster finder if selected
+  if (optionString.Contains("ClusterizerV1")) {
+    static AliTOFClusterFinderV1 tofClus(fTOFcalib);
+
+    // decoder version option
+    if (optionString.Contains("DecoderV0")) {
+      tofClus.SetDecoderVersion(0);
+    }
+    else if (optionString.Contains("DecoderV1")) {
+      tofClus.SetDecoderVersion(1);
+    }
+    else {
+      tofClus.SetDecoderVersion(2);
+    }
+    
+    tofClus.Digits2RecPoints(rawReader, clustersTree);
+  }
+  else {
+    static AliTOFClusterFinder tofClus(fTOFcalib);
+    
+    // decoder version option
+    if (optionString.Contains("DecoderV0")) {
+      tofClus.SetDecoderVersion(0);
+    }
+    else if (optionString.Contains("DecoderV1")) {
+      tofClus.SetDecoderVersion(1);
+    }
+    else {
+      tofClus.SetDecoderVersion(2);
+    }
+
+    tofClus.Digits2RecPoints(rawReader, clustersTree);
+  }
 
 }
 
 //_____________________________________________________________________________
-AliTracker* AliTOFReconstructor::CreateTracker(AliRunLoader* runLoader) const
+void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
+                                      TTree *clustersTree) const
 {
-// create a TOF tracker
+  //
+  // reconstruct clusters from digits
+  //
 
-  AliTOFGeometry* geom = GetTOFGeometry(runLoader);
-  if (!geom) return NULL;
-  //  Double_t parPID[] = {130., 5.};
-  Double_t parPID[] = {80., 5.};
-  TString selectedTracker = GetOption();
-  // use MI tracker if selected
-  if (selectedTracker.Contains("MI")) return new AliTOFtrackerMI(geom,parPID);
+  AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree")); 
 
-  return new AliTOFtracker(geom, parPID);
-}
+  TString optionString = GetOption();
+  // use V1 cluster finder if selected
+  if (optionString.Contains("ClusterizerV1")) {
+    static AliTOFClusterFinderV1 tofClus(fTOFcalib);
+
+    // decoder version option
+    if (optionString.Contains("DecoderV0")) {
+      tofClus.SetDecoderVersion(0);
+    }
+    else if (optionString.Contains("DecoderV1")) {
+      tofClus.SetDecoderVersion(1);
+    }
+    else {
+      tofClus.SetDecoderVersion(2);
+    }
+    
+    tofClus.Digits2RecPoints(digitsTree, clustersTree);
+  }
+  else {
+    static AliTOFClusterFinder tofClus(fTOFcalib);
+
+    // decoder version option
+    if (optionString.Contains("DecoderV0")) {
+      tofClus.SetDecoderVersion(0);
+    }
+    else if (optionString.Contains("DecoderV1")) {
+      tofClus.SetDecoderVersion(1);
+    }
+    else {
+      tofClus.SetDecoderVersion(2);
+    }
+    
+    tofClus.Digits2RecPoints(digitsTree, clustersTree);
+  }
 
+}
 //_____________________________________________________________________________
-void AliTOFReconstructor::FillESD(AliRunLoader* /*runLoader*/, 
-                                 AliESD* /*esd*/) const
+  void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
 {
-// nothing to be done
+// reconstruct clusters from digits
+
+  AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree")); 
+
+  TString optionString = GetOption();
+  // use V1 cluster finder if selected
+  if (optionString.Contains("ClusterizerV1")) {
+    static AliTOFClusterFinderV1 tofClus(fTOFcalib);
+
+    // decoder version option
+    if (optionString.Contains("DecoderV0")) {
+      tofClus.SetDecoderVersion(0);
+    }
+    else if (optionString.Contains("DecoderV1")) {
+      tofClus.SetDecoderVersion(1);
+    }
+    else {
+      tofClus.SetDecoderVersion(2);
+    }
+    
+    tofClus.Raw2Digits(reader, digitsTree);
+  }
+  else {
+    static AliTOFClusterFinder tofClus(fTOFcalib);
+
+    // decoder version option
+    if (optionString.Contains("DecoderV0")) {
+      tofClus.SetDecoderVersion(0);
+    }
+    else if (optionString.Contains("DecoderV1")) {
+      tofClus.SetDecoderVersion(1);
+    }
+    else {
+      tofClus.SetDecoderVersion(2);
+    }
+    
+    tofClus.Raw2Digits(reader, digitsTree);
+  }
 
 }
 
 //_____________________________________________________________________________
-AliTOFGeometry* AliTOFReconstructor::GetTOFGeometry(AliRunLoader* runLoader) const
+AliTracker* AliTOFReconstructor::CreateTracker() const
 {
-// get the TOF parameters
 
-  AliTOFGeometry *tofGeom;
+  // 
+  // create a TOF tracker using 
+  // TOF Reco Param collected by STEER
+  //
 
-  runLoader->CdGAFile();
-  TDirectory *savedir=gDirectory; 
-  TFile *in=(TFile*)gFile;  
-  if (!in->IsOpen()) {
-    AliWarning("Geometry file is not open default  TOF geometry will be used");
-    tofGeom = new AliTOFGeometry();
+  TString selectedTracker = GetOption();
+  AliTracker *tracker;
+  // use MI tracker if selected
+  if (selectedTracker.Contains("TrackerMI")) {
+    tracker = new AliTOFtrackerMI();
+  }
+  // use V1 tracker if selected
+  else if (selectedTracker.Contains("TrackerV1")) {
+    tracker =  new AliTOFtrackerV1();
   }
   else {
-    in->cd();  
-    tofGeom = (AliTOFGeometry*) in->Get("TOFgeometry");
+    tracker = new AliTOFtracker();
   }
+  return tracker;
 
-  savedir->cd();  
+}
+
+//_____________________________________________________________________________
+void AliTOFReconstructor::FillEventTimeWithTOF(AliESDEvent *event, AliESDpid *esdPID)
+{
+  //
+  // Fill AliESDEvent::fTOFHeader variable
+  // It contains the event_time estiamted by the TOF combinatorial algorithm
+  //
+
+  Float_t tofResolution = GetRecoParam()->GetTimeResolution();// TOF time resolution in ps
+  AliTOFT0maker *tofT0maker = new AliTOFT0maker(esdPID,fTOFcalib);
+  //AliTOFT0maker tofT0maker = AliTOFT0maker(esdPID,fTOFcalib);
+  tofT0maker->SetTimeResolution(tofResolution);
+  tofT0maker->ComputeT0TOF(event);
+  tofT0maker->WriteInESD(event);
+  tofT0maker->~AliTOFT0maker();
+  delete tofT0maker;
 
-  if (!tofGeom) {
-    AliError("no TOF geometry available");
-    return NULL;
-  }
-  return tofGeom;
 }
+