]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerAgent.cxx
updates from Fengchu
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerAgent.cxx
CommitLineData
89858ccc 1// $Id$
2
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//**************************************************************************
18
19/** @file AliHLTTriggerAgent.cxx
20 @author Matthias Richter
21 @date
22 @brief Agent of the libAliHLTTrigger library
23*/
24
25#include <cassert>
26#include "AliHLTTriggerAgent.h"
18a9a5ad 27#include "AliHLTTriggerDecision.h"
8a8ea98b 28#include "AliHLTGlobalTriggerDecision.h"
18a9a5ad 29#include "AliHLTOUT.h"
30#include "AliHLTMessage.h"
31#include "AliESDEvent.h"
c86017ac 32#include "TObjString.h"
33#include "TObjArray.h"
18a9a5ad 34#include "TArrayC.h"
8a8ea98b 35#include "TFile.h"
36#include "TTree.h"
89858ccc 37
38// header files of library components
c86017ac 39#include "AliHLTTriggerBarrelMultiplicity.h"
5f4502cc 40#include "AliHLTD0Trigger.h"
41#include "AliHLTTriggerITSMultiplicity.h"
fde46e9e 42#include "AliHLTTriggerBarrelGeomMultiplicity.h"
5d79eb88 43#include "AliHLTGlobalTriggerComponent.h"
765d85f8 44#include "AliHLTTriggerPhosClusterEnergy.h"
739e2587 45#include "AliHLTTriggerEmcalClusterEnergy.h"
f86ecd3e 46#include "AliHLTTriggerPhosMip.h"
495570cd 47#include "AliHLTTriggerTrdClusterMultiplicity.h"
fc2b0c6d 48#include "AliHLTTriggerGammaConversion.h"
c1550d2c 49#include "AliHLTMuonSpectroTriggerComponent.h"
4d097162 50#include "AliHLTUpcTriggerComponent.h"
411a92da 51#include "AliHLTTriggerCosmics.h"
742ae1c4 52#include "AliHLTTriggerCounterComponent.h"
8ffa7c29 53#include "AliHLTTriggerEmcalElectron.h"
2af64080 54//#include "AliHLTTriggerFastJet.h"
574b4a21 55#include "AliHLTFastJetMonitorComponent.h"
56#include "AliHLTEmcalElectronMonitorComponent.h"
89858ccc 57
58/** global instance for agent registration */
59AliHLTTriggerAgent gAliHLTTriggerAgent;
60
61/** ROOT macro for the implementation of ROOT specific class methods */
62ClassImp(AliHLTTriggerAgent)
63
64AliHLTTriggerAgent::AliHLTTriggerAgent()
18a9a5ad 65 : AliHLTModuleAgent("Trigger")
66 , fTriggerDecisionHandler(NULL)
89858ccc 67{
68 // see header file for class documentation
69 // or
70 // refer to README to build package
71 // or
72 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
73}
74
75AliHLTTriggerAgent::~AliHLTTriggerAgent()
76{
77 // see header file for class documentation
78}
79
80int AliHLTTriggerAgent::RegisterComponents(AliHLTComponentHandler* pHandler) const
81{
82 // see header file for class documentation
83 assert(pHandler);
84 if (!pHandler) return -EINVAL;
5d79eb88 85 pHandler->AddComponent(new AliHLTGlobalTriggerComponent);
c86017ac 86 pHandler->AddComponent(new AliHLTTriggerBarrelMultiplicity);
5f4502cc 87 pHandler->AddComponent(new AliHLTTriggerITSMultiplicity);
88 pHandler->AddComponent(new AliHLTD0Trigger);
fde46e9e 89 pHandler->AddComponent(new AliHLTTriggerBarrelGeomMultiplicity);
765d85f8 90 pHandler->AddComponent(new AliHLTTriggerPhosClusterEnergy);
739e2587 91 pHandler->AddComponent(new AliHLTTriggerEmcalClusterEnergy);
f86ecd3e 92 pHandler->AddComponent(new AliHLTTriggerPhosMip);
fc2b0c6d 93 pHandler->AddComponent(new AliHLTTriggerTrdClusterMultiplicity);
94 pHandler->AddComponent(new AliHLTTriggerGammaConversion);
c1550d2c 95 pHandler->AddComponent(new AliHLTMuonSpectroTriggerComponent);
4d097162 96 pHandler->AddComponent(new AliHLTUpcTriggerComponent);
411a92da 97 pHandler->AddComponent(new AliHLTTriggerCosmics);
742ae1c4 98 pHandler->AddComponent(new AliHLTTriggerCounterComponent);
8ffa7c29 99 pHandler->AddComponent(new AliHLTTriggerEmcalElectron);
574b4a21 100 //pHandler->AddComponent(new AliHLTTriggerFastJet);
101 pHandler->AddComponent(new AliHLTFastJetMonitorComponent);
102 pHandler->AddComponent(new AliHLTEmcalElectronMonitorComponent);
8ffa7c29 103 return 0;
89858ccc 104}
105
c86017ac 106int AliHLTTriggerAgent::CreateConfigurations(AliHLTConfigurationHandler* pHandler,
f7aab453 107 AliRawReader* rawReader,
108 AliRunLoader* runloader) const
c86017ac 109{
110 // see header file for class documentation
111 if (!pHandler) return -EINVAL;
112
113 TString triggerInputs;
114 TString triggerOutputs;
115 TString configurationId;
116 /////////////////////////////////////////////////////////////////////////////////////
117 //
118 // a central barrel charged particle multiplicity trigger
119 configurationId="TRIGGER-Barrel-Multiplicity";
120
feb0a3ff 121 // define the inputs for the BarrelMultiplicityTrigger
c86017ac 122 triggerInputs="GLOBAL-esd-converter";
123
124 // check for the availibility
125 TObjArray* pTokens=triggerInputs.Tokenize(" ");
126 triggerInputs="";
127 if (pTokens) {
128 for (int n=0; n<pTokens->GetEntriesFast(); n++) {
9ebd174b 129 if (!pTokens->At(n)) continue;
130 TString module=pTokens->At(n)->GetName();
c86017ac 131 if (pHandler->FindConfiguration(module.Data())) {
132 triggerInputs+=module;
133 triggerInputs+=" ";
134 }
135 }
136 delete pTokens;
137 }
138
feb0a3ff 139 TString arg;
c86017ac 140 if (triggerInputs.Length()>0) {
feb0a3ff 141 // define multiple instances of the BarrelMultiplicityTrigger with different settings
c86017ac 142 HLTInfo("Configuring inputs for %s: %s", configurationId.Data(), triggerInputs.Data());
143 pHandler->CreateConfiguration(configurationId.Data(), "BarrelMultiplicityTrigger", triggerInputs.Data(), "");
144 if (triggerOutputs.Length()>0) triggerOutputs+=" ";
145 triggerOutputs+=configurationId;
feb0a3ff 146
147 configurationId="TRIGGER-Barrel-HighMultiplicity";
148 arg="-triggername BarrelHighMultiplicity";
149 pHandler->CreateConfiguration(configurationId.Data(), "BarrelMultiplicityTrigger", triggerInputs.Data(), arg.Data());
150 if (triggerOutputs.Length()>0) triggerOutputs+=" ";
151 triggerOutputs+=configurationId;
152
153 configurationId="TRIGGER-Barrel-Pt_v01";
154 arg="-triggername BarrelPt_v01";
155 pHandler->CreateConfiguration(configurationId.Data(), "BarrelMultiplicityTrigger", triggerInputs.Data(), arg.Data());
156 if (triggerOutputs.Length()>0) triggerOutputs+=" ";
157 triggerOutputs+=configurationId;
158
159 configurationId="TRIGGER-Barrel-Pt_v02";
160 arg="-triggername BarrelPt_v02";
161 pHandler->CreateConfiguration(configurationId.Data(), "BarrelMultiplicityTrigger", triggerInputs.Data(), arg.Data());
162 if (triggerOutputs.Length()>0) triggerOutputs+=" ";
163 triggerOutputs+=configurationId;
164
165 configurationId="TRIGGER-Barrel-Pt_v03";
166 arg="-triggername BarrelPt_v03";
167 pHandler->CreateConfiguration(configurationId.Data(), "BarrelMultiplicityTrigger", triggerInputs.Data(), arg.Data());
168 if (triggerOutputs.Length()>0) triggerOutputs+=" ";
169 triggerOutputs+=configurationId;
c86017ac 170 } else {
171 HLTWarning("No inputs for %s found, skipping component", configurationId.Data());
172 }
c1550d2c 173
174 /////////////////////////////////////////////////////////////////////////////////////
175 // The muon spectrometer trigger
176 configurationId = "TRIGGER-Muon-Spectrometer";
177
178 // define the inputsfor the muon spectrometer trigger.
179 if (pHandler->FindConfiguration("dHLT-sim-fromRaw")) {
180 triggerInputs = "dHLT-sim-fromRaw";
181 }
182 else if (pHandler->FindConfiguration("dHLT-sim")) {
183 triggerInputs = "dHLT-sim";
184 }
185 else if (pHandler->FindConfiguration("dHLT-sim-fromMC")) {
186 triggerInputs = "dHLT-sim-fromMC";
187 }
188
189 if (triggerInputs.Length() > 0) {
190 HLTInfo("Configuring inputs for %s: %s", configurationId.Data(), triggerInputs.Data());
191 pHandler->CreateConfiguration(configurationId.Data(), "MuonSpectroTrigger", triggerInputs.Data(), "-makestats");
192 if (triggerOutputs.Length() > 0) triggerOutputs += " ";
193 triggerOutputs += configurationId;
194 } else {
195 HLTWarning("No inputs for %s found, skipping component.", configurationId.Data());
196 }
c86017ac 197
f7aab453 198 /////////////////////////////////////////////////////////////////////////////////////
199 // D0 trigger
200 configurationId = "TRIGGER-D0";
201 if(runloader && !rawReader){
202 // simulation without simulated raw data
0f4240c3 203 // use ESD as input
f7aab453 204 triggerInputs="GLOBAL-esd-converter ";
f7aab453 205 }
206 else{
207 // simulation with simulated raw data, or raw data reconstruction
208 // use input from ITS tracker and vertexer directly
209 triggerInputs="ITS-tracker GLOBAL-vertexer";
210 }
211
212 // check for the availibility of inputs
213 pTokens=triggerInputs.Tokenize(" ");
214 triggerInputs="";
215 if (pTokens) {
216 for (int n=0; n<pTokens->GetEntriesFast(); n++) {
9ebd174b 217 if (!pTokens->At(n)) continue;
218 TString module=pTokens->At(n)->GetName();
f7aab453 219 if (pHandler->FindConfiguration(module.Data())) {
220 triggerInputs+=module;
221 triggerInputs+=" ";
222 }
223 }
224 delete pTokens;
225 }
226
227 TString argD0 = "";
228 if (triggerInputs.Length()>0) {
229 HLTInfo("Configuring inputs for %s: %s", configurationId.Data(), triggerInputs.Data());
230 pHandler->CreateConfiguration(configurationId.Data(), "D0Trigger", triggerInputs.Data(), argD0.Data());
94001d9d 231 // FIXME: due to a rare segfault for reconstruction of PbPb data the
232 // component is temporarily excluded
233 // https://savannah.cern.ch/bugs/?72590
234 //if (triggerOutputs.Length()>0) triggerOutputs+=" ";
235 //triggerOutputs+=configurationId;
f7aab453 236 } else {
237 HLTWarning("No inputs for %s found, skipping component", configurationId.Data());
238 }
239
c86017ac 240 /////////////////////////////////////////////////////////////////////////////////////
241 //
242 // the global trigger component
243 configurationId="GLOBAL-Trigger";
244 HLTInfo("setting inputs for %s: %s", configurationId.Data(), triggerOutputs.IsNull()?"none":triggerOutputs.Data());
9ebd174b 245 pHandler->CreateConfiguration(configurationId.Data(), "HLTGlobalTrigger", triggerOutputs.Data(), "-skipctp");
c86017ac 246
247 return 0;
248}
249
250const char* AliHLTTriggerAgent::GetReconstructionChains(AliRawReader* /*rawReader*/,
251 AliRunLoader* runloader) const
252{
253 // see header file for class documentation
254 if (runloader) {
255 // reconstruction chains for AliRoot simulation
256 // Note: run loader is only available while running embedded into
257 // AliRoot simulation
258
259 // currently disabled due to a problem compiling the runtime trigger library
18a9a5ad 260 return "GLOBAL-Trigger";
c86017ac 261 }
262 return NULL;
263}
264
265const char* AliHLTTriggerAgent::GetRequiredComponentLibraries() const
266{
267 // see header file for class documentation
268
86aebdca 269 return "";
c86017ac 270}
271
89858ccc 272int AliHLTTriggerAgent::GetHandlerDescription(AliHLTComponentDataType dt,
273 AliHLTUInt32_t /*spec*/,
274 AliHLTOUTHandlerDesc& desc) const
275{
9ebd174b 276 // get description of HLTOUT data blocks handled by this agent
89858ccc 277
18a9a5ad 278 // handler of the trigger decisions {'ROOTTOBJ':'HLT '}
279 // currently stored as a TObject with the common data type and origin
280 // HLTOUT. However we might need a separate data type in order to
281 // avoid interference with other handlers
282 // the handler produces an ESD object in order to be merged to the
283 // hltEsd afterwards
9ebd174b 284 // 2009-11-17 adding the data types for (global) trigger decisions
285 // {GLOBTRIG:HLT } and {TRIG_DEC:HLT }
8a8ea98b 286 // the TObject data types stays for a while in order to preserve
287 // backward compatibility
288 if (dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginOut) ||
289 dt==kAliHLTDataTypeTriggerDecision ||
290 dt==kAliHLTDataTypeGlobalTrigger) {
18a9a5ad 291 desc=AliHLTOUTHandlerDesc(AliHLTModuleAgent::kEsd, dt, GetModuleId());
292 return 1;
293 }
294
9ebd174b 295 // handler for the HLT readout list and trigger data data blocks {'HLTRDLST':'HLT '}
89858ccc 296 if (dt==AliHLTComponentDataTypeInitializer("HLTRDLST", kAliHLTDataOriginOut) ||
297 dt==AliHLTComponentDataTypeInitializer("HLTTRGDT", kAliHLTDataOriginOut)) {
298 desc=AliHLTOUTHandlerDesc(kProprietary, dt, GetModuleId());
299 return 1;
300 }
301
302 return 0;
303}
304
305AliHLTOUTHandler* AliHLTTriggerAgent::GetOutputHandler(AliHLTComponentDataType dt,
18a9a5ad 306 AliHLTUInt32_t /*spec*/)
89858ccc 307{
308 // see header file for class documentation
309
18a9a5ad 310 // raw data blocks to be fed into offline reconstruction
8a8ea98b 311 if ((dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginOut) ||
312 (dt==kAliHLTDataTypeTriggerDecision) ||
313 (dt==kAliHLTDataTypeGlobalTrigger))) {
18a9a5ad 314 if (!fTriggerDecisionHandler) {
315 fTriggerDecisionHandler=new AliHLTTriggerAgent::AliHLTTriggerDecisionHandler;
316 }
317 return fTriggerDecisionHandler;
318 }
319
89858ccc 320 // handler for the HLT readou list and trigger data data blocks {'HLTRDLST':'HLT '}
321 if (dt==AliHLTComponentDataTypeInitializer("HLTRDLST", kAliHLTDataOriginOut) ||
322 dt==AliHLTComponentDataTypeInitializer("HLTTRGDT", kAliHLTDataOriginOut)) {
323 return NULL;
324 }
325
326 return NULL;
327}
328
329int AliHLTTriggerAgent::DeleteOutputHandler(AliHLTOUTHandler* pInstance)
330{
331 // see header file for class documentation
332 if (pInstance==NULL) return -EINVAL;
333
18a9a5ad 334 if (pInstance==fTriggerDecisionHandler) {
335 delete fTriggerDecisionHandler;
336 fTriggerDecisionHandler=NULL;
337 }
338
89858ccc 339 return 0;
340}
18a9a5ad 341
342AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::AliHLTTriggerDecisionHandler()
343 : AliHLTOUTHandler()
344 , fESD(NULL)
345 , fpData(NULL)
346 , fSize(0)
8a8ea98b 347 , fpESDfile(NULL)
348 , fpESDtree(NULL)
18a9a5ad 349{
350 // see header file for class documentation
351}
352
353AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::~AliHLTTriggerDecisionHandler()
354{
355 // see header file for class documentation
8a8ea98b 356 if (fpESDtree) {
357 fpESDtree->GetUserInfo()->Clear();
358 delete fpESDtree;
359 }
360 fpESDtree=NULL;
361
362 if (fpESDfile) {
363 fpESDfile->Close();
364 delete fpESDfile;
365 }
366 fpESDfile=NULL;
367
18a9a5ad 368 if (fESD) delete fESD;
369 fESD=NULL;
370
371 if (fpData) delete fpData;
372 fpData=NULL;
373 fSize=0;
374}
375
376int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::ProcessData(AliHLTOUT* pData)
377{
378 // see header file for class documentation
379 if (!pData) return -EINVAL;
8a8ea98b 380 int iResult=0;
381 AliHLTGlobalTriggerDecision* pGlobalDecision=NULL;
382 TObjArray triggerDecisions;
383 triggerDecisions.SetOwner(kTRUE);
384 for (iResult=pData->SelectFirstDataBlock(); iResult>=0; iResult=pData->SelectNextDataBlock()) {
385 AliHLTComponentDataType dt=kAliHLTVoidDataType;
386 AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
387 if ((iResult=pData->GetDataBlockDescription(dt, spec))<0) break;
18a9a5ad 388 TObject* pObject=pData->GetDataObject();
389 if (pObject) {
8a8ea98b 390 if(dt==kAliHLTDataTypeGlobalTrigger) {
391 if (!pGlobalDecision) {
392 if ((pGlobalDecision=dynamic_cast<AliHLTGlobalTriggerDecision*>(pObject))==NULL ||
393 (pGlobalDecision=dynamic_cast<AliHLTGlobalTriggerDecision*>(pGlobalDecision->Clone()))==NULL) {
394 HLTFatal("can not convert object of name %s (%s) to HLTGlobalTriggerDecsion according to data type", pObject->GetName(), pObject->Class()->GetName());
395 }
396 } else {
397 HLTWarning("multiple HLT GlobalTrigger decision objects, ignoring all but the first one");
398 }
399 } else if (dt==kAliHLTDataTypeTriggerDecision) {
400 if (pObject->IsA() == AliHLTTriggerDecision::Class() &&
401 !(pObject->IsA() == AliHLTGlobalTriggerDecision::Class())) {
402 AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(pObject);
403 if (pDecision) {
404 if (pGlobalDecision) {
405 // add directly
406 pGlobalDecision->AddTriggerInput(*pDecision);
407 } else {
408 // schedule
409 triggerDecisions.Add(pDecision->Clone());
410 }
411 } else {
412 HLTFatal("can not convert object of name %s (%s) to HLT TriggerDecsion according to data type", pObject->GetName(), pObject->Class()->GetName());
413 }
414 }
415 } else if (dt==(kAliHLTDataTypeTObject|kAliHLTDataOriginOut)){
416 // this is the branch for keeping compatibility
417 // the first version of the trigger framework was using the kAliHLTDataTypeTObject
418 // data type instead of the specific data types for HLT triggers
419 // this effects the cosmic data taken Sep to Oct 2009
420 if (pObject->IsA() == AliHLTGlobalTriggerDecision::Class()) {
421 if (!pGlobalDecision) {
422 if ((pGlobalDecision=dynamic_cast<AliHLTGlobalTriggerDecision*>(pObject))==NULL ||
423 (pGlobalDecision=dynamic_cast<AliHLTGlobalTriggerDecision*>(pGlobalDecision->Clone()))==NULL) {
424 HLTFatal("can not convert object of name %s (%s) to HLTGlobalTriggerDecsion according to data type", pObject->GetName(), pObject->Class()->GetName());
425 }
426 } else {
427 HLTWarning("multiple HLT GlobalTrigger decision objects, ignoring all but the first one");
428 }
429 } else if (pObject->IsA() == AliHLTTriggerDecision::Class()) {
430 AliHLTTriggerDecision* pDecision=dynamic_cast<AliHLTTriggerDecision*>(pObject);
431 if (pDecision) {
432 if (pGlobalDecision) {
433 // add directly
434 pGlobalDecision->AddTriggerInput(*pDecision);
435 } else {
436 // schedule
437 triggerDecisions.Add(pDecision->Clone());
438 }
439 } else {
440 HLTFatal("can not convert object of name %s (%s) to HLT TriggerDecsion according to data type", pObject->GetName(), pObject->Class()->GetName());
441 }
442 }
443 }
444 pData->ReleaseDataObject(pObject);
445 pObject=NULL;
446 } else {
447 HLTError("can not get TObject from HLTOUT buffer");
448 iResult=-ENODATA;
449 }
450 }
451 // -ENOENT just signals that there are no more entries
452 if (iResult==-ENOENT) iResult=0;
453
454 if (pGlobalDecision) {
455 for (int i=0; i<triggerDecisions.GetEntriesFast(); i++) {
456 if (triggerDecisions[i]) {
457 pGlobalDecision->AddTriggerInput(*((AliHLTTriggerDecision*)triggerDecisions[i]));
458 }
459 }
460 triggerDecisions.Delete();
461 AliHLTTriggerDecision* pDecision=pGlobalDecision;
462 {
30d84601 463 if (pDecision) {
e13512e4 464 //pDecision->Print();
30d84601 465 HLTDebug("extracted %s", pDecision->GetName());
18a9a5ad 466 if (!fESD) {
467 // create the ESD container, but without std content
468 fESD = new AliESDEvent;
469 }
470 if (!fpData) fpData=new TArrayC;
471 if (fESD && fpData) {
472 fESD->Reset();
30d84601 473 TObject* pESDObject=fESD->FindListObject("HLTGlobalTrigger");
474 if (pESDObject) {
475 // copy the content to the already existing object
8a8ea98b 476 pDecision->Copy(*pESDObject);
30d84601 477 } else {
478 // add a new object
8a8ea98b 479 fESD->AddObject(pDecision->Clone());
30d84601 480 }
8a8ea98b 481 WriteESD();
18a9a5ad 482 AliHLTMessage* pMsg=AliHLTMessage::Stream(fESD);
483 if (pMsg) {
484 if (!pMsg->CompBuffer()) {
485 fSize=pMsg->Length();
486 fpData->Set(fSize, pMsg->Buffer());
487 } else {
488 fSize=pMsg->CompLength();
489 fpData->Set(fSize, pMsg->CompBuffer());
490 }
d2f8c983 491 delete pMsg;
492 pMsg=NULL;
18a9a5ad 493 } else {
494 HLTError("streaming of objects failed");
495 }
496 } else {
497 HLTError("memory allocation failed");
498 iResult=-ENOMEM;
499 }
18a9a5ad 500 }
18a9a5ad 501 }
8a8ea98b 502 delete pGlobalDecision;
503 pGlobalDecision=NULL;
504 } else {
505 HLTError("no global trigger found in data collection");
18a9a5ad 506 }
8a8ea98b 507
e13512e4 508 if (iResult>=0) {
e13512e4 509 return fSize;
510 }
18a9a5ad 511 fSize=0;
512 return iResult;
513}
514
515int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::GetProcessedData(const AliHLTUInt8_t* &pData)
516{
517 // see header file for class documentation
518 if (!fpData) {
519 pData=NULL;
520 return 0;
521 }
522
523 pData=reinterpret_cast<AliHLTUInt8_t*>(fpData->GetArray());
524 return fSize;
525}
526
527int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::ReleaseProcessedData(const AliHLTUInt8_t* pData, int size)
528{
529 // see header file for class documentation
530 int iResult=0;
531 if (!fpData || size != fSize ||
532 const_cast<AliHLTUInt8_t*>(pData) != reinterpret_cast<AliHLTUInt8_t*>(fpData->GetArray())) {
533 HLTError("attempt to release to wrong data buffer %p size %d, expected %p size %d", pData, size, fpData?fpData->GetArray():NULL, fSize);
534 }
535 fSize=0;
536 return iResult;
537}
8a8ea98b 538
539int AliHLTTriggerAgent::AliHLTTriggerDecisionHandler::WriteESD()
540{
541 // see header file for class documentation
542 int iResult=0;
543 if (!fESD) return 0;
544 if (!fpESDfile) {
545 fpESDfile=new TFile("HLTdecision.root", "RECREATE");
546 }
547 if (!fpESDtree) {
548 fpESDtree=new TTree("HLTesdTree", "Tree with HLT ESD containing HLT decision");
549 if (fpESDtree) {
550 fESD->WriteToTree(fpESDtree);
551 fpESDtree->GetUserInfo()->Add(fESD);
552 }
553 }
554 if (!fpESDfile || !fpESDtree) return -ENOMEM;
555
556 fpESDtree->Fill();
557 fpESDfile->cd();
558 fpESDtree->Write(fpESDtree->GetName(),TObject::kOverwrite);
559
560 return iResult;
561}