]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/rec/AliHLTReconstructor.cxx
- support for event by event reconstruction added to AliHLTSystem
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTReconstructor.cxx
CommitLineData
3e820254 1// $Id$
2
c534985b 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 AliHLTReconstruction.cxx
20 @author Matthias Richter
21 @date
22 @brief Binding class for HLT reconstruction in AliRoot. */
3e820254 23
24#include <TSystem.h>
25#include <TObjString.h>
26#include "AliHLTReconstructor.h"
27#include "AliLog.h"
28#include "AliHLTSystem.h"
29
30ClassImp(AliHLTReconstructor)
31
32AliHLTReconstructor::AliHLTReconstructor()
33 :
34 AliReconstructor(),
35 fpSystem(NULL)
36{
37 //constructor
38}
39
40AliHLTReconstructor::~AliHLTReconstructor()
41{
42 //destructor
dee38f1b 43
3e820254 44 if (fpSystem) {
dee38f1b 45 AliDebug(0, Form("delete HLT system: status %#x", fpSystem->GetStatusFlags()));
46 if (fpSystem->CheckStatus(AliHLTSystem::kReady)) {
47 // send specific 'event' to execute the stop sequence
48 fpSystem->Reconstruct(0, NULL, NULL);
49 }
3e820254 50 delete fpSystem;
51 }
52 fpSystem=NULL;
53}
54
55void AliHLTReconstructor::Init()
56{
57 // init the reconstructor
58 if (!fpSystem) fpSystem=new AliHLTSystem;
59 if (!fpSystem) {
60 AliError("can not create AliHLTSystem object");
61 return;
62 }
63 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
64 AliError("HLT system in error state");
65 return;
66 }
67
68 // the options scan has been moved to AliHLTSystem, the old code
69 // here is kept to be able to run an older version of the HLT code
70 // with newer AliRoot versions.
71 TString libs("");
72 TString option = GetOption();
73 TObjArray* pTokens=option.Tokenize(" ");
74 option="";
75 if (pTokens) {
76 int iEntries=pTokens->GetEntries();
77 for (int i=0; i<iEntries; i++) {
78 TString token=(((TObjString*)pTokens->At(i))->GetString());
79 if (token.Contains("loglevel=")) {
80 TString param=token.ReplaceAll("loglevel=", "");
81 if (param.IsDigit()) {
82 fpSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
83 } else if (param.BeginsWith("0x") &&
84 param.Replace(0,2,"",0).IsHex()) {
85 int severity=0;
86 sscanf(param.Data(),"%x", &severity);
87 fpSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
88 } else {
89 AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
90 }
91 } else if (token.Contains("alilog=off")) {
92 fpSystem->SwitchAliLog(0);
93 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
94 libs+=token;
95 libs+=" ";
96 } else {
97 if (option.Length()>0) option+=" ";
98 option+=token;
99 }
100 }
101 delete pTokens;
102 }
7f9ab840 103
3e820254 104 if (!libs.IsNull() &&
105 (!fpSystem->CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
106 (fpSystem->LoadComponentLibraries(libs.Data())<0)) {
107 AliError("error while loading HLT libraries");
108 return;
109 }
110
111 if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
112 typedef int (*AliHLTSystemSetOptions)(AliHLTSystem* pInstance, const char* options);
113 gSystem->Load("libHLTinterface.so");
114 AliHLTSystemSetOptions pFunc=(AliHLTSystemSetOptions)(gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemSetOptions"));
115 if (pFunc) {
116 if ((pFunc)(fpSystem, option.Data())<0) {
117 AliError("error setting options for HLT system");
118 return;
119 }
120 } else if (option.Length()>0) {
121 AliError(Form("version of HLT system does not support the options \'%s\'", option.Data()));
122 return;
123 }
124 if ((fpSystem->Configure())<0) {
125 AliError("error during HLT system configuration");
126 return;
127 }
128 }
129}
130
131void AliHLTReconstructor::Reconstruct(AliRawReader* /*rawReader*/, TTree* /*clustersTree*/) const
132{
133 // reconstruction of real data without writing of ESD
134
135 // all reconstruction has been moved to FillESD
136// int iResult=0;
137// if (fpSystem) {
138// if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
139// AliError("HLT system in error state");
140// return;
141// }
142// if ((iResult=fpSystem->Reconstruct(1, NULL, rawReader))>=0) {
143// }
144// }
145}
146
147void AliHLTReconstructor::FillESD(AliRawReader* rawReader, TTree* /*clustersTree*/,
148 AliESDEvent* esd) const
149{
150 // reconstruct real data and fill ESD
151 int iResult=0;
152 if (fpSystem) {
153 if (fpSystem->CheckStatus(AliHLTSystem::kError)) {
154 AliError("HLT system in error state");
155 return;
156 }
157 if (!fpSystem->CheckStatus(AliHLTSystem::kReady)) {
158 AliError("HLT system in wrong state");
159 return;
160 }
161 if ((iResult=fpSystem->Reconstruct(1, NULL, rawReader))>=0) {
162 fpSystem->FillESD(-1, NULL, esd);
163 }
164 }
165}
7f9ab840 166
29312178 167void AliHLTReconstructor::Reconstruct(TTree* /*digitsTree*/, TTree* /*clustersTree*/) const
7f9ab840 168{
169 // reconstruct simulated data
170
171 // all reconstruction has been moved to FillESD
172 //AliReconstructor::Reconstruct(digitsTree,clustersTree);
173}
174
175void AliHLTReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, AliESDEvent* esd) const
176{
177 // reconstruct simulated data and fill ESD
178
179 // later this is the place to extract the simulated HLT data
180 // for now it's only an user failure condition as he tries to run HLT reconstruction
181 // on simulated data
182 TString option = GetOption();
183 if (!option.IsNull()) {
184 AliWarning(Form("HLT reconstruction of simulated data takes place in AliSimulation\n"
185 " /*** run macro *****************************************/\n"
186 " AliSimulation sim;\n"
187 " sim.SetRunHLT(\"%s\");\n"
188 " sim.SetRunGeneration(kFALSE);\n"
189 " sim.SetMakeDigits(\"\");\n"
190 " sim.SetMakeSDigits(\"\");\n"
191 " sim.SetMakeDigitsFromHits(\"\");\n"
192 " sim.Run();\n"
193 " /*********************************************************/", option.Data()));
194 }
195 AliReconstructor::FillESD(digitsTree,clustersTree,esd);
196}