/**************************************************************************
- * 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 <TFile.h>
+#include <TObjString.h>
+#include <TObjArray.h>
+#include <TTreeStream.h>
+#include <TDirectory.h>
-#include "AliRunLoader.h"
#include "AliRawReader.h"
-#include "AliLog.h"
-#include "AliESDTrdTrack.h"
-#include "AliESDEvent.h"
#include "AliTRDReconstructor.h"
-#include "AliTRDclusterizerV1.h"
-#include "AliTRDclusterizerV2.h"
-#include "AliTRDtracker.h"
-#include "AliTRDpidESD.h"
-#include "AliTRDgtuTrack.h"
+#include "AliTRDclusterizer.h"
#include "AliTRDrawData.h"
+#include "AliTRDrawStreamBase.h"
#include "AliTRDdigitsManager.h"
+#include "AliTRDtrackerV1.h"
+
+#define SETFLG(n,f) ((n) |= f)
+#define CLRFLG(n,f) ((n) &= ~f)
ClassImp(AliTRDReconstructor)
-Bool_t AliTRDReconstructor::fgkSeedingOn = kFALSE;
-Int_t AliTRDReconstructor::fgStreamLevel = 0; // Stream (debug) level
+TClonesArray *AliTRDReconstructor::fgClusters = NULL;
+TClonesArray *AliTRDReconstructor::fgTracklets = NULL;
+Char_t const * AliTRDReconstructor::fgSteerNames[kNsteer] = {
+ "DigitsConversion "
+ ,"Write Clusters "
+ ,"Write Online Tracklets "
+ ,"Stand Alone Tracking "
+ ,"HLT Mode "
+ ,"Process Online Tracklets"
+ ,"Debug Streaming "
+};
+Char_t const * AliTRDReconstructor::fgSteerFlags[kNsteer] = {
+ "dc"// digits conversion [false]
+ ,"cw"// write clusters [true]
+ ,"tw"// write online tracklets [false]
+ ,"sa"// track seeding (stand alone tracking) [true]
+ ,"hlt"// HLT reconstruction [false]
+ ,"tp"// also use online tracklets for reconstruction [false]
+ ,"deb"// Write debug stream [false]
+};
+Char_t const * AliTRDReconstructor::fgTaskNames[AliTRDrecoParam::kTRDreconstructionTasks] = {
+ "Clusterizer"
+ ,"Tracker"
+ ,"PID"
+};
+Char_t const * AliTRDReconstructor::fgTaskFlags[AliTRDrecoParam::kTRDreconstructionTasks] = {
+ "cl"
+ ,"tr"
+ ,"pd"
+};
+Int_t AliTRDReconstructor::fgNTimeBins = -1;
+
+//_____________________________________________________________________________
+AliTRDReconstructor::AliTRDReconstructor()
+ :AliReconstructor()
+ ,fSteerParam(0)
+ ,fClusterizer(NULL)
+{
+ // setting default "ON" steering parameters
+ // owner of debug streamers
+ SETFLG(fSteerParam, kOwner);
+ // write clusters [cw]
+ SETFLG(fSteerParam, kWriteClusters);
+ // track seeding (stand alone tracking) [sa]
+ SETFLG(fSteerParam, kSeeding);
+
+ memset(fDebugStream, 0, sizeof(TTreeSRedirector *) * AliTRDrecoParam::kTRDreconstructionTasks);
+}
+
+//_____________________________________________________________________________
+AliTRDReconstructor::~AliTRDReconstructor()
+{
+ //
+ // Destructor
+ //
+
+ if(fgClusters) {
+ fgClusters->Delete();
+ delete fgClusters;
+ fgClusters = NULL;
+ }
+ if(fgTracklets) {
+ fgTracklets->Delete();
+ delete fgTracklets;
+ fgTracklets = NULL;
+ }
+ if(fSteerParam&kOwner){
+ for(Int_t itask = 0; itask < AliTRDrecoParam::kTRDreconstructionTasks; itask++)
+ if(fDebugStream[itask]) delete fDebugStream[itask];
+ }
+ if(fClusterizer){
+ delete fClusterizer;
+ fClusterizer = NULL;
+ }
+}
+
+
+//_____________________________________________________________________________
+void AliTRDReconstructor::Init(){
+ //
+ // Init Options
+ //
+ SetOption(GetOption());
+ Options(fSteerParam);
+
+ if(!fClusterizer){
+ fClusterizer = new AliTRDclusterizer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]);
+ fClusterizer->SetReconstructor(this);
+ }
+
+ // Make Debug Streams when Debug Streaming
+ if(IsDebugStreaming()){
+ for(Int_t task = 0; task < AliTRDrecoParam::kTRDreconstructionTasks; task++){
+ TDirectory *savedir = gDirectory;
+ fDebugStream[task] = new TTreeSRedirector(Form("TRD.Debug%s.root", fgTaskNames[task]));
+ savedir->cd();
+ SETFLG(fSteerParam, kOwner);
+ }
+ }
+}
//_____________________________________________________________________________
void AliTRDReconstructor::ConvertDigits(AliRawReader *rawReader
- , TTree *digitsTree) const
+ , TTree *digitsTree) const
{
//
// Convert raw data digits into digit objects in a root tree
//
- AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
+ //AliInfo("Convert raw data digits into digit objects [RawReader -> Digit TTree]");
AliTRDrawData rawData;
rawReader->Reset();
rawReader->Select("TRD");
+ AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data());
AliTRDdigitsManager *manager = rawData.Raw2Digits(rawReader);
manager->MakeBranch(digitsTree);
manager->WriteDigits();
}
//_____________________________________________________________________________
-void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader
- , AliRawReader *rawReader) const
+void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
+ , TTree *clusterTree) const
{
//
// Reconstruct clusters
//
- AliInfo("Reconstruct TRD clusters from RAW data [RunLoader, RawReader]");
+ //AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
- AliLoader *loader = runLoader->GetLoader("TRDLoader");
- loader->LoadRecPoints("recreate");
-
- runLoader->CdGAFile();
- Int_t nEvents = runLoader->GetNumberOfEvents();
rawReader->Reset();
rawReader->Select("TRD");
+ AliTRDrawStreamBase::SetRawStreamVersion(GetRecoParam()->GetRawStreamVersion()->Data());
- for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
-
- if (!rawReader->NextEvent()) break;
-
- // Old (slow) cluster finder
- //AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer");
- //clusterer.Open(runLoader->GetFileName(),iEvent);
- //clusterer.ReadDigits(rawReader);
- //clusterer.MakeClusters();
-
- // New (fast) cluster finder
- AliTRDclusterizerV2 clusterer("clusterer","TRD clusterizer");
- clusterer.Open(runLoader->GetFileName(),iEvent);
- clusterer.Raw2ClustersChamber(rawReader);
-
- clusterer.WriteClusters(-1);
-
+ if(!fClusterizer){
+ AliFatal("Clusterizer not available!");
+ return;
}
- loader->UnloadRecPoints();
+ fClusterizer->ResetRecPoints();
-}
+ fClusterizer->OpenOutput(clusterTree);
+ fClusterizer->SetUseLabels(kFALSE);
+ fClusterizer->Raw2ClustersChamber(rawReader);
+
+ fgNTimeBins = fClusterizer->GetNTimeBins();
+
+ if(IsWritingClusters()) return;
-//_____________________________________________________________________________
-void AliTRDReconstructor::Reconstruct(AliRawReader *rawReader
- , TTree *clusterTree) const
-{
- //
- // Reconstruct clusters
- //
-
- AliInfo("Reconstruct TRD clusters from RAW data [RawReader -> Cluster TTree]");
+ // take over ownership of clusters
+ fgClusters = fClusterizer->RecPoints();
+ fClusterizer->SetClustersOwner(kFALSE);
- rawReader->Reset();
- rawReader->Select("TRD");
-
- // Old (slow) cluster finder
- //AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer");
- //clusterer.OpenOutput(clusterTree);
- //clusterer.ReadDigits(rawReader);
- //clusterer.MakeClusters();
-
- // New (fast) cluster finder
- AliTRDclusterizerV2 clusterer("clusterer","TRD clusterizer");
- clusterer.OpenOutput(clusterTree);
- clusterer.SetAddLabels(kFALSE);
- clusterer.Raw2ClustersChamber(rawReader);
+ // take over ownership of online tracklets
+ fgTracklets = fClusterizer->TrackletsArray();
+ fClusterizer->SetTrackletsOwner(kFALSE);
}
//_____________________________________________________________________________
//
// Reconstruct clusters
//
- AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
- //AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer");
- AliTRDclusterizerV2 clusterer("clusterer","TRD clusterizer");
+ //AliInfo("Reconstruct TRD clusters from Digits [Digit TTree -> Cluster TTree]");
+
+ AliTRDclusterizer clusterer(fgTaskNames[AliTRDrecoParam::kClusterizer], fgTaskNames[AliTRDrecoParam::kClusterizer]);
+ clusterer.SetReconstructor(this);
clusterer.OpenOutput(clusterTree);
clusterer.ReadDigits(digitsTree);
clusterer.MakeClusters();
-}
-
-//_____________________________________________________________________________
-void AliTRDReconstructor::Reconstruct(AliRunLoader *runLoader) const
-{
- //
- // Reconstruct clusters
- //
- AliInfo("Reconstruct TRD clusters [AliRunLoader]");
- AliLoader *loader = runLoader->GetLoader("TRDLoader");
- loader->LoadRecPoints("recreate");
+ fgNTimeBins = clusterer.GetNTimeBins();
- runLoader->CdGAFile();
- Int_t nEvents = runLoader->GetNumberOfEvents();
+ if(IsWritingClusters()) return;
- for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
- AliTRDclusterizerV1 clusterer("clusterer","TRD clusterizer");
- //AliTRDclusterizerV2 clusterer("clusterer","TRD clusterizer");
- clusterer.Open(runLoader->GetFileName(),iEvent);
- clusterer.ReadDigits();
- clusterer.MakeClusters();
- clusterer.WriteClusters(-1);
- }
+ // take over ownership of clusters
+ fgClusters = clusterer.RecPoints();
+ clusterer.SetClustersOwner(kFALSE);
- loader->UnloadRecPoints();
+ // take over ownership of online tracklets
+ fgTracklets = clusterer.TrackletsArray();
+ clusterer.SetTrackletsOwner(kFALSE);
}
//_____________________________________________________________________________
-AliTracker *AliTRDReconstructor::CreateTracker(AliRunLoader *runLoader) const
+AliTracker *AliTRDReconstructor::CreateTracker() const
{
//
// Create a TRD tracker
//
- runLoader->CdGAFile();
-
- return new AliTRDtracker(gFile);
+ //return new AliTRDtracker(NULL);
+ AliTRDtrackerV1 *tracker = new AliTRDtrackerV1();
+ tracker->SetReconstructor(this);
+ return tracker;
}
//_____________________________________________________________________________
-void AliTRDReconstructor::FillESD(AliRunLoader* /*runLoader*/
- , AliRawReader* /*rawReader*/
- , AliESDEvent* /*esd*/) const
+void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
+ , TTree* /*clusterTree*/
+ , AliESDEvent* /*esd*/) const
{
//
// Fill ESD
}
//_____________________________________________________________________________
-void AliTRDReconstructor::FillESD(AliRawReader* /*rawReader*/
- , TTree* /*clusterTree*/
- , AliESDEvent* /*esd*/) const
+void AliTRDReconstructor::SetOption(Option_t *opt)
{
//
- // Fill ESD
+ // Read option string into the steer param.
//
+ AliReconstructor::SetOption(opt);
+
+ TString s(opt);
+ TObjArray *opar = s.Tokenize(",");
+ for(Int_t ipar=0; ipar<opar->GetEntriesFast(); ipar++){
+ Bool_t processed = kFALSE;
+ TString sopt(((TObjString*)(*opar)[ipar])->String());
+ for(Int_t iopt=0; iopt<kNsteer; iopt++){
+ if(!sopt.Contains(fgSteerFlags[iopt])) continue;
+ SETFLG(fSteerParam, BIT(iopt));
+ if(sopt.Contains("!")) CLRFLG(fSteerParam, BIT(iopt));
+ processed = kTRUE;
+ break;
+ }
+ if(processed) continue;
+
+ AliWarning(Form("Unknown option flag %s.", sopt.Data()));
+ }
}
//_____________________________________________________________________________
-void AliTRDReconstructor::FillESD(TTree* /*digitsTree*/
- , TTree* /*clusterTree*/
- , AliESDEvent* /*esd*/) const
+void AliTRDReconstructor::Options(UInt_t steer)
{
//
- // Fill ESD
+ // Print the options
//
+ for(Int_t iopt=0; iopt<kNsteer; iopt++){
+ AliDebugGeneral("AliTRDReconstructor", 1, Form(" %s[%s]%s", fgSteerNames[iopt], fgSteerFlags[iopt], steer ?(((steer>>iopt)&1)?" : ON":" : OFF"):""));
+ }
}
-//_____________________________________________________________________________
-void AliTRDReconstructor::FillESD(AliRunLoader* /*runLoader*/
- , AliESDEvent* /*esd*/) const
-{
- //
- // Fill ESD
- //
-
-}