X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2Fsim%2FAliHLTSimulation.cxx;h=c48ea8931a54448dde5389ee0b7860c2311afc0c;hb=bdc4041caf27fbaed45cbc4495c31e1025454a2e;hp=417e6d3fe60c5fce6caac80b103b8bc46adbd275;hpb=8dd792350fb7f52ffd92155d417f958a2f0513a1;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/sim/AliHLTSimulation.cxx b/HLT/sim/AliHLTSimulation.cxx index 417e6d3fe60..c48ea8931a5 100644 --- a/HLT/sim/AliHLTSimulation.cxx +++ b/HLT/sim/AliHLTSimulation.cxx @@ -26,6 +26,7 @@ #include "TObjArray.h" #include "TObjString.h" #include "AliHLTSimulation.h" +#include "AliSimulation.h" #include "AliLog.h" #include "AliRun.h" #include "AliRunLoader.h" @@ -37,16 +38,20 @@ #include "AliCDBMetaData.h" #include "AliCDBStorage.h" #include "AliGRPObject.h" +#include "AliGRPManager.h" #include "AliHLTSystem.h" +#include "AliHLTConfigurationHandler.h" #include "AliHLTPluginBase.h" #include "AliRawReaderFile.h" #include "AliRawReaderDate.h" #include "AliRawReaderRoot.h" #include "AliESDEvent.h" #include "AliHLTOUTComponent.h" -#include "AliMagF.h" +#include "AliTracker.h" #include "TGeoGlobalMagField.h" #include "TSystem.h" +#include "TMath.h" +#include "TGeoGlobalMagField.h" #if ALIHLTSIMULATION_LIBRARY_VERSION != LIBHLTSIM_VERSION #error library version in header file and lib*.pkg do not match @@ -56,10 +61,10 @@ ClassImp(AliHLTSimulation); AliHLTSimulation::AliHLTSimulation() - : - fOptions(), - fpPluginBase(new AliHLTPluginBase), - fpRawReader(NULL) + : fOptions() + , fpPluginBase(new AliHLTPluginBase) + , fpRawReader(NULL) + , fNEvents(-1) { // see header file for class documentation // or @@ -152,8 +157,37 @@ 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 (token.Contains("events=")) { + fNEvents=token.ReplaceAll("events=", "").Atoi(); } else { if (sysOp.Length()>0) sysOp+=" "; sysOp+=token; @@ -161,71 +195,31 @@ 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()) { - int runNo=pRunLoader->GetHeader()->GetRun(); - // init solenoid field - Double_t solenoidBz=0; - AliMagF *field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField(); - if (field) { - solenoidBz=field->SolenoidField()*field->Factor(); - AliDebug(0,Form("magnetic field: %f %f", field->SolenoidField(),field->Factor())); + // 2009-11-07 magnetic field handling fo HLT components has been switched to the + // global AliMagF instance, the HLT/ConfigHLT/SolenoidBz entry is obsolete + // The global instance is either established by the AliRoot environment or the + // component external interface. + if (TGeoGlobalMagField::Instance()->GetField()) { + AliDebug(0, Form("magnetic field: %f", AliTracker::GetBz())); } else { // workaround for bug #51285 - AliError("can not get the AliMagF instance, falling back to GRP entry"); - AliCDBEntry *pGRPEntry = man->Get("GRP/GRP/Data", runNo); - if (pGRPEntry) { - AliGRPObject* pGRPData=dynamic_cast(pGRPEntry->GetObject()); - assert(pGRPData!=NULL); - if (pGRPData) { - // this is just a workaround at the moment, common functionality in AliReconstruction - // is needed to reconstruct the magnetic field in a common way - // the code is partly taken from AliReconstruction::InitGRP - Bool_t ok = kTRUE; - Float_t l3Current = pGRPData->GetL3Current((AliGRPObject::Stats)0); - if (l3Current == AliGRPObject::GetInvalidFloat()) { - AliError("GRP/GRP/Data entry: missing value for the L3 current !"); - ok = kFALSE; - } - - Char_t l3Polarity = pGRPData->GetL3Polarity(); - if (l3Polarity == AliGRPObject::GetInvalidChar()) { - AliError("GRP/GRP/Data entry: missing value for the L3 polarity !"); - ok = kFALSE; - } - - if (ok) { - solenoidBz=l3Current/6000; - if (l3Polarity) solenoidBz*=-1; - } else { - AliError("invalid L3 field information in GRP entry"); - } - } + AliGRPManager grpman; + if (grpman.ReadGRPEntry() && + grpman.SetMagField()) { + // nothing to do any more } - } - const char* cdbSolenoidPath="HLT/ConfigHLT/SolenoidBz"; - TString cdbSolenoidParam; - cdbSolenoidParam.Form("-solenoidBz %f", solenoidBz); - - // check if the entry is already there - AliCDBEntry *pEntry = man->Get(cdbSolenoidPath, runNo); - TObjString* pString=NULL; - if (pEntry) pString=dynamic_cast(pEntry->GetObject()); - - if (!pEntry || !pString || pString->GetString().CompareTo(cdbSolenoidParam)!=0) { - TObjString obj(cdbSolenoidParam); - AliCDBPath cdbSolenoidEntry(cdbSolenoidPath); - AliCDBId cdbSolenoidId(cdbSolenoidEntry, runNo, runNo, 0, 0); - AliCDBMetaData cdbMetaData; - cdbMetaData.SetResponsible("Matthias.Richter@cern.ch"); - cdbMetaData.SetComment("Automatically produced GRP entry (AliHLTSimulation) for the magnetic field initialization of HLT components"); - man->Put(&obj, cdbSolenoidId, &cdbMetaData); - - // unload the cache due to bug #51281 - man->UnloadFromCache(cdbSolenoidPath); + AliError(Form("can not get the AliMagF instance, falling back to GRP entry (%f)", AliTracker::GetBz())); } } else if (man) { AliError("OCDB default storage not yet set, can not prepare OCDB entries"); @@ -233,14 +227,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; } @@ -249,7 +249,6 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options) return 0; } - int AliHLTSimulation::Run(AliRunLoader* pRunLoader) { // HLT reconstruction for simulated data @@ -263,7 +262,6 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader) return -EINVAL; } - int nEvents = pRunLoader->GetNumberOfEvents(); int iResult=0; AliHLTSystem* pSystem=fpPluginBase->GetInstance(); @@ -277,15 +275,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 = (fNEvents<0 || fNEvents>pRunLoader->GetNumberOfEvents())?pRunLoader->GetNumberOfEvents():fNEvents; + 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 @@ -294,7 +322,6 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader) return iResult; } - AliHLTSimulation* AliHLTSimulationCreateInstance() { // see header file for function documentation @@ -331,7 +358,7 @@ int AliHLTSimulationGetLibraryVersion() return LIBHLTSIM_VERSION; } -int AliHLTSimulationInitOCDB(AliHLTSimulation* /*pSim*/) +int AliHLTSimulationSetup(AliHLTSimulation* /*pHLTSim*/, AliSimulation* pSim, const char* specificObjects) { // see header file for function documentation @@ -340,18 +367,34 @@ int AliHLTSimulationInitOCDB(AliHLTSimulation* /*pSim*/) // all the jobs want to put entries into the OCDB. The solution is to // make them temporary, since they are only used to propagate information // from the simulation to the reconstruction. - AliCDBManager* man = AliCDBManager::Instance(); - if (man && man->IsDefaultStorageSet()) - { - man->SetSpecificStorage("HLT/ConfigHLT/SolenoidBz", Form("local://%s",gSystem->pwd())); - man->SetSpecificStorage("HLT/ConfigHLT/esdLayout", Form("local://%s",gSystem->pwd())); + + if (!pSim) return -EINVAL; + const char* entries[]={ + NULL + }; + + TString specificStorage; + specificStorage.Form("local://%s",gSystem->pwd()); + for (const char** pEntry=entries; *pEntry!=NULL; pEntry++) { + const char* pObject=specificObjects?strstr(specificObjects, *pEntry):NULL; + if (pObject) { + // skip this entry if it is found in the list and either + // last one or separated by a blank + pObject+=strlen(*pEntry); + if (*pObject==0 || *pObject==' ') continue; + } + pSim->SetSpecificStorage(*pEntry, specificStorage.Data()); } + + return 0; } -extern "C" void AliHLTSimulationCompileInfo(const char*& date, const char*& time) +#ifndef HAVE_COMPILEINFO +extern "C" void CompileInfo(const char*& date, const char*& time) { // the fall back compile info of the HLTsim library // this is not up-to-date if other files have been changed and recompiled date=__DATE__; time=__TIME__; return; } +#endif