]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDReconstructor.cxx
changes in AliTRDdigitsManager
[u/mrichter/AliRoot.git] / TRD / AliTRDReconstructor.cxx
index 67692e59f92edab95770a5e0536b00167898deda..b1e8da1bb5000236292f851800aa009527166c80 100644 (file)
@@ -1,17 +1,17 @@
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
 
 /* $Id$ */
 
 #include "AliTRDtrackerV1.h"
 #include "AliTRDrecoParam.h"
 
+#include "TTreeStream.h"
+
+#define SETFLG(n,f) ((n) |= f)
+#define CLRFLG(n,f) ((n) &= ~f)
+
 ClassImp(AliTRDReconstructor)
 
 TClonesArray *AliTRDReconstructor::fgClusters = 0x0;
 //_____________________________________________________________________________
 AliTRDReconstructor::AliTRDReconstructor()
   :AliReconstructor()
-  ,fSteerParam(0x00000007)
+  ,fSteerParam(0)
 {
-  //
-  // Default constructor
-  //
+  // setting default "ON" steering parameters
+  // write clusters [cw]
+  SETFLG(fSteerParam, kWriteClusters);
+  // track seeding (stand alone tracking) [sa]
+  SETFLG(fSteerParam, kSeeding);
+  // PID method in reconstruction (NN) [nn]
+  SETFLG(fSteerParam, kSteerPID);
 
   memset(fStreamLevel, 0, 5*sizeof(UChar_t));
+  memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * 4);
   // Xe tail cancellation parameters
   fTCParams[0] = 1.156; // r1
   fTCParams[1] = 0.130; // r2
@@ -65,7 +75,7 @@ AliTRDReconstructor::AliTRDReconstructor()
   fTCParams[5] = 0.62;  // r2
   fTCParams[6] = 0.0087;// c1
   fTCParams[7] = 0.07;  // c2
-
+  SetBit(kOwner, kTRUE);
 }
 
 //_____________________________________________________________________________
@@ -73,58 +83,54 @@ AliTRDReconstructor::AliTRDReconstructor(const AliTRDReconstructor &r)
   :AliReconstructor(r)
   ,fSteerParam(r.fSteerParam)
 {
-  //
-  // Copy constructor
-  //
-
-  memcpy(fStreamLevel,r.fStreamLevel, 5*sizeof(UChar_t));
-  memcpy(fTCParams   ,r.fTCParams   , 8*sizeof(Double_t));
-
+  memcpy(fStreamLevel, r.fStreamLevel, 5*sizeof(UChar_t));
+  memcpy(fTCParams, r.fTCParams, 8*sizeof(Double_t));
+  memcpy(fDebugStream, r.fDebugStream, sizeof(TTreeSRedirector *) *4);
+  SetBit(kOwner, kFALSE);
 }
 
 //_____________________________________________________________________________
 AliTRDReconstructor::~AliTRDReconstructor()
 {
-  //
-  // Destructor
-  //
-
   if(fgClusters) {
     fgClusters->Delete(); delete fgClusters;
   }
-
+  if(TestBit(kOwner)){
+    for(Int_t itask = 0; itask < 4; itask++)
+      if(fDebugStream[itask]) delete fDebugStream[itask];
+  }
 }
 
+
 //_____________________________________________________________________________
