]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/sim/AliHLTSimulation.cxx
removing the generation of the local solenoidBz OCDB entry
[u/mrichter/AliRoot.git] / HLT / sim / AliHLTSimulation.cxx
index 577813ea445f936a9c36a999f93d4c1c505b7d1d..e599da0745df7f8b5769083b6a5a7dc45a638ba3 100644 (file)
@@ -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,6 +38,7 @@
 #include "AliCDBMetaData.h"
 #include "AliCDBStorage.h"
 #include "AliGRPObject.h"
+#include "AliGRPManager.h"
 #include "AliHLTSystem.h"
 #include "AliHLTPluginBase.h"
 #include "AliRawReaderFile.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
@@ -169,68 +172,20 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
     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()));
+    // 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<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");
-         }
-       }
+      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<TObjString*>(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");    
@@ -336,7 +291,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
 
@@ -345,18 +300,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