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 AliHLTReconstructor.cxx
20 @author Matthias Richter
22 @brief Binding class for HLT reconstruction in AliRoot. */
25 #include <TObjString.h>
26 #include "AliHLTReconstructor.h"
28 #include "AliESDEvent.h"
29 #include "AliHLTSystem.h"
30 #include "AliHLTOUTRawReader.h"
31 #include "AliHLTOUTDigitReader.h"
32 #include "AliHLTEsdManager.h"
34 ClassImp(AliHLTReconstructor)
36 AliHLTReconstructor::AliHLTReconstructor()
39 AliHLTReconstructorBase(),
40 fFctProcessHLTOUT(NULL),
46 AliHLTReconstructor::~AliHLTReconstructor()
50 AliHLTSystem* pSystem=GetInstance();
52 AliDebug(0, Form("delete HLT system: status %#x", pSystem->GetStatusFlags()));
53 if (pSystem->CheckStatus(AliHLTSystem::kReady)) {
54 // send specific 'event' to execute the stop sequence
55 pSystem->Reconstruct(0, NULL, NULL);
59 if (fpEsdManager) delete fpEsdManager;
63 void AliHLTReconstructor::Init()
65 // init the reconstructor
66 AliHLTSystem* pSystem=GetInstance();
68 AliError("can not create AliHLTSystem object");
71 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
72 AliError("HLT system in error state");
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.
80 TString option = GetOption();
81 TObjArray* pTokens=option.Tokenize(" ");
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()) {
90 pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi());
91 } else if (param.BeginsWith("0x") &&
92 param.Replace(0,2,"",0).IsHex()) {
94 sscanf(param.Data(),"%x", &severity);
95 pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity);
97 AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected");
99 } else if (token.Contains("alilog=off")) {
100 pSystem->SwitchAliLog(0);
101 } else if (token.BeginsWith("lib") && token.EndsWith(".so")) {
105 if (option.Length()>0) option+=" ";
112 if (!libs.IsNull() &&
113 (!pSystem->CheckStatus(AliHLTSystem::kLibrariesLoaded)) &&
114 (pSystem->LoadComponentLibraries(libs.Data())<0)) {
115 AliError("error while loading HLT libraries");
119 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
120 typedef int (*AliHLTSystemSetOptions)(AliHLTSystem* pInstance, const char* options);
121 gSystem->Load("libHLTinterface.so");
122 AliHLTSystemSetOptions pFunc=(AliHLTSystemSetOptions)(gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemSetOptions"));
124 if ((pFunc)(pSystem, option.Data())<0) {
125 AliError("error setting options for HLT system");
128 } else if (option.Length()>0) {
129 AliError(Form("version of HLT system does not support the options \'%s\'", option.Data()));
132 if ((pSystem->Configure())<0) {
133 AliError("error during HLT system configuration");
138 gSystem->Load("libHLTinterface.so");
139 fFctProcessHLTOUT=gSystem->DynFindSymbol("libHLTinterface.so", "AliHLTSystemProcessHLTOUT");
141 fpEsdManager=new AliHLTEsdManager;
144 void AliHLTReconstructor::Reconstruct(AliRawReader* /*rawReader*/, TTree* /*clustersTree*/) const
146 // reconstruction of real data without writing of ESD
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();
153 void AliHLTReconstructor::FillESD(AliRawReader* rawReader, TTree* /*clustersTree*/,
154 AliESDEvent* esd) const
156 // reconstruct real data and fill ESD
157 if (!rawReader || !esd) {
158 AliError("missing raw reader or esd object");
162 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
163 // code needs to be moved back to Reconstruct as soon es HLT loader is implemented
165 AliHLTSystem* pSystem=GetInstance();
167 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
168 AliError("HLT system in error state");
171 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
172 AliError("HLT system in wrong state");
175 if ((iResult=pSystem->Reconstruct(1, NULL, rawReader))>=0) {
178 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
181 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
182 AliError("HLT system in error state");
185 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
186 AliError("HLT system in wrong state");
189 pSystem->FillESD(-1, NULL, esd);
191 AliHLTOUTRawReader* pHLTOUT=new AliHLTOUTRawReader(rawReader, esd->GetEventNumberInFile(), fpEsdManager);
193 ProcessHLTOUT(pHLTOUT, esd);
196 AliError("error creating HLTOUT handler");
201 void AliHLTReconstructor::Reconstruct(TTree* /*digitsTree*/, TTree* /*clustersTree*/) const
203 // reconstruct simulated data
205 // all reconstruction has been moved to FillESD
206 //AliReconstructor::Reconstruct(digitsTree,clustersTree);
209 void AliHLTReconstructor::FillESD(TTree* /*digitsTree*/, TTree* /*clustersTree*/, AliESDEvent* esd) const
211 // reconstruct simulated data and fill ESD
213 // later this is the place to extract the simulated HLT data
214 // for now it's only an user failure condition as he tries to run HLT reconstruction
216 TString option = GetOption();
217 if (!option.IsNull() &&
218 (option.Contains("config=") || option.Contains("chains="))) {
219 AliWarning(Form("HLT reconstruction of simulated data takes place in AliSimulation\n"
220 " /*** run macro *****************************************/\n"
221 " AliSimulation sim;\n"
222 " sim.SetRunHLT(\"%s\");\n"
223 " sim.SetRunGeneration(kFALSE);\n"
224 " sim.SetMakeDigits(\"\");\n"
225 " sim.SetMakeSDigits(\"\");\n"
226 " sim.SetMakeDigitsFromHits(\"\");\n"
228 " /*********************************************************/", option.Data()));
230 AliHLTSystem* pSystem=GetInstance();
232 if (pSystem->CheckStatus(AliHLTSystem::kError)) {
233 AliError("HLT system in error state");
236 if (!pSystem->CheckStatus(AliHLTSystem::kReady)) {
237 AliError("HLT system in wrong state");
241 AliHLTOUTDigitReader* pHLTOUT=new AliHLTOUTDigitReader(esd->GetEventNumberInFile(), fpEsdManager);
243 ProcessHLTOUT(pHLTOUT, esd);
246 AliError("error creating HLTOUT handler");
251 void AliHLTReconstructor::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) const
253 // treatment of simulated or real HLTOUT data
254 if (!pHLTOUT) return;
255 AliHLTSystem* pSystem=GetInstance();
257 AliError("error getting HLT system instance");
261 if (pHLTOUT->Init()<0) {
262 AliError("error : initialization of HLTOUT handler failed");
266 if (fFctProcessHLTOUT) {
267 typedef int (*AliHLTSystemProcessHLTOUT)(AliHLTSystem* pInstance, AliHLTOUT* pHLTOUT, AliESDEvent* esd);
268 AliHLTSystemProcessHLTOUT pFunc=(AliHLTSystemProcessHLTOUT)fFctProcessHLTOUT;
269 if ((pFunc)(pSystem, pHLTOUT, esd)<0) {
270 AliError("error processing HLTOUT");