From 5879742fd7659b4629a24c7e8e25a7da6d5b6ce2 Mon Sep 17 00:00:00 2001 From: richterm Date: Thu, 27 Jan 2011 23:14:24 +0000 Subject: [PATCH] activating individual HLT simulations from digits and raw data --- HLT/sim/AliHLTSimulation.cxx | 92 +++++++++++++++++++++++++++++++----- HLT/sim/AliHLTSimulation.h | 30 +++++++----- 2 files changed, 97 insertions(+), 25 deletions(-) diff --git a/HLT/sim/AliHLTSimulation.cxx b/HLT/sim/AliHLTSimulation.cxx index 45359cdca4c..f29961b857a 100644 --- a/HLT/sim/AliHLTSimulation.cxx +++ b/HLT/sim/AliHLTSimulation.cxx @@ -40,6 +40,7 @@ #include "AliGRPObject.h" #include "AliGRPManager.h" #include "AliHLTSystem.h" +#include "AliHLTConfigurationHandler.h" #include "AliHLTPluginBase.h" #include "AliRawReaderFile.h" #include "AliRawReaderDate.h" @@ -60,10 +61,9 @@ ClassImp(AliHLTSimulation); AliHLTSimulation::AliHLTSimulation() - : - fOptions(), - fpPluginBase(new AliHLTPluginBase), - fpRawReader(NULL) + : fOptions() + , fpPluginBase(new AliHLTPluginBase) + , fpRawReader(NULL) { // see header file for class documentation // or @@ -156,8 +156,35 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options) } } else if (token.Contains("writerawfiles=")) { if (!token.ReplaceAll("writerawfiles=", "").Contains("HLT")) { + if (TestBit(kOneChain) && AliHLTOUTComponent::TestGlobalOption(AliHLTOUTComponent::kWriteRawFiles)) { + AliWarning("empty argument 'writerawfiles=' disables HLTOUTComponent mode 'raw' which was set by argument 'hltout-mode'"); + } AliHLTOUTComponent::ClearGlobalOption(AliHLTOUTComponent::kWriteRawFiles); } + } else if (token.BeginsWith("hltout-mode=")) { + // this is a legacy mode to emulate the behavior before Dec 2010 where only + // one chain was executed on either digits or simulated raw data and the output + // was controlled via global flags + // add to the arguments for AliHLTSystem as also there the information is needed + if (sysOp.Length()>0) sysOp+=" "; + sysOp+=token; + TString param=token.ReplaceAll("hltout-mode=", ""); + SetBit(kOneChain); + if (param.CompareTo("raw")==0) { + // please note that this option + AliHLTOUTComponent::SetGlobalOption(AliHLTOUTComponent::kWriteRawFiles); + AliHLTOUTComponent::ClearGlobalOption(AliHLTOUTComponent::kWriteDigits); + } else if (param.CompareTo("digits")==0) { + // please note that this option + AliHLTOUTComponent::ClearGlobalOption(AliHLTOUTComponent::kWriteRawFiles); + AliHLTOUTComponent::SetGlobalOption(AliHLTOUTComponent::kWriteDigits); + } else if (param.CompareTo("legacy")==0) { + AliHLTOUTComponent::SetGlobalOption(AliHLTOUTComponent::kWriteRawFiles); + AliHLTOUTComponent::SetGlobalOption(AliHLTOUTComponent::kWriteDigits); + } else { + AliError(Form("invalid parameter for argument 'hltout-mode=' %s, allowed: raw, digits, legacy ... ignoring argument and using the standard simulation", param.Data())); + ResetBit(kOneChain); + } } else { if (sysOp.Length()>0) sysOp+=" "; sysOp+=token; @@ -165,6 +192,12 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options) } delete pTokens; } + // only store the options for AliHLTSystem + fOptions=sysOp; + + // if no specific hltout-mode has been chosen set the split mode for + // running separate chains for digits and raw data + if (!fOptions.Contains("hltout-mode=")) fOptions+=" hltout-mode=split"; AliCDBManager* man = AliCDBManager::Instance(); if (man && man->IsDefaultStorageSet()) @@ -191,14 +224,20 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options) AliError("unable to get instance of AliCDBMetaData, can not prepare OCDB entries"); } - // scan options - if (pSystem->ScanOptions(sysOp.Data())<0) { + // configure the main HLTSystem instance for digit simulation (pRawReader NULL) + return ConfigureHLTSystem(pSystem, fOptions.Data(), pRunLoader, TestBit(kOneChain)?fpRawReader:NULL); +} + +int AliHLTSimulation::ConfigureHLTSystem(AliHLTSystem* pSystem, const char* options, AliRunLoader* pRunLoader, AliRawReader* pRawReader) const +{ + // scan options and configure AliHLTSystem + if (pSystem->ScanOptions(options)<0) { AliError("error setting options for HLT system"); return -EINVAL; } if (!pSystem->CheckStatus(AliHLTSystem::kReady)) { - if ((pSystem->Configure(fpRawReader, pRunLoader))<0) { + if ((pSystem->Configure(pRawReader, pRunLoader))<0) { AliError("error during HLT system configuration"); return -EFAULT; } @@ -207,7 +246,6 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options) return 0; } - int AliHLTSimulation::Run(AliRunLoader* pRunLoader) { // HLT reconstruction for simulated data @@ -221,7 +259,6 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader) return -EINVAL; } - int nEvents = pRunLoader->GetNumberOfEvents(); int iResult=0; AliHLTSystem* pSystem=fpPluginBase->GetInstance(); @@ -235,15 +272,45 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader) return -EFAULT; } + // run the main HLTSystem instance for digit simulation (pRawReader NULL) + // in legacy mode only one chain is run and the output is controlled via + // global flags + if (!TestBit(kOneChain)) AliInfo("running HLT simulation for digits"); + iResult=RunHLTSystem(pSystem, pRunLoader, TestBit(kOneChain)?fpRawReader:NULL); + + // now run once again with the raw data as input, a completely new HLT system + // with new configurations is used + if (fpRawReader && !TestBit(kOneChain)) { + AliInfo("running HLT simulation for raw data"); + int iLocalResult=0; + AliHLTConfigurationHandler* confHandler=new AliHLTConfigurationHandler; + // note that the configuration handler is owned by the + // AliHLTSystem instance from now on + AliHLTSystem rawSimulation(kHLTLogDefault, "", NULL, confHandler); + if ((iLocalResult=ConfigureHLTSystem(&rawSimulation, fOptions.Data(), pRunLoader, fpRawReader))>=0) { + iLocalResult=RunHLTSystem(&rawSimulation, pRunLoader, fpRawReader); + } + if (iResult>=0) iResult=iLocalResult; + } + + return iResult; +} + +int AliHLTSimulation::RunHLTSystem(AliHLTSystem* pSystem, AliRunLoader* pRunLoader, AliRawReader* pRawReader) const +{ + // run reconstruction cycle for AliHLTSystem + int nEvents = pRunLoader->GetNumberOfEvents(); + int iResult=0; + // Note: the rawreader is already placed at the first event - if ((iResult=pSystem->Reconstruct(1, pRunLoader, fpRawReader))>=0) { + if ((iResult=pSystem->Reconstruct(1, pRunLoader, pRawReader))>=0) { pSystem->FillESD(0, pRunLoader, NULL); for (int i=1; iNextEvent()) { + if (pRawReader && !pRawReader->NextEvent()) { AliError("mismatch in event count, rawreader corrupted"); break; } - pSystem->Reconstruct(1, pRunLoader, fpRawReader); + pSystem->Reconstruct(1, pRunLoader, pRawReader); pSystem->FillESD(i, pRunLoader, NULL); } // send specific 'event' to execute the stop sequence @@ -252,7 +319,6 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader) return iResult; } - AliHLTSimulation* AliHLTSimulationCreateInstance() { // see header file for function documentation diff --git a/HLT/sim/AliHLTSimulation.h b/HLT/sim/AliHLTSimulation.h index 06631e9cfde..c3c517451d2 100644 --- a/HLT/sim/AliHLTSimulation.h +++ b/HLT/sim/AliHLTSimulation.h @@ -1,5 +1,5 @@ //-*- Mode: C++ -*- -// @(#) $Id$ +// $Id$ #ifndef ALIHLTSIMULATION_H #define ALIHLTSIMULATION_H @@ -7,17 +7,12 @@ * ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ -/** @file AliHLTSimulation.h - @author Matthias Richter - @date - @brief Binding class for HLT simulation in AliRoot - -// see below for class documentation -// or -// refer to README to build package -// or -// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt - */ +/// @file AliHLTSimulation.h +/// @author Matthias Richter +/// @date +/// @brief Binding class for HLT simulation in AliRoot +/// + /** * @defgroup alihlt_aliroot_simulation HLT simulation in AliRoot * This section describes the the simulation of the HLT in AliRoot. @@ -63,6 +58,7 @@ class AliRunLoader; class AliHLTPluginBase; class AliRawReader; class AliSimulation; +class AliHLTSystem; /** * @class AliHLTSimulation @@ -101,9 +97,19 @@ class AliHLTSimulation : public TObject { /** init simulation */ int Init(AliRunLoader* pRunLoader, const char* options); + int ConfigureHLTSystem(AliHLTSystem* pSystem, const char* options, AliRunLoader* pRunLoader, AliRawReader* pRawReader) const; + /** run simulation with an instance of the run loader */ int Run(AliRunLoader* pRunLoader); + /// run reconstruction cycle for AliHLTSystem + int RunHLTSystem(AliHLTSystem* pSystem, AliRunLoader* pRunLoader, AliRawReader* pRawReader) const; + + enum EOptions { + // indicate that only one chain should be run, behavior before Dec 2010 + kOneChain = BIT(15) + }; + private: /** standard constructor */ AliHLTSimulation(); -- 2.39.3