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