#include "TObjArray.h"
#include "TObjString.h"
#include "AliHLTSimulation.h"
+#include "AliSimulation.h"
#include "AliLog.h"
#include "AliRun.h"
#include "AliRunLoader.h"
#include "AliHeader.h"
-#include "AliTracker.h"
#include "AliCDBManager.h"
#include "AliCDBEntry.h"
#include "AliCDBPath.h"
#include "AliCDBId.h"
#include "AliCDBMetaData.h"
+#include "AliCDBStorage.h"
+#include "AliGRPObject.h"
#include "AliHLTSystem.h"
#include "AliHLTPluginBase.h"
#include "AliRawReaderFile.h"
#include "AliRawReaderRoot.h"
#include "AliESDEvent.h"
#include "AliHLTOUTComponent.h"
+#include "AliMagF.h"
+#include "TGeoGlobalMagField.h"
+#include "TSystem.h"
+#include "TMath.h"
#if ALIHLTSIMULATION_LIBRARY_VERSION != LIBHLTSIM_VERSION
#error library version in header file and lib*.pkg do not match
delete pTokens;
}
- // init solenoid field
- Double_t solenoidBz=AliTracker::GetBz();
AliCDBManager* man = AliCDBManager::Instance();
if (man && man->IsDefaultStorageSet())
{
- const char* cdbSolenoidPath="HLT/ConfigHLT/SolenoidBz";
int runNo=pRunLoader->GetHeader()->GetRun();
+
+ // init solenoid field
+ Double_t solenoidBz=0;
+ AliMagF *field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+ if (field) {
+ // this field definition is rather awkward: AliMagF::SolenoidField returns
+ // a signed value, the amazing thing is that the sign is opposite to that
+ // one in the factor. So the abs value has to be used. Lets assume, there
+ // is a reason for that confusing implementation ...
+ solenoidBz=TMath::Abs(field->SolenoidField())*field->Factor();
+ AliDebug(0,Form("magnetic field: %f %f", field->SolenoidField(),field->Factor()));
+ } 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<AliGRPObject*>(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");
+ }
+ }
+ }
+ }
+ const char* cdbSolenoidPath="HLT/ConfigHLT/SolenoidBz";
TString cdbSolenoidParam;
cdbSolenoidParam.Form("-solenoidBz %f", solenoidBz);
if (!pEntry || !pString || pString->GetString().CompareTo(cdbSolenoidParam)!=0) {
TObjString obj(cdbSolenoidParam);
AliCDBPath cdbSolenoidEntry(cdbSolenoidPath);
- AliCDBId cdbSolenoidId(cdbSolenoidEntry, runNo, runNo);
+ 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);
}
+ } else if (man) {
+ AliError("OCDB default storage not yet set, can not prepare OCDB entries");
+ } else {
+ AliError("unable to get instance of AliCDBMetaData, can not prepare OCDB entries");
}
// scan options
return LIBHLTSIM_VERSION;
}
-extern "C" void AliHLTSimulationCompileInfo(const char*& date, const char*& time)
+int AliHLTSimulationSetup(AliHLTSimulation* /*pHLTSim*/, AliSimulation* pSim, const char* specificObjects)
+{
+ // see header file for function documentation
+
+ // this is an attempt to solve issue #48360
+ // since there are many jobs running in parallel during the production,
+ // 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.
+
+ if (!pSim) return -EINVAL;
+ const char* entries[]={
+ "HLT/ConfigHLT/SolenoidBz",
+ 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;
+}
+
+#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