]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/rec/AliHLTReconstructor.cxx
Adding OADB to CMake
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTReconstructor.cxx
index e9114feef63e0c288772a1639ada15705d37c705..dd9f5d1de7f230f3e8b9aa02c915a21a084bda2e 100644 (file)
 //* provided "as is" without express or implied warranty.                  *
 //**************************************************************************
 
-/** @file   AliHLTReconstructor.cxx
-    @author Matthias Richter
-    @date   
-    @brief  Binding class for HLT reconstruction in AliRoot. */
+//  @file   AliHLTReconstructor.cxx
+//  @author Matthias Richter
+//  @date   
+//  @brief  Binding class for HLT reconstruction in AliRoot
+//          Implements bot the interface to run HLT chains embedded into
+//          AliReconstruction and the unpacking and treatment of HLTOUT
 
 #include <TSystem.h>
 #include <TObjString.h>
 
 class AliCDBEntry;
 
+/** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTReconstructor)
 
 AliHLTReconstructor::AliHLTReconstructor()
-  : 
-  AliReconstructor(),
-  fFctProcessHLTOUT(NULL),
-  fpEsdManager(NULL),
-  fpPluginBase(new AliHLTPluginBase)
+  : AliReconstructor()
+  , fpEsdManager(NULL)
+  , fpPluginBase(new AliHLTPluginBase)
   , fFlags(0)
 { 
   //constructor
 }
 
 AliHLTReconstructor::AliHLTReconstructor(const char* options)
-  : 
-  AliReconstructor(),
-  fFctProcessHLTOUT(NULL),
-  fpEsdManager(NULL),
-  fpPluginBase(new AliHLTPluginBase)
+  : AliReconstructor()
+  , fpEsdManager(NULL)
+  , fpPluginBase(new AliHLTPluginBase)
   , fFlags(0)
 { 
   //constructor
@@ -126,7 +125,6 @@ void AliHLTReconstructor::Init()
   // the options scan has been moved to AliHLTSystem, the old code
   // here is kept to be able to run an older version of the HLT code
   // with newer AliRoot versions.
-  TString libs("");
   TString option = GetOption();
   TObjArray* pTokens=option.Tokenize(" ");
   option="";
@@ -150,14 +148,13 @@ void AliHLTReconstructor::Init()
        pSystem->SwitchAliLog(0);
       } else if (token.CompareTo("ignore-hltout")==0) {
        fFlags|=kAliHLTReconstructorIgnoreHLTOUT;
+      } else if (token.CompareTo("ignore-ctp")==0) {
+       fFlags|=kAliHLTReconstructorIgnoreCTP;
       } else if (token.Contains("esdmanager=")) {
        token.ReplaceAll("esdmanager=", "");
        token.ReplaceAll(","," ");
        token.ReplaceAll("'","");
        esdManagerOptions=token;
-      } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
-       libs+=token;
-       libs+=" ";
       } else {
        if (option.Length()>0) option+=" ";
        option+=token;
@@ -168,7 +165,8 @@ void AliHLTReconstructor::Init()
 
   TString ecsParam;
   TString ctpParam;
-  if (BuildCTPTriggerClassString(ctpParam)>=0) {
+  if ((fFlags&kAliHLTReconstructorIgnoreCTP)==0 &&
+      BuildCTPTriggerClassString(ctpParam)>=0) {
     if (!ecsParam.IsNull()) ecsParam+=";";
     ecsParam+="CTP_TRIGGER_CLASS=";
     ecsParam+=ctpParam;
@@ -179,24 +177,9 @@ void AliHLTReconstructor::Init()
     option+=ecsParam;
   }
 
-  if (!libs.IsNull() &&
-      (!pSystem->CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
-      (pSystem->LoadComponentLibraries(libs.Data())<0)) {
-    AliError("error while loading HLT libraries");
-    return;
-  }
-
   if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
-    typedef int (*AliHLTSystemSetOptions)(AliHLTSystem* pInstance, const char* options);
-    gSystem->Load("libHLTinterface.so");
-    AliHLTSystemSetOptions pFunc=(AliHLTSystemSetOptions)(gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemSetOptions"));
-    if (pFunc) {
-      if ((pFunc)(pSystem, option.Data())<0) {
+    if (pSystem->ScanOptions(option.Data())<0) {
       AliError("error setting options for HLT system");
-      return;  
-      }
-    } else if (option.Length()>0) {
-      AliError(Form("version of HLT system does not support the options \'%s\'", option.Data()));
       return;
     }
     if ((pSystem->Configure())<0) {
@@ -205,97 +188,14 @@ void AliHLTReconstructor::Init()
     }
   }
 
-  gSystem->Load("libHLTinterface.so");
-  fFctProcessHLTOUT=(void (*)())gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemProcessHLTOUT");
-
   fpEsdManager=AliHLTEsdManager::New();
   fpEsdManager->SetOption(esdManagerOptions.Data());
 
-  InitStreamerInfos();
+  AliHLTMisc::Instance().InitStreamerInfos(fgkCalibStreamerInfoEntry);
 }
 
 const char* AliHLTReconstructor::fgkCalibStreamerInfoEntry="HLT/Calib/StreamerInfo";
 
-int AliHLTReconstructor::InitStreamerInfos()
-{
-  // init streamer infos for HLT reconstruction
-  // Root schema evolution is not enabled for AliHLTMessage and all streamed objects.
-  // Objects in the raw data payload rely on the availability of the correct stream info.
-  // The relevant streamer info for a specific run is stored in the OCDB.
-  // The method evaluates the following entries:
-  // - HLT/Calib/StreamerInfo
-  int iResult=0;
-
-  // to be activated later, this is supposed to go as patch into the v4-17-Release branch
-  // which doe snot have the AliHLTMisc implementation
-  //AliCDBEntry* pEntry=AliHLTMisc::Instance().LoadOCDBEntry(fgkCalibStreamerInfoEntry);
-  AliCDBEntry* pEntry=AliCDBManager::Instance()->Get(fgkCalibStreamerInfoEntry);
-  TObject* pObject=NULL;
-  //if (pEntry && (pObject=AliHLTMisc::Instance().ExtractObject(pEntry))!=NULL)
-  if (pEntry && (pObject=pEntry->GetObject())!=NULL)
-    {
-    TObjArray* pSchemas=dynamic_cast<TObjArray*>(pObject);
-    if (pSchemas) {
-      iResult=InitStreamerInfos(pSchemas);
-    } else {
-      AliError(Form("internal mismatch in OCDB entry %s: wrong class type", fgkCalibStreamerInfoEntry));
-    }
-  } else {
-    AliWarning(Form("missing HLT reco data (%s), skipping initialization of streamer info for TObjects in HLT raw data payload", fgkCalibStreamerInfoEntry));
-  }
-  return iResult;
-}
-
-int AliHLTReconstructor::InitStreamerInfos(TObjArray* pSchemas) const
-{
-  // init streamer infos for HLT reconstruction from an array of TStreamerInfo objects
-
-  for (int i=0; i<pSchemas->GetEntriesFast(); i++) {
-    if (pSchemas->At(i)) {
-      TStreamerInfo* pSchema=dynamic_cast<TStreamerInfo*>(pSchemas->At(i));
-      if (pSchema) {
-       int version=pSchema->GetClassVersion();
-       TClass* pClass=TClass::GetClass(pSchema->GetName());
-       if (pClass) {
-         if (pClass->GetClassVersion()==version) {
-           AliDebug(0,Form("skipping schema definition %d version %d to class %s as this is the native version", i, version, pSchema->GetName()));
-           continue;
-         }
-         TObjArray* pInfos=pClass->GetStreamerInfos();
-         if (pInfos /*&& version<pInfos->GetEntriesFast()*/) {
-           if (pInfos->At(version)==NULL) {
-             TStreamerInfo* pClone=(TStreamerInfo*)pSchema->Clone();
-             if (pClone) {
-               pClone->SetClass(pClass);
-               pClone->BuildOld();
-               pInfos->AddAtAndExpand(pClone, version);
-               AliDebug(0,Form("adding schema definition %d version %d to class %s", i, version, pSchema->GetName()));
-             } else {
-               AliError(Form("skipping schema definition %d (%s), unable to create clone object", i, pSchema->GetName()));
-             }
-           } else {
-             TStreamerInfo* pInfo=dynamic_cast<TStreamerInfo*>(pInfos->At(version));
-             if (pInfo && pInfo->GetClassVersion()==version) {
-               AliDebug(0,Form("schema definition %d version %d already available in class %s, skipping ...", i, version, pSchema->GetName()));
-             } else {
-               AliError(Form("can not verify version for already existing schema definition %d (%s) version %d: version of existing definition is %d", i, pSchema->GetName(), version, pInfo?pInfo->GetClassVersion():-1));
-             }
-           }
-         } else {
-           AliError(Form("skipping schema definition %d (%s), unable to set version %d in info array of size %d", i, pSchema->GetName(), version, pInfos?pInfos->GetEntriesFast():-1));
-         }
-       } else {
-         AliError(Form("skipping schema definition %d (%s), unable to find class", i, pSchema->GetName()));
-       }
-      } else {
-       AliError(Form("skipping schema definition %d, not of TStreamerInfo", i));
-      }
-    }
-  }
-
-  return 0;
-}
-
 void AliHLTReconstructor::Reconstruct(AliRawReader* rawReader, TTree* /*clustersTree*/) const 
 {
   // reconstruction of real data without writing of ESD
@@ -357,7 +257,7 @@ void AliHLTReconstructor::FillESD(AliRawReader* rawReader, TTree* /*clustersTree
     }
     AliHLTOUTRawReader* pHLTOUT=new AliHLTOUTRawReader(input, esd->GetEventNumberInFile(), fpEsdManager);
     if (pHLTOUT) {
-      ProcessHLTOUT(pHLTOUT, esd);
+      ProcessHLTOUT(pHLTOUT, esd, (pSystem->GetGlobalLoggingLevel()&kHLTLogDebug)!=0);
       delete pHLTOUT;
     } else {
       AliError("error creating HLTOUT handler");
@@ -456,7 +356,7 @@ void AliHLTReconstructor::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd, bo
       if (pObject) {
        TObjArray* pArray=dynamic_cast<TObjArray*>(pObject);
        if (pArray) {
-         InitStreamerInfos(pArray);
+         AliHLTMisc::Instance().InitStreamerInfos(pArray);
        } else {
          AliError(Form("wrong class type of streamer info list: expected TObjArray, but object is of type %s", pObject->Class()->GetName()));
        }
@@ -468,13 +368,10 @@ void AliHLTReconstructor::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd, bo
     }
   }
 
-  if (fFctProcessHLTOUT) {
-    typedef int (*AliHLTSystemProcessHLTOUT)(AliHLTSystem* pInstance, AliHLTOUT* pHLTOUT, AliESDEvent* esd);
-    AliHLTSystemProcessHLTOUT pFunc=(AliHLTSystemProcessHLTOUT)fFctProcessHLTOUT;
-    if ((pFunc)(pSystem, pHLTOUT, esd)<0) {
-      AliError("error processing HLTOUT");
-    }
+  if (pSystem->ProcessHLTOUT(pHLTOUT, esd)<0) {
+    AliError("error processing HLTOUT");
   }
+
   if (bVerbose) {
     AliInfo("HLT ESD content:");
     esd->Print();
@@ -607,7 +504,7 @@ int AliHLTReconstructor::BuildCTPTriggerClassString(TString& triggerclasses) con
            delete pTokens;
          }
        } else {
-         AliError(Form("can not find trigger cluster %s in config", trclass->GetCluster()));
+         AliError(Form("can not find trigger cluster %s in config", trclass->GetCluster()?trclass->GetCluster()->GetName():"NULL"));
          iResult=-EPROTO;
          break;
        }