]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/sim/AliHLTSimulation.cxx
Possibility to specify event selection criteria within the raw-data input URI. The...
[u/mrichter/AliRoot.git] / HLT / sim / AliHLTSimulation.cxx
index bd1f58b09f0bb06555148c18fe7a8f09726ee24c..600cc0572764b879a4d14642e7b2cf9d7f19cd20 100644 (file)
@@ -1,20 +1,20 @@
 // $Id$
 
 // $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
 
 /** @file   AliHLTSimulation.cxx
     @author Matthias Richter
 #include "TObjString.h"
 #include "AliHLTSimulation.h"
 #include "AliLog.h"
 #include "TObjString.h"
 #include "AliHLTSimulation.h"
 #include "AliLog.h"
+#include "AliRun.h"
 #include "AliRunLoader.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 "AliHLTSystem.h"
 #include "AliRawReaderFile.h"
 #include "AliRawReaderDate.h"
 #include "AliHLTSystem.h"
 #include "AliRawReaderFile.h"
 #include "AliRawReaderDate.h"
@@ -45,6 +53,7 @@ ClassImp(AliHLTSimulation);
 AliHLTSimulation::AliHLTSimulation()
   :
   fOptions(),
 AliHLTSimulation::AliHLTSimulation()
   :
   fOptions(),
+  fpSystem(NULL),
   fpRawReader(NULL)
 {
   // see header file for class documentation
   fpRawReader(NULL)
 {
   // see header file for class documentation
@@ -57,6 +66,10 @@ AliHLTSimulation::AliHLTSimulation()
 AliHLTSimulation::~AliHLTSimulation()
 {
   // see header file for function documentation
 AliHLTSimulation::~AliHLTSimulation()
 {
   // see header file for function documentation
+  if (fpSystem) {
+    delete fpSystem;
+  }
+  fpSystem=NULL;
   if (fpRawReader) {
     delete fpRawReader;
   }
   if (fpRawReader) {
     delete fpRawReader;
   }
@@ -83,12 +96,12 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
   fOptions=options;
   TString sysOp;
 
   fOptions=options;
   TString sysOp;
 
-  AliHLTSystem* pSystem=GetInstance();
-  if (!pSystem) {
-    AliError("can not get AliHLTSystem instance");
+  if (!fpSystem) fpSystem=new AliHLTSystem;
+  if (!fpSystem) {
+    AliError("can not create AliHLTSystem object");
     return -ENOMEM;
   }
     return -ENOMEM;
   }
-  if (pSystem->CheckStatus(AliHLTSystem::kError)) {
+  if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
     AliError("HLT system in error state");
     return -EFAULT;
   }
     AliError("HLT system in error state");
     return -EFAULT;
   }
@@ -110,14 +123,13 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
        } else if (!param.IsNull()) {
          AliInfo(Form("creating AliRawReaderDate (%s)", param.Data()));
          fpRawReader = new AliRawReaderDate(param);
        } 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++);
            if (count!=pRunLoader->GetNumberOfEvents()) {
        }
        if (fpRawReader) {
            fpRawReader->RewindEvents();
            int count=0;
            for (; fpRawReader->NextEvent(); count++);
            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;
            }
                            pRunLoader->GetNumberOfEvents(), count));
              count=0;
            }
@@ -141,14 +153,40 @@ int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
     delete pTokens;
   }
 
     delete pTokens;
   }
 
+  // init solenoid field
+  Bool_t bUniformField=kTRUE;
+  AliTracker::SetFieldMap(pRunLoader->GetAliRun()->Field(),bUniformField);
+  Double_t solenoidBz=AliTracker::GetBz();
+  AliCDBManager* man = AliCDBManager::Instance();
+  if (man && man->IsDefaultStorageSet())
+  {
+    const char* cdbSolenoidPath="HLT/ConfigHLT/SolenoidBz";
+    int runNo=pRunLoader->GetHeader()->GetRun();
+    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);
+      AliCDBMetaData cdbMetaData;
+      man->Put(&obj, cdbSolenoidId, &cdbMetaData);
+    }
+  }
+
   // scan options
   // scan options
-  if (pSystem->ScanOptions(sysOp.Data())<0) {
+  if (fpSystem->ScanOptions(sysOp.Data())<0) {
     AliError("error setting options for HLT system");
     return -EINVAL;    
   }
 
     AliError("error setting options for HLT system");
     return -EINVAL;    
   }
 
-  if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
-    if ((pSystem->Configure(pRunLoader))<0) {
+  if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
+    if ((fpSystem->Configure(pRunLoader))<0) {
       AliError("error during HLT system configuration");
       return -EFAULT;
     }
       AliError("error during HLT system configuration");
       return -EFAULT;
     }
@@ -169,29 +207,24 @@ int AliHLTSimulation::Run(AliRunLoader* pRunLoader)
   int nEvents = pRunLoader->GetNumberOfEvents();
   int iResult=0;
 
   int nEvents = pRunLoader->GetNumberOfEvents();
   int iResult=0;
 
-  AliHLTSystem* pSystem=GetInstance();
-  if (!pSystem) {
-    AliError("can not get AliHLTSystem instance");
-    return -ENOMEM;
-  }
-  if (pSystem->CheckStatus(AliHLTSystem::kError)) {
+  if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
     AliError("HLT system in error state");
     return -EFAULT;
   }
 
   // Note: the rawreader is already placed at the first event
     AliError("HLT system in error state");
     return -EFAULT;
   }
 
   // Note: the rawreader is already placed at the first event
-  if ((iResult=pSystem->Reconstruct(1, pRunLoader, fpRawReader))>=0) {
-    pSystem->FillESD(0, pRunLoader, NULL);
+  if ((iResult=fpSystem->Reconstruct(1, pRunLoader, fpRawReader))>=0) {
+    fpSystem->FillESD(0, pRunLoader, NULL);
     for (int i=1; i<nEvents; i++) {
       if (fpRawReader && !fpRawReader->NextEvent()) {
     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;
       }
        break;
       }
-      pSystem->Reconstruct(1, pRunLoader, fpRawReader);
-      pSystem->FillESD(i, pRunLoader, NULL);
+      fpSystem->Reconstruct(1, pRunLoader, fpRawReader);
+      fpSystem->FillESD(i, pRunLoader, NULL);
     }
     // send specific 'event' to execute the stop sequence
     }
     // send specific 'event' to execute the stop sequence
-    pSystem->Reconstruct(0, NULL, NULL);
+    fpSystem->Reconstruct(0, NULL, NULL);
   }
   return iResult;
 }
   }
   return iResult;
 }