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