]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
integration of AliHLTSystem into Reconstructor (LocalReconstruction); handling of...
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Mar 2007 15:16:39 +0000 (15:16 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Mar 2007 15:16:39 +0000 (15:16 +0000)
HLT/src/AliHLTReconstructor.cxx
HLT/src/AliHLTReconstructor.h

index 53816f4233076fb4fd368265261e5b476b31f7fd..a8435ca7e5808eb8a91ae5b0d175d27a9fb2643c 100644 (file)
@@ -13,6 +13,7 @@
 #include <Riostream.h>
 #include <TSystem.h>
 #include <TArrayF.h>
+#include <TObjString.h>
 
 #include <AliRunLoader.h>
 #include <AliHeader.h>
@@ -32,6 +33,7 @@
 #include "AliHLTHoughTrack.h"
 #include "AliHLTTrackArray.h"
 
+#include "AliLog.h"
 #include "AliRun.h"
 #include "AliITS.h"
 #include "AliHLTITStracker.h"
 #include "MUON/src/AliRoot/AliHLTMUONTracker.h"
 #include "MUON/src/AliRoot/AliHLTMUONHitReconstructor.h"
 #include "AliRawReader.h"
+#include "AliHLTSystem.h"
+
 #if __GNUC__== 3
 using namespace std;
 #endif
 
+const char* kHLTDefaultLibs[]= {
+  "libAliHLTUtil.so", 
+  "libAliHLTTPC.so", 
+  //  "libAliHLTSample.so",
+  "libAliHLTPHOS.so",
+  NULL
+};
+
 ClassImp(AliHLTReconstructor)
 
-AliHLTReconstructor::AliHLTReconstructor(): AliReconstructor() 
+AliHLTReconstructor::AliHLTReconstructor()
+  : 
+  AliReconstructor(),
+  fDoHough(0),
+  fDoTracker(1),
+  fDoBench(0),
+  fDoCleanUp(0),
+  fpSystem(NULL)
 { 
   //constructor
 #ifndef use_logging
   AliHLTLog::fgLevel=AliHLTLog::kWarning;
 #endif
-  fDoTracker=1;
-  fDoHough=0;
-  fDoBench=0;
-  fDoCleanUp=1;
 }
 
-AliHLTReconstructor::AliHLTReconstructor(Bool_t doTracker, Bool_t doHough): AliReconstructor() 
-{ 
+AliHLTReconstructor::AliHLTReconstructor(Bool_t doTracker, Bool_t doHough)
+  : 
+  AliReconstructor(),
+  fDoHough(doHough),
+  fDoTracker(doTracker),
+  fDoBench(0),
+  fDoCleanUp(0),
+  fpSystem(new AliHLTSystem)
+{
   //constructor
 #ifndef use_logging
   AliHLTLog::fgLevel=AliHLTLog::kWarning;
 #endif
-  fDoTracker=doTracker;
-  fDoHough=doHough;
+}
+
+AliHLTReconstructor::AliHLTReconstructor(const AliHLTReconstructor&)
+  :
+  AliReconstructor(),
+  fDoHough(0),
+  fDoTracker(0),
+  fDoBench(0),
+  fDoCleanUp(0),
+  fpSystem(NULL)
+{
+  // not a valid copy constructor
+}
+
+AliHLTReconstructor& AliHLTReconstructor::operator=(const AliHLTReconstructor&)
+{
+  // not a valid assignment operator
+  fDoHough=0;
+  fDoTracker=0;
   fDoBench=0;
-  fDoCleanUp=1;
+  fDoCleanUp=0;
+  fpSystem=NULL;
+  return *this;
 }
 
 AliHLTReconstructor::~AliHLTReconstructor()
 { 
-  //deconstructor
+  //destructor
   if(fDoCleanUp){
     char name[256];
     gSystem->Exec("rm -rf hlt");
@@ -81,35 +122,105 @@ AliHLTReconstructor::~AliHLTReconstructor()
     sprintf(name, "rm -f hough_*.root hough_*.dat");
     gSystem->Exec(name);
   }
+  if (fpSystem) {
+    delete fpSystem;
+  }
+  fpSystem=NULL;
 }
 
-void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader) const
+void AliHLTReconstructor::Init(AliRunLoader* runLoader)
 {
-  // do the standard and hough reconstruction chain
+  // init the reconstructor
   if(!runLoader) {
-    LOG(AliHLTLog::kFatal,"AliHLTReconstructor::Reconstruct","RunLoader")
-      <<" Missing RunLoader! 0x0"<<ENDLOG;
+    AliError("Missing RunLoader! 0x0");
+    return;
+  }
+
+  if (!fpSystem) fpSystem=new AliHLTSystem;
+  if (!fpSystem) {
+    AliError("can not create AliHLTSystem object");
     return;
   }
-  gSystem->Exec("rm -rf hlt");
-  gSystem->MakeDirectory("hlt");
-  gSystem->Exec("rm -rf hough");
-  gSystem->MakeDirectory("hough");
-
-  Bool_t isinit=AliHLTTransform::Init(runLoader);
-  if(!isinit){
-    LOG(AliHLTLog::kError,"AliHLTReconstructor::Reconstruct","Transformer")
-     << "Could not create transform settings, please check log for error messages!" << ENDLOG;
+  if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
+    AliError("HLT system in error state");
     return;
   }
 
-  Int_t nEvents = runLoader->GetNumberOfEvents();
+  TString libs("");
+  TString option = GetOption();
+  TObjArray* pTokens=option.Tokenize(" ");
+  if (pTokens) {
+    int iEntries=pTokens->GetEntries();
+    for (int i=0; i<iEntries; i++) {
+      TString token=(((TObjString*)pTokens->At(i))->GetString());
+      if (token.Contains("loglevel=")) {
+       TString param=token.ReplaceAll("loglevel=", "");
+       if (param.IsDigit()) {
+         fpSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
+       } else if (param.BeginsWith("0x") &&
+                  param.Replace(0,2,"",0).IsHex()) {
+         int severity=0;
+         sscanf(param.Data(),"%x", &severity);
+         fpSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
+       } else {
+         AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
+       }
+      } else if (token.Contains("alilog=off")) {
+       fpSystem->SwitchAliLog(0);
+      } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
+       libs+=token;
+       libs+=" ";
+      } else {
+       AliWarning(Form("unknown option: %s", token.Data()));
+      }
+    }
+    delete pTokens;
+  }
+  
+  Bool_t bForceLibLoad=0;
+  if (bForceLibLoad=(libs.IsNull())) {
+    const char** deflib=kHLTDefaultLibs;
+    while (*deflib) {
+      libs+=*deflib++;
+      libs+=" ";
+    }
+  }
+  if ((bForceLibLoad || !fpSystem->CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
+      (fpSystem->LoadComponentLibraries(libs.Data())<0)) {
+    AliError("error while loading HLT libraries");
+    return;
+  }
+  if (!fpSystem->CheckStatus(AliHLTSystem::kReady) &&
+      (fpSystem->Configure(runLoader))<0) {
+    AliError("error during HLT system configuration");
+    return;
+  }
+}
+
+void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader) const
+{
+  // reconstruction of simulated data
+  Reconstruct(runLoader, NULL);
+}
+
+void AliHLTReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawReader) const 
+{
+  // reconstruction of real data if rawReader!=NULL
+  if(!runLoader) {
+    AliError("Missing RunLoader! 0x0");
+    return;
+  }
 
-  for(Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
-    runLoader->GetEvent(iEvent);
+  Int_t nEvents = runLoader->GetNumberOfEvents();
+  int iResult=0;
 
-    if(fDoTracker) ReconstructWithConformalMapping(runLoader,iEvent);
-    if(fDoHough) ReconstructWithHoughTransform(runLoader,iEvent);
+  if (fpSystem) {
+    if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
+      AliError("HLT system in error state");
+      return;
+    }
+    if ((iResult=fpSystem->Reconstruct(nEvents, runLoader, rawReader))>=0) {
+    }
   }
 }
 