-void AliTRDReconstructor::Init()
-{
+void AliTRDReconstructor::Init(){
   //
   // Init Options
   //
-
   SetOption(GetOption());
 
-  AliInfo("TRD reconstruction will use the following settings:");
-  printf("\tWrite Clusters         [cw] : %s\n", fSteerParam&kWriteClusters?"yes":"no");
-  printf("\tWrite Online Tracklets [tw] : %s\n", fSteerParam&kWriteTracklets?"yes":"no");
-  printf("\tDrift Gas Argon        [ar] : %s\n", fSteerParam&kDriftGas?"yes":"no");
-  printf("\tStand Alone Tracking   [sa] : %s\n", fSteerParam&kSeeding?"yes":"no");
-  printf("\tHLT         Tracking  [hlt] : %s\n", fSteerParam&kHLT?"yes":"no");
-  printf("\tNN PID                 [nn] : %s\n", fSteerParam&kSteerPID?"yes":"no");
-  printf("\tStreaming Levels            : Clusterizer[%d] Tracker[%d] PID[%d]\n"
-        ,fStreamLevel[kClusterizer]
-        ,fStreamLevel[kTracker]
-        ,fStreamLevel[kPID]);
-
+  AliInfo(Form("\tDigitsConversion       [dc] : %s", fSteerParam&kDigitsConversion?"yes":"no"));
+  AliInfo(Form("\tWrite Clusters         [cw] : %s", fSteerParam&kWriteClusters?"yes":"no"));
+  AliInfo(Form("\tWrite Online Tracklets [tw] : %s", fSteerParam&kWriteTracklets?"yes":"no"));
+  AliInfo(Form("\tDrift Gas Argon        [ar] : %s", fSteerParam&kDriftGas?"yes":"no"));
+  AliInfo(Form("\tStand Alone Tracking   [sa] : %s", fSteerParam&kSeeding?"yes":"no"));
+  AliInfo(Form("\tHLT         Tracking  [hlt] : %s", fSteerParam&kHLT?"yes":"no"));
+  AliInfo(Form("\tCosmic Reconstruction [cos] : %s", fSteerParam&kCosmic?"yes":"no"));
+  AliInfo(Form("\tNN PID                 [nn] : %s", fSteerParam&kSteerPID?"yes":"no"));
+  AliInfo(Form("\t8 dEdx slices in ESD   [8s] : %s", fSteerParam&kEightSlices?"yes":"no"));
+  AliInfo(Form("\tStreaming Levels            : Clusterizer[%d] Tracker[%d] PID[%d]", fStreamLevel[kClusterizer], fStreamLevel[kTracker], fStreamLevel[kPID]));
 }
 
 //_____________________________________________________________________________
 void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
-                                     , TTree *digitsTree) const
+              , TTree *digitsTree) const
 {
   //
   // Convert raw data digits into digit objects in a root tree
   //
+  AliInfo("Feature not available for the moment."); return;
+
+  AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
 
   AliTRDrawData rawData;
   rawReader->Reset();
@@ -144,13 +150,16 @@ void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
   // Reconstruct clusters
   //
 
+  //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
+
+
   rawReader->Reset();
   rawReader->Select("TRD");
 
   // New (fast) cluster finder
-  AliTRDclusterizer clusterer("clusterer","TRD clusterizer");
-  clusterer.SetReconstructor(this);
-  clusterer.OpenOutput(clusterTree);
+  AliTRDclusterizer clusterer("clusterer","TRD clusterizer",this);
+  //clusterer.SetReconstructor(this);                 //     ^| "this" tells the digitsmanager that we are reading raw files
+  clusterer.OpenOutput(clusterTree);                  //        it is not strictly necessaray but will give a speed up
   clusterer.SetAddLabels(kFALSE);
   clusterer.Raw2ClustersChamber(rawReader);
   
@@ -159,7 +168,6 @@ void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
   // take over ownership of clusters
   fgClusters = clusterer.RecPoints();
   clusterer.SetClustersOwner(kFALSE);
-
 }
 
 //_____________________________________________________________________________
@@ -170,9 +178,11 @@ void AliTRDReconstructor::Reconstruct(TTree *digitsTree
   // Reconstruct clusters
   //
 
+  //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
+
   AliTRDclusterizer clusterer("clusterer","TRD clusterizer");
-  clusterer.SetReconstructor(this);
-  clusterer.OpenOutput(clusterTree);
+  clusterer.SetReconstructor(this);                  //    ^| no this, because we are reading from digitsTree
+  clusterer.OpenOutput(clusterTree);                 //       it is necessary to NOT have the "this" here!
   clusterer.ReadDigits(digitsTree);
   clusterer.MakeClusters();
 
@@ -181,7 +191,6 @@ void AliTRDReconstructor::Reconstruct(TTree *digitsTree
   // take over ownership of clusters
   fgClusters = clusterer.RecPoints();
   clusterer.SetClustersOwner(kFALSE);
-
 }
 
 //_____________________________________________________________________________
@@ -200,8 +209,8 @@ AliTracker *AliTRDReconstructor::CreateTracker() const
 
 //_____________________________________________________________________________
 void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
-                               , TTree* /*clusterTree*/
-                               , AliESDEvent* /*esd*/) const
+        , TTree* /*clusterTree*/
+        , AliESDEvent* /*esd*/) const
 {
   //
   // Fill ESD
@@ -209,84 +218,97 @@ void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
 
 }
 
+
 //_____________________________________________________________________________
 void AliTRDReconstructor::SetOption(Option_t *opt)
 {
-  //
-  // Read option string into the steer param.
-  //
-  // Default steer param values
-  //
-  // write clusters [cw] = true
-  // track seeding (stand alone tracking) [sa] = true
-  // PID method in reconstruction (NN) [nn] = true
-  // write online tracklets [tw] = false
-  // drift gas [ar] = false
-  // HLT tracking [hlt] = false
-  //
-
-  fSteerParam = 0x00000007;
+// Read option string into the steer param.
+//
+// Default steer param values
+//
+// digits conversion [dc] = false
+// drift gas [ar] = false - do not update the number of exponentials in the TC !
+// write clusters [cw] = true
+// write online tracklets [tw] = false
+// track seeding (stand alone tracking) [sa] = true
+// PID method in reconstruction (NN) [nn] = true
+// 8 dEdx slices in ESD [8s] = false 
+// HLT tracking [hlt] = false
+// Cosmic Reconstruction [cos] = false
+//
+
+  AliReconstructor::SetOption(opt);
 
   TString s(opt);
   TObjArray *opar = s.Tokenize(",");
   for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
     TString sopt(((TObjString*)(*opar)[ipar])->String());
-    if(sopt.Contains("!cw")){ 
-      fSteerParam &= ~kWriteClusters;
+    if(sopt.Contains("dc")){
+      SETFLG(fSteerParam, kDigitsConversion);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kDigitsConversion);
+      continue;        
+    } else if(sopt.Contains("cw")){ 
+      SETFLG(fSteerParam, kWriteClusters);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kWriteClusters);
+      continue;
+    } else if(sopt.Contains("sa")){
+      SETFLG(fSteerParam, kSeeding);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kSeeding);
       continue;
