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