]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/rec/AliHLTReconstructor.cxx
- HLT simulation writes digit data in addition to raw data
[u/mrichter/AliRoot.git] / HLT / rec / AliHLTReconstructor.cxx
CommitLineData
3e820254 1// $Id$
2
c5123824 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//**************************************************************************
c534985b 18
3a7c0444 19/** @file AliHLTReconstructor.cxx
c534985b 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"
c5123824 28#include "AliESDEvent.h"
3e820254 29#include "AliHLTSystem.h"
c5123824 30#include "AliHLTOUTRawReader.h"
31#include "AliHLTOUTDigitReader.h"
32#include "AliHLTEsdManager.h"
3e820254 33
34ClassImp(AliHLTReconstructor)
35
36AliHLTReconstructor::AliHLTReconstructor()
37 :
38 AliReconstructor(),
c5123824 39 AliHLTReconstructorBase(),
40 fFctProcessHLTOUT(NULL),
41 fpEsdManager(NULL)
3e820254 42{
43 //constructor
44}
45
46AliHLTReconstructor::~AliHLTReconstructor()
47{
48 //destructor
dee38f1b 49
a3ef3c1d 50 AliHLTSystem* pSystem=GetInstance();
51 if (pSystem) {
52 AliDebug(0, Form("delete HLT system: status %#x", pSystem->GetStatusFlags()));
53 if (pSystem->CheckStatus(AliHLTSystem::kReady)) {
dee38f1b 54 // send specific 'event' to execute the stop sequence
a3ef3c1d 55 pSystem->Reconstruct(0, NULL, NULL);
dee38f1b 56 }
3e820254 57 }
c5123824 58
59 if (fpEsdManager) delete fpEsdManager;
60 fpEsdManager=NULL;
3e820254 61}
62
63void AliHLTReconstructor::Init()
64{
65 // init the reconstructor
a3ef3c1d 66 AliHLTSystem* pSystem=GetInstance();
67 if (!pSystem) {
3e820254 68 AliError("can not create AliHLTSystem object");
69 return;
70 }
a3ef3c1d 71 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
3e820254 72 AliError("HLT system in error state");
73 return;
74 }
75
76 // the options scan has been moved to AliHLTSystem, the old code
77 // here is kept to be able to run an older version of the HLT code
78 // with newer AliRoot versions.
79 TString libs("");
80 TString option = GetOption();
81 TObjArray* pTokens=option.Tokenize(" ");
82 option="";
83 if (pTokens) {
84 int iEntries=pTokens->GetEntries();
85 for (int i=0; i<iEntries; i++) {
86 TString token=(((TObjString*)pTokens->At(i))->GetString());
87 if (token.Contains("loglevel=")) {
88 TString param=token.ReplaceAll("loglevel=", "");
89 if (param.IsDigit()) {
a3ef3c1d 90 pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
3e820254 91 } else if (param.BeginsWith("0x") &&
92 param.Replace(0,2,"",0).IsHex()) {
93 int severity=0;
94 sscanf(param.Data(),"%x", &severity);
a3ef3c1d 95 pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
3e820254 96 } else {
97 AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
98 }
99 } else if (token.Contains("alilog=off")) {
a3ef3c1d 100 pSystem->SwitchAliLog(0);
3e820254 101 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
102 libs+=token;
103 libs+=" ";
104 } else {
105 if (option.Length()>0) option+=" ";
106 option+=token;
107 }
108 }
109 delete pTokens;
110 }
7f9ab840 111
3e820254 112 if (!libs.IsNull() &&
a3ef3c1d 113 (!pSystem->CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
114 (pSystem->LoadComponentLibraries(libs.Data())<0)) {
3e820254 115 AliError("error while loading HLT libraries");
116 return;
117 }
118
a3ef3c1d 119 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
3e820254 120 typedef int (*AliHLTSystemSetOptions)(AliHLTSystem* pInstance, const char* options);
121 gSystem->Load("libHLTinterface.so");
122 AliHLTSystemSetOptions pFunc=(AliHLTSystemSetOptions)(gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemSetOptions"));
123 if (pFunc) {
a3ef3c1d 124 if ((pFunc)(pSystem, option.Data())<0) {
3e820254 125 AliError("error setting options for HLT system");
126 return;
127 }
128 } else if (option.Length()>0) {
129 AliError(Form("version of HLT system does not support the options \'%s\'", option.Data()));
130 return;
131 }
a3ef3c1d 132 if ((pSystem->Configure())<0) {
3e820254 133 AliError("error during HLT system configuration");
134 return;
135 }
136 }
c5123824 137
138 gSystem->Load("libHLTinterface.so");
139 fFctProcessHLTOUT=gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemProcessHLTOUT");
140
141 fpEsdManager=new AliHLTEsdManager;
3e820254 142}
143
144void AliHLTReconstructor::Reconstruct(AliRawReader* /*rawReader*/, TTree* /*clustersTree*/) const
145{
146 // reconstruction of real data without writing of ESD
c5123824 147 // For each event, HLT reconstruction chains can be executed and
148 // added to the existing HLTOUT data
149 // The HLTOUT data is finally processed in FillESD
150 AliHLTSystem* pSystem=GetInstance();
3e820254 151}
152
153void AliHLTReconstructor::FillESD(AliRawReader* rawReader, TTree* /*clustersTree*/,
154 AliESDEvent* esd) const
155{
156 // reconstruct real data and fill ESD
c5123824 157 if (!rawReader || !esd) {
158 AliError("missing raw reader or esd object");
159 return;
160 }
161
162 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
163 // code needs to be moved back to Reconstruct as soon es HLT loader is implemented
3e820254 164 int iResult=0;
a3ef3c1d 165 AliHLTSystem* pSystem=GetInstance();
166 if (pSystem) {
167 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
3e820254 168 AliError("HLT system in error state");
169 return;
170 }
a3ef3c1d 171 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
3e820254 172 AliError("HLT system in wrong state");
173 return;
174 }
a3ef3c1d 175 if ((iResult=pSystem->Reconstruct(1, NULL, rawReader))>=0) {
c5123824 176 }
177 }
178 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
179
180 if (pSystem) {
181 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
182 AliError("HLT system in error state");
183 return;
184 }
185 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
186 AliError("HLT system in wrong state");
187 return;
188 }
189 pSystem->FillESD(-1, NULL, esd);
190
191 AliHLTOUTRawReader* pHLTOUT=new AliHLTOUTRawReader(rawReader, esd->GetEventNumberInFile(), fpEsdManager);
192 if (pHLTOUT) {
193 ProcessHLTOUT(pHLTOUT, esd);
194 } else {
195 AliError("error creating HLTOUT handler");
3e820254 196 }
197 }
198}
7f9ab840 199
29312178 200void AliHLTReconstructor::Reconstruct(TTree* /*digitsTree*/, TTree* /*clustersTree*/) const
7f9ab840 201{
202 // reconstruct simulated data
203
204 // all reconstruction has been moved to FillESD
205 //AliReconstructor::Reconstruct(digitsTree,clustersTree);
206}
207
c5123824 208void AliHLTReconstructor::FillESD(TTree* /*digitsTree*/, TTree* /*clustersTree*/, AliESDEvent* esd) const
7f9ab840 209{
210 // reconstruct simulated data and fill ESD
211
212 // later this is the place to extract the simulated HLT data
213 // for now it's only an user failure condition as he tries to run HLT reconstruction
214 // on simulated data
215 TString option = GetOption();
c5123824 216 if (!option.IsNull() &&
217 (option.Contains("config=") || option.Contains("chains="))) {
7f9ab840 218 AliWarning(Form("HLT reconstruction of simulated data takes place in AliSimulation\n"
219 " /*** run macro *****************************************/\n"
220 " AliSimulation sim;\n"
221 " sim.SetRunHLT(\"%s\");\n"
222 " sim.SetRunGeneration(kFALSE);\n"
223 " sim.SetMakeDigits(\"\");\n"
224 " sim.SetMakeSDigits(\"\");\n"
225 " sim.SetMakeDigitsFromHits(\"\");\n"
226 " sim.Run();\n"
227 " /*********************************************************/", option.Data()));
228 }
c5123824 229 AliHLTSystem* pSystem=GetInstance();
230 if (pSystem) {
231 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
232 AliError("HLT system in error state");
233 return;
234 }
235 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
236 AliError("HLT system in wrong state");
237 return;
238 }
239
240 AliHLTOUTDigitReader* pHLTOUT=new AliHLTOUTDigitReader(esd->GetEventNumberInFile(), fpEsdManager);
241 if (pHLTOUT) {
242 ProcessHLTOUT(pHLTOUT, esd);
243 } else {
244 AliError("error creating HLTOUT handler");
245 }
246 }
247}
248
249void AliHLTReconstructor::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) const
250{
251 // treatmen of simulated or real HLTOUT data
252 if (!pHLTOUT) return;
253 AliHLTSystem* pSystem=GetInstance();
254 if (!pSystem) {
255 AliError("error getting HLT system instance");
256 return;
257 }
258
259 if (pHLTOUT->Init()<0) {
260 AliError("error : initialization of HLTOUT handler failed");
261 return;
262 }
263
264 if (fFctProcessHLTOUT) {
265 typedef int (*AliHLTSystemProcessHLTOUT)(AliHLTSystem* pInstance, AliHLTOUT* pHLTOUT, AliESDEvent* esd);
266 AliHLTSystemProcessHLTOUT pFunc=(AliHLTSystemProcessHLTOUT)fFctProcessHLTOUT;
267 if ((pFunc)(pSystem, pHLTOUT, esd)<0) {
268 AliError("error processing HLTOUT");
269 }
270 }
7f9ab840 271}