]> 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 e47d286b87f9f172cfb34dbd19b81a5e384cc394..e599da0745df7f8b5769083b6a5a7dc45a638ba3 100644 (file)
@@ -1,20 +1,20 @@
 // $Id$
 
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- *                                                                        *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
- *                  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.                  *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  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   AliHLTSimulation.cxx
     @author Matthias Richter
 #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 "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliCDBPath.h"
+#include "AliCDBId.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBStorage.h"
+#include "AliGRPObject.h"
+#include "AliGRPManager.h"
 #include "AliHLTSystem.h"
+#include "AliHLTPluginBase.h"
 #include "AliRawReaderFile.h"
 #include "AliRawReaderDate.h"
 #include "AliRawReaderRoot.h"
+#include "AliESDEvent.h"
+#include "AliHLTOUTComponent.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
@@ -43,7 +62,7 @@ ClassImp(AliHLTSimulation);
 AliHLTSimulation::AliHLTSimulation()
   :
   fOptions(),
-  fpSystem(NULL),
+  fpPluginBase(new AliHLTPluginBase),
   fpRawReader(NULL)
 {
   // see header file for class documentation
@@ -56,10 +75,9 @@ AliHLTSimulation::AliHLTSimulation()
 AliHLTSimulation::~AliHLTSimulation()
 {
   // see header file for function documentation
-  if (fpSystem) {
-    delete fpSystem;
-  }
-  fpSystem=NULL;
+  if (fpPluginBase) delete fpPluginBase;
+  fpPluginBase=NULL;
+
   if (fpRawReader) {
     delete fpRawReader;
   }
@@ -86,12 +104,17 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
   fOptions=options;
   TString sysOp;
 
-  if (!fpSystem) fpSystem=new AliHLTSystem;
-  if (!fpSystem) {
-    AliError("can not create AliHLTSystem object");
+  if(!fpPluginBase) {
+    AliError("internal initialization failed");
+    return -EINVAL;
+  }
+
+  AliHLTSystem* pSystem=fpPluginBase->GetInstance();
+  if (!pSystem) {
+    AliError("can not get AliHLTSystem instance");
     return -ENOMEM;
   }
-  if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
+  if (pSystem->CheckStatus(AliHLTSystem::kError)) {
     AliError("HLT system in error state");
     return -EFAULT;
   }
@@ -113,14 +136,13 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
        } else if (!param.IsNull()) {
          AliInfo(Form("creating AliRawReaderDate (%s)", param.Data()));
          fpRawReader = new AliRawReaderDate(param);
-         fpRawReader->SelectEvents(7);
        }
        if (fpRawReader) {
            fpRawReader->RewindEvents();
            int count=0;
-           for (; fpRawReader->NextEvent(); count++);
+           for ( ; fpRawReader->NextEvent(); count++) {/* empty body */};
            if (count!=pRunLoader->GetNumberOfEvents()) {
-             AliError(Form("missmatch in event count: runloader %d, rawreader %d; ignoring rawreader", 
+             AliError(Form("mismatch in event count: runloader %d, rawreader %d; ignoring rawreader", 
                            pRunLoader->GetNumberOfEvents(), count));
              count=0;
            }
@@ -132,6 +154,10 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
              fpRawReader=NULL;
            }
        }
+      } else if (token.Contains("writerawfiles=")) {
+       if (!token.ReplaceAll("writerawfiles=", "").Contains("HLT")) {
+         AliHLTOUTComponent::ClearGlobalOption(AliHLTOUTComponent::kWriteRawFiles);
+       }
       } else {
        if (sysOp.Length()>0) sysOp+=" ";
        sysOp+=token;
@@ -140,14 +166,41 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
     delete pTokens;
   }
 
+  AliCDBManager* man = AliCDBManager::Instance();
+  if (man && man->IsDefaultStorageSet())
+  {
+    int runNo=pRunLoader->GetHeader()->GetRun();
+
+    // init solenoid field
+    // 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
+      AliGRPManager grpman;
+      if (grpman.ReadGRPEntry() &&
+         grpman.SetMagField()) {
+       // nothing to do any more
+      }
+      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");    
+  } else {
+    AliError("unable to get instance of AliCDBMetaData, can not prepare OCDB entries");    
+  }
+
   // scan options
-  if (fpSystem->ScanOptions(sysOp.Data())<0) {
+  if (pSystem->ScanOptions(sysOp.Data())<0) {
     AliError("error setting options for HLT system");
     return -EINVAL;    
   }
 
-  if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
-    if ((fpSystem->Configure(pRunLoader))<0) {
+  if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
+    if ((pSystem->Configure(fpRawReader, pRunLoader))<0) {
       AliError("error during HLT system configuration");
       return -EFAULT;
     }
@@ -160,6 +213,11 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
 int AliHLTSimulation::Run(AliRunLoader* pRunLoader)
 {
   // HLT reconstruction for simulated data  
+  if(!fpPluginBase) {
+    AliError("internal initialization failed");
+    return -EINVAL;
+  }
+
   if(!pRunLoader) {
     AliError("Missing RunLoader! 0x0");
     return -EINVAL;
@@ -168,22 +226,30 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader)
   int nEvents = pRunLoader->GetNumberOfEvents();
   int iResult=0;
 
-  if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
+  AliHLTSystem* pSystem=fpPluginBase->GetInstance();
+  if (!pSystem) {
+    AliError("can not get AliHLTSystem instance");
+    return -ENOMEM;
+  }
+
+  if (pSystem->CheckStatus(AliHLTSystem::kError)) {
     AliError("HLT system in error state");
     return -EFAULT;
   }
 
   // Note: the rawreader is already placed at the first event
-  if ((iResult=fpSystem->Reconstruct(1, pRunLoader, fpRawReader))>=0) {
+  if ((iResult=pSystem->Reconstruct(1, pRunLoader, fpRawReader))>=0) {
+    pSystem->FillESD(0, pRunLoader, NULL);
     for (int i=1; i<nEvents; i++) {
       if (fpRawReader && !fpRawReader->NextEvent()) {
-       AliError("missmatch in event count, rawreader corrupted");
+       AliError("mismatch in event count, rawreader corrupted");
        break;
       }
-      fpSystem->Reconstruct(1, pRunLoader, fpRawReader);
+      pSystem->Reconstruct(1, pRunLoader, fpRawReader);
+      pSystem->FillESD(i, pRunLoader, NULL);
     }
     // send specific 'event' to execute the stop sequence
-    fpSystem->Reconstruct(0, NULL, NULL);
+    pSystem->Reconstruct(0, NULL, NULL);
   }
   return iResult;
 }
@@ -224,3 +290,44 @@ int AliHLTSimulationGetLibraryVersion()
   // see header file for function documentation
   return LIBHLTSIM_VERSION;
 }
+
+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[]={
+    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