<commit_before>// $Id$

//**************************************************************************
//* This file is property of and copyright by the ALICE HLT Project        * 
//* ALICE Experiment at CERN, All rights reserved.                         *
//*                                                                        *
//* Primary Authors: <NAME> <<EMAIL>>        *
//*                  for The ALICE HLT Project.                            *
//*                                                                        *
//* 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.                  *
//**************************************************************************

//  @file   AliHLTReconstructor.cxx
//  @author <NAME>
//  @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>
#include "TFile.h"
#include "TTree.h"
#include "TObject.h"
#include "TObjArray.h"
#include "TClass.h"
#include "TStreamerInfo.h"
#include "AliHLTReconstructor.h"
#include "AliLog.h"
#include "AliRawReader.h"
#include "AliESDEvent.h"
#include "AliHLTSystem.h"
#include "AliHLTOUTRawReader.h"
#include "AliHLTOUTDigitReader.h"
#include "AliHLTEsdManager.h"
#include "AliHLTPluginBase.h"
#include "AliHLTMisc.h"
#include "AliCDBManager.h"
#include "AliCDBEntry.h"
#include "AliHLTMessage.h"
#include "AliCentralTrigger.h"
#include "AliTriggerConfiguration.h"
#include "AliTriggerClass.h"
#include "AliTriggerCluster.h"
#include "AliDAQ.h"

class AliCDBEntry;

/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTReconstructor)

AliHLTReconstructor::AliHLTReconstructor()
  : AliReconstructor()
  , fpEsdManager(NULL)
  , fpPluginBase(new AliHLTPluginBase)
  , fFlags(0)
{ 
  //constructor
}

AliHLTReconstructor::AliHLTReconstructor(const char* options)
  : AliReconstructor()
  , fpEsdManager(NULL)
  , fpPluginBase(new AliHLTPluginBase)
  , fFlags(0)
{ 
  //constructor
  if (options) Init(options);
}

AliHLTReconstructor::~AliHLTReconstructor()
{ 
  //destructor

  if (fpPluginBase) {
  AliHLTSystem* pSystem=fpPluginBase->GetInstance();
  if (pSystem) {
    AliDebug(0, Form("terminate HLT system: status %#x", pSystem->GetStatusFlags()));
    if (pSystem->CheckStatus(AliHLTSystem::kStarted)) {
      // send specific 'event' to execute the stop sequence
      pSystem->Reconstruct(0, NULL, NULL);
    }
  }
  delete fpPluginBase;
  }
  fpPluginBase=NULL;

  if (fpEsdManager) AliHLTEsdManager::Delete(fpEsdManager);
  fpEsdManager=NULL;
}

void AliHLTReconstructor::Init(const char* options)
{
  // init the reconstructor
  SetOption(options);
  Init();
}

