c5123824 |
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 | |
04df9166 |
19 | /// @file AliHLTEsdManagerImplementation.cxx |
20 | /// @author Matthias Richter |
21 | /// @date |
22 | /// @brief Manager for merging and writing of HLT ESDs |
23 | /// This is an implementation of the abstract interface AliHLTEsdManager |
c5123824 |
24 | |
f1207f29 |
25 | #include "AliHLTEsdManagerImplementation.h" |
c5123824 |
26 | #include "AliHLTComponent.h" |
27 | #include "AliESDEvent.h" |
28 | #include "AliHLTMessage.h" |
29 | #include "AliESDEvent.h" |
f527516f |
30 | #include "AliESDtrack.h" |
2bc81aef |
31 | #include "AliESDFMD.h" |
32 | #include "AliESDVZERO.h" |
33 | #include "AliESDTZERO.h" |
34 | #include "AliESDCaloCells.h" |
35 | #include "AliMultiplicity.h" |
36 | #include "AliESDACORDE.h" |
c5123824 |
37 | #include "TFile.h" |
38 | #include "TTree.h" |
39 | #include "TClass.h" |
40 | #include "TObject.h" |
90c37647 |
41 | #include "TList.h" |
c5123824 |
42 | |
5b687e5d |
43 | const float kAliESDVZERODefaultTime = -1024.; |
44 | const float kAliESDVZERODefaultTimeGlitch = 1e-6; |
45 | const float kAliESDZDCDefaultEMEnergy = 0.; |
46 | const float kAliESDZDCDefaultEMEnergyGlitch = 1e-6; |
47 | |
c5123824 |
48 | /** ROOT macro for the implementation of ROOT specific class methods */ |
f1207f29 |
49 | ClassImp(AliHLTEsdManagerImplementation) |
c5123824 |
50 | |
f1207f29 |
51 | AliHLTEsdManagerImplementation::AliHLTEsdManagerImplementation() |
c5123824 |
52 | : |
794de106 |
53 | fESDs() |
54 | , fDirectory() |
55 | , fWriteLocal(false) |
c5123824 |
56 | { |
57 | // see header file for class documentation |
58 | // or |
59 | // refer to README to build package |
60 | // or |
61 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt |
5b687e5d |
62 | |
63 | CheckClassConditions(); |
c5123824 |
64 | } |
65 | |
f1207f29 |
66 | AliHLTEsdManagerImplementation::~AliHLTEsdManagerImplementation() |
c5123824 |
67 | { |
68 | // see header file for class documentation |
62ff1e23 |
69 | for (unsigned int i=0; i<fESDs.size(); i++) { |
70 | if (fESDs[i]) { |
71 | delete fESDs[i]; |
72 | } |
73 | fESDs[i]=NULL; |
74 | } |
c5123824 |
75 | } |
76 | |
794de106 |
77 | int AliHLTEsdManagerImplementation::SetOption(const char* option) |
78 | { |
79 | // see header file for class documentation |
80 | int iResult=0; |
81 | TString strOptions=option; |
82 | TObjArray* pTokens=strOptions.Tokenize(" "); |
83 | if (pTokens) { |
84 | if (pTokens->GetEntriesFast()>0) { |
85 | for (int n=0; n<pTokens->GetEntriesFast(); n++) { |
86 | TString data=((TObjString*)pTokens->At(n))->GetString(); |
87 | if (data.IsNull()) continue; |
88 | |
89 | if (data.CompareTo("-writelocal")==0) { |
90 | fWriteLocal=true; |
91 | } else if (data.Contains("-directory=")) { |
92 | data.ReplaceAll("-directory=", ""); |
93 | SetDirectory(data.Data()); |
94 | } else { |
95 | HLTError("unknown argument %s", data.Data()); |
96 | iResult=-EINVAL; |
97 | break; |
98 | } |
99 | } |
100 | } |
101 | delete pTokens; |
102 | } |
103 | return iResult; |
104 | } |
105 | |
f1207f29 |
106 | AliHLTEsdManagerImplementation::AliHLTEsdListEntry* AliHLTEsdManagerImplementation::Find(AliHLTComponentDataType dt) const |
c5123824 |
107 | { |
108 | // see header file for class documentation |
109 | AliHLTEsdListEntry* pEntry=NULL; |
110 | for (unsigned int i=0; i<fESDs.size(); i++) { |
62ff1e23 |
111 | if (fESDs[i] && *(fESDs[i])==dt) { |
112 | pEntry=const_cast<AliHLTEsdListEntry*>(fESDs[i]); |
c5123824 |
113 | } |
114 | } |
115 | return pEntry; |
116 | } |
117 | |
f1207f29 |
118 | int AliHLTEsdManagerImplementation::WriteESD(const AliHLTUInt8_t* pBuffer, AliHLTUInt32_t size, |
c5123824 |
119 | AliHLTComponentDataType dt, AliESDEvent* tgtesd, int eventno) |
120 | { |
121 | // see header file for class documentation |
122 | if (!pBuffer && size<=0) return -EINVAL; |
123 | int iResult=0; |
124 | AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer); |
125 | if (firstWord==size-sizeof(AliHLTUInt32_t)) { |
126 | HLTDebug("create object from block %s size %d", AliHLTComponent::DataType2Text(dt).c_str(), size); |
127 | AliHLTMessage msg(const_cast<AliHLTUInt8_t*>(pBuffer), size); |
128 | TClass* objclass=msg.GetClass(); |
129 | TObject* pObj=msg.ReadObject(objclass); |
130 | if (pObj && objclass) { |
131 | HLTDebug("object %p type %s created", pObj, objclass->GetName()); |
132 | AliESDEvent* pESD=dynamic_cast<AliESDEvent*>(pObj); |
133 | TTree* pTree=NULL; |
134 | if (!pESD) { |
135 | pTree=dynamic_cast<TTree*>(pObj); |
136 | if (pTree) { |
137 | pESD=new AliESDEvent; |
138 | pESD->CreateStdContent(); |
139 | if (pTree->GetEntries()>0) { |
140 | if (pTree->GetEntries()>1) { |
141 | HLTWarning("only one entry allowed for ESD embedded into tree, data block %s contains tree with %d entires, taking first entry", |
142 | AliHLTComponent::DataType2Text(dt).c_str(), pTree->GetEntries()); |
143 | } |
144 | pESD->ReadFromTree(pTree); |
145 | pTree->GetEvent(0); |
146 | } |
147 | } else { |
148 | HLTWarning("tree of data block %s has no events, skipping data block", AliHLTComponent::DataType2Text(dt).c_str()); |
149 | } |
150 | } |
151 | if (pESD) { |
152 | AliHLTEsdListEntry* entry=Find(dt); |
153 | if (!entry) { |
57584811 |
154 | if ((entry=new AliHLTEsdListEntry(dt))!=NULL) { |
155 | if (!fDirectory.IsNull()) { |
156 | entry->SetDirectory(fDirectory); |
157 | } |
158 | fESDs.push_back(entry); |
90c37647 |
159 | } |
c5123824 |
160 | } |
57584811 |
161 | if (entry) { |
162 | if (tgtesd) { |
57584811 |
163 | Merge(tgtesd, pESD); |
57584811 |
164 | } |
794de106 |
165 | |
166 | // Matthias 2009-06-06: writing of individual ESD files for the different origins was a |
167 | // first attempt when functionality was missing in the AliRoot framework and remained as |
168 | // debugging feature. ESD merging is now implemented and data written to the hltEsd, so |
169 | // the feature is now disabled by default because it causes increasing memory consumption. |
170 | // Presumably not because of a memory leak but the way the internal TTree is used and kept |
171 | // in memory. |
172 | // Writing of local files can be optionally switched on as e.g. by the EsdCollector component. |
173 | if (fWriteLocal) entry->WriteESD(pESD, eventno); |
c5123824 |
174 | } else { |
175 | HLTError("internal mismatch, can not create list entry"); |
176 | iResult=-ENOMEM; |
177 | } |
178 | } else { |
179 | HLTWarning("data block %s is not of class type AliESDEvent, ignoring ...", AliHLTComponent::DataType2Text(dt).c_str()); |
180 | } |
181 | if (pTree) { |
182 | // ESD has been created and must be cleaned up |
242e6536 |
183 | pESD->Reset(); |
c5123824 |
184 | delete pESD; |
185 | pESD=NULL; |
186 | } |
187 | delete pObj; |
188 | pObj=NULL; |
189 | } else { |
190 | } |
191 | } |
192 | return iResult; |
193 | } |
194 | |
f1207f29 |
195 | int AliHLTEsdManagerImplementation::PadESDs(int eventno) |
c5123824 |
196 | { |
197 | // see header file for class documentation |
90c37647 |
198 | int iResult=0; |
199 | for (unsigned int i=0; i<fESDs.size(); i++) { |
200 | if (fESDs[i]) { |
201 | int res=fESDs[i]->WriteESD(NULL, eventno); |
202 | if (res<0 && iResult>=0) iResult=res; |
203 | } |
204 | } |
205 | return iResult; |
c5123824 |
206 | } |
207 | |
f1207f29 |
208 | void AliHLTEsdManagerImplementation::SetDirectory(const char* directory) |
c5123824 |
209 | { |
210 | // see header file for class documentation |
90c37647 |
211 | if (!directory) return; |
212 | fDirectory=directory; |
213 | for (unsigned int i=0; i<fESDs.size(); i++) { |
214 | if (fESDs[i]) { |
215 | fESDs[i]->SetDirectory(directory); |
216 | } |
217 | } |
218 | } |
219 | |
f1207f29 |
220 | TString AliHLTEsdManagerImplementation::GetFileNames(AliHLTComponentDataType dt) const |
90c37647 |
221 | { |
222 | TString result; |
223 | for (unsigned int i=0; i<fESDs.size(); i++) { |
224 | if (fESDs[i] && *(fESDs[i])==dt) { |
225 | if (!result.IsNull()) result+=" "; |
226 | result+=fESDs[i]->GetFileName(); |
227 | } |
c5123824 |
228 | } |
90c37647 |
229 | return result; |
230 | } |
c5123824 |
231 | |
f1207f29 |
232 | TTree* AliHLTEsdManagerImplementation::EmbedIntoTree(AliESDEvent* pESD, const char* name, const char* title) |
90c37647 |
233 | { |
234 | // see header file for class documentation |
235 | int iResult=0; |
236 | TTree* pTree=new TTree(name, title); |
237 | if (pTree) { |
238 | pESD->WriteToTree(pTree); |
239 | pTree->Fill(); |
240 | pTree->GetUserInfo()->Add(pESD); |
241 | } else { |
242 | iResult=-ENOMEM; |
c5123824 |
243 | } |
244 | |
90c37647 |
245 | if (iResult<0) { |
246 | pTree->GetUserInfo()->Clear(); |
247 | delete pTree; |
c5123824 |
248 | } |
90c37647 |
249 | |
250 | return pTree; |
251 | } |
252 | |
f1207f29 |
253 | AliHLTEsdManagerImplementation::AliHLTEsdListEntry::AliHLTEsdListEntry(AliHLTComponentDataType dt) |
90c37647 |
254 | : |
255 | fName(), |
256 | fDirectory(), |
83cb7e1d |
257 | fDt(dt), |
258 | fpFile(NULL), |
259 | fpTree(NULL), |
f527516f |
260 | fpEsd(NULL), |
261 | fPrefix() |
90c37647 |
262 | { |
263 | // see header file for class documentation |
264 | } |
265 | |
f1207f29 |
266 | AliHLTEsdManagerImplementation::AliHLTEsdListEntry::~AliHLTEsdListEntry() |
90c37647 |
267 | { |
268 | // see header file for class documentation |
242e6536 |
269 | if (fpEsd) delete fpEsd; |
270 | fpEsd=NULL; |
271 | |
272 | if (fpTree) delete fpTree; |
273 | fpTree=NULL; |
274 | |
ba93bdb0 |
275 | if (fpFile) { |
276 | fpFile->Close(); |
277 | delete fpFile; |
278 | } |
242e6536 |
279 | fpFile=NULL; |
c5123824 |
280 | } |
281 | |
f1207f29 |
282 | bool AliHLTEsdManagerImplementation::AliHLTEsdListEntry::operator==(AliHLTComponentDataType dt) const |
c5123824 |
283 | { |
284 | // see header file for class documentation |
285 | return fDt==dt; |
286 | } |
287 | |
f1207f29 |
288 | int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteESD(AliESDEvent* pSrcESD, int eventno) |
c5123824 |
289 | { |
83cb7e1d |
290 | // see header file for class documentation |
291 | int iResult=0; |
d0d53f68 |
292 | |
83cb7e1d |
293 | if (fName.IsNull()) { |
294 | // this is the first event, create the file name |
83cb7e1d |
295 | fName=""; |
296 | if (!fDirectory.IsNull()) { |
297 | fName+=fDirectory; fName+="/"; |
298 | } |
f527516f |
299 | fName+="Ali"; fName+=GetPrefix(); |
83cb7e1d |
300 | if (fDt!=kAliHLTDataTypeESDObject && |
301 | fDt!=kAliHLTDataTypeESDTree) { |
302 | |
303 | HLTWarning("non-standard ESD type %s", AliHLTComponent::DataType2Text(fDt).c_str()); |
304 | TString id; |
305 | id.Insert(0, fDt.fID, kAliHLTComponentDataTypefIDsize); |
306 | id.Remove(TString::kTrailing, ' '); |
307 | id.ToUpper(); |
308 | fName+="_"; fName+=id; fName+=".root"; |
309 | } else { |
310 | fName+="ESDs.root"; |
311 | } |
312 | |
313 | fpFile=new TFile(fName, "RECREATE"); |
314 | fpTree=new TTree("esdTree", "Tree with HLT ESD objects"); |
b952ebda |
315 | fpTree->SetDirectory(0); |
83cb7e1d |
316 | fpEsd=new AliESDEvent; |
317 | if (fpEsd) { |
318 | fpEsd->CreateStdContent(); |
b952ebda |
319 | *fpEsd=*pSrcESD; |
83cb7e1d |
320 | if (fpTree) { |
321 | fpEsd->WriteToTree(fpTree); |
322 | } |
323 | } |
324 | } |
325 | |
326 | if (fpFile && fpTree && fpEsd) { |
327 | // synchronize and add empty events |
328 | fpEsd->Reset(); |
329 | int nofCurrentEvents=fpTree->GetEntries(); |
330 | if (nofCurrentEvents<eventno) { |
331 | iResult=1; // indicate tree to be written |
332 | HLTDebug("adding %d empty events to file %s", eventno-nofCurrentEvents, fName.Data()); |
333 | for (int i=nofCurrentEvents; i<eventno; i++) { |
334 | fpTree->Fill(); |
335 | } |
336 | } |
337 | |
338 | if (iResult>=0 && pSrcESD) { |
b952ebda |
339 | int nofObjects=fpEsd->GetList()->GetEntries(); |
83cb7e1d |
340 | *fpEsd=*pSrcESD; |
b952ebda |
341 | if (nofObjects!=fpEsd->GetList()->GetEntries()) { |
342 | // The source ESD contains object not present in the target ESD |
343 | // before. Those objects will not be written to the tree since |
344 | // the branch layout has been created earlier. |
345 | // Create new tree with the additional branches, copy the entries |
346 | // of the current tree into the new tree, and continue. |
347 | TTree* pNewTree=new TTree("esdTree", "Tree with HLT ESD objects"); |
348 | pNewTree->SetDirectory(0); |
349 | AliESDEvent* readESD=new AliESDEvent; |
350 | readESD->CreateStdContent(); |
351 | readESD->ReadFromTree(fpTree); |
352 | fpEsd->Reset(); |
353 | fpEsd->WriteToTree(pNewTree); |
354 | HLTDebug("cloning tree with %d entries", fpTree->GetEntries()); |
355 | for (int event=0; event<fpTree->GetEntries(); event++) { |
356 | fpTree->GetEntry(event); |
357 | *fpEsd=*readESD; |
358 | pNewTree->Fill(); |
359 | fpEsd->Reset(); |
360 | } |
361 | fpFile->Close(); |
362 | delete fpFile; |
363 | delete readESD; |
364 | delete fpTree; |
365 | fpFile=new TFile(fName, "RECREATE"); |
366 | fpTree=pNewTree; |
367 | *fpEsd=*pSrcESD; |
368 | HLTDebug("new ESD with %d objects", fpEsd->GetList()->GetEntries()); |
369 | } |
83cb7e1d |
370 | fpTree->Fill(); |
371 | iResult=1; // indicate tree to be written |
372 | } |
373 | |
374 | if (iResult>0) { |
375 | fpFile->cd(); |
376 | fpTree->GetUserInfo()->Add(fpEsd); |
377 | fpTree->Write(fpTree->GetName(),TObject::kOverwrite); |
378 | fpTree->GetUserInfo()->Clear(); |
379 | } |
380 | } |
90c37647 |
381 | |
382 | return iResult; |
383 | } |
384 | |
f1207f29 |
385 | void AliHLTEsdManagerImplementation::AliHLTEsdListEntry::SetDirectory(const char* directory) |
90c37647 |
386 | { |
387 | // see header file for class documentation |
388 | if (!directory) return; |
389 | if (!fName.IsNull()) { |
390 | HLTWarning("ESD entry already in writing mode (%s), ignoring directory", fName.Data()); |
391 | return; |
392 | } |
393 | fDirectory=directory; |
394 | } |
395 | |
f1207f29 |
396 | const char* AliHLTEsdManagerImplementation::AliHLTEsdListEntry::GetFileName() const |
90c37647 |
397 | { |
398 | // see header file for class documentation |
399 | return fName.Data(); |
c5123824 |
400 | } |
f527516f |
401 | |
402 | const char* AliHLTEsdManagerImplementation::AliHLTEsdListEntry::GetPrefix() |
403 | { |
404 | // see header file for class documentation |
405 | if (fPrefix.IsNull()) { |
406 | fPrefix.Insert(0, fDt.fOrigin, kAliHLTComponentDataTypefOriginSize); |
407 | fPrefix.Remove(TString::kTrailing, ' '); |
408 | fPrefix.ToUpper(); |
409 | if (!fPrefix.Contains("HLT")) { |
410 | fPrefix.Insert(0, "HLT"); |
411 | } |
412 | } |
413 | return fPrefix.Data(); |
414 | } |
415 | |
57584811 |
416 | int AliHLTEsdManagerImplementation::Merge(AliESDEvent* pTgt, AliESDEvent* pSrc) const |
f527516f |
417 | { |
418 | // see header file for class documentation |
419 | int iResult=0; |
420 | if (!pTgt || !pSrc) return -EINVAL; |
421 | |
f527516f |
422 | TIter next(pSrc->GetList()); |
423 | TObject* pSrcObject=NULL; |
57584811 |
424 | static int warningCount=0; |
f527516f |
425 | while ((pSrcObject=next())) { |
426 | if(!pSrcObject->InheritsFrom("TCollection")){ |
427 | // simple objects |
2bc81aef |
428 | // for every type of object we have to find out whether it is empty or not |
429 | // objects are only copied if non-empty, otherwise valid content would be |
430 | // overridden by empty objects during the merging |
431 | bool copy=false; |
30d84601 |
432 | TString name=pSrcObject->GetName(); |
18a9a5ad |
433 | if(pSrcObject->InheritsFrom("AliHLTTriggerDecision")){ |
2bc81aef |
434 | copy=true; |
435 | } else if (pSrcObject->IsA()==AliESDRun::Class()) { |
436 | AliESDRun* pESDRun=dynamic_cast<AliESDRun*>(pSrcObject); |
437 | // zero might be a valid run no in simulation, so we check also whether the CTP trigger classes are set |
438 | copy=(pESDRun && (pESDRun->GetRunNumber()>0 || !pESDRun->GetActiveTriggerClasses().IsNull())); |
439 | } else if (pSrcObject->IsA()==AliESDHeader::Class()) { |
440 | AliESDHeader* pESDHeader=dynamic_cast<AliESDHeader*>(pSrcObject); |
441 | copy=(pESDHeader && pESDHeader->GetTriggerMask()!=0); |
442 | } else if (pSrcObject->IsA()==AliESDVertex::Class()) { |
443 | AliESDVertex* pESDVertex=dynamic_cast<AliESDVertex*>(pSrcObject); |
444 | copy=(pESDVertex && pESDVertex->GetNContributors()>0); |
445 | } else if (pSrcObject->IsA()==AliESDTZERO::Class()) { |
446 | AliESDTZERO* pESDTZero=dynamic_cast<AliESDTZERO*>(pSrcObject); |
447 | copy=(pESDTZero && (pESDTZero->GetT0zVertex()!=0.0 || pESDTZero->GetT0()!=0.0)); |
448 | } else if (pSrcObject->IsA()==AliESDVZERO::Class()) { |
5b687e5d |
449 | AliESDVZERO* pESDVZERO=dynamic_cast<AliESDVZERO*>(pSrcObject); |
450 | // object contains data if one of the times exceeds the default value |
451 | copy=pESDVZERO && |
452 | (pESDVZERO->GetV0ATime() > kAliESDVZERODefaultTime+kAliESDVZERODefaultTimeGlitch || |
453 | pESDVZERO->GetV0CTime() > kAliESDVZERODefaultTime+kAliESDVZERODefaultTimeGlitch); |
2bc81aef |
454 | } else if (pSrcObject->IsA()==AliESDFMD::Class()) { |
455 | AliESDFMD* pESDFMD=dynamic_cast<AliESDFMD*>(pSrcObject); |
456 | copy=(pESDFMD && false); // have to find an easy valid condition |
457 | } else if (pSrcObject->IsA()==AliESDZDC::Class()) { |
458 | AliESDZDC* pESDZDC=dynamic_cast<AliESDZDC*>(pSrcObject); |
5b687e5d |
459 | // object contains data if the EM energies are different from the default value |
460 | copy=pESDZDC && |
461 | (TMath::Abs(pESDZDC->GetZDCEMEnergy(0)-kAliESDZDCDefaultEMEnergy) > kAliESDZDCDefaultEMEnergyGlitch || |
462 | TMath::Abs(pESDZDC->GetZDCEMEnergy(1)-kAliESDZDCDefaultEMEnergy) > kAliESDZDCDefaultEMEnergyGlitch); |
2bc81aef |
463 | } else if (pSrcObject->IsA()==AliMultiplicity::Class()) { |
464 | AliMultiplicity* pMultiplicity=dynamic_cast<AliMultiplicity*>(pSrcObject); |
465 | copy=(pMultiplicity && pMultiplicity->GetNumberOfTracklets()>0); |
466 | } else if (pSrcObject->IsA()==AliESDCaloTrigger::Class()) { |
467 | AliESDCaloTrigger* pESDCaloTrigger=dynamic_cast<AliESDCaloTrigger*>(pSrcObject); |
468 | copy=(pESDCaloTrigger && false); // have to find an easy valid condition |
469 | } else if (pSrcObject->IsA()==AliESDCaloCells::Class()) { |
470 | AliESDCaloCells* pESDCaloCells=dynamic_cast<AliESDCaloCells*>(pSrcObject); |
471 | copy=(pESDCaloCells && false); // have to find an easy valid condition |
472 | } else if (pSrcObject->IsA()==AliESDACORDE::Class()) { |
473 | AliESDACORDE* pESDACORDE=dynamic_cast<AliESDACORDE*>(pSrcObject); |
474 | copy=(pESDACORDE && false); // have to find an easy valid condition |
f5ea7ce2 |
475 | } else if (!AliHLTESDEventHelper::IsStdContent(name)) { |
476 | // this is likely to be ok as long as it is not any object of the std content. |
477 | copy=true; |
2bc81aef |
478 | } else { |
f5ea7ce2 |
479 | HLTError("no merging implemented for object %s, omitting", name.Data()); |
2bc81aef |
480 | } |
481 | if (copy) { |
e13512e4 |
482 | //pSrcObject->Print(); |
30d84601 |
483 | TObject* pTgtObject=pTgt->FindListObject(name); |
18a9a5ad |
484 | if (pTgtObject) { |
30d84601 |
485 | pSrcObject->Copy(*pTgtObject); |
18a9a5ad |
486 | } else { |
30d84601 |
487 | pTgt->AddObject(pSrcObject->Clone()); |
18a9a5ad |
488 | } |
18a9a5ad |
489 | } |
f527516f |
490 | } else if(pSrcObject->InheritsFrom("TClonesArray")){ |
491 | TClonesArray* pTClA=dynamic_cast<TClonesArray*>(pSrcObject); |
492 | if (pTClA!=NULL && pTClA->GetEntriesFast()>0) { |
30d84601 |
493 | TString name=pTClA->GetName(); |
f527516f |
494 | TObject* pTgtObject=pTgt->GetList()->FindObject(name); |
495 | TClonesArray* pTgtArray=NULL; |
57584811 |
496 | if (pTgtObject!=NULL && pTgtObject->InheritsFrom("TClonesArray")){ |
f527516f |
497 | pTgtArray=dynamic_cast<TClonesArray*>(pTgtObject); |
498 | if (pTgtArray) { |
499 | TString classType=pTClA->Class()->GetName(); |
500 | if (classType.CompareTo(pTgtArray->Class()->GetName())==0) { |
501 | if (pTgtArray->GetEntries()==0) { |
57584811 |
502 | pTgtArray->ExpandCreate(pTClA->GetEntries()); |
503 | for(int i=0; i<pTClA->GetEntriesFast(); ++i){ |
504 | (*pTClA)[i]->Copy(*((*pTgtArray)[i])); |
505 | } |
f527516f |
506 | } else { |
57584811 |
507 | if (warningCount++<10) { |
508 | HLTWarning("TClonesArray \"%s\" in target ESD %p is already filled with %d entries", |
509 | name.Data(), pTgt, pTgtArray->GetEntries()); |
510 | } |
511 | iResult=-EBUSY; |
f527516f |
512 | } |
513 | } else { |
57584811 |
514 | if (warningCount++<10) { |
515 | HLTWarning("TClonesArray \"%s\" exists in target ESD %p, but describes incompatible class type %s instead of %s", |
516 | name.Data(), pTgt, pTgtArray->GetClass()->GetName(), pTClA->GetClass()->GetName()); |
517 | } |
518 | iResult=-EBUSY; |
f527516f |
519 | } |
520 | } else { |
57584811 |
521 | if (warningCount++<10) { |
522 | HLTError("internal error: dynamic cast failed for object %s %p", pTgtObject->GetName(), pTgtObject); |
523 | } |
524 | iResult=-EBUSY; |
f527516f |
525 | } |
526 | } else if (pTgtObject) { |
57584811 |
527 | if (warningCount++<10) { |
528 | HLTWarning("object \"%s\" does already exist in target ESD %p, but is %s rather than TClonesArray" |
529 | " skipping data", |
530 | name.Data(), pTgt, pTgtObject->Class()->GetName()); |
f527516f |
531 | } |
57584811 |
532 | iResult=-EBUSY; |
f527516f |
533 | } else { |
57584811 |
534 | if (warningCount++<10) { |
535 | HLTWarning("object \"%s\" does not exist in target ESD %p, data can not be copied because it will be lost when filling the tree", |
536 | name.Data(), pTgt); |
f527516f |
537 | } |
57584811 |
538 | iResult=-ENOENT; |
f527516f |
539 | } |
540 | } |
541 | } |
542 | } |
543 | return iResult; |
544 | } |
f5ea7ce2 |
545 | |
546 | bool AliHLTEsdManagerImplementation::AliHLTESDEventHelper::IsStdContent(const char* key) |
547 | { |
548 | // check if the key denotes a std object |
549 | TString needle=key; |
550 | for (int i=0; i<kESDListN; i++) { |
551 | if (needle.CompareTo(fgkESDListName[i])==0) return true; |
552 | } |
553 | return false; |
554 | } |
5b687e5d |
555 | |
556 | int AliHLTEsdManagerImplementation::CheckClassConditions() const |
557 | { |
558 | // this is a helper method which checks if some thing in the default |
559 | // object initialization changes during the evolution of the source code |
560 | // which is necessary for checking the validity of data in the object |
561 | |
562 | // check AliESDVZERO |
563 | AliESDVZERO vzerodummy; |
564 | if (TMath::Abs(vzerodummy.GetV0ATime()-kAliESDVZERODefaultTime) > kAliESDVZERODefaultTimeGlitch || |
565 | TMath::Abs(vzerodummy.GetV0CTime()-kAliESDVZERODefaultTime) > kAliESDVZERODefaultTimeGlitch) { |
566 | HLTWarning("initialization of AliESDVZERO has changed, default time values now %f/%f, " |
567 | "revision of condition might be needed", |
568 | vzerodummy.GetV0ATime(), vzerodummy.GetV0CTime()); |
569 | } |
570 | |
571 | // check AliESDZDC |
572 | AliESDZDC zdcdummy; |
573 | if (TMath::Abs(zdcdummy.GetZDCEMEnergy(0)-kAliESDZDCDefaultEMEnergy) > kAliESDZDCDefaultEMEnergyGlitch || |
574 | TMath::Abs(zdcdummy.GetZDCEMEnergy(1)-kAliESDZDCDefaultEMEnergy) > kAliESDZDCDefaultEMEnergyGlitch) { |
575 | HLTWarning("initialization of AliESDZDC has changed, default em energy values now %f/%f, " |
576 | "revision of condition might be needed", |
577 | zdcdummy.GetZDCEMEnergy(0), zdcdummy.GetZDCEMEnergy(1)); |
578 | } |
579 | |
580 | return 0; |
581 | } |