-    } else if(sopt.Contains("!sa")){
-      fSteerParam &= ~kSeeding;
+    } else if(sopt.Contains("nn")){
+      SETFLG(fSteerParam, kSteerPID);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kSteerPID);
       continue;
-    } else if(sopt.Contains("!nn")){
-      fSteerParam &= ~kSteerPID;
+    } else if(sopt.Contains("8s")){
+      SETFLG(fSteerParam, kEightSlices);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kEightSlices);
       continue;
     } else if(sopt.Contains("tw")){
-      if(!sopt.Contains("!")) fSteerParam |= kWriteTracklets;
+      SETFLG(fSteerParam, kWriteTracklets);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kWriteTracklets);
       continue;        
     } else if(sopt.Contains("ar")){
-      if(!sopt.Contains("!")) fSteerParam |= kDriftGas;
+      SETFLG(fSteerParam, kDriftGas);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kDriftGas);
       continue;        
     } else if(sopt.Contains("hlt")){
-      if(!sopt.Contains("!")) fSteerParam |= kHLT;
+      SETFLG(fSteerParam, kHLT);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kHLT);
       continue;        
+    } else if(sopt.Contains("cos")){
+      SETFLG(fSteerParam, kCosmic);
+      if(sopt.Contains("!")) CLRFLG(fSteerParam, kCosmic);
     } else if(sopt.Contains("sl")){
-       TObjArray *stl = sopt.Tokenize("_");
-       if(stl->GetEntriesFast() < 3) continue;
-                       TString taskstr(((TObjString*)(*stl)[1])->String());
-                       TString levelstring(((TObjString*)(*stl)[2])->String());
-       // Set the stream Level
-       Int_t level = levelstring.Atoi();
-       AliTRDReconstructorTask task = kTracker;
-       if(taskstr.CompareTo("cl") == 0) task = kClusterizer;   
-       else if(taskstr.CompareTo("tr") == 0) task = kTracker;
-       else if(taskstr.CompareTo("pi") == 0) task = kPID;
-       SetStreamLevel(level, task);
-       continue;
-               }
+      TObjArray *stl = sopt.Tokenize("_");
+      if(stl->GetEntriesFast() < 3) continue;
+      TString taskstr(((TObjString*)(*stl)[1])->String());
+      TString levelstring(((TObjString*)(*stl)[2])->String());
+      // Set the stream Level
+      Int_t level = levelstring.Atoi();
+      AliTRDReconstructorTask task = kTracker;
+      if(taskstr.CompareTo("raw") == 0) task = kRawReader;     
+      else if(taskstr.CompareTo("cl") == 0) task = kClusterizer;       
+      else if(taskstr.CompareTo("tr") == 0) task = kTracker;
+      else if(taskstr.CompareTo("pi") == 0) task = kPID;
+      SetStreamLevel(level, task);
+      continue;
+    }
   }
-
 }
 
 //_____________________________________________________________________________
-void AliTRDReconstructor::SetStreamLevel(Int_t level, AliTRDReconstructorTask task)
-{
+void AliTRDReconstructor::SetStreamLevel(Int_t level, AliTRDReconstructorTask task){
   //
   // Set the Stream Level for one of the tasks Clusterizer, Tracker or PID
   //
-
-  TString taskname;
-  switch(task) {
-    case kClusterizer: 
-      taskname = "Clusterizer";
-      break;
-    case kTracker: 
-      taskname = "Tracker";
-      break;
-    case kPID: 
-      taskname = "PID";
-      break;
-  }
-
+  TString taskname[4] = {"RawReader", "Clusterizer", "Tracker", "PID"};
+  const Int_t minLevel[4] = {1, 1, 2, 1}; // the minimum debug level upon which a debug stream is created for different tasks
+  //AliInfo(Form("Setting Stream Level for Task %s to %d", taskname.Data(),level));
   fStreamLevel[(Int_t)task] = level;
-
+  // Initialize DebugStreamer if not yet done
+  if(level >= minLevel[task] && !fDebugStream[task]){
+    TDirectory *savedir = gDirectory;
+    fDebugStream[task] = new TTreeSRedirector(Form("TRD.%sDebug.root", taskname[task].Data()));
+    savedir->cd();
+  }
 }