- support for event by event reconstruction added to AliHLTSystem
[u/mrichter/AliRoot.git] / HLT / sim / AliHLTSimulation.cxx
CommitLineData
4cbaf07b 1// $Id$
2
3/**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
6 * *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
9 * *
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 **************************************************************************/
18
19/** @file AliHLTSimulation.cxx
20 @author Matthias Richter
21 @date
22 @brief Binding class for HLT simulation in AliRoot. */
23
24#include <cassert>
25#include <cerrno>
26#include "AliHLTSimulation.h"
27#include "AliLog.h"
28#include "AliRunLoader.h"
29#include "AliHLTSystem.h"
30
31#if ALIHLTSIMULATION_LIBRARY_VERSION != LIBHLTSIM_VERSION
32#error library version in header file and lib*.pkg do not match
33#endif
34
35/** ROOT macro for the implementation of ROOT specific class methods */
36ClassImp(AliHLTSimulation);
37
38AliHLTSimulation::AliHLTSimulation()
39 :
40 fOptions(),
41 fpSystem(NULL)
42{
43 // see header file for class documentation
44 // or
45 // refer to README to build package
46 // or
47 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
48}
49
50AliHLTSimulation::~AliHLTSimulation()
51{
52 // see header file for function documentation
53 if (fpSystem) {
54 delete fpSystem;
55 }
56 fpSystem=NULL;
57}
58
59AliHLTSimulation* AliHLTSimulation::CreateInstance()
60{
61 // see header file for function documentation
62 return new AliHLTSimulation;
63}
64
65int AliHLTSimulation::DeleteInstance(AliHLTSimulation* pSim)
66{
67 // see header file for function documentation
68 assert(pSim!=NULL);
69 delete pSim;
70 return 0;
71}
72
73int AliHLTSimulation::Init(AliRunLoader* pRunLoader, const char* options)
74{
75 // init the simulation
76 fOptions=options;
77
78 if (!fpSystem) fpSystem=new AliHLTSystem;
79 if (!fpSystem) {
80 AliError("can not create AliHLTSystem object");
81 return -ENOMEM;
82 }
83 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
84 AliError("HLT system in error state");
85 return -EFAULT;
86 }
87
88 if (fpSystem->ScanOptions(options)<0) {
89 AliError("error setting options for HLT system");
90 return -EINVAL;
91 }
92
93 if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
94 if ((fpSystem->Configure(pRunLoader))<0) {
95 AliError("error during HLT system configuration");
96 return -EFAULT;
97 }
98 }
99
100 return 0;
101}
102
103
104int AliHLTSimulation::Run(AliRunLoader* pRunLoader)
105{
106 // HLT reconstruction for simulated data
107 if(!pRunLoader) {
108 AliError("Missing RunLoader! 0x0");
109 return -EINVAL;
110 }
111
112 Int_t nEvents = pRunLoader->GetNumberOfEvents();
113 int iResult=0;
114
115 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
116 AliError("HLT system in error state");
117 return -EFAULT;
118 }
119 if ((iResult=fpSystem->Reconstruct(nEvents, pRunLoader, NULL))>=0) {
dee38f1b 120 // send specific 'event' to execute the stop sequence
121 fpSystem->Reconstruct(0, NULL, NULL);
4cbaf07b 122 }
123 return iResult;
124}
125
126
127AliHLTSimulation* AliHLTSimulationCreateInstance()
128{
129 // see header file for function documentation
130 return AliHLTSimulation::CreateInstance();
131}
132
133int AliHLTSimulationDeleteInstance(AliHLTSimulation* pSim)
134{
135 // see header file for function documentation
136 return AliHLTSimulation::DeleteInstance(pSim);
137}
138
139int AliHLTSimulationInit(AliHLTSimulation* pSim, AliRunLoader* pRunLoader, const char* options)
140{
141 assert(pSim!=NULL);
142 if (pSim) {
143 return pSim->Init(pRunLoader, options);
144 }
145 return -ENODEV;
146}
147
148int AliHLTSimulationRun(AliHLTSimulation* pSim, AliRunLoader* pRunLoader)
149{
150 assert(pSim!=NULL);
151 if (pSim) {
152 return pSim->Run(pRunLoader);
153 }
154 return -ENODEV;
155}
156
157int AliHLTSimulationGetLibraryVersion()
158{
159 // see header file for function documentation
160 return LIBHLTSIM_VERSION;
161}