@@ -213,10 +324,26 @@ void AliHLTReconstructor::FillESD(AliRunLoader* runLoader,
                                  AliESD* esd) const
 {
   //fill the esd file with found tracks
+  if(!runLoader) {
+    AliError("Missing RunLoader! 0x0");
+    return;
+  }
   Int_t iEvent = runLoader->GetEventNumber();
-
+  if (fpSystem) {
+    if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
+      AliError("HLT system in error state");
+      return;
+    }
+    if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
+      AliError("HLT system in wrong state");
+      return;
+    }
+    fpSystem->FillESD(iEvent, runLoader, esd);
+  }
+  /*
   if(fDoTracker) FillESDforConformalMapping(esd,iEvent);
   if(fDoHough) FillESDforHoughTransform(esd,iEvent);
+  */
 }
 
 void AliHLTReconstructor::FillESDforConformalMapping(AliESD* esd,Int_t iEvent) const
index 45d502a3f48eef1db5eb466ce5ad9d51b8b5bb28..ad8e4e012d1d4c9223d1f480982fc07812de40c9 100644 (file)
@@ -8,24 +8,40 @@
 #ifdef use_reconstruction
 #include "AliReconstructor.h"
 
+class AliHLTSystem;
+
 class AliHLTReconstructor: public AliReconstructor {
 public:
   AliHLTReconstructor();
   AliHLTReconstructor(Bool_t doTracker, Bool_t doHough);
+  /** not a valid copy constructor, defined according to effective C++ style */
+  AliHLTReconstructor(const AliHLTReconstructor& src);
+  /** not a valid assignment op, but defined according to effective C++ style */
+  AliHLTReconstructor& operator=(const AliHLTReconstructor& src);
+  /** destructor */
   virtual ~AliHLTReconstructor();
 
+  /** init the reconstructor */
+  void Init(AliRunLoader* runLoader);
+
+  /** reconstruct simulated MC data */
+  void Reconstruct(AliRunLoader* runLoader) const;
+  /** reconstruct data from RawReader */
+  void Reconstruct(AliRunLoader* runLoader, AliRawReader* rawReader) const;
+
+  /** create a tracker */
+  AliTracker*  CreateTracker(AliRunLoader*) const;
+
+  /** fill esd for one event */
+  void FillESD(AliRunLoader* runLoader, AliESD* esd) const;
+
   virtual void         Reconstruct(TTree* digitsTree, TTree* clustersTree) const{
     AliReconstructor::Reconstruct(digitsTree,clustersTree);
   }
   virtual void         Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {
     AliReconstructor::Reconstruct(rawReader,clustersTree);
   }
-  virtual void         Reconstruct(AliRunLoader* runLoader) const;
-  virtual void         Reconstruct(AliRunLoader* runLoader, 
-                                  AliRawReader* rawReader) const {
-    AliReconstructor::Reconstruct(runLoader,rawReader);
-  }
-  virtual AliTracker*  CreateTracker(AliRunLoader*) const;
+
   virtual void         FillESD(TTree* digitsTree, TTree* clustersTree, 
                               AliESD* esd) const {
     AliReconstructor::FillESD(digitsTree,clustersTree,esd);
@@ -34,7 +50,6 @@ public:
                               AliESD* esd) const {
     AliReconstructor::FillESD(rawReader,clustersTree,esd);
   }
-  virtual void         FillESD(AliRunLoader* runLoader, AliESD* esd) const;
   virtual void         FillESD(AliRunLoader* runLoader, 
                               AliRawReader* rawReader, AliESD* esd) const {
     AliReconstructor:: FillESD(runLoader,rawReader,esd);
@@ -53,7 +68,11 @@ private:
   Bool_t fDoBench;   //store the benchmark results
   Bool_t fDoCleanUp; //delete tmp tracking files
 
-  ClassDef(AliHLTReconstructor, 0)   // class for the TPC reconstruction
+  AliHLTSystem* fpSystem; //! HLT steering object
+  Int_t  fRecEvents;      //! number of reconstructed events
+  Int_t  fFilled;         //! number of event filled to ESD
+
+  ClassDef(AliHLTReconstructor, 1)   // class for the TPC reconstruction
 };
 #endif