]>
Commit | Line | Data |
---|---|---|
3e820254 | 1 | // $Id$ |
2 | ||
c5123824 | 3 | //************************************************************************** |
a31bc263 | 4 | //* This file is property of and copyright by the * |
c5123824 | 5 | //* ALICE Experiment at CERN, All rights reserved. * |
6 | //* * | |
7 | //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
c5123824 | 8 | //* * |
9 | //* Permission to use, copy, modify and distribute this software and its * | |
10 | //* documentation strictly for non-commercial purposes is hereby granted * | |
11 | //* without fee, provided that the above copyright notice appears in all * | |
12 | //* copies and that both the copyright notice and this permission notice * | |
13 | //* appear in the supporting documentation. The authors make no claims * | |
14 | //* about the suitability of this software for any purpose. It is * | |
15 | //* provided "as is" without express or implied warranty. * | |
16 | //************************************************************************** | |
c534985b | 17 | |
69edd0d6 | 18 | // @file AliHLTReconstructor.cxx |
19 | // @author Matthias Richter | |
20 | // @date | |
21 | // @brief Binding class for HLT reconstruction in AliRoot | |
22 | // Implements bot the interface to run HLT chains embedded into | |
23 | // AliReconstruction and the unpacking and treatment of HLTOUT | |
3e820254 | 24 | |
25 | #include <TSystem.h> | |
26 | #include <TObjString.h> | |
032c5e5e | 27 | #include "TFile.h" |
28 | #include "TTree.h" | |
dc5556e5 | 29 | #include "TObject.h" |
30 | #include "TObjArray.h" | |
31 | #include "TClass.h" | |
32 | #include "TStreamerInfo.h" | |
3e820254 | 33 | #include "AliHLTReconstructor.h" |
34 | #include "AliLog.h" | |
032c5e5e | 35 | #include "AliRawReader.h" |
c5123824 | 36 | #include "AliESDEvent.h" |
3e820254 | 37 | #include "AliHLTSystem.h" |
c5123824 | 38 | #include "AliHLTOUTRawReader.h" |
39 | #include "AliHLTOUTDigitReader.h" | |
40 | #include "AliHLTEsdManager.h" | |
00ddfaca | 41 | #include "AliHLTPluginBase.h" |
dc5556e5 | 42 | #include "AliHLTMisc.h" |
43 | #include "AliCDBManager.h" | |
44 | #include "AliCDBEntry.h" | |
d3382be1 | 45 | #include "AliHLTMessage.h" |
c4ffab2c | 46 | #include "AliCentralTrigger.h" |
47 | #include "AliTriggerConfiguration.h" | |
48 | #include "AliTriggerClass.h" | |
49 | #include "AliTriggerCluster.h" | |
50 | #include "AliDAQ.h" | |
56c9a306 | 51 | #include "AliRunLoader.h" |
dc5556e5 | 52 | |
53 | class AliCDBEntry; | |
3e820254 | 54 | |
69edd0d6 | 55 | /** ROOT macro for the implementation of ROOT specific class methods */ |
3e820254 | 56 | ClassImp(AliHLTReconstructor) |
57 | ||
58 | AliHLTReconstructor::AliHLTReconstructor() | |
69edd0d6 | 59 | : AliReconstructor() |
60 | , fpEsdManager(NULL) | |
61 | , fpPluginBase(new AliHLTPluginBase) | |
3eb6bcbe | 62 | , fFlags(0) |
a31bc263 | 63 | , fProcessingStep(kProcessingStepUndefined) |
3e820254 | 64 | { |
65 | //constructor | |
66 | } | |
67 | ||
032c5e5e | 68 | AliHLTReconstructor::AliHLTReconstructor(const char* options) |
69edd0d6 | 69 | : AliReconstructor() |
70 | , fpEsdManager(NULL) | |
71 | , fpPluginBase(new AliHLTPluginBase) | |
3eb6bcbe | 72 | , fFlags(0) |
a31bc263 | 73 | , fProcessingStep(kProcessingStepUndefined) |
032c5e5e | 74 | { |
75 | //constructor | |
76 | if (options) Init(options); | |
77 | } | |
78 | ||
3e820254 | 79 | AliHLTReconstructor::~AliHLTReconstructor() |
80 | { | |
81 | //destructor | |
dee38f1b | 82 | |
56c9a306 | 83 | if (fpEsdManager) AliHLTEsdManager::Delete(fpEsdManager); |
84 | fpEsdManager=NULL; | |
85 | ||
00ddfaca | 86 | if (fpPluginBase) { |
87 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); | |
a3ef3c1d | 88 | if (pSystem) { |
00ddfaca | 89 | AliDebug(0, Form("terminate HLT system: status %#x", pSystem->GetStatusFlags())); |
3dd8541e | 90 | if (pSystem->CheckStatus(AliHLTSystem::kStarted)) { |
dee38f1b | 91 | // send specific 'event' to execute the stop sequence |
a3ef3c1d | 92 | pSystem->Reconstruct(0, NULL, NULL); |
dee38f1b | 93 | } |
3e820254 | 94 | } |
00ddfaca | 95 | delete fpPluginBase; |
96 | } | |
97 | fpPluginBase=NULL; | |
c5123824 | 98 | |
3e820254 | 99 | } |
100 | ||
032c5e5e | 101 | void AliHLTReconstructor::Init(const char* options) |
102 | { | |
103 | // init the reconstructor | |
104 | SetOption(options); | |
105 | Init(); | |
106 | } | |
107 | ||
3e820254 | 108 | void AliHLTReconstructor::Init() |
109 | { | |
110 | // init the reconstructor | |
00ddfaca | 111 | if (!fpPluginBase) { |
112 | AliError("internal memory error: can not get AliHLTSystem instance from plugin"); | |
113 | return; | |
114 | } | |
115 | ||
116 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); | |
a3ef3c1d | 117 | if (!pSystem) { |
3e820254 | 118 | AliError("can not create AliHLTSystem object"); |
119 | return; | |
120 | } | |
a3ef3c1d | 121 | if (pSystem->CheckStatus(AliHLTSystem::kError)) { |
3e820254 | 122 | AliError("HLT system in error state"); |
123 | return; | |
124 | } | |
125 | ||
21d97a90 | 126 | TString esdManagerOptions; |
127 | ||
3e820254 | 128 | // the options scan has been moved to AliHLTSystem, the old code |
129 | // here is kept to be able to run an older version of the HLT code | |
130 | // with newer AliRoot versions. | |
3e820254 | 131 | TString option = GetOption(); |
132 | TObjArray* pTokens=option.Tokenize(" "); | |
133 | option=""; | |
134 | if (pTokens) { | |
135 | int iEntries=pTokens->GetEntries(); | |
136 | for (int i=0; i<iEntries; i++) { | |
137 | TString token=(((TObjString*)pTokens->At(i))->GetString()); | |
138 | if (token.Contains("loglevel=")) { | |
139 | TString param=token.ReplaceAll("loglevel=", ""); | |
140 | if (param.IsDigit()) { | |
a3ef3c1d | 141 | pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)param.Atoi()); |
3e820254 | 142 | } else if (param.BeginsWith("0x") && |
143 | param.Replace(0,2,"",0).IsHex()) { | |
144 | int severity=0; | |
145 | sscanf(param.Data(),"%x", &severity); | |
a3ef3c1d | 146 | pSystem->SetGlobalLoggingLevel((AliHLTComponentLogSeverity)severity); |
3e820254 | 147 | } else { |
148 | AliWarning("wrong parameter for option \'loglevel=\', (hex) number expected"); | |
149 | } | |
150 | } else if (token.Contains("alilog=off")) { | |
a3ef3c1d | 151 | pSystem->SwitchAliLog(0); |
3eb6bcbe | 152 | } else if (token.CompareTo("ignore-hltout")==0) { |
153 | fFlags|=kAliHLTReconstructorIgnoreHLTOUT; | |
930201f4 | 154 | } else if (token.CompareTo("run-online-config")==0) { |
155 | fFlags|=kAliHLTReconstructorIgnoreHLTOUT; | |
156 | if (option.Length()>0) option+=" "; | |
157 | option+=token; | |
75cbb181 | 158 | } else if (token.CompareTo("ignore-ctp")==0) { |
159 | fFlags|=kAliHLTReconstructorIgnoreCTP; | |
21d97a90 | 160 | } else if (token.Contains("esdmanager=")) { |
161 | token.ReplaceAll("esdmanager=", ""); | |
162 | token.ReplaceAll(","," "); | |
163 | token.ReplaceAll("'",""); | |
164 | esdManagerOptions=token; | |
3e820254 | 165 | } else { |
166 | if (option.Length()>0) option+=" "; | |
167 | option+=token; | |
168 | } | |
169 | } | |
170 | delete pTokens; | |
171 | } | |
7f9ab840 | 172 | |
c4ffab2c | 173 | TString ecsParam; |
174 | TString ctpParam; | |
75cbb181 | 175 | if ((fFlags&kAliHLTReconstructorIgnoreCTP)==0 && |
176 | BuildCTPTriggerClassString(ctpParam)>=0) { | |
c4ffab2c | 177 | if (!ecsParam.IsNull()) ecsParam+=";"; |
178 | ecsParam+="CTP_TRIGGER_CLASS="; | |
179 | ecsParam+=ctpParam; | |
180 | } | |
181 | ||
182 | if (!ecsParam.IsNull()) { | |
183 | option+=" ECS="; | |
184 | option+=ecsParam; | |
185 | } | |
186 | ||
a3ef3c1d | 187 | if (!pSystem->CheckStatus(AliHLTSystem::kReady)) { |
69edd0d6 | 188 | if (pSystem->ScanOptions(option.Data())<0) { |
3e820254 | 189 | AliError("error setting options for HLT system"); |
3e820254 | 190 | return; |
191 | } | |
a3ef3c1d | 192 | if ((pSystem->Configure())<0) { |
3e820254 | 193 | AliError("error during HLT system configuration"); |
194 | return; | |
195 | } | |
196 | } | |
c5123824 | 197 | |
f1207f29 | 198 | fpEsdManager=AliHLTEsdManager::New(); |
27a77ce0 | 199 | if (fpEsdManager) { |
200 | fpEsdManager->SetOption(esdManagerOptions.Data()); | |
201 | } | |
dc5556e5 | 202 | |
b251fffc | 203 | AliHLTMisc::Instance().InitStreamerInfos(fgkCalibStreamerInfoEntry); |
dc5556e5 | 204 | } |
205 | ||
824ab48a | 206 | void AliHLTReconstructor::Terminate() |
76797417 | 207 | { |
a31bc263 | 208 | /// overloaded from AliReconstructor: terminate event processing |
209 | ||
210 | // indicate step 'Terminate' | |
211 | SetProcessingStep(kProcessingStepTerminate); | |
212 | ||
76797417 | 213 | AliInfo("terminating"); |
214 | if (fpPluginBase) { | |
a31bc263 | 215 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); |
216 | if (pSystem) { | |
06b7d051 | 217 | // 2012-04-02 |
218 | // clean up the HLTOUT instance if still existing, currently FinishEvent | |
219 | // is not called at the end of the event processing and the cleanup | |
220 | // needs to be done here to avoid a warning message. Later it can be | |
221 | // declared a malfunction if the HLTOUT instance is still existing at | |
222 | // this point. | |
223 | AliHLTOUT* pHLTOUT=NULL; | |
224 | pSystem->InvalidateHLTOUT(&pHLTOUT); | |
225 | if (pHLTOUT) { | |
226 | pHLTOUT->Reset(); | |
227 | delete pHLTOUT; | |
228 | pHLTOUT=NULL; | |
229 | } | |
230 | ||
a31bc263 | 231 | AliDebug(0, Form("terminate HLT system: status %#x", pSystem->GetStatusFlags())); |
232 | if (pSystem->CheckStatus(AliHLTSystem::kStarted)) { | |
233 | // send specific 'event' to execute the stop sequence | |
234 | pSystem->Reconstruct(0, NULL, NULL); | |
235 | } | |
236 | } | |
237 | } | |
238 | } | |
239 | ||
240 | void AliHLTReconstructor::FinishEvent() | |
241 | { | |
242 | /// overloaded from AliReconstructor: finish current event | |
243 | if (!fpPluginBase) return; | |
244 | ||
245 | // indicate step 'FinishEvent' | |
246 | SetProcessingStep(kProcessingStepFinishEvent); | |
247 | ||
248 | AliInfo("finishing event"); | |
76797417 | 249 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); |
250 | if (pSystem) { | |
a31bc263 | 251 | // this is the end of the lifetime of the HLTOUT instance |
252 | // called after all other modules have been reconstructed | |
253 | AliHLTOUT* pHLTOUT=NULL; | |
254 | pSystem->InvalidateHLTOUT(&pHLTOUT); | |
255 | if (pHLTOUT) { | |
256 | pHLTOUT->Reset(); | |
257 | delete pHLTOUT; | |
258 | pHLTOUT=NULL; | |
76797417 | 259 | } |
260 | } | |
76797417 | 261 | } |
262 | ||
dc5556e5 | 263 | const char* AliHLTReconstructor::fgkCalibStreamerInfoEntry="HLT/Calib/StreamerInfo"; |
264 | ||
06995b88 | 265 | void AliHLTReconstructor::Reconstruct(AliRawReader* rawReader, TTree* /*clustersTree*/) const |
3e820254 | 266 | { |
267 | // reconstruction of real data without writing of ESD | |
c5123824 | 268 | // For each event, HLT reconstruction chains can be executed and |
269 | // added to the existing HLTOUT data | |
270 | // The HLTOUT data is finally processed in FillESD | |
56c9a306 | 271 | |
00ddfaca | 272 | if (!fpPluginBase) { |
273 | AliError("internal memory error: can not get AliHLTSystem instance from plugin"); | |
274 | return; | |
275 | } | |
276 | ||
3e820254 | 277 | int iResult=0; |
00ddfaca | 278 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); |
06995b88 | 279 | |
a3ef3c1d | 280 | if (pSystem) { |
d82bb2b6 | 281 | AliHLTOUT* pHLTOUT=NULL; |
282 | pSystem->InvalidateHLTOUT(&pHLTOUT); | |
283 | if (pHLTOUT) { | |
a31bc263 | 284 | // at this stage we always have a new event, regardless state of |
285 | // fProcessingStep; build the HLTOUT instance from scratch | |
286 | pHLTOUT->Reset(); | |
d82bb2b6 | 287 | delete pHLTOUT; |
288 | pHLTOUT=NULL; | |
289 | } | |
a3ef3c1d | 290 | if (pSystem->CheckStatus(AliHLTSystem::kError)) { |
3e820254 | 291 | AliError("HLT system in error state"); |
292 | return; | |
293 | } | |
a3ef3c1d | 294 | if (!pSystem->CheckStatus(AliHLTSystem::kReady)) { |
3e820254 | 295 | AliError("HLT system in wrong state"); |
296 | return; | |
297 | } | |
56c9a306 | 298 | |
a31bc263 | 299 | // indicate the local reconstruction step |
300 | SetProcessingStep(kProcessingStepLocal); | |
301 | ||
56c9a306 | 302 | // init the HLTOUT instance for the current event |
303 | // not nice. Have to query the global run loader to get the current event no. | |
304 | Int_t eventNo=-1; | |
305 | AliRunLoader* runloader = AliRunLoader::Instance(); | |
306 | if (runloader) { | |
307 | eventNo=runloader->GetEventNumber(); | |
308 | } | |
309 | if (eventNo>=0) { | |
310 | AliRawReader* input=NULL; | |
311 | if ((fFlags&kAliHLTReconstructorIgnoreHLTOUT) == 0 ) { | |
312 | input=rawReader; | |
313 | } | |
d82bb2b6 | 314 | pHLTOUT=new AliHLTOUTRawReader(input, eventNo, fpEsdManager); |
56c9a306 | 315 | if (pHLTOUT) { |
316 | if (pHLTOUT->Init()>=0) { | |
317 | pSystem->InitHLTOUT(pHLTOUT); | |
318 | } else { | |
319 | AliError("error : initialization of HLTOUT handler failed"); | |
320 | } | |
321 | } else { | |
322 | AliError("memory allocation failed: can not create AliHLTOUT object"); | |
323 | } | |
324 | } else { | |
325 | AliError("can not get event number"); | |
326 | } | |
327 | ||
a3ef3c1d | 328 | if ((iResult=pSystem->Reconstruct(1, NULL, rawReader))>=0) { |
c5123824 | 329 | } |
330 | } | |
06995b88 | 331 | } |
332 | ||
333 | void AliHLTReconstructor::FillESD(AliRawReader* rawReader, TTree* /*clustersTree*/, | |
334 | AliESDEvent* esd) const | |
335 | { | |
336 | // reconstruct real data and fill ESD | |
337 | if (!rawReader || !esd) { | |
338 | AliError("missing raw reader or esd object"); | |
339 | return; | |
340 | } | |
341 | ||
00ddfaca | 342 | if (!fpPluginBase) { |
343 | AliError("internal memory error: can not get AliHLTSystem instance from plugin"); | |
344 | return; | |
345 | } | |
346 | ||
347 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); | |
c5123824 | 348 | |
349 | if (pSystem) { | |
350 | if (pSystem->CheckStatus(AliHLTSystem::kError)) { | |
351 | AliError("HLT system in error state"); | |
352 | return; | |
353 | } | |
354 | if (!pSystem->CheckStatus(AliHLTSystem::kReady)) { | |
355 | AliError("HLT system in wrong state"); | |
356 | return; | |
357 | } | |
358 | pSystem->FillESD(-1, NULL, esd); | |
359 | ||
56c9a306 | 360 | // the HLTOUT handler has either been created in the AliHLTReconstructor::Reconstruct |
361 | // step of this event or is created now. In either case the instance is deleted after | |
362 | // the processing | |
363 | AliHLTOUT* pHLTOUT=NULL; | |
364 | pSystem->InvalidateHLTOUT(&pHLTOUT); | |
a31bc263 | 365 | if (pHLTOUT && fProcessingStep!=kProcessingStepLocal) { |
366 | // this is a new event, if local reconstruction would have been executed | |
367 | // the HLTOUT instance would have been created for the current event already, | |
368 | // in all other cases one has to create the HLTOUT instance here | |
369 | pHLTOUT->Reset(); | |
370 | delete pHLTOUT; | |
371 | pHLTOUT=NULL; | |
372 | } | |
56c9a306 | 373 | if (!pHLTOUT) { |
374 | AliRawReader* input=NULL; | |
375 | if ((fFlags&kAliHLTReconstructorIgnoreHLTOUT) == 0 ) { | |
376 | input=rawReader; | |
377 | } | |
378 | pHLTOUT=new AliHLTOUTRawReader(input, esd->GetEventNumberInFile(), fpEsdManager); | |
3eb6bcbe | 379 | } |
a31bc263 | 380 | |
381 | // indicate step 'ESD filling' | |
382 | SetProcessingStep(kProcessingStepESD); | |
383 | ||
c5123824 | 384 | if (pHLTOUT) { |
0bba252a | 385 | ProcessHLTOUT(pHLTOUT, esd, (pSystem->GetGlobalLoggingLevel()&kHLTLogDebug)!=0); |
a31bc263 | 386 | // 2012-03-30: a change in the module sequence of AliReconstruction is soon |
387 | // going to be applied: HLT reconstruction is executed fully (i.e. both local | |
388 | // reconstruction and FillESD) before all the other modules. In order to make the | |
389 | // HLTOUT data available for other modules it is kept here and released in the method | |
390 | // FinishEvent | |
391 | pSystem->InitHLTOUT(pHLTOUT); | |
c5123824 | 392 | } else { |
393 | AliError("error creating HLTOUT handler"); | |
3e820254 | 394 | } |
395 | } | |
396 | } | |
7f9ab840 | 397 | |
29312178 | 398 | void AliHLTReconstructor::Reconstruct(TTree* /*digitsTree*/, TTree* /*clustersTree*/) const |
7f9ab840 | 399 | { |
400 | // reconstruct simulated data | |
401 | ||
56c9a306 | 402 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); |
403 | ||
404 | if (pSystem) { | |
405 | // create the HLTOUT instance in order to be available for other detector reconstruction | |
d82bb2b6 | 406 | // first cleanup any existing instance |
407 | AliHLTOUT* pHLTOUT=NULL; | |
408 | pSystem->InvalidateHLTOUT(&pHLTOUT); | |
409 | if (pHLTOUT) { | |
a31bc263 | 410 | // at this stage we always have a new event, regardless state of |
411 | // fProcessingStep; build the HLTOUT instance from scratch | |
412 | pHLTOUT->Reset(); | |
d82bb2b6 | 413 | delete pHLTOUT; |
414 | pHLTOUT=NULL; | |
415 | } | |
56c9a306 | 416 | |
a31bc263 | 417 | // indicate the local reconstruction step |
418 | SetProcessingStep(kProcessingStepLocal); | |
419 | ||
56c9a306 | 420 | // not nice. Have to query the global run loader to get the current event no. |
421 | // This is related to the missing AliLoader for HLT. | |
422 | // Since AliReconstruction can not provide a digits tree, the file needs to be accessed | |
423 | // explicitely, and the corresponding event needs to be selected. | |
424 | Int_t eventNo=-1; | |
425 | AliRunLoader* runloader = AliRunLoader::Instance(); | |
426 | if (runloader) { | |
427 | eventNo=runloader->GetEventNumber(); | |
428 | } | |
429 | if (eventNo>=0) { | |
430 | const char* digitfile=NULL; | |
431 | if ((fFlags&kAliHLTReconstructorIgnoreHLTOUT) == 0 ) { | |
432 | digitfile="HLT.Digits.root"; | |
433 | } | |
434 | ||
d82bb2b6 | 435 | pHLTOUT=new AliHLTOUTDigitReader(eventNo, fpEsdManager, digitfile); |
56c9a306 | 436 | if (pHLTOUT) { |
437 | if (pHLTOUT->Init()>=0) { | |
438 | pSystem->InitHLTOUT(pHLTOUT); | |
439 | } else { | |
440 | AliError("error : initialization of HLTOUT handler failed"); | |
441 | } | |
442 | } else { | |
443 | AliError("memory allocation failed: can not create AliHLTOUT object"); | |
444 | } | |
445 | } else { | |
446 | AliError("can not get event number"); | |
447 | } | |
448 | ||
449 | // all data processing happens in FillESD | |
450 | } | |
7f9ab840 | 451 | } |
452 | ||
c5123824 | 453 | void AliHLTReconstructor::FillESD(TTree* /*digitsTree*/, TTree* /*clustersTree*/, AliESDEvent* esd) const |
7f9ab840 | 454 | { |
455 | // reconstruct simulated data and fill ESD | |
456 | ||
457 | // later this is the place to extract the simulated HLT data | |
458 | // for now it's only an user failure condition as he tries to run HLT reconstruction | |
459 | // on simulated data | |
460 | TString option = GetOption(); | |
c5123824 | 461 | if (!option.IsNull() && |
462 | (option.Contains("config=") || option.Contains("chains="))) { | |
7ae41d91 | 463 | AliWarning(Form("You are trying to run a custom HLT chain on digits data.\n\n" |
464 | "HLT reconstruction can be run embedded into AliReconstruction from\n" | |
465 | "raw data (real or simulated)). Reconstruction of digit data takes\n" | |
466 | "place in AliSimulation, appropriate input conversion is needed to\n" | |
467 | "feed data from the detector digits into the HLT chain.\n" | |
468 | "Consider running embedded into AliSimulation.\n" | |
7f9ab840 | 469 | " /*** run macro *****************************************/\n" |
470 | " AliSimulation sim;\n" | |
471 | " sim.SetRunHLT(\"%s\");\n" | |
472 | " sim.SetRunGeneration(kFALSE);\n" | |
473 | " sim.SetMakeDigits(\"\");\n" | |
474 | " sim.SetMakeSDigits(\"\");\n" | |
475 | " sim.SetMakeDigitsFromHits(\"\");\n" | |
476 | " sim.Run();\n" | |
7ae41d91 | 477 | " /*********************************************************/\n\n", |
478 | option.Data())); | |
7f9ab840 | 479 | } |
00ddfaca | 480 | if (!fpPluginBase) { |
481 | AliError("internal memory error: can not get AliHLTSystem instance from plugin"); | |
482 | return; | |
483 | } | |
484 | ||
485 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); | |
c5123824 | 486 | if (pSystem) { |
487 | if (pSystem->CheckStatus(AliHLTSystem::kError)) { | |
488 | AliError("HLT system in error state"); | |
489 | return; | |
490 | } | |
491 | if (!pSystem->CheckStatus(AliHLTSystem::kReady)) { | |
492 | AliError("HLT system in wrong state"); | |
493 | return; | |
494 | } | |
495 | ||
56c9a306 | 496 | // the HLTOUT handler has either been created in the AliHLTReconstructor::Reconstruct |
497 | // step of this event or is created now. In either case the instance is deleted after | |
498 | // the processing | |
499 | AliHLTOUT* pHLTOUT=NULL; | |
500 | pSystem->InvalidateHLTOUT(&pHLTOUT); | |
a31bc263 | 501 | if (pHLTOUT && fProcessingStep!=kProcessingStepLocal) { |
502 | // this is a new event, if local reconstruction would have been executed | |
503 | // the HLTOUT instance would have been created for the current event already, | |
504 | // in all other cases one has to create the HLTOUT instance here | |
505 | pHLTOUT->Reset(); | |
506 | delete pHLTOUT; | |
507 | pHLTOUT=NULL; | |
508 | } | |
56c9a306 | 509 | if (!pHLTOUT) { |
510 | const char* digitfile=NULL; | |
511 | if ((fFlags&kAliHLTReconstructorIgnoreHLTOUT) == 0 ) { | |
512 | digitfile="HLT.Digits.root"; | |
513 | } | |
514 | pHLTOUT=new AliHLTOUTDigitReader(esd->GetEventNumberInFile(), fpEsdManager, digitfile); | |
7ae41d91 | 515 | } |
516 | ||
a31bc263 | 517 | // indicate step 'ESD filling' |
518 | SetProcessingStep(kProcessingStepESD); | |
519 | ||
c5123824 | 520 | if (pHLTOUT) { |
fbe9adaf | 521 | ProcessHLTOUT(pHLTOUT, esd, (pSystem->GetGlobalLoggingLevel()&kHLTLogDebug)!=0); |
a31bc263 | 522 | // 2012-03-30: a change in the module sequence of AliReconstruction is soon |
523 | // going to be applied: HLT reconstruction is executed fully (i.e. both local | |
524 | // reconstruction and FillESD) before all the other modules. In order to make the | |
525 | // HLTOUT data available for other modules it is kept here and released in the method | |
526 | // FinishEvent | |
527 | pSystem->InitHLTOUT(pHLTOUT); | |
c5123824 | 528 | } else { |
529 | AliError("error creating HLTOUT handler"); | |
530 | } | |
531 | } | |
532 | } | |
533 | ||
b005ef92 | 534 | void AliHLTReconstructor::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd, bool bVerbose) const |
c5123824 | 535 | { |
f94e8c27 | 536 | // treatment of simulated or real HLTOUT data |
c5123824 | 537 | if (!pHLTOUT) return; |
00ddfaca | 538 | if (!fpPluginBase) { |
539 | AliError("internal memory error: can not get AliHLTSystem instance from plugin"); | |
540 | return; | |
541 | } | |
542 | ||
543 | AliHLTSystem* pSystem=fpPluginBase->GetInstance(); | |
c5123824 | 544 | if (!pSystem) { |
545 | AliError("error getting HLT system instance"); | |
546 | return; | |
547 | } | |
548 | ||
549 | if (pHLTOUT->Init()<0) { | |
550 | AliError("error : initialization of HLTOUT handler failed"); | |
551 | return; | |
552 | } | |
553 | ||
b005ef92 | 554 | if (bVerbose) |
555 | PrintHLTOUTContent(pHLTOUT); | |
556 | ||
d3382be1 | 557 | int blockindex=pHLTOUT->SelectFirstDataBlock(kAliHLTDataTypeStreamerInfo); |
558 | if (blockindex>=0) { | |
559 | const AliHLTUInt8_t* pBuffer=NULL; | |
560 | AliHLTUInt32_t size=0; | |
561 | if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) { | |
562 | TObject* pObject=AliHLTMessage::Extract(pBuffer, size); | |
563 | if (pObject) { | |
564 | TObjArray* pArray=dynamic_cast<TObjArray*>(pObject); | |
565 | if (pArray) { | |
b251fffc | 566 | AliHLTMisc::Instance().InitStreamerInfos(pArray); |
d3382be1 | 567 | } else { |
568 | AliError(Form("wrong class type of streamer info list: expected TObjArray, but object is of type %s", pObject->Class()->GetName())); | |
569 | } | |
570 | } else { | |
571 | AliError(Form("failed to extract object from data block of type %s", AliHLTComponent::DataType2Text(kAliHLTDataTypeStreamerInfo).c_str())); | |
572 | } | |
573 | } else { | |
574 | AliError(Form("failed to get data buffer for block of type %s", AliHLTComponent::DataType2Text(kAliHLTDataTypeStreamerInfo).c_str())); | |
575 | } | |
576 | } | |
577 | ||
69edd0d6 | 578 | if (pSystem->ProcessHLTOUT(pHLTOUT, esd)<0) { |
579 | AliError("error processing HLTOUT"); | |
c5123824 | 580 | } |
69edd0d6 | 581 | |
9e31b43e | 582 | if (bVerbose && esd) { |
fbe9adaf | 583 | AliInfo("HLT ESD content:"); |
584 | esd->Print(); | |
585 | } | |
7f9ab840 | 586 | } |
032c5e5e | 587 | |
588 | void AliHLTReconstructor::ProcessHLTOUT(const char* digitFile, AliESDEvent* pEsd) const | |
589 | { | |
590 | // debugging/helper function to examine simulated data | |
591 | if (!digitFile) return; | |
592 | ||
593 | // read the number of events | |
594 | TFile f(digitFile); | |
595 | if (f.IsZombie()) return; | |
596 | TTree* pTree=NULL; | |
597 | f.GetObject("rawhltout", pTree); | |
598 | if (!pTree) { | |
599 | AliWarning(Form("can not find tree rawhltout in file %s", digitFile)); | |
600 | return ; | |
601 | } | |
602 | int nofEvents=pTree->GetEntries(); | |
603 | f.Close(); | |
604 | //delete pTree; OF COURSE NOT! its an object in the file | |
605 | pTree=NULL; | |
606 | ||
607 | for (int event=0; event<nofEvents; event++) { | |
608 | AliHLTOUTDigitReader* pHLTOUT=new AliHLTOUTDigitReader(event, fpEsdManager, digitFile); | |
609 | if (pHLTOUT) { | |
610 | AliInfo(Form("event %d", event)); | |
b005ef92 | 611 | ProcessHLTOUT(pHLTOUT, pEsd, true); |
032c5e5e | 612 | delete pHLTOUT; |
613 | } else { | |
614 | AliError("error creating HLTOUT handler"); | |
615 | } | |
616 | } | |
617 | } | |
618 | ||
619 | void AliHLTReconstructor::ProcessHLTOUT(AliRawReader* pRawReader, AliESDEvent* pEsd) const | |
620 | { | |
621 | // debugging/helper function to examine simulated or real HLTOUT data | |
622 | if (!pRawReader) return; | |
623 | ||
624 | pRawReader->RewindEvents(); | |
625 | for (int event=0; pRawReader->NextEvent(); event++) { | |
626 | AliHLTOUTRawReader* pHLTOUT=new AliHLTOUTRawReader(pRawReader, event, fpEsdManager); | |
627 | if (pHLTOUT) { | |
628 | AliInfo(Form("event %d", event)); | |
c63e8be4 | 629 | // the two event fields contain: period - orbit - bunch crossing counter |
630 | // id[0] id[1] | |
631 | // |32 0|32 0| | |
632 | // | |
91dc3cdd | 633 | // | 28 bit | 24 bit | 12| |
c63e8be4 | 634 | // period orbit bcc |
635 | AliHLTUInt64_t eventId=0; | |
636 | const UInt_t* rawreaderEventId=pRawReader->GetEventId(); | |
637 | if (rawreaderEventId) { | |
638 | eventId=rawreaderEventId[0]; | |
639 | eventId=eventId<<32; | |
640 | eventId|=rawreaderEventId[1]; | |
641 | } | |
642 | AliInfo(Form("Event Id from rawreader:\t 0x%016llx", eventId)); | |
b005ef92 | 643 | ProcessHLTOUT(pHLTOUT, pEsd, true); |
032c5e5e | 644 | delete pHLTOUT; |
645 | } else { | |
646 | AliError("error creating HLTOUT handler"); | |
647 | } | |
648 | } | |
649 | } | |
650 | ||
651 | void AliHLTReconstructor::PrintHLTOUTContent(AliHLTOUT* pHLTOUT) const | |
652 | { | |
653 | // print the block specifications of the HLTOUT data blocks | |
654 | if (!pHLTOUT) return; | |
655 | int iResult=0; | |
656 | ||
c63e8be4 | 657 | AliInfo(Form("Event Id from hltout:\t 0x%016llx", pHLTOUT->EventId())); |
032c5e5e | 658 | for (iResult=pHLTOUT->SelectFirstDataBlock(); |
659 | iResult>=0; | |
660 | iResult=pHLTOUT->SelectNextDataBlock()) { | |
661 | AliHLTComponentDataType dt=kAliHLTVoidDataType; | |
662 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec; | |
663 | pHLTOUT->GetDataBlockDescription(dt, spec); | |
664 | const AliHLTUInt8_t* pBuffer=NULL; | |
665 | AliHLTUInt32_t size=0; | |
666 | if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) { | |
667 | pHLTOUT->ReleaseDataBuffer(pBuffer); | |
668 | pBuffer=NULL; // just a dummy | |
669 | } | |
670 | AliInfo(Form(" %s 0x%x: size %d", AliHLTComponent::DataType2Text(dt).c_str(), spec, size)); | |
671 | } | |
672 | } | |
c4ffab2c | 673 | |
674 | int AliHLTReconstructor::BuildCTPTriggerClassString(TString& triggerclasses) const | |
675 | { | |
676 | // build the CTP trigger class string from the OCDB entry of the CTP trigger | |
677 | int iResult=0; | |
678 | ||
679 | triggerclasses.Clear(); | |
680 | AliCentralTrigger* pCTP = new AliCentralTrigger(); | |
681 | AliTriggerConfiguration *config=NULL; | |
682 | TString configstr(""); | |
683 | if (pCTP->LoadConfiguration(configstr) && | |
684 | (config = pCTP->GetConfiguration())!=NULL) { | |
685 | const TObjArray& classesArray = config->GetClasses(); | |
686 | int nclasses = classesArray.GetEntriesFast(); | |
687 | for( int iclass=0; iclass < nclasses; iclass++ ) { | |
688 | AliTriggerClass* trclass = NULL; | |
689 | if (classesArray.At(iclass) && (trclass=dynamic_cast<AliTriggerClass*>(classesArray.At(iclass)))!=NULL) { | |
690 | TString entry; | |
691 | int trindex = TMath::Nint(TMath::Log2(trclass->GetMask())); | |
692 | entry.Form("%02d:%s:", trindex, trclass->GetName()); | |
693 | AliTriggerCluster* cluster=NULL; | |
694 | TObject* clusterobj=config->GetClusters().FindObject(trclass->GetCluster()); | |
695 | if (clusterobj && (cluster=dynamic_cast<AliTriggerCluster*>(clusterobj))!=NULL) { | |
696 | TString detectors=cluster->GetDetectorsInCluster(); | |
697 | TObjArray* pTokens=detectors.Tokenize(" "); | |
698 | if (pTokens) { | |
699 | for (int dix=0; dix<pTokens->GetEntriesFast(); dix++) { | |
700 | int id=AliDAQ::DetectorID(((TObjString*)pTokens->At(dix))->GetString()); | |
701 | if (id>=0) { | |
702 | TString detstr; detstr.Form("%s%02d", dix>0?"-":"", id); | |
703 | entry+=detstr; | |
704 | } else { | |
705 | AliError(Form("invalid detector name extracted from trigger cluster: %s (%s)", ((TObjString*)pTokens->At(dix))->GetString().Data(), detectors.Data())); | |
706 | iResult=-EPROTO; | |
707 | break; | |
708 | } | |
709 | } | |
710 | delete pTokens; | |
711 | } | |
712 | } else { | |
b251fffc | 713 | AliError(Form("can not find trigger cluster %s in config", trclass->GetCluster()?trclass->GetCluster()->GetName():"NULL")); |
c4ffab2c | 714 | iResult=-EPROTO; |
715 | break; | |
716 | } | |
717 | if (!triggerclasses.IsNull()) triggerclasses+=","; | |
718 | triggerclasses+=entry; | |
719 | } | |
720 | } | |
721 | } | |
722 | ||
723 | return iResult; | |
724 | } |