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