3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
19 /** @file AliHLTSimulation.cxx
20 @author Matthias Richter
22 @brief Binding class for HLT simulation in AliRoot. */
26 #include "TObjArray.h"
27 #include "TObjString.h"
28 #include "AliHLTSimulation.h"
30 #include "AliRunLoader.h"
31 #include "AliHLTSystem.h"
32 #include "AliRawReaderFile.h"
33 #include "AliRawReaderDate.h"
34 #include "AliRawReaderRoot.h"
36 #if ALIHLTSIMULATION_LIBRARY_VERSION != LIBHLTSIM_VERSION
37 #error library version in header file and lib*.pkg do not match
40 /** ROOT macro for the implementation of ROOT specific class methods */
41 ClassImp(AliHLTSimulation);
43 AliHLTSimulation::AliHLTSimulation()
49 // see header file for class documentation
51 // refer to README to build package
53 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
56 AliHLTSimulation::~AliHLTSimulation()
58 // see header file for function documentation
69 AliHLTSimulation* AliHLTSimulation::CreateInstance()
71 // see header file for function documentation
72 return new AliHLTSimulation;
75 int AliHLTSimulation::DeleteInstance(AliHLTSimulation* pSim)
77 // see header file for function documentation
83 int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
85 // init the simulation
89 if (!fpSystem) fpSystem=new AliHLTSystem;
91 AliError("can not create AliHLTSystem object");
94 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
95 AliError("HLT system in error state");
99 // scan options for specific entries
100 TObjArray* pTokens=fOptions.Tokenize(" ");
102 int iEntries=pTokens->GetEntries();
103 for (int i=0; i<iEntries; i++) {
104 TString token=(((TObjString*)pTokens->At(i))->GetString());
105 if (token.Contains("rawfile=")) {
106 TString param=token.ReplaceAll("rawfile=", "");
107 if (param.EndsWith("/")) {
108 AliInfo(Form("creating AliRawReaderFile (%s)", param.Data()));
109 fpRawReader = new AliRawReaderFile(param);
110 } else if (param.EndsWith(".root")) {
111 AliInfo(Form("creating AliRawReaderRoot (%s)", param.Data()));
112 fpRawReader = new AliRawReaderRoot(param);
113 } else if (!param.IsNull()) {
114 AliInfo(Form("creating AliRawReaderDate (%s)", param.Data()));
115 fpRawReader = new AliRawReaderDate(param);
116 fpRawReader->SelectEvents(7);
119 fpRawReader->RewindEvents();
121 for (; fpRawReader->NextEvent(); count++);
122 if (count!=pRunLoader->GetNumberOfEvents()) {
123 AliError(Form("missmatch in event count: runloader %d, rawreader %d; ignoring rawreader",
124 pRunLoader->GetNumberOfEvents(), count));
128 fpRawReader->RewindEvents();
129 fpRawReader->NextEvent();
136 if (sysOp.Length()>0) sysOp+=" ";
144 if (fpSystem->ScanOptions(sysOp.Data())<0) {
145 AliError("error setting options for HLT system");
149 if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
150 if ((fpSystem->Configure(pRunLoader))<0) {
151 AliError("error during HLT system configuration");
160 int AliHLTSimulation::Run(AliRunLoader* pRunLoader)
162 // HLT reconstruction for simulated data
164 AliError("Missing RunLoader! 0x0");
168 int nEvents = pRunLoader->GetNumberOfEvents();
171 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
172 AliError("HLT system in error state");
176 // Note: the rawreader is already placed at the first event
177 if ((iResult=fpSystem->Reconstruct(1, pRunLoader, fpRawReader))>=0) {
178 for (int i=1; i<nEvents; i++) {
179 if (fpRawReader && !fpRawReader->NextEvent()) {
180 AliError("missmatch in event count, rawreader corrupted");
183 fpSystem->Reconstruct(1, pRunLoader, fpRawReader);
185 // send specific 'event' to execute the stop sequence
186 fpSystem->Reconstruct(0, NULL, NULL);
192 AliHLTSimulation* AliHLTSimulationCreateInstance()
194 // see header file for function documentation
195 return AliHLTSimulation::CreateInstance();
198 int AliHLTSimulationDeleteInstance(AliHLTSimulation* pSim)
200 // see header file for function documentation
201 return AliHLTSimulation::DeleteInstance(pSim);
204 int AliHLTSimulationInit(AliHLTSimulation* pSim, AliRunLoader* pRunLoader, const char* options)
208 return pSim->Init(pRunLoader, options);
213 int AliHLTSimulationRun(AliHLTSimulation* pSim, AliRunLoader* pRunLoader)
217 return pSim->Run(pRunLoader);
222 int AliHLTSimulationGetLibraryVersion()
224 // see header file for function documentation
225 return LIBHLTSIM_VERSION;