void AliHLTReconstructor::Init()
{
  // init the reconstructor
  if (!fpPluginBase) {
    AliError("internal memory error: can not get AliHLTSystem instance from plugin");
    return;
  }

  AliHLTSystem* pSystem=fpPluginBase->GetInstance();
  if (!pSystem) {
    AliError("can not create AliHLTSystem object");
    return;
  }
  if (pSystem->CheckStatus(AliHLTSystem::kError)) {
    AliError("HLT system in error state");
    return;
  }

  TString esdManagerOptions;

  // 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 option = GetOption();
  TObjArray* pTokens=option.Tokenize(" ");
  option="";
  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()) {
	  pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
	} else if (param.BeginsWith("0x") &&
		   param.Replace(0,2,"",0).IsHex()) {
	  int severity=0;
	  sscanf(param.Data(),"%x", &severity);
	  pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
	} else {
	  AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
	}
      } else if (token.Contains("alilog=off")) {
	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 (option.Length()>0) option+=" ";
	option+=token;
      }
    }
    delete pTokens;
  }

  TString ecsParam;
  TString ctpParam;
  if ((fFlags&kAliHLTReconstructorIgnoreCTP)==0 &&
      BuildCTPTriggerClassString(ctpParam)>=0) {
    if (!ecsParam.IsNull()) ecsParam+=";";
    ecsParam+="CTP_TRIGGER_CLASS=";
    ecsParam+=ctpParam;
  }

  if (!ecsParam.IsNull()) {
    option+=" ECS=";
    option+=ecsParam;
  }

  if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
    if (pSystem->ScanOptions(option.Data())<0) {<commit_msg>ignore HLTOUT if option 'run-online-config' is found (Lars)<commit_after>// $Id$

//**************************************************************************
//* This file is property of and copyright by the ALICE HLT Project        * 
//* ALICE Experiment at CERN, All rights reserved.                         *
//*                                                                        *
//* Primary Authors: <NAME> <<EMAIL>>        *
//*                  for The ALICE HLT Project.                            *
//*                                                                        *
//* 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.                  *
//**************************************************************************

//  @file   AliHLTReconstructor.cxx
//  @author <NAME>
//  @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>
#include "TFile.h"
#include "TTree.h"
#include "TObject.h"
#include "TObjArray.h"
#include "TClass.h"
#include "TStreamerInfo.h"
#include "AliHLTReconstructor.h"
#include "AliLog.h"
#include "AliRawReader.h"
#include "AliESDEvent.h"
#include "AliHLTSystem.h"
#include "AliHLTOUTRawReader.h"
#include "AliHLTOUTDigitReader.h"
#include "AliHLTEsdManager.h"
#include "AliHLTPluginBase.h"
#include "AliHLTMisc.h"
#include "AliCDBManager.h"
#include "AliCDBEntry.h"
#include "AliHLTMessage.h"
#include "AliCentralTrigger.h"
#include "AliTriggerConfiguration.h"
#include "AliTriggerClass.h"
#include "AliTriggerCluster.h"
#include "AliDAQ.h"

class AliCDBEntry;

/** ROOT macro for the implementation of ROOT specific class methods */
ClassImp(AliHLTReconstructor)

AliHLTReconstructor::AliHLTReconstructor()
  : AliReconstructor()
  , fpEsdManager(NULL)
  , fpPluginBase(new AliHLTPluginBase)
  , fFlags(0)
{ 
  //constructor
}

AliHLTReconstructor::AliHLTReconstructor(const char* options)
  : AliReconstructor()
  , fpEsdManager(NULL)
  , fpPluginBase(new AliHLTPluginBase)
  , fFlags(0)
{ 
  //constructor
  if (options) Init(options);
}

AliHLTReconstructor::~AliHLTReconstructor()
{ 
  //destructor

  if (fpPluginBase) {
  AliHLTSystem* pSystem=fpPluginBase->GetInstance();
  if (pSystem) {
    AliDebug(0, Form("terminate HLT system: status %#x", pSystem->GetStatusFlags()));
    if (pSystem->CheckStatus(AliHLTSystem::kStarted)) {
      // send specific 'event' to execute the stop sequence
      pSystem->Reconstruct(0, NULL, NULL);
    }
  }
  delete fpPluginBase;
  }
  fpPluginBase=NULL;

  if (fpEsdManager) AliHLTEsdManager::Delete(fpEsdManager);
  fpEsdManager=NULL;
}

void AliHLTReconstructor::Init(const char* options)
{
  // init the reconstructor
  SetOption(options);
  Init();
}

void AliHLTReconstructor::Init()
{
  // init the reconstructor
  if (!fpPluginBase) {
    AliError("internal memory error: can not get AliHLTSystem instance from plugin");
    return;
  }

  AliHLTSystem* pSystem=fpPluginBase->GetInstance();
  if (!pSystem) {
    AliError("can not create AliHLTSystem object");
    return;
  }
  if (pSystem->CheckStatus(AliHLTSystem::kError)) {
    AliError("HLT system in error state");
    return;
  }

  TString esdManagerOptions;

  // 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 option = GetOption();
  TObjArray* pTokens=option.Tokenize(" ");
  option="";
  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()) {
	  pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
	} else if (param.BeginsWith("0x") &&
		   param.Replace(0,2,"",0).IsHex()) {
	  int severity=0;
	  sscanf(param.Data(),"%x", &severity);
	  pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
	} else {
	  AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
	}
      } else if (token.Contains("alilog=off")) {
	pSystem->SwitchAliLog(0);
      } else if (token.CompareTo("ignore-hltout")==0) {
	fFlags|=kAliHLTReconstructorIgnoreHLTOUT;
      } else if (token.CompareTo("run-online-config")==0) {
        fFlags|=kAliHLTReconstructorIgnoreHLTOUT;
	if (option.Length()>0) option+=" ";
	option+=token;
      } 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 (option.Length()>0) option+=" ";
	option+=token;
      }
    }
    delete pTokens;
  }

  TString ecsParam;
  TString ctpParam;
  if ((fFlags&kAliHLTReconstructorIgnoreCTP)==0 &&
      BuildCTPTriggerClassString(ctpParam)>=0) {
    if (!ecsParam.IsNull()) ecsParam+=";";
    ecsParam+="CTP_TRIGGER_CLASS=";
    ecsParam+=ctpParam;
  }

  if (!ecsParam.IsNull()) {
    option+=" ECS=";
    option+=ecsParam;
  }

  if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
    if (pSystem->ScanOptions(option.Data())<0) {
{'fraction_non_alphanumeric': 0.15753245621678139, 'fraction_numerical': 0.003136708199006709, 'mean_word_length': 3.545742574257426, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3843525', 'n_tokens_mistral': 3729, 'n_tokens_neox': 3659, 'n_words': 847}