]>
Commit | Line | Data |
---|---|---|
af885e0f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
f56a9fa7 | 19 | // Implementation of the AliESDEvent class |
6989bff3 | 20 | // This is the class to deal with during the physics analysis of data. |
f56a9fa7 | 21 | // It also ensures the backward compatibility with the old ESD format. |
6989bff3 | 22 | /* |
23 | AliESDEvent *ev= new AliESDEvent(); | |
24 | ev->ReadFromTree(esdTree); | |
25 | ... | |
26 | for (Int_t i=0; i<nev; i++) { | |
27 | esdTree->GetEntry(i); | |
28 | if(ev->GetAliESDOld())ev->CopyFromOldESD(); | |
29 | */ | |
7d44c466 | 30 | // The AliESDInputHandler does this automatically for you |
f56a9fa7 | 31 | // |
32 | // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch | |
af885e0f | 33 | //----------------------------------------------------------------- |
34 | ||
35 | #include "TList.h" | |
cd1d4ee0 | 36 | #include "TRefArray.h" |
af885e0f | 37 | #include <TNamed.h> |
2a3dfb14 | 38 | #include <TROOT.h> |
39 | #include <TInterpreter.h> | |
af885e0f | 40 | |
41 | #include "AliESDEvent.h" | |
42 | #include "AliESDfriend.h" | |
43 | #include "AliESDVZERO.h" | |
af885e0f | 44 | #include "AliESDFMD.h" |
45 | #include "AliESD.h" | |
f0106218 | 46 | #include "AliESDMuonTrack.h" |
47 | #include "AliESDPmdTrack.h" | |
48 | #include "AliESDTrdTrack.h" | |
49 | #include "AliESDVertex.h" | |
50 | #include "AliESDcascade.h" | |
51 | #include "AliESDPmdTrack.h" | |
6c8e0967 | 52 | #include "AliESDTrdTrigger.h" |
f0106218 | 53 | #include "AliESDTrdTrack.h" |
52cd0cc0 | 54 | #include "AliESDTrdTracklet.h" |
f0106218 | 55 | #include "AliESDVertex.h" |
518573d7 | 56 | #include "AliVertexerTracks.h" |
f0106218 | 57 | #include "AliESDcascade.h" |
58 | #include "AliESDkink.h" | |
59 | #include "AliESDtrack.h" | |
60 | #include "AliESDHLTtrack.h" | |
61 | #include "AliESDCaloCluster.h" | |
e649177a | 62 | #include "AliESDCaloCells.h" |
f0106218 | 63 | #include "AliESDv0.h" |
64 | #include "AliESDFMD.h" | |
65 | #include "AliESDVZERO.h" | |
66 | #include "AliMultiplicity.h" | |
67 | #include "AliRawDataErrorLog.h" | |
e649177a | 68 | #include "AliLog.h" |
bd95bae7 | 69 | #include "AliESDACORDE.h" |
8b12d288 | 70 | #include "AliESDHLTDecision.h" |
fba4b2e2 | 71 | #include "AliCentrality.h" |
820b4d9e | 72 | #ifdef MFT_UPGRADE |
73 | #include "AliESDMFT.h" | |
74 | #endif | |
ce7adfe9 | 75 | #include "AliEventplane.h" |
8b12d288 | 76 | |
820b4d9e | 77 | |
af885e0f | 78 | ClassImp(AliESDEvent) |
79 | ||
60e8f114 | 80 | |
81 | ||
82 | // here we define the names, some classes are no TNamed, therefore the classnames | |
83 | // are the Names | |
6989bff3 | 84 | const char* AliESDEvent::fgkESDListName[kESDListN] = {"AliESDRun", |
f858b00e | 85 | "AliESDHeader", |
86 | "AliESDZDC", | |
87 | "AliESDFMD", | |
88 | "AliESDVZERO", | |
89 | "AliESDTZERO", | |
90 | "TPCVertex", | |
91 | "SPDVertex", | |
92 | "PrimaryVertex", | |
93 | "AliMultiplicity", | |
94 | "PHOSTrigger", | |
95 | "EMCALTrigger", | |
96 | "SPDPileupVertices", | |
97 | "TrkPileupVertices", | |
98 | "Tracks", | |
99 | "MuonTracks", | |
100 | "PmdTracks", | |
6c8e0967 | 101 | "AliESDTrdTrigger", |
f858b00e | 102 | "TrdTracks", |
52cd0cc0 | 103 | "TrdTracklets", |
f858b00e | 104 | "V0s", |
105 | "Cascades", | |
106 | "Kinks", | |
107 | "CaloClusters", | |
108 | "EMCALCells", | |
109 | "PHOSCells", | |
110 | "AliRawDataErrorLogs", | |
111 | "AliESDACORDE", | |
820b4d9e | 112 | "AliTOFHeader" |
113 | #ifdef MFT_UPGRADE | |
114 | // , "AliESDMFT" | |
115 | #endif | |
116 | }; | |
bd95bae7 | 117 | |
af885e0f | 118 | //______________________________________________________________________________ |
119 | AliESDEvent::AliESDEvent(): | |
024c7734 | 120 | AliVEvent(), |
af885e0f | 121 | fESDObjects(new TList()), |
122 | fESDRun(0), | |
123 | fHeader(0), | |
124 | fESDZDC(0), | |
125 | fESDFMD(0), | |
126 | fESDVZERO(0), | |
127 | fESDTZERO(0), | |
06cc9d95 | 128 | fTPCVertex(0), |
af885e0f | 129 | fSPDVertex(0), |
130 | fPrimaryVertex(0), | |
131 | fSPDMult(0), | |
132 | fPHOSTrigger(0), | |
133 | fEMCALTrigger(0), | |
bd95bae7 | 134 | fESDACORDE(0), |
6c8e0967 | 135 | fTrdTrigger(0), |
04d01397 | 136 | fSPDPileupVertices(0), |
137 | fTrkPileupVertices(0), | |
af885e0f | 138 | fTracks(0), |
139 | fMuonTracks(0), | |
140 | fPmdTracks(0), | |
141 | fTrdTracks(0), | |
52cd0cc0 | 142 | fTrdTracklets(0), |
af885e0f | 143 | fV0s(0), |
144 | fCascades(0), | |
145 | fKinks(0), | |
146 | fCaloClusters(0), | |
e649177a | 147 | fEMCALCells(0), fPHOSCells(0), |
af885e0f | 148 | fErrorLogs(0), |
149 | fESDOld(0), | |
1bd10080 | 150 | fESDFriendOld(0), |
60e8f114 | 151 | fConnected(kFALSE), |
f858b00e | 152 | fUseOwnList(kFALSE), |
2eec2a33 | 153 | fTOFHeader(0), |
ce7adfe9 | 154 | fCentrality(0), |
155 | fEventplane(0) | |
820b4d9e | 156 | #ifdef MFT_UPGRADE |
157 | // , fESDMFT(0) | |
158 | #endif | |
af885e0f | 159 | { |
160 | } | |
161 | //______________________________________________________________________________ | |
162 | AliESDEvent::AliESDEvent(const AliESDEvent& esd): | |
024c7734 | 163 | AliVEvent(esd), |
af885e0f | 164 | fESDObjects(new TList()), |
165 | fESDRun(new AliESDRun(*esd.fESDRun)), | |
166 | fHeader(new AliESDHeader(*esd.fHeader)), | |
167 | fESDZDC(new AliESDZDC(*esd.fESDZDC)), | |
168 | fESDFMD(new AliESDFMD(*esd.fESDFMD)), | |
169 | fESDVZERO(new AliESDVZERO(*esd.fESDVZERO)), | |
170 | fESDTZERO(new AliESDTZERO(*esd.fESDTZERO)), | |
06cc9d95 | 171 | fTPCVertex(new AliESDVertex(*esd.fTPCVertex)), |
af885e0f | 172 | fSPDVertex(new AliESDVertex(*esd.fSPDVertex)), |
173 | fPrimaryVertex(new AliESDVertex(*esd.fPrimaryVertex)), | |
174 | fSPDMult(new AliMultiplicity(*esd.fSPDMult)), | |
175 | fPHOSTrigger(new AliESDCaloTrigger(*esd.fPHOSTrigger)), | |
176 | fEMCALTrigger(new AliESDCaloTrigger(*esd.fEMCALTrigger)), | |
bd95bae7 | 177 | fESDACORDE(new AliESDACORDE(*esd.fESDACORDE)), |
6c8e0967 | 178 | fTrdTrigger(new AliESDTrdTrigger(*esd.fTrdTrigger)), |
04d01397 | 179 | fSPDPileupVertices(new TClonesArray(*esd.fSPDPileupVertices)), |
180 | fTrkPileupVertices(new TClonesArray(*esd.fTrkPileupVertices)), | |
af885e0f | 181 | fTracks(new TClonesArray(*esd.fTracks)), |
182 | fMuonTracks(new TClonesArray(*esd.fMuonTracks)), | |
183 | fPmdTracks(new TClonesArray(*esd.fPmdTracks)), | |
184 | fTrdTracks(new TClonesArray(*esd.fTrdTracks)), | |
52cd0cc0 | 185 | fTrdTracklets(new TClonesArray(*esd.fTrdTracklets)), |
af885e0f | 186 | fV0s(new TClonesArray(*esd.fV0s)), |
187 | fCascades(new TClonesArray(*esd.fCascades)), | |
188 | fKinks(new TClonesArray(*esd.fKinks)), | |
189 | fCaloClusters(new TClonesArray(*esd.fCaloClusters)), | |
e649177a | 190 | fEMCALCells(new AliESDCaloCells(*esd.fEMCALCells)), |
191 | fPHOSCells(new AliESDCaloCells(*esd.fPHOSCells)), | |
af885e0f | 192 | fErrorLogs(new TClonesArray(*esd.fErrorLogs)), |
7251b311 | 193 | fESDOld(esd.fESDOld ? new AliESD(*esd.fESDOld) : 0), |
194 | fESDFriendOld(esd.fESDFriendOld ? new AliESDfriend(*esd.fESDFriendOld) : 0), | |
60e8f114 | 195 | fConnected(esd.fConnected), |
f858b00e | 196 | fUseOwnList(esd.fUseOwnList), |
2eec2a33 | 197 | fTOFHeader(new AliTOFHeader(*esd.fTOFHeader)), |
ce7adfe9 | 198 | fCentrality(new AliCentrality(*esd.fCentrality)), |
199 | fEventplane(new AliEventplane(*esd.fEventplane)) | |
820b4d9e | 200 | #ifdef MFT_UPGRADE |
201 | // , fESDMFT(new AliESDMFT(*esd.fESDMFT)) | |
202 | #endif | |
203 | ||
204 | ||
af885e0f | 205 | { |
820b4d9e | 206 | printf("copying ESD event...\n"); // AU |
af885e0f | 207 | // CKB init in the constructor list and only add here ... |
208 | AddObject(fESDRun); | |
209 | AddObject(fHeader); | |
210 | AddObject(fESDZDC); | |
211 | AddObject(fESDFMD); | |
212 | AddObject(fESDVZERO); | |
213 | AddObject(fESDTZERO); | |
06cc9d95 | 214 | AddObject(fTPCVertex); |
af885e0f | 215 | AddObject(fSPDVertex); |
216 | AddObject(fPrimaryVertex); | |
217 | AddObject(fSPDMult); | |
218 | AddObject(fPHOSTrigger); | |
219 | AddObject(fEMCALTrigger); | |
6c8e0967 | 220 | AddObject(fTrdTrigger); |
04d01397 | 221 | AddObject(fSPDPileupVertices); |
222 | AddObject(fTrkPileupVertices); | |
af885e0f | 223 | AddObject(fTracks); |
224 | AddObject(fMuonTracks); | |
225 | AddObject(fPmdTracks); | |
226 | AddObject(fTrdTracks); | |
52cd0cc0 | 227 | AddObject(fTrdTracklets); |
af885e0f | 228 | AddObject(fV0s); |
229 | AddObject(fCascades); | |
230 | AddObject(fKinks); | |
231 | AddObject(fCaloClusters); | |
e649177a | 232 | AddObject(fEMCALCells); |
233 | AddObject(fPHOSCells); | |
af885e0f | 234 | AddObject(fErrorLogs); |
bd95bae7 | 235 | AddObject(fESDACORDE); |
f858b00e | 236 | AddObject(fTOFHeader); |
820b4d9e | 237 | #ifdef MFT_UPGRADE |
238 | // AddObject(fESDMFT); | |
239 | #endif | |
af885e0f | 240 | GetStdContent(); |
241 | ||
242 | } | |
243 | ||
244 | //______________________________________________________________________________ | |
245 | AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) { | |
246 | ||
247 | // Assignment operator | |
248 | ||
249 | if(&source == this) return *this; | |
024c7734 | 250 | AliVEvent::operator=(source); |
af885e0f | 251 | |
732a24fe | 252 | // This assumes that the list is already created |
253 | // and that the virtual void Copy(Tobject&) function | |
254 | // is correctly implemented in the derived class | |
255 | // otherwise only TObject::Copy() will be used | |
256 | ||
257 | ||
102c56c8 | 258 | |
732a24fe | 259 | if((fESDObjects->GetSize()==0)&&(source.fESDObjects->GetSize()>=kESDListN)){ |
260 | // We cover the case that we do not yet have the | |
261 | // standard content but the source has it | |
262 | CreateStdContent(); | |
263 | } | |
264 | ||
265 | TIter next(source.GetList()); | |
266 | TObject *its = 0; | |
267 | TString name; | |
268 | while ((its = next())) { | |
269 | name.Form("%s", its->GetName()); | |
270 | TObject *mine = fESDObjects->FindObject(name.Data()); | |
271 | if(!mine){ | |
102c56c8 | 272 | TClass* pClass=TClass::GetClass(its->ClassName()); |
273 | if (!pClass) { | |
274 | AliWarning(Form("Can not find class description for entry %s (%s)\n", | |
275 | its->ClassName(), name.Data())); | |
276 | continue; | |
277 | } | |
732a24fe | 278 | |
102c56c8 | 279 | mine=(TObject*)pClass->New(); |
280 | if(!mine){ | |
281 | // not in this: can be added to list | |
282 | AliWarning(Form("%s:%d Could not find %s for copying \n", | |
283 | (char*)__FILE__,__LINE__,name.Data())); | |
284 | continue; | |
285 | } | |
286 | if(mine->InheritsFrom("TNamed")){ | |
287 | ((TNamed*)mine)->SetName(name); | |
288 | } | |
289 | else if(mine->InheritsFrom("TCollection")){ | |
11becff8 | 290 | if(mine->InheritsFrom("TClonesArray")) { |
291 | TClonesArray* tcits = dynamic_cast<TClonesArray*>(its); | |
292 | if (tcits) | |
293 | dynamic_cast<TClonesArray*>(mine)->SetClass(tcits->GetClass()); | |
294 | } | |
102c56c8 | 295 | dynamic_cast<TCollection*>(mine)->SetName(name); |
296 | } | |
297 | AliDebug(1, Form("adding object %s of type %s", mine->GetName(), mine->ClassName())); | |
298 | AddObject(mine); | |
299 | } | |
300 | ||
732a24fe | 301 | if(!its->InheritsFrom("TCollection")){ |
302 | // simple objects | |
303 | its->Copy(*mine); | |
304 | } | |
305 | else if(its->InheritsFrom("TClonesArray")){ | |
306 | // Create or expand the tclonesarray pointers | |
307 | // so we can directly copy to the object | |
308 | TClonesArray *its_tca = (TClonesArray*)its; | |
309 | TClonesArray *mine_tca = (TClonesArray*)mine; | |
310 | ||
311 | // this leaves the capacity of the TClonesArray the same | |
312 | // except for a factor of 2 increase when size > capacity | |
313 | // does not release any memory occupied by the tca | |
314 | mine_tca->ExpandCreate(its_tca->GetEntriesFast()); | |
315 | for(int i = 0;i < its_tca->GetEntriesFast();++i){ | |
316 | // copy | |
317 | TObject *mine_tca_obj = mine_tca->At(i); | |
318 | TObject *its_tca_obj = its_tca->At(i); | |
319 | // no need to delete first | |
320 | // pointers within the class should be handled by Copy()... | |
321 | // Can there be Empty slots? | |
322 | its_tca_obj->Copy(*mine_tca_obj); | |
323 | } | |
324 | } | |
325 | else{ | |
326 | AliWarning(Form("%s:%d cannot copy TCollection \n", | |
327 | (char*)__FILE__,__LINE__)); | |
328 | } | |
329 | } | |
af885e0f | 330 | |
2eec2a33 | 331 | fCentrality = source.fCentrality; |
ce7adfe9 | 332 | fEventplane = source.fEventplane; |
2eec2a33 | 333 | |
334 | fConnected = source.fConnected; | |
a2fbb067 | 335 | fUseOwnList = source.fUseOwnList; |
af885e0f | 336 | |
af885e0f | 337 | return *this; |
af885e0f | 338 | } |
339 | ||
340 | ||
341 | //______________________________________________________________________________ | |
342 | AliESDEvent::~AliESDEvent() | |
343 | { | |
344 | // | |
345 | // Standard destructor | |
346 | // | |
347 | ||
001b9beb | 348 | // everthing on the list gets deleted automatically |
139f2194 | 349 | |
350 | ||
60e8f114 | 351 | if(fESDObjects&&!fConnected) |
352 | { | |
353 | delete fESDObjects; | |
354 | fESDObjects = 0; | |
355 | } | |
cb62947d | 356 | if (fCentrality) delete fCentrality; |
ce7adfe9 | 357 | if (fEventplane) delete fEventplane; |
60e8f114 | 358 | |
af885e0f | 359 | } |
360 | ||
732a24fe | 361 | void AliESDEvent::Copy(TObject &obj) const { |
362 | ||
363 | // interface to TOBject::Copy | |
364 | // Copies the content of this into obj! | |
365 | // bascially obj = *this | |
366 | ||
367 | if(this==&obj)return; | |
368 | AliESDEvent *robj = dynamic_cast<AliESDEvent*>(&obj); | |
369 | if(!robj)return; // not an AliESEvent | |
370 | *robj = *this; | |
371 | return; | |
372 | } | |
373 | ||
af885e0f | 374 | //______________________________________________________________________________ |
375 | void AliESDEvent::Reset() | |
376 | { | |
377 | ||
102c56c8 | 378 | // Handle the cases |
379 | // Std content + Non std content | |
380 | ||
af885e0f | 381 | // Reset the standard contents |
382 | ResetStdContent(); | |
102c56c8 | 383 | |
384 | // reset for the old data without AliESDEvent... | |
af885e0f | 385 | if(fESDOld)fESDOld->Reset(); |
d7749dec | 386 | if(fESDFriendOld){ |
387 | fESDFriendOld->~AliESDfriend(); | |
388 | new (fESDFriendOld) AliESDfriend(); | |
389 | } | |
102c56c8 | 390 | // |
391 | ||
392 | if(fESDObjects->GetSize()>kESDListN){ | |
393 | // we have non std content | |
394 | // this also covers esdfriends | |
395 | for(int i = kESDListN;i < fESDObjects->GetSize();++i){ | |
396 | TObject *pObject = fESDObjects->At(i); | |
397 | // TClonesArrays | |
398 | if(pObject->InheritsFrom(TClonesArray::Class())){ | |
399 | ((TClonesArray*)pObject)->Delete(); | |
400 | } | |
401 | else if(!pObject->InheritsFrom(TCollection::Class())){ | |
00b66af8 | 402 | TClass *pClass = TClass::GetClass(pObject->ClassName()); |
403 | if (pClass && pClass->GetListOfMethods()->FindObject("Clear")) { | |
404 | AliDebug(1, Form("Clear for object %s class %s", pObject->GetName(), pObject->ClassName())); | |
405 | pObject->Clear(); | |
406 | } | |
407 | else { | |
408 | AliDebug(1, Form("ResetWithPlacementNew for object %s class %s", pObject->GetName(), pObject->ClassName())); | |
409 | ResetWithPlacementNew(pObject); | |
410 | } | |
102c56c8 | 411 | } |
412 | else{ | |
65b25288 | 413 | AliWarning(Form("No reset for %s \n", |
102c56c8 | 414 | pObject->ClassName())); |
415 | } | |
416 | } | |
d7749dec | 417 | } |
418 | ||
102c56c8 | 419 | } |
420 | ||
421 | Bool_t AliESDEvent::ResetWithPlacementNew(TObject *pObject){ | |
422 | Long_t dtoronly = TObject::GetDtorOnly(); | |
423 | TClass *pClass = TClass::GetClass(pObject->ClassName()); | |
424 | TObject::SetDtorOnly(pObject); | |
425 | delete pObject; | |
426 | // Recreate with placement new | |
427 | pClass->New(pObject); | |
428 | // Restore the state. | |
429 | TObject::SetDtorOnly((void*)dtoronly); | |
430 | return kTRUE; | |
af885e0f | 431 | } |
432 | ||
433 | void AliESDEvent::ResetStdContent() | |
434 | { | |
435 | // Reset the standard contents | |
436 | if(fESDRun) fESDRun->Reset(); | |
437 | if(fHeader) fHeader->Reset(); | |
93d96ff5 | 438 | if(fCentrality) fCentrality->Reset(); |
439 | if(fEventplane) fEventplane->Reset(); | |
af885e0f | 440 | if(fESDZDC) fESDZDC->Reset(); |
0f0eb29c | 441 | if(fESDFMD) { |
a2fbb067 | 442 | fESDFMD->Clear(); |
0f0eb29c | 443 | } |
6989bff3 | 444 | if(fESDVZERO){ |
445 | // reset by callin d'to /c'tor keep the pointer | |
446 | fESDVZERO->~AliESDVZERO(); | |
447 | new (fESDVZERO) AliESDVZERO(); | |
448 | } | |
bd95bae7 | 449 | if(fESDACORDE){ |
450 | fESDACORDE->~AliESDACORDE(); | |
451 | new (fESDACORDE) AliESDACORDE(); | |
452 | } | |
af885e0f | 453 | if(fESDTZERO) fESDTZERO->Reset(); |
454 | // CKB no clear/reset implemented | |
06cc9d95 | 455 | if(fTPCVertex){ |
456 | fTPCVertex->~AliESDVertex(); | |
457 | new (fTPCVertex) AliESDVertex(); | |
458 | fTPCVertex->SetName(fgkESDListName[kTPCVertex]); | |
459 | } | |
af885e0f | 460 | if(fSPDVertex){ |
316c6cd9 | 461 | fSPDVertex->~AliESDVertex(); |
af885e0f | 462 | new (fSPDVertex) AliESDVertex(); |
6989bff3 | 463 | fSPDVertex->SetName(fgkESDListName[kSPDVertex]); |
af885e0f | 464 | } |
465 | if(fPrimaryVertex){ | |
316c6cd9 | 466 | fPrimaryVertex->~AliESDVertex(); |
af885e0f | 467 | new (fPrimaryVertex) AliESDVertex(); |
6989bff3 | 468 | fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]); |
af885e0f | 469 | } |
316c6cd9 | 470 | if(fSPDMult){ |
471 | fSPDMult->~AliMultiplicity(); | |
472 | new (fSPDMult) AliMultiplicity(); | |
473 | } | |
f858b00e | 474 | if(fTOFHeader){ |
475 | fTOFHeader->~AliTOFHeader(); | |
476 | new (fTOFHeader) AliTOFHeader(); | |
477 | //fTOFHeader->SetName(fgkESDListName[kTOFHeader]); | |
478 | } | |
6c8e0967 | 479 | if (fTrdTrigger) { |
480 | fTrdTrigger->~AliESDTrdTrigger(); | |
481 | new (fTrdTrigger) AliESDTrdTrigger(); | |
482 | } | |
820b4d9e | 483 | #ifdef MFT_UPGRADE |
484 | //if(fESDMFT){ | |
485 | // fESDMFT->~AliESDMFT(); | |
486 | // new (fESDMFT) AliESDMFT(); | |
487 | // } | |
488 | #endif | |
489 | ||
042d5330 | 490 | if(fPHOSTrigger)fPHOSTrigger->DeAllocate(); |
491 | if(fEMCALTrigger)fEMCALTrigger->DeAllocate(); | |
04d01397 | 492 | if(fSPDPileupVertices)fSPDPileupVertices->Delete(); |
493 | if(fTrkPileupVertices)fTrkPileupVertices->Delete(); | |
bc9a7b42 | 494 | if(fTracks)fTracks->Delete(); |
6989bff3 | 495 | if(fMuonTracks)fMuonTracks->Delete(); |
496 | if(fPmdTracks)fPmdTracks->Delete(); | |
497 | if(fTrdTracks)fTrdTracks->Delete(); | |
52cd0cc0 | 498 | if(fTrdTracklets)fTrdTracklets->Delete(); |
6989bff3 | 499 | if(fV0s)fV0s->Delete(); |
500 | if(fCascades)fCascades->Delete(); | |
501 | if(fKinks)fKinks->Delete(); | |
bc9a7b42 | 502 | if(fCaloClusters)fCaloClusters->Delete(); |
e649177a | 503 | if(fPHOSCells)fPHOSCells->DeleteContainer(); |
504 | if(fEMCALCells)fEMCALCells->DeleteContainer(); | |
16167d49 | 505 | if(fErrorLogs) fErrorLogs->Delete(); |
af885e0f | 506 | |
d7749dec | 507 | // don't reset fconnected fConnected and the list |
60e8f114 | 508 | |
af885e0f | 509 | } |
510 | ||
511 | ||
512 | Int_t AliESDEvent::AddV0(const AliESDv0 *v) { | |
513 | // | |
514 | // Add V0 | |
515 | // | |
516 | TClonesArray &fv = *fV0s; | |
517 | Int_t idx=fV0s->GetEntriesFast(); | |
518 | new(fv[idx]) AliESDv0(*v); | |
519 | return idx; | |
520 | } | |
521 | ||
522 | //______________________________________________________________________________ | |
523 | void AliESDEvent::Print(Option_t *) const | |
524 | { | |
525 | // | |
526 | // Print header information of the event | |
527 | // | |
528 | printf("ESD run information\n"); | |
529 | printf("Event # in file %d Bunch crossing # %d Orbit # %d Period # %d Run # %d Trigger %lld Magnetic field %f \n", | |
530 | GetEventNumberInFile(), | |
531 | GetBunchCrossNumber(), | |
532 | GetOrbitNumber(), | |
533 | GetPeriodNumber(), | |
534 | GetRunNumber(), | |
535 | GetTriggerMask(), | |
536 | GetMagneticField() ); | |
c017f53f | 537 | if (fPrimaryVertex) |
538 | printf("Vertex: (%.4f +- %.4f, %.4f +- %.4f, %.4f +- %.4f) cm\n", | |
af885e0f | 539 | fPrimaryVertex->GetXv(), fPrimaryVertex->GetXRes(), |
540 | fPrimaryVertex->GetYv(), fPrimaryVertex->GetYRes(), | |
541 | fPrimaryVertex->GetZv(), fPrimaryVertex->GetZRes()); | |
1c7554f9 | 542 | printf("Mean vertex in RUN: X=%.4f Y=%.4f Z=%.4f cm\n", |
543 | GetDiamondX(),GetDiamondY(),GetDiamondZ()); | |
c017f53f | 544 | if(fSPDMult) |
af885e0f | 545 | printf("SPD Multiplicity. Number of tracklets %d \n", |
546 | fSPDMult->GetNumberOfTracklets()); | |
04d01397 | 547 | printf("Number of pileup primary vertices reconstructed with SPD %d\n", |
c017f53f | 548 | GetNumberOfPileupVerticesSPD()); |
04d01397 | 549 | printf("Number of pileup primary vertices reconstructed using the tracks %d\n", |
c017f53f | 550 | GetNumberOfPileupVerticesTracks()); |
af885e0f | 551 | printf("Number of tracks: \n"); |
552 | printf(" charged %d\n", GetNumberOfTracks()); | |
553 | printf(" muon %d\n", GetNumberOfMuonTracks()); | |
554 | printf(" pmd %d\n", GetNumberOfPmdTracks()); | |
555 | printf(" trd %d\n", GetNumberOfTrdTracks()); | |
52cd0cc0 | 556 | printf(" trd trkl %d\n", GetNumberOfTrdTracklets()); |
af885e0f | 557 | printf(" v0 %d\n", GetNumberOfV0s()); |
558 | printf(" cascades %d\n", GetNumberOfCascades()); | |
559 | printf(" kinks %d\n", GetNumberOfKinks()); | |
38f940fb | 560 | if(fPHOSCells)printf(" PHOSCells %d\n", fPHOSCells->GetNumberOfCells()); |
561 | else printf(" PHOSCells not in the Event\n"); | |
562 | if(fEMCALCells)printf(" EMCALCells %d\n", fEMCALCells->GetNumberOfCells()); | |
563 | else printf(" EMCALCells not in the Event\n"); | |
af885e0f | 564 | printf(" CaloClusters %d\n", GetNumberOfCaloClusters()); |
af885e0f | 565 | printf(" FMD %s\n", (fESDFMD ? "yes" : "no")); |
566 | printf(" VZERO %s\n", (fESDVZERO ? "yes" : "no")); | |
820b4d9e | 567 | #ifdef MFT_UPGRADE |
568 | //printf(" MFT %s\n", (fESDMFT ? "yes" : "no")); | |
569 | #endif | |
570 | ||
571 | ||
8b12d288 | 572 | TObject* pHLTDecision=GetHLTTriggerDecision(); |
573 | printf("HLT trigger decision: %s\n", pHLTDecision?pHLTDecision->GetOption():"not available"); | |
574 | if (pHLTDecision) pHLTDecision->Print("compact"); | |
024c7734 | 575 | |
576 | return; | |
af885e0f | 577 | } |
578 | ||
7d44c466 | 579 | void AliESDEvent::SetESDfriend(const AliESDfriend *ev) const { |
af885e0f | 580 | // |
581 | // Attaches the complementary info to the ESD | |
582 | // | |
583 | if (!ev) return; | |
584 | ||
5300bdab | 585 | // to be sure that we set the tracks also |
586 | // in case of old esds | |
60e8f114 | 587 | // if(fESDOld)CopyFromOldESD(); |
5300bdab | 588 | |
af885e0f | 589 | Int_t ntrk=ev->GetNumberOfTracks(); |
590 | ||
591 | for (Int_t i=0; i<ntrk; i++) { | |
592 | const AliESDfriendTrack *f=ev->GetTrack(i); | |
593 | GetTrack(i)->SetFriendTrack(f); | |
594 | } | |
595 | } | |
596 | ||
7d44c466 | 597 | Bool_t AliESDEvent::RemoveKink(Int_t rm) const { |
a023d8d8 | 598 | // --------------------------------------------------------- |
599 | // Remove a kink candidate and references to it from ESD, | |
600 | // if this candidate does not come from a reconstructed decay | |
601 | // Not yet implemented... | |
602 | // --------------------------------------------------------- | |
603 | Int_t last=GetNumberOfKinks()-1; | |
604 | if ((rm<0)||(rm>last)) return kFALSE; | |
605 | ||
606 | return kTRUE; | |
607 | } | |
608 | ||
7d44c466 | 609 | Bool_t AliESDEvent::RemoveV0(Int_t rm) const { |
a023d8d8 | 610 | // --------------------------------------------------------- |
611 | // Remove a V0 candidate and references to it from ESD, | |
612 | // if this candidate does not come from a reconstructed decay | |
613 | // --------------------------------------------------------- | |
614 | Int_t last=GetNumberOfV0s()-1; | |
615 | if ((rm<0)||(rm>last)) return kFALSE; | |
616 | ||
617 | AliESDv0 *v0=GetV0(rm); | |
618 | Int_t idxP=v0->GetPindex(), idxN=v0->GetNindex(); | |
619 | ||
620 | v0=GetV0(last); | |
621 | Int_t lastIdxP=v0->GetPindex(), lastIdxN=v0->GetNindex(); | |
622 | ||
623 | Int_t used=0; | |
624 | ||
625 | // Check if this V0 comes from a reconstructed decay | |
626 | Int_t ncs=GetNumberOfCascades(); | |
627 | for (Int_t n=0; n<ncs; n++) { | |
628 | AliESDcascade *cs=GetCascade(n); | |
629 | ||
630 | Int_t csIdxP=cs->GetPindex(); | |
631 | Int_t csIdxN=cs->GetNindex(); | |
632 | ||
633 | if (idxP==csIdxP) | |
634 | if (idxN==csIdxN) return kFALSE; | |
635 | ||
636 | if (csIdxP==lastIdxP) | |
637 | if (csIdxN==lastIdxN) used++; | |
638 | } | |
639 | ||
640 | //Replace the removed V0 with the last V0 | |
641 | TClonesArray &a=*fV0s; | |
642 | delete a.RemoveAt(rm); | |
643 | ||
644 | if (rm==last) return kTRUE; | |
645 | ||
646 | //v0 is pointing to the last V0 candidate... | |
647 | new (a[rm]) AliESDv0(*v0); | |
648 | delete a.RemoveAt(last); | |
649 | ||
650 | if (!used) return kTRUE; | |
651 | ||
652 | ||
653 | // Remap the indices of the daughters of reconstructed decays | |
654 | for (Int_t n=0; n<ncs; n++) { | |
655 | AliESDcascade *cs=GetCascade(n); | |
656 | ||
657 | ||
658 | Int_t csIdxP=cs->GetPindex(); | |
659 | Int_t csIdxN=cs->GetNindex(); | |
660 | ||
661 | if (csIdxP==lastIdxP) | |
662 | if (csIdxN==lastIdxN) { | |
663 | cs->AliESDv0::SetIndex(1,idxP); | |
664 | cs->AliESDv0::SetIndex(0,idxN); | |
665 | used--; | |
666 | if (!used) return kTRUE; | |
667 | } | |
668 | } | |
669 | ||
670 | return kTRUE; | |
671 | } | |
672 | ||
7d44c466 | 673 | Bool_t AliESDEvent::RemoveTrack(Int_t rm) const { |
d64bd07d | 674 | // --------------------------------------------------------- |
7f68891d | 675 | // Remove a track and references to it from ESD, |
676 | // if this track does not come from a reconstructed decay | |
d64bd07d | 677 | // --------------------------------------------------------- |
7f68891d | 678 | Int_t last=GetNumberOfTracks()-1; |
679 | if ((rm<0)||(rm>last)) return kFALSE; | |
680 | ||
681 | Int_t used=0; | |
d64bd07d | 682 | |
6fca035d | 683 | // Check if this track comes from the reconstructed primary vertices |
684 | if (fTPCVertex && fTPCVertex->GetStatus()) { | |
685 | UShort_t *primIdx=fTPCVertex->GetIndices(); | |
686 | Int_t n=fTPCVertex->GetNIndices(); | |
687 | while (n--) { | |
688 | Int_t idx=Int_t(primIdx[n]); | |
689 | if (rm==idx) return kFALSE; | |
690 | if (idx==last) used++; | |
691 | } | |
692 | } | |
693 | if (fPrimaryVertex && fPrimaryVertex->GetStatus()) { | |
694 | UShort_t *primIdx=fPrimaryVertex->GetIndices(); | |
695 | Int_t n=fPrimaryVertex->GetNIndices(); | |
696 | while (n--) { | |
697 | Int_t idx=Int_t(primIdx[n]); | |
698 | if (rm==idx) return kFALSE; | |
699 | if (idx==last) used++; | |
700 | } | |
701 | } | |
702 | ||
d64bd07d | 703 | // Check if this track comes from a reconstructed decay |
7f68891d | 704 | Int_t nv0=GetNumberOfV0s(); |
705 | for (Int_t n=0; n<nv0; n++) { | |
706 | AliESDv0 *v0=GetV0(n); | |
707 | ||
708 | Int_t idx=v0->GetNindex(); | |
709 | if (rm==idx) return kFALSE; | |
710 | if (idx==last) used++; | |
711 | ||
712 | idx=v0->GetPindex(); | |
713 | if (rm==idx) return kFALSE; | |
714 | if (idx==last) used++; | |
715 | } | |
716 | ||
717 | Int_t ncs=GetNumberOfCascades(); | |
718 | for (Int_t n=0; n<ncs; n++) { | |
719 | AliESDcascade *cs=GetCascade(n); | |
d64bd07d | 720 | |
7f68891d | 721 | Int_t idx=cs->GetIndex(); |
722 | if (rm==idx) return kFALSE; | |
723 | if (idx==last) used++; | |
fdbe4208 | 724 | |
725 | AliESDv0 *v0=cs; | |
726 | idx=v0->GetNindex(); | |
727 | if (rm==idx) return kFALSE; | |
728 | if (idx==last) used++; | |
729 | ||
730 | idx=v0->GetPindex(); | |
731 | if (rm==idx) return kFALSE; | |
732 | if (idx==last) used++; | |
7f68891d | 733 | } |
734 | ||
735 | Int_t nkn=GetNumberOfKinks(); | |
736 | for (Int_t n=0; n<nkn; n++) { | |
737 | AliESDkink *kn=GetKink(n); | |
738 | ||
739 | Int_t idx=kn->GetIndex(0); | |
740 | if (rm==idx) return kFALSE; | |
741 | if (idx==last) used++; | |
742 | ||
743 | idx=kn->GetIndex(1); | |
744 | if (rm==idx) return kFALSE; | |
745 | if (idx==last) used++; | |
746 | } | |
d64bd07d | 747 | |
8303b114 | 748 | // Check if this track is associated with a CaloCluster |
749 | Int_t ncl=GetNumberOfCaloClusters(); | |
750 | for (Int_t n=0; n<ncl; n++) { | |
751 | AliESDCaloCluster *cluster=GetCaloCluster(n); | |
752 | TArrayI *arr=cluster->GetTracksMatched(); | |
753 | Int_t s=arr->GetSize(); | |
754 | while (s--) { | |
755 | Int_t idx=arr->At(s); | |
756 | if (rm==idx) return kFALSE; | |
757 | if (idx==last) used++; | |
758 | } | |
759 | } | |
760 | ||
761 | ||
d64bd07d | 762 | |
7f68891d | 763 | //Replace the removed track with the last track |
764 | TClonesArray &a=*fTracks; | |
765 | delete a.RemoveAt(rm); | |
766 | ||
767 | if (rm==last) return kTRUE; | |
768 | ||
769 | AliESDtrack *t=GetTrack(last); | |
770 | t->SetID(rm); | |
771 | new (a[rm]) AliESDtrack(*t); | |
772 | delete a.RemoveAt(last); | |
773 | ||
6fca035d | 774 | |
7f68891d | 775 | if (!used) return kTRUE; |
776 | ||
777 | ||
6fca035d | 778 | // Remap the indices of the tracks used for the primary vertex reconstruction |
779 | if (fTPCVertex && fTPCVertex->GetStatus()) { | |
780 | UShort_t *primIdx=fTPCVertex->GetIndices(); | |
781 | Int_t n=fTPCVertex->GetNIndices(); | |
782 | while (n--) { | |
783 | Int_t idx=Int_t(primIdx[n]); | |
784 | if (idx==last) { | |
785 | primIdx[n]=Short_t(rm); | |
786 | used--; | |
787 | if (!used) return kTRUE; | |
788 | } | |
789 | } | |
790 | } | |
791 | if (fPrimaryVertex && fPrimaryVertex->GetStatus()) { | |
792 | UShort_t *primIdx=fPrimaryVertex->GetIndices(); | |
793 | Int_t n=fPrimaryVertex->GetNIndices(); | |
794 | while (n--) { | |
795 | Int_t idx=Int_t(primIdx[n]); | |
796 | if (idx==last) { | |
797 | primIdx[n]=Short_t(rm); | |
798 | used--; | |
799 | if (!used) return kTRUE; | |
800 | } | |
801 | } | |
802 | } | |
803 | ||
7f68891d | 804 | // Remap the indices of the daughters of reconstructed decays |
805 | for (Int_t n=0; n<nv0; n++) { | |
806 | AliESDv0 *v0=GetV0(n); | |
807 | if (v0->GetIndex(0)==last) { | |
808 | v0->SetIndex(0,rm); | |
809 | used--; | |
810 | if (!used) return kTRUE; | |
811 | } | |
812 | if (v0->GetIndex(1)==last) { | |
813 | v0->SetIndex(1,rm); | |
814 | used--; | |
815 | if (!used) return kTRUE; | |
816 | } | |
817 | } | |
818 | ||
819 | for (Int_t n=0; n<ncs; n++) { | |
820 | AliESDcascade *cs=GetCascade(n); | |
821 | if (cs->GetIndex()==last) { | |
822 | cs->SetIndex(rm); | |
823 | used--; | |
824 | if (!used) return kTRUE; | |
825 | } | |
fdbe4208 | 826 | AliESDv0 *v0=cs; |
827 | if (v0->GetIndex(0)==last) { | |
828 | v0->SetIndex(0,rm); | |
829 | used--; | |
830 | if (!used) return kTRUE; | |
831 | } | |
832 | if (v0->GetIndex(1)==last) { | |
833 | v0->SetIndex(1,rm); | |
834 | used--; | |
835 | if (!used) return kTRUE; | |
836 | } | |
7f68891d | 837 | } |
838 | ||
839 | for (Int_t n=0; n<nkn; n++) { | |
840 | AliESDkink *kn=GetKink(n); | |
841 | if (kn->GetIndex(0)==last) { | |
842 | kn->SetIndex(rm,0); | |
843 | used--; | |
844 | if (!used) return kTRUE; | |
845 | } | |
846 | if (kn->GetIndex(1)==last) { | |
847 | kn->SetIndex(rm,1); | |
848 | used--; | |
849 | if (!used) return kTRUE; | |
850 | } | |
851 | } | |
d64bd07d | 852 | |
8303b114 | 853 | // Remap the indices of the tracks accosicated with CaloClusters |
854 | for (Int_t n=0; n<ncl; n++) { | |
855 | AliESDCaloCluster *cluster=GetCaloCluster(n); | |
856 | TArrayI *arr=cluster->GetTracksMatched(); | |
857 | Int_t s=arr->GetSize(); | |
858 | while (s--) { | |
859 | Int_t idx=arr->At(s); | |
860 | if (idx==last) { | |
861 | arr->AddAt(rm,s); | |
862 | used--; | |
863 | if (!used) return kTRUE; | |
864 | } | |
865 | } | |
866 | } | |
867 | ||
d64bd07d | 868 | return kTRUE; |
869 | } | |
870 | ||
871 | ||
7f68891d | 872 | Bool_t AliESDEvent::Clean(Float_t *cleanPars) { |
873 | // | |
874 | // Remove the data which are not needed for the physics analysis. | |
875 | // | |
a023d8d8 | 876 | // 1) Cleaning the V0 candidates |
877 | // --------------------------- | |
878 | // If the cosine of the V0 pointing angle "csp" and | |
879 | // the DCA between the daughter tracks "dca" does not satisfy | |
880 | // the conditions | |
881 | // | |
882 | // csp > cleanPars[1] + dca/cleanPars[0]*(1.- cleanPars[1]) | |
883 | // | |
884 | // an attempt to remove this V0 candidate from ESD is made. | |
885 | // | |
886 | // The V0 candidate gets removed if it does not belong to any | |
887 | // recosntructed cascade decay | |
888 | // | |
889 | // 12.11.2007, optimal values: cleanPars[0]=0.5, cleanPars[1]=0.999 | |
890 | // | |
891 | // 2) Cleaning the tracks | |
892 | // ---------------------- | |
893 | // If track's transverse parameter is larger than cleanPars[2] | |
7f68891d | 894 | // OR |
a023d8d8 | 895 | // track's longitudinal parameter is larger than cleanPars[3] |
896 | // an attempt to remove this track from ESD is made. | |
7f68891d | 897 | // |
a023d8d8 | 898 | // The track gets removed if it does not come |
899 | // from a reconstructed decay | |
7f68891d | 900 | // |
a023d8d8 | 901 | Bool_t rc=kFALSE; |
902 | ||
903 | Float_t dcaMax=cleanPars[0]; | |
904 | Float_t cspMin=cleanPars[1]; | |
905 | ||
906 | Int_t nV0s=GetNumberOfV0s(); | |
907 | for (Int_t i=nV0s-1; i>=0; i--) { | |
908 | AliESDv0 *v0=GetV0(i); | |
909 | ||
910 | Float_t dca=v0->GetDcaV0Daughters(); | |
911 | Float_t csp=v0->GetV0CosineOfPointingAngle(); | |
912 | Float_t cspcut=cspMin + dca/dcaMax*(1.-cspMin); | |
449e752b | 913 | if (csp > cspcut) continue; |
914 | if (RemoveV0(i)) rc=kTRUE; | |
a023d8d8 | 915 | } |
916 | ||
7f68891d | 917 | |
a023d8d8 | 918 | Float_t dmax=cleanPars[2], zmax=cleanPars[3]; |
7f68891d | 919 | |
06cc9d95 | 920 | const AliESDVertex *vertex=GetPrimaryVertexSPD(); |
a023d8d8 | 921 | Bool_t vtxOK=vertex->GetStatus(); |
7f68891d | 922 | |
923 | Int_t nTracks=GetNumberOfTracks(); | |
924 | for (Int_t i=nTracks-1; i>=0; i--) { | |
925 | AliESDtrack *track=GetTrack(i); | |
926 | Float_t xy,z; track->GetImpactParameters(xy,z); | |
927 | if ((TMath::Abs(xy) > dmax) || (vtxOK && (TMath::Abs(z) > zmax))) { | |
928 | if (RemoveTrack(i)) rc=kTRUE; | |
929 | } | |
930 | } | |
931 | ||
932 | return rc; | |
933 | } | |
934 | ||
6dc21f57 | 935 | Char_t AliESDEvent::AddPileupVertexSPD(const AliESDVertex *vtx) |
04d01397 | 936 | { |
937 | // Add a pileup primary vertex reconstructed with SPD | |
938 | TClonesArray &ftr = *fSPDPileupVertices; | |
6dc21f57 | 939 | Char_t n=Char_t(ftr.GetEntriesFast()); |
940 | AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx); | |
941 | vertex->SetID(n); | |
942 | return n; | |
04d01397 | 943 | } |
944 | ||
6dc21f57 | 945 | Char_t AliESDEvent::AddPileupVertexTracks(const AliESDVertex *vtx) |
04d01397 | 946 | { |
947 | // Add a pileup primary vertex reconstructed with SPD | |
948 | TClonesArray &ftr = *fTrkPileupVertices; | |
6dc21f57 | 949 | Char_t n=Char_t(ftr.GetEntriesFast()); |
950 | AliESDVertex *vertex = new(ftr[n]) AliESDVertex(*vtx); | |
951 | vertex->SetID(n); | |
952 | return n; | |
04d01397 | 953 | } |
954 | ||
6989bff3 | 955 | Int_t AliESDEvent::AddTrack(const AliESDtrack *t) |
956 | { | |
af885e0f | 957 | // Add track |
958 | TClonesArray &ftr = *fTracks; | |
959 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(*t); | |
960 | track->SetID(fTracks->GetEntriesFast()-1); | |
961 | return track->GetID(); | |
962 | } | |
963 | ||
65a0cf79 | 964 | AliESDtrack* AliESDEvent::NewTrack() |
965 | { | |
966 | // Add a new track | |
967 | TClonesArray &ftr = *fTracks; | |
968 | AliESDtrack * track = new(ftr[fTracks->GetEntriesFast()])AliESDtrack(); | |
969 | track->SetID(fTracks->GetEntriesFast()-1); | |
970 | return track; | |
971 | } | |
972 | ||
6989bff3 | 973 | void AliESDEvent::AddMuonTrack(const AliESDMuonTrack *t) |
974 | { | |
f0106218 | 975 | TClonesArray &fmu = *fMuonTracks; |
976 | new(fmu[fMuonTracks->GetEntriesFast()]) AliESDMuonTrack(*t); | |
977 | } | |
978 | ||
6989bff3 | 979 | void AliESDEvent::AddPmdTrack(const AliESDPmdTrack *t) |
980 | { | |
f0106218 | 981 | TClonesArray &fpmd = *fPmdTracks; |
982 | new(fpmd[fPmdTracks->GetEntriesFast()]) AliESDPmdTrack(*t); | |
983 | } | |
984 | ||
6c8e0967 | 985 | void AliESDEvent::SetTrdTrigger(const AliESDTrdTrigger *t) |
986 | { | |
987 | *fTrdTrigger = *t; | |
988 | } | |
989 | ||
6989bff3 | 990 | void AliESDEvent::AddTrdTrack(const AliESDTrdTrack *t) |
991 | { | |
f0106218 | 992 | TClonesArray &ftrd = *fTrdTracks; |
993 | new(ftrd[fTrdTracks->GetEntriesFast()]) AliESDTrdTrack(*t); | |
994 | } | |
995 | ||
52cd0cc0 | 996 | void AliESDEvent::AddTrdTracklet(const AliESDTrdTracklet *trkl) |
997 | { | |
998 | new ((*fTrdTracklets)[fTrdTracklets->GetEntriesFast()]) AliESDTrdTracklet(*trkl); | |
999 | } | |
f0106218 | 1000 | |
6989bff3 | 1001 | Int_t AliESDEvent::AddKink(const AliESDkink *c) |
1002 | { | |
af885e0f | 1003 | // Add kink |
1004 | TClonesArray &fk = *fKinks; | |
1005 | AliESDkink * kink = new(fk[fKinks->GetEntriesFast()]) AliESDkink(*c); | |
1006 | kink->SetID(fKinks->GetEntriesFast()); // CKB different from the other imps.. | |
1007 | return fKinks->GetEntriesFast()-1; | |
1008 | } | |
1009 | ||
f0106218 | 1010 | |
6989bff3 | 1011 | void AliESDEvent::AddCascade(const AliESDcascade *c) |
1012 | { | |
f0106218 | 1013 | TClonesArray &fc = *fCascades; |
1014 | new(fc[fCascades->GetEntriesFast()]) AliESDcascade(*c); | |
1015 | } | |
1016 | ||
1017 | ||
6989bff3 | 1018 | Int_t AliESDEvent::AddCaloCluster(const AliESDCaloCluster *c) |
1019 | { | |
af885e0f | 1020 | // Add calocluster |
1021 | TClonesArray &fc = *fCaloClusters; | |
1022 | AliESDCaloCluster *clus = new(fc[fCaloClusters->GetEntriesFast()]) AliESDCaloCluster(*c); | |
1023 | clus->SetID(fCaloClusters->GetEntriesFast()-1); | |
1024 | return fCaloClusters->GetEntriesFast()-1; | |
1025 | } | |
1026 | ||
1027 | ||
7d44c466 | 1028 | void AliESDEvent::AddRawDataErrorLog(const AliRawDataErrorLog *log) const { |
6989bff3 | 1029 | TClonesArray &errlogs = *fErrorLogs; |
1030 | new(errlogs[errlogs.GetEntriesFast()]) AliRawDataErrorLog(*log); | |
1031 | } | |
f0106218 | 1032 | |
af6f24c9 | 1033 | void AliESDEvent::SetZDCData(AliESDZDC * obj) |
1034 | { | |
1035 | // use already allocated space | |
1036 | if(fESDZDC) | |
1037 | *fESDZDC = *obj; | |
1038 | } | |
1039 | ||
06cc9d95 | 1040 | void AliESDEvent::SetPrimaryVertexTPC(const AliESDVertex *vertex) |
1041 | { | |
1042 | // Set the TPC vertex | |
1043 | // use already allocated space | |
1044 | if(fTPCVertex){ | |
1045 | *fTPCVertex = *vertex; | |
1046 | fTPCVertex->SetName(fgkESDListName[kTPCVertex]); | |
1047 | } | |
1048 | } | |
1049 | ||
1050 | void AliESDEvent::SetPrimaryVertexSPD(const AliESDVertex *vertex) | |
6989bff3 | 1051 | { |
1052 | // Set the SPD vertex | |
60e8f114 | 1053 | // use already allocated space |
1054 | if(fSPDVertex){ | |
316c6cd9 | 1055 | *fSPDVertex = *vertex; |
6989bff3 | 1056 | fSPDVertex->SetName(fgkESDListName[kSPDVertex]); |
60e8f114 | 1057 | } |
1058 | } | |
1059 | ||
c264b61b | 1060 | void AliESDEvent::SetPrimaryVertexTracks(const AliESDVertex *vertex) |
6989bff3 | 1061 | { |
c264b61b | 1062 | // Set the primary vertex reconstructed using he ESD tracks. |
6989bff3 | 1063 | // use already allocated space |
60e8f114 | 1064 | if(fPrimaryVertex){ |
316c6cd9 | 1065 | *fPrimaryVertex = *vertex; |
6989bff3 | 1066 | fPrimaryVertex->SetName(fgkESDListName[kPrimaryVertex]); |
60e8f114 | 1067 | } |
1068 | } | |
1069 | ||
c264b61b | 1070 | const AliESDVertex * AliESDEvent::GetPrimaryVertex() const |
1071 | { | |
1072 | // | |
1073 | // Get the "best" available reconstructed primary vertex. | |
1074 | // | |
1075 | if(fPrimaryVertex){ | |
1076 | if (fPrimaryVertex->GetStatus()) return fPrimaryVertex; | |
1077 | } | |
1078 | if(fSPDVertex){ | |
1079 | if (fSPDVertex->GetStatus()) return fSPDVertex; | |
1080 | } | |
1081 | if(fTPCVertex) return fTPCVertex; | |
1082 | ||
1083 | AliWarning("No primary vertex available. Returning the \"default\"..."); | |
1084 | return fSPDVertex; | |
1085 | } | |
1086 | ||
518573d7 | 1087 | AliESDVertex * AliESDEvent::PrimaryVertexTracksUnconstrained() const |
1088 | { | |
1089 | // | |
1090 | // Removes diamond constraint from fPrimaryVertex (reconstructed with tracks) | |
1091 | // Returns a AliESDVertex which has to be deleted by the user | |
1092 | // | |
1093 | if(!fPrimaryVertex) { | |
1094 | AliWarning("No primary vertex from tracks available."); | |
1095 | return 0; | |
1096 | } | |
1097 | if(!fPrimaryVertex->GetStatus()) { | |
1098 | AliWarning("No primary vertex from tracks available."); | |
1099 | return 0; | |
1100 | } | |
1101 | ||
1102 | AliVertexerTracks vertexer(GetMagneticField()); | |
1103 | Float_t diamondxyz[3]={(Float_t)GetDiamondX(),(Float_t)GetDiamondY(),0.}; | |
1104 | Float_t diamondcovxy[3]; GetDiamondCovXY(diamondcovxy); | |
1105 | Float_t diamondcov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,7.}; | |
1106 | AliESDVertex *vertex = | |
1107 | (AliESDVertex*)vertexer.RemoveConstraintFromVertex(fPrimaryVertex,diamondxyz,diamondcov); | |
1108 | ||
1109 | return vertex; | |
1110 | } | |
1111 | ||
6989bff3 | 1112 | void AliESDEvent::SetMultiplicity(const AliMultiplicity *mul) |
1113 | { | |
1114 | // Set the SPD Multiplicity | |
f0106218 | 1115 | if(fSPDMult){ |
316c6cd9 | 1116 | *fSPDMult = *mul; |
f0106218 | 1117 | } |
1118 | } | |
1119 | ||
1120 | ||
6989bff3 | 1121 | void AliESDEvent::SetFMDData(AliESDFMD * obj) |
1122 | { | |
af885e0f | 1123 | // use already allocated space |
1124 | if(fESDFMD){ | |
316c6cd9 | 1125 | *fESDFMD = *obj; |
af885e0f | 1126 | } |
1127 | } | |
1128 | ||
6989bff3 | 1129 | void AliESDEvent::SetVZEROData(AliESDVZERO * obj) |
1130 | { | |
af885e0f | 1131 | // use already allocated space |
1132 | if(fESDVZERO) | |
6989bff3 | 1133 | *fESDVZERO = *obj; |
af885e0f | 1134 | } |
1135 | ||
b0e13b29 | 1136 | void AliESDEvent::SetTZEROData(AliESDTZERO * obj) |
1137 | { | |
1138 | // use already allocated space | |
1139 | if(fESDTZERO) | |
1140 | *fESDTZERO = *obj; | |
1141 | } | |
1142 | ||
820b4d9e | 1143 | #ifdef MFT_UPGRADE |
1144 | //void AliESDEvent::SetMFTData(AliESDMFT * obj) | |
1145 | //{ | |
1146 | // if(fESDMFT) | |
1147 | // *fESDMFT = *obj; | |
1148 | //} | |
1149 | #endif | |
1150 | ||
bd95bae7 | 1151 | void AliESDEvent::SetACORDEData(AliESDACORDE * obj) |
1152 | { | |
1153 | if(fESDACORDE) | |
1154 | *fESDACORDE = *obj; | |
1155 | } | |
1156 | ||
1157 | ||
6989bff3 | 1158 | void AliESDEvent::GetESDfriend(AliESDfriend *ev) const |
1159 | { | |
af885e0f | 1160 | // |
1161 | // Extracts the complementary info from the ESD | |
1162 | // | |
1163 | if (!ev) return; | |
1164 | ||
1165 | Int_t ntrk=GetNumberOfTracks(); | |
1166 | ||
1167 | for (Int_t i=0; i<ntrk; i++) { | |
80799a5f | 1168 | AliESDtrack *t=GetTrack(i); |
af885e0f | 1169 | const AliESDfriendTrack *f=t->GetFriendTrack(); |
1170 | ev->AddTrack(f); | |
80799a5f | 1171 | |
1172 | t->ReleaseESDfriendTrack();// Not to have two copies of "friendTrack" | |
1173 | ||
af885e0f | 1174 | } |
af885e0f | 1175 | |
b090e6a3 | 1176 | AliESDfriend *fr = (AliESDfriend*)(const_cast<AliESDEvent*>(this)->FindListObject("AliESDfriend")); |
1177 | if (fr) ev->SetVZEROfriend(fr->GetVZEROfriend()); | |
1178 | } | |
af885e0f | 1179 | |
1180 | void AliESDEvent::AddObject(TObject* obj) | |
1181 | { | |
1182 | // Add an object to the list of object. | |
1183 | // Please be aware that in order to increase performance you should | |
1184 | // refrain from using TObjArrays (if possible). Use TClonesArrays, instead. | |
1185 | fESDObjects->SetOwner(kTRUE); | |
1186 | fESDObjects->AddLast(obj); | |
1187 | } | |
1188 | ||
1189 | ||
1190 | void AliESDEvent::GetStdContent() | |
1191 | { | |
1192 | // set pointers for standard content | |
60e8f114 | 1193 | // get by name much safer and not a big overhead since not called very often |
1194 | ||
6989bff3 | 1195 | fESDRun = (AliESDRun*)fESDObjects->FindObject(fgkESDListName[kESDRun]); |
1196 | fHeader = (AliESDHeader*)fESDObjects->FindObject(fgkESDListName[kHeader]); | |
1197 | fESDZDC = (AliESDZDC*)fESDObjects->FindObject(fgkESDListName[kESDZDC]); | |
1198 | fESDFMD = (AliESDFMD*)fESDObjects->FindObject(fgkESDListName[kESDFMD]); | |
1199 | fESDVZERO = (AliESDVZERO*)fESDObjects->FindObject(fgkESDListName[kESDVZERO]); | |
1200 | fESDTZERO = (AliESDTZERO*)fESDObjects->FindObject(fgkESDListName[kESDTZERO]); | |
06cc9d95 | 1201 | fTPCVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kTPCVertex]); |
6989bff3 | 1202 | fSPDVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kSPDVertex]); |
1203 | fPrimaryVertex = (AliESDVertex*)fESDObjects->FindObject(fgkESDListName[kPrimaryVertex]); | |
1204 | fSPDMult = (AliMultiplicity*)fESDObjects->FindObject(fgkESDListName[kSPDMult]); | |
1205 | fPHOSTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kPHOSTrigger]); | |
1206 | fEMCALTrigger = (AliESDCaloTrigger*)fESDObjects->FindObject(fgkESDListName[kEMCALTrigger]); | |
04d01397 | 1207 | fSPDPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kSPDPileupVertices]); |
1208 | fTrkPileupVertices = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrkPileupVertices]); | |
6989bff3 | 1209 | fTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTracks]); |
1210 | fMuonTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kMuonTracks]); | |
1211 | fPmdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kPmdTracks]); | |
6c8e0967 | 1212 | fTrdTrigger = (AliESDTrdTrigger*)fESDObjects->FindObject(fgkESDListName[kTrdTrigger]); |
6989bff3 | 1213 | fTrdTracks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracks]); |
52cd0cc0 | 1214 | fTrdTracklets = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kTrdTracklets]); |
6989bff3 | 1215 | fV0s = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kV0s]); |
1216 | fCascades = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCascades]); | |
1217 | fKinks = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kKinks]); | |
1218 | fCaloClusters = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kCaloClusters]); | |
e649177a | 1219 | fEMCALCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kEMCALCells]); |
1220 | fPHOSCells = (AliESDCaloCells*)fESDObjects->FindObject(fgkESDListName[kPHOSCells]); | |
6989bff3 | 1221 | fErrorLogs = (TClonesArray*)fESDObjects->FindObject(fgkESDListName[kErrorLogs]); |
bd95bae7 | 1222 | fESDACORDE = (AliESDACORDE*)fESDObjects->FindObject(fgkESDListName[kESDACORDE]); |
f858b00e | 1223 | fTOFHeader = (AliTOFHeader*)fESDObjects->FindObject(fgkESDListName[kTOFHeader]); |
820b4d9e | 1224 | #ifdef MFT_UPGRADE |
1225 | // fESDMFT = (AliESDMFT*)fESDObjects->FindObject(fgkESDListName[kESDMFT]); | |
1226 | #endif | |
af885e0f | 1227 | } |
1228 | ||
1229 | void AliESDEvent::SetStdNames(){ | |
1230 | // Set the names of the standard contents | |
60e8f114 | 1231 | // |
102c56c8 | 1232 | if(fESDObjects->GetEntries()>=kESDListN){ |
1233 | for(int i = 0;i < fESDObjects->GetEntries() && i<kESDListN;i++){ | |
60e8f114 | 1234 | TObject *fObj = fESDObjects->At(i); |
1235 | if(fObj->InheritsFrom("TNamed")){ | |
6989bff3 | 1236 | ((TNamed*)fObj)->SetName(fgkESDListName[i]); |
60e8f114 | 1237 | } |
1238 | else if(fObj->InheritsFrom("TClonesArray")){ | |
6989bff3 | 1239 | ((TClonesArray*)fObj)->SetName(fgkESDListName[i]); |
60e8f114 | 1240 | } |
1241 | } | |
1242 | } | |
1243 | else{ | |
90e88950 | 1244 | AliWarning("Std Entries missing"); |
60e8f114 | 1245 | } |
af885e0f | 1246 | } |
1247 | ||
a2fbb067 | 1248 | |
1249 | void AliESDEvent::CreateStdContent(Bool_t bUseThisList){ | |
1250 | fUseOwnList = bUseThisList; | |
1251 | CreateStdContent(); | |
1252 | } | |
1253 | ||
af885e0f | 1254 | void AliESDEvent::CreateStdContent() |
1255 | { | |
1256 | // create the standard AOD content and set pointers | |
1257 | ||
1258 | // create standard objects and add them to the TList of objects | |
1259 | AddObject(new AliESDRun()); | |
1260 | AddObject(new AliESDHeader()); | |
1261 | AddObject(new AliESDZDC()); | |
1262 | AddObject(new AliESDFMD()); | |
1263 | AddObject(new AliESDVZERO()); | |
1264 | AddObject(new AliESDTZERO()); | |
1265 | AddObject(new AliESDVertex()); | |
1266 | AddObject(new AliESDVertex()); | |
06cc9d95 | 1267 | AddObject(new AliESDVertex()); |
af885e0f | 1268 | AddObject(new AliMultiplicity()); |
1269 | AddObject(new AliESDCaloTrigger()); | |
1270 | AddObject(new AliESDCaloTrigger()); | |
04d01397 | 1271 | AddObject(new TClonesArray("AliESDVertex",0)); |
1272 | AddObject(new TClonesArray("AliESDVertex",0)); | |
af885e0f | 1273 | AddObject(new TClonesArray("AliESDtrack",0)); |
1274 | AddObject(new TClonesArray("AliESDMuonTrack",0)); | |
1275 | AddObject(new TClonesArray("AliESDPmdTrack",0)); | |
6c8e0967 | 1276 | AddObject(new AliESDTrdTrigger()); |
af885e0f | 1277 | AddObject(new TClonesArray("AliESDTrdTrack",0)); |
52cd0cc0 | 1278 | AddObject(new TClonesArray("AliESDTrdTracklet",0)); |
af885e0f | 1279 | AddObject(new TClonesArray("AliESDv0",0)); |
1280 | AddObject(new TClonesArray("AliESDcascade",0)); | |
1281 | AddObject(new TClonesArray("AliESDkink",0)); | |
1282 | AddObject(new TClonesArray("AliESDCaloCluster",0)); | |
e649177a | 1283 | AddObject(new AliESDCaloCells()); |
1284 | AddObject(new AliESDCaloCells()); | |
af885e0f | 1285 | AddObject(new TClonesArray("AliRawDataErrorLog",0)); |
bd95bae7 | 1286 | AddObject(new AliESDACORDE()); |
f858b00e | 1287 | AddObject(new AliTOFHeader()); |
820b4d9e | 1288 | #ifdef MFT_UPGRADE |
1289 | //AddObject(new AliESDMFT()); | |
1290 | #endif | |
1291 | ||
af885e0f | 1292 | // check the order of the indices against enum... |
1293 | ||
af885e0f | 1294 | // set names |
1295 | SetStdNames(); | |
60e8f114 | 1296 | // read back pointers |
1297 | GetStdContent(); | |
af885e0f | 1298 | } |
1299 | ||
2811495d | 1300 | TObject* AliESDEvent::FindListObject(const char *name) const { |
7d44c466 | 1301 | // |
1302 | // Find object with name "name" in the list of branches | |
1303 | // | |
d7749dec | 1304 | if(fESDObjects){ |
1305 | return fESDObjects->FindObject(name); | |
1306 | } | |
001b9beb | 1307 | return 0; |
1308 | } | |
1309 | ||
cd1d4ee0 | 1310 | Int_t AliESDEvent::GetPHOSClusters(TRefArray *clusters) const |
1311 | { | |
1312 | // fills the provided TRefArray with all found phos clusters | |
e649177a | 1313 | |
cd1d4ee0 | 1314 | clusters->Clear(); |
e649177a | 1315 | |
cd1d4ee0 | 1316 | AliESDCaloCluster *cl = 0; |
1317 | for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { | |
e649177a | 1318 | |
1319 | if ( (cl = GetCaloCluster(i)) ) { | |
cd1d4ee0 | 1320 | if (cl->IsPHOS()){ |
1321 | clusters->Add(cl); | |
e649177a | 1322 | AliDebug(1,Form("IsPHOS cluster %d Size: %d \n",i,clusters->GetEntriesFast())); |
cd1d4ee0 | 1323 | } |
1324 | } | |
1325 | } | |
1326 | return clusters->GetEntriesFast(); | |
1327 | } | |
1328 | ||
1329 | Int_t AliESDEvent::GetEMCALClusters(TRefArray *clusters) const | |
1330 | { | |
e649177a | 1331 | // fills the provided TRefArray with all found emcal clusters |
cd1d4ee0 | 1332 | |
1333 | clusters->Clear(); | |
1334 | ||
1335 | AliESDCaloCluster *cl = 0; | |
1336 | for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) { | |
1337 | ||
e649177a | 1338 | if ( (cl = GetCaloCluster(i)) ) { |
cd1d4ee0 | 1339 | if (cl->IsEMCAL()){ |
1340 | clusters->Add(cl); | |
e649177a | 1341 | AliDebug(1,Form("IsEMCAL cluster %d Size: %d \n",i,clusters->GetEntriesFast())); |
cd1d4ee0 | 1342 | } |
1343 | } | |
1344 | } | |
1345 | return clusters->GetEntriesFast(); | |
1346 | } | |
1347 | ||
f12d42ce | 1348 | void AliESDEvent::WriteToTree(TTree* tree) const { |
38f940fb | 1349 | // Book the branches as in TTree::Branch(TCollection*) |
1350 | // but add a "." at the end of top level branches which are | |
1351 | // not a TClonesArray | |
1352 | ||
1353 | ||
1354 | TString branchname; | |
1355 | TIter next(fESDObjects); | |
7d44c466 | 1356 | const Int_t kSplitlevel = 99; // default value in TTree::Branch() |
1357 | const Int_t kBufsize = 32000; // default value in TTree::Branch() | |
38f940fb | 1358 | TObject *obj = 0; |
1359 | ||
1360 | while ((obj = next())) { | |
1361 | branchname.Form("%s", obj->GetName()); | |
32ba9c61 | 1362 | if(branchname.CompareTo("AliESDfriend")==0)branchname = "ESDfriend."; |
7d44c466 | 1363 | if ((kSplitlevel > 1) && !obj->InheritsFrom(TClonesArray::Class())) { |
732a24fe | 1364 | if(!branchname.EndsWith("."))branchname += "."; |
38f940fb | 1365 | } |
102c56c8 | 1366 | if (!tree->FindBranch(branchname)) { |
771c4f86 | 1367 | // For the custom streamer to be called splitlevel |
1368 | // has to be negative, only needed for HLT | |
1369 | Int_t splitLevel = (TString(obj->ClassName()) == "AliHLTGlobalTriggerDecision") ? -1 : kSplitlevel - 1; | |
1370 | tree->Bronch(branchname, obj->ClassName(), fESDObjects->GetObjectRef(obj),kBufsize, splitLevel); | |
102c56c8 | 1371 | } |
38f940fb | 1372 | } |
38f940fb | 1373 | } |
1374 | ||
cd1d4ee0 | 1375 | |
f7ec3414 | 1376 | void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){ |
7d44c466 | 1377 | // |
1378 | // Connect the ESDEvent to a tree | |
1379 | // | |
6989bff3 | 1380 | if(!tree){ |
90e88950 | 1381 | AliWarning("AliESDEvent::ReadFromTree() Zero Pointer to Tree \n"); |
6989bff3 | 1382 | return; |
1383 | } | |
024c7734 | 1384 | // load the TTree |
6989bff3 | 1385 | if(!tree->GetTree())tree->LoadTree(0); |
024c7734 | 1386 | |
001b9beb | 1387 | // if we find the "ESD" branch on the tree we do have the old structure |
1bd10080 | 1388 | if(tree->GetBranch("ESD")) { |
1389 | char ** address = (char **)(tree->GetBranch("ESD")->GetAddress()); | |
0eb6eb59 | 1390 | // do we have the friend branch |
1391 | TBranch * esdFB = tree->GetBranch("ESDfriend."); | |
1392 | char ** addressF = 0; | |
1393 | if(esdFB)addressF = (char **)(esdFB->GetAddress()); | |
6989bff3 | 1394 | if (!address) { |
90e88950 | 1395 | AliInfo("AliESDEvent::ReadFromTree() Reading old Tree"); |
1bd10080 | 1396 | tree->SetBranchAddress("ESD", &fESDOld); |
0eb6eb59 | 1397 | if(esdFB){ |
1398 | tree->SetBranchAddress("ESDfriend.",&fESDFriendOld); | |
1399 | } | |
6989bff3 | 1400 | } else { |
90e88950 | 1401 | AliInfo("AliESDEvent::ReadFromTree() Reading old Tree"); |
1402 | AliInfo("Branch already connected. Using existing branch address."); | |
1bd10080 | 1403 | fESDOld = (AliESD*) (*address); |
0eb6eb59 | 1404 | // addressF can still be 0, since branch needs to switched on |
1405 | if(addressF)fESDFriendOld = (AliESDfriend*) (*addressF); | |
6989bff3 | 1406 | } |
0eb6eb59 | 1407 | |
6989bff3 | 1408 | // have already connected the old ESD structure... ? |
1409 | // reuse also the pointer of the AlliESDEvent | |
1410 | // otherwise create new ones | |
6989bff3 | 1411 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
1412 | ||
1413 | if(connectedList){ | |
1414 | // If connected use the connected list of objects | |
0eb6eb59 | 1415 | if(fESDObjects!= connectedList){ |
1416 | // protect when called twice | |
1417 | fESDObjects->Delete(); | |
1418 | fESDObjects = connectedList; | |
1419 | } | |
6989bff3 | 1420 | GetStdContent(); |
0eb6eb59 | 1421 | |
0eb6eb59 | 1422 | |
d7749dec | 1423 | // The pointer to the friend changes when called twice via InitIO |
1424 | // since AliESDEvent is deleted | |
0eb6eb59 | 1425 | TObject* oldf = FindListObject("AliESDfriend"); |
1426 | TObject* newf = 0; | |
1427 | if(addressF){ | |
1428 | newf = (TObject*)*addressF; | |
1429 | } | |
1430 | if(newf!=0&&oldf!=newf){ | |
1431 | // remove the old reference | |
1432 | // Should we also delete it? Or is this handled in TTree I/O | |
1433 | // since it is created by the first SetBranchAddress | |
1434 | fESDObjects->Remove(oldf); | |
1435 | // add the new one | |
1436 | fESDObjects->Add(newf); | |
1437 | } | |
1438 | ||
6989bff3 | 1439 | fConnected = true; |
b93c2026 | 1440 | return; |
6989bff3 | 1441 | } |
1442 | // else... | |
1443 | CreateStdContent(); // create for copy | |
0eb6eb59 | 1444 | // if we have the esdfriend add it, so we always can access it via the userinfo |
1445 | if(fESDFriendOld)AddObject(fESDFriendOld); | |
6989bff3 | 1446 | // we are not owner of the list objects |
1447 | // must not delete it | |
efea3f54 | 1448 | fESDObjects->SetOwner(kTRUE); |
6989bff3 | 1449 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
1450 | tree->GetUserInfo()->Add(fESDObjects); | |
1451 | fConnected = true; | |
1452 | return; | |
af885e0f | 1453 | } |
0eb6eb59 | 1454 | |
732a24fe | 1455 | |
1456 | delete fESDOld; | |
1457 | fESDOld = 0; | |
af885e0f | 1458 | // Try to find AliESDEvent |
1459 | AliESDEvent *esdEvent = 0; | |
1460 | esdEvent = (AliESDEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliESDEvent"); | |
001b9beb | 1461 | if(esdEvent){ |
941603c0 | 1462 | // Check if already connected to tree |
efea3f54 | 1463 | esdEvent->Reset(); |
139f2194 | 1464 | TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree")); |
f7ec3414 | 1465 | |
1466 | ||
1467 | if (connectedList && (strcmp(opt, "reconnect"))) { | |
139f2194 | 1468 | // If connected use the connected list if objects |
1469 | fESDObjects->Delete(); | |
b5bc83df | 1470 | fESDObjects = connectedList; |
1471 | GetStdContent(); | |
60e8f114 | 1472 | fConnected = true; |
139f2194 | 1473 | return; |
1474 | } | |
732a24fe | 1475 | |
139f2194 | 1476 | // Connect to tree |
001b9beb | 1477 | // prevent a memory leak when reading back the TList |
28a79204 | 1478 | // if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete(); |
f7ec3414 | 1479 | |
a2fbb067 | 1480 | if(!fUseOwnList){ |
a2fbb067 | 1481 | // create a new TList from the UserInfo TList... |
1482 | // copy constructor does not work... | |
1483 | fESDObjects = (TList*)(esdEvent->GetList()->Clone()); | |
efea3f54 | 1484 | fESDObjects->SetOwner(kTRUE); |
a2fbb067 | 1485 | } |
1486 | else if ( fESDObjects->GetEntries()==0){ | |
1487 | // at least create the std content if we want to read to our list | |
1488 | CreateStdContent(); | |
1489 | } | |
732a24fe | 1490 | |
1491 | // in principle | |
1492 | // we only need new things in the list if we do no already have it.. | |
1493 | // TODO just add new entries | |
1494 | ||
af885e0f | 1495 | if(fESDObjects->GetEntries()<kESDListN){ |
90e88950 | 1496 | AliWarning(Form("AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n", |
1497 | fESDObjects->GetEntries(),kESDListN)); | |
af885e0f | 1498 | } |
1499 | // set the branch addresses | |
1500 | TIter next(fESDObjects); | |
1501 | TNamed *el; | |
1502 | while((el=(TNamed*)next())){ | |
1503 | TString bname(el->GetName()); | |
af885e0f | 1504 | if(bname.CompareTo("AliESDfriend")==0) |
1505 | { | |
1506 | // AliESDfriend does not have a name ... | |
4453d900 | 1507 | TBranch *br = tree->GetBranch("ESDfriend."); |
588195ca | 1508 | if (br) tree->SetBranchAddress("ESDfriend.",fESDObjects->GetObjectRef(el)); |
af885e0f | 1509 | } |
1510 | else{ | |
38f940fb | 1511 | // check if branch exists under this Name |
1512 | TBranch *br = tree->GetBranch(bname.Data()); | |
1513 | if(br){ | |
1514 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
1515 | } | |
1516 | else{ | |
1517 | br = tree->GetBranch(Form("%s.",bname.Data())); | |
1518 | if(br){ | |
1519 | tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el)); | |
1520 | } | |
1521 | else{ | |
90e88950 | 1522 | AliWarning(Form("AliESDEvent::ReadFromTree() No Branch found with Name %s or %s.",bname.Data(),bname.Data())); |
38f940fb | 1523 | } |
1524 | ||
1525 | } | |
af885e0f | 1526 | } |
1527 | } | |
1528 | GetStdContent(); | |
1529 | // when reading back we are not owner of the list | |
1530 | // must not delete it | |
efea3f54 | 1531 | fESDObjects->SetOwner(kTRUE); |
60e8f114 | 1532 | fESDObjects->SetName("ESDObjectsConnectedToTree"); |
139f2194 | 1533 | // we are not owner of the list objects |
1534 | // must not delete it | |
60e8f114 | 1535 | tree->GetUserInfo()->Add(fESDObjects); |
efea3f54 | 1536 | tree->GetUserInfo()->SetOwner(kFALSE); |
60e8f114 | 1537 | fConnected = true; |
efea3f54 | 1538 | }// no esdEvent --> |
af885e0f | 1539 | else { |
001b9beb | 1540 | // we can't get the list from the user data, create standard content |
1541 | // and set it by hand (no ESDfriend at the moment | |
af885e0f | 1542 | CreateStdContent(); |
1543 | TIter next(fESDObjects); | |
1544 | TNamed *el; | |
1545 | while((el=(TNamed*)next())){ | |
1546 | TString bname(el->GetName()); | |
732a24fe | 1547 | TBranch *br = tree->GetBranch(bname.Data()); |
1548 | if(br){ | |
1549 | tree->SetBranchAddress(bname.Data(),fESDObjects->GetObjectRef(el)); | |
1550 | } | |
1551 | else{ | |
1552 | br = tree->GetBranch(Form("%s.",bname.Data())); | |
1553 | if(br){ | |
1554 | tree->SetBranchAddress(Form("%s.",bname.Data()),fESDObjects->GetObjectRef(el)); | |
1555 | } | |
1556 | } | |
af885e0f | 1557 | } |
1558 | GetStdContent(); | |
1559 | // when reading back we are not owner of the list | |
1560 | // must not delete it | |
316cf4cc | 1561 | fESDObjects->SetOwner(kTRUE); |
af885e0f | 1562 | } |
af885e0f | 1563 | } |
1564 | ||
1565 | ||
1566 | void AliESDEvent::CopyFromOldESD() | |
1567 | { | |
1568 | // Method which copies over everthing from the old esd structure to the | |
1569 | // new | |
af885e0f | 1570 | if(fESDOld){ |
1571 | ResetStdContent(); | |
1572 | // Run | |
1573 | SetRunNumber(fESDOld->GetRunNumber()); | |
1574 | SetPeriodNumber(fESDOld->GetPeriodNumber()); | |
6ca8842a | 1575 | SetMagneticField(fESDOld->GetMagneticField()); |
af885e0f | 1576 | |
1577 | // leave out diamond ... | |
1578 | // SetDiamond(const AliESDVertex *vertex) { fESDRun->SetDiamond(vertex);} | |
1579 | ||
1580 | // header | |
1581 | SetTriggerMask(fESDOld->GetTriggerMask()); | |
1582 | SetOrbitNumber(fESDOld->GetOrbitNumber()); | |
1583 | SetTimeStamp(fESDOld->GetTimeStamp()); | |
1584 | SetEventType(fESDOld->GetEventType()); | |
1585 | SetEventNumberInFile(fESDOld->GetEventNumberInFile()); | |
1586 | SetBunchCrossNumber(fESDOld->GetBunchCrossNumber()); | |
1587 | SetTriggerCluster(fESDOld->GetTriggerCluster()); | |
1588 | ||
1589 | // ZDC | |
1590 | ||
1591 | SetZDC(fESDOld->GetZDCN1Energy(), | |
a85132e7 | 1592 | fESDOld->GetZDCP1Energy(), |
1593 | fESDOld->GetZDCEMEnergy(), | |
1594 | 0, | |
1595 | fESDOld->GetZDCN2Energy(), | |
1596 | fESDOld->GetZDCP2Energy(), | |
2b6cdc43 | 1597 | fESDOld->GetZDCParticipants(), |
5f0ec064 | 1598 | 0, |
1599 | 0, | |
1600 | 0, | |
1601 | 0, | |
1602 | 0, | |
2b6cdc43 | 1603 | 0); |
af885e0f | 1604 | |
1605 | // FMD | |
1606 | ||
cb6aa27f | 1607 | if(fESDOld->GetFMDData())SetFMDData(fESDOld->GetFMDData()); |
af885e0f | 1608 | |
1609 | // T0 | |
1610 | ||
1611 | SetT0zVertex(fESDOld->GetT0zVertex()); | |
1612 | SetT0(fESDOld->GetT0()); | |
1613 | // leave amps out | |
1614 | ||
1615 | // VZERO | |
c06eaba2 | 1616 | if (fESDOld->GetVZEROData()) SetVZEROData(fESDOld->GetVZEROData()); |
af885e0f | 1617 | |
06cc9d95 | 1618 | if(fESDOld->GetVertex())SetPrimaryVertexSPD(fESDOld->GetVertex()); |
af885e0f | 1619 | |
c264b61b | 1620 | if(fESDOld->GetPrimaryVertex())SetPrimaryVertexTracks(fESDOld->GetPrimaryVertex()); |
af885e0f | 1621 | |
cb6aa27f | 1622 | if(fESDOld->GetMultiplicity())SetMultiplicity(fESDOld->GetMultiplicity()); |
1bd10080 | 1623 | |
af885e0f | 1624 | for(int i = 0;i<fESDOld->GetNumberOfTracks();i++){ |
1625 | AddTrack(fESDOld->GetTrack(i)); | |
1626 | } | |
1627 | ||
1628 | for(int i = 0;i<fESDOld->GetNumberOfMuonTracks();i++){ | |
1629 | AddMuonTrack(fESDOld->GetMuonTrack(i)); | |
1630 | } | |
1631 | ||
1632 | for(int i = 0;i<fESDOld->GetNumberOfPmdTracks();i++){ | |
1633 | AddPmdTrack(fESDOld->GetPmdTrack(i)); | |
1634 | } | |
1635 | ||
1636 | for(int i = 0;i<fESDOld->GetNumberOfTrdTracks();i++){ | |
1637 | AddTrdTrack(fESDOld->GetTrdTrack(i)); | |
1638 | } | |
1639 | ||
1640 | for(int i = 0;i<fESDOld->GetNumberOfV0s();i++){ | |
1641 | AddV0(fESDOld->GetV0(i)); | |
1642 | } | |
1643 | ||
1644 | for(int i = 0;i<fESDOld->GetNumberOfCascades();i++){ | |
1645 | AddCascade(fESDOld->GetCascade(i)); | |
1646 | } | |
1647 | ||
1648 | for(int i = 0;i<fESDOld->GetNumberOfKinks();i++){ | |
1649 | AddKink(fESDOld->GetKink(i)); | |
1650 | } | |
1651 | ||
1652 | ||
1653 | for(int i = 0;i<fESDOld->GetNumberOfCaloClusters();i++){ | |
1654 | AddCaloCluster(fESDOld->GetCaloCluster(i)); | |
1655 | } | |
820b4d9e | 1656 | |
1657 | #ifdef MFT_UPGRADE | |
1658 | // MFT | |
1659 | // if (fESDOld->GetMFTData()) SetMFTData(fESDOld->GetMFTData()); | |
1660 | #endif | |
1bd10080 | 1661 | |
af885e0f | 1662 | }// if fesdold |
1663 | } | |
1664 | ||
2a3dfb14 | 1665 | Bool_t AliESDEvent::IsEventSelected(const char *trigExpr) const |
1666 | { | |
1667 | // Check if the event satisfies the trigger | |
1668 | // selection expression trigExpr. | |
1669 | // trigExpr can be any logical expression | |
1670 | // of the trigger classes defined in AliESDRun | |
1671 | // In case of wrong syntax return kTRUE. | |
1672 | ||
1673 | TString expr(trigExpr); | |
1674 | if (expr.IsNull()) return kTRUE; | |
1675 | ||
1676 | ULong64_t mask = GetTriggerMask(); | |
1677 | for(Int_t itrig = 0; itrig < AliESDRun::kNTriggerClasses; itrig++) { | |
1678 | if (mask & (1ull << itrig)) { | |
1679 | expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"1"); | |
1680 | } | |
1681 | else { | |
1682 | expr.ReplaceAll(GetESDRun()->GetTriggerClass(itrig),"0"); | |
1683 | } | |
1684 | } | |
1685 | ||
1686 | Int_t error; | |
1687 | if ((gROOT->ProcessLineFast(expr.Data(),&error) == 0) && | |
1688 | (error == TInterpreter::kNoError)) { | |
1689 | return kFALSE; | |
1690 | } | |
1691 | ||
1692 | return kTRUE; | |
1693 | ||
1694 | } | |
1695 | ||
3b286f80 | 1696 | TObject* AliESDEvent::GetHLTTriggerDecision() const |
1697 | { | |
1698 | // get the HLT trigger decission object | |
1699 | ||
1700 | // cast away const'nes because the FindListObject method | |
1701 | // is not const | |
1702 | AliESDEvent* pNonConst=const_cast<AliESDEvent*>(this); | |
1703 | return pNonConst->FindListObject("HLTGlobalTrigger"); | |
1704 | } | |
1705 | ||
1706 | TString AliESDEvent::GetHLTTriggerDescription() const | |
1707 | { | |
1708 | // get the HLT trigger decission description | |
1709 | TString description; | |
1710 | TObject* pDecision=GetHLTTriggerDecision(); | |
1711 | if (pDecision) { | |
1712 | description=pDecision->GetTitle(); | |
1713 | } | |
1714 | ||
1715 | return description; | |
1716 | } | |
1717 | ||
1718 | Bool_t AliESDEvent::IsHLTTriggerFired(const char* name) const | |
1719 | { | |
1720 | // get the HLT trigger decission description | |
1721 | TObject* pDecision=GetHLTTriggerDecision(); | |
1722 | if (!pDecision) return kFALSE; | |
1723 | ||
1724 | Option_t* option=pDecision->GetOption(); | |
1725 | if (option==NULL || *option!='1') return kFALSE; | |
1726 | ||
1727 | if (name) { | |
1728 | TString description=GetHLTTriggerDescription(); | |
1729 | Int_t index=description.Index(name); | |
1730 | if (index<0) return kFALSE; | |
1731 | index+=strlen(name); | |
1732 | if (index>=description.Length()) return kFALSE; | |
1733 | if (description[index]!=0 && description[index]!=' ') return kFALSE; | |
1734 | } | |
1735 | return kTRUE; | |
1736 | } | |
af885e0f | 1737 | |
a98c78e5 | 1738 | //______________________________________________________________________________ |
1739 | Bool_t AliESDEvent::IsPileupFromSPD(Int_t minContributors, | |
1740 | Double_t minZdist, | |
1741 | Double_t nSigmaZdist, | |
1742 | Double_t nSigmaDiamXY, | |
1743 | Double_t nSigmaDiamZ) const{ | |
e741cb7c | 1744 | // |
1745 | // This function checks if there was a pile up | |
1746 | // reconstructed with SPD | |
1747 | // | |
e741cb7c | 1748 | Int_t nc1=fSPDVertex->GetNContributors(); |
1749 | if(nc1<1) return kFALSE; | |
1750 | Int_t nPileVert=GetNumberOfPileupVerticesSPD(); | |
1751 | if(nPileVert==0) return kFALSE; | |
a98c78e5 | 1752 | |
e741cb7c | 1753 | for(Int_t i=0; i<nPileVert;i++){ |
1754 | const AliESDVertex* pv=GetPileupVertexSPD(i); | |
e741cb7c | 1755 | Int_t nc2=pv->GetNContributors(); |
a98c78e5 | 1756 | if(nc2>=minContributors){ |
1757 | Double_t z1=fSPDVertex->GetZ(); | |
1758 | Double_t z2=pv->GetZ(); | |
1759 | Double_t distZ=TMath::Abs(z2-z1); | |
1760 | Double_t distZdiam=TMath::Abs(z2-GetDiamondZ()); | |
569d954c | 1761 | Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ()); |
a98c78e5 | 1762 | if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information |
1763 | if(distZ>minZdist && distZdiam<cutZdiam){ | |
1764 | Double_t x2=pv->GetX(); | |
1765 | Double_t y2=pv->GetY(); | |
1766 | Double_t distXdiam=TMath::Abs(x2-GetDiamondX()); | |
1767 | Double_t distYdiam=TMath::Abs(y2-GetDiamondY()); | |
1768 | Double_t cov1[6],cov2[6]; | |
1769 | fSPDVertex->GetCovarianceMatrix(cov1); | |
1770 | pv->GetCovarianceMatrix(cov2); | |
1771 | Double_t errxDist=TMath::Sqrt(cov2[0]+GetSigma2DiamondX()); | |
1772 | Double_t erryDist=TMath::Sqrt(cov2[2]+GetSigma2DiamondY()); | |
1773 | Double_t errzDist=TMath::Sqrt(cov1[5]+cov2[5]); | |
1774 | Double_t cutXdiam=nSigmaDiamXY*errxDist; | |
1775 | if(GetSigma2DiamondX()<0.0001)cutXdiam=99999.; //protection for missing diamond information | |
1776 | Double_t cutYdiam=nSigmaDiamXY*erryDist; | |
1777 | if(GetSigma2DiamondY()<0.0001)cutYdiam=99999.; //protection for missing diamond information | |
1778 | if( (distXdiam<cutXdiam) && (distYdiam<cutYdiam) && (distZ>nSigmaZdist*errzDist) ){ | |
1779 | return kTRUE; | |
1780 | } | |
1781 | } | |
e741cb7c | 1782 | } |
e741cb7c | 1783 | } |
a98c78e5 | 1784 | return kFALSE; |
1785 | } | |
e741cb7c | 1786 | |
4ace6760 | 1787 | //______________________________________________________________________________ |
1788 | void AliESDEvent::EstimateMultiplicity(Int_t &tracklets, Int_t &trITSTPC, Int_t &trITSSApure, Double_t eta, Bool_t useDCAFlag,Bool_t useV0Flag) const | |
1789 | { | |
1790 | // | |
1791 | // calculates 3 estimators for the multiplicity in the -eta:eta range | |
1792 | // tracklets : using SPD tracklets only | |
1793 | // trITSTPC : using TPC/ITS + complementary ITS SA tracks + tracklets from clusters not used by tracks | |
1794 | // trITSSApure : using ITS standalone tracks + tracklets from clusters not used by tracks | |
1795 | // if useDCAFlag is true: account for the ESDtrack flag marking the tracks with large DCA | |
1796 | // if useV0Flag is true: account for the ESDtrack flag marking conversion and K0's V0s | |
1797 | tracklets = trITSSApure = trITSTPC = 0; | |
1798 | int ntr = fSPDMult ? fSPDMult->GetNumberOfTracklets() : 0; | |
1799 | // | |
1800 | // count tracklets | |
1801 | for (int itr=ntr;itr--;) { | |
1802 | if (TMath::Abs(fSPDMult->GetEta(itr))>eta) continue; | |
1803 | tracklets++; | |
1804 | if (fSPDMult->FreeClustersTracklet(itr,0)) trITSTPC++; // not used in ITS/TPC or ITS_SA track | |
1805 | if (fSPDMult->FreeClustersTracklet(itr,1)) trITSSApure++; // not used in ITS_SA_Pure track | |
1806 | } | |
1807 | // | |
1808 | // count real tracks | |
1809 | ntr = GetNumberOfTracks(); | |
1810 | for (int itr=ntr;itr--;) { | |
1811 | AliESDtrack *t = GetTrack(itr); | |
1812 | if (TMath::Abs(t->Eta())>eta) continue; | |
1813 | if (!t->IsOn(AliESDtrack::kITSin)) continue; | |
1814 | if (useDCAFlag && t->IsOn(AliESDtrack::kMultSec)) continue; | |
1815 | if (useV0Flag && t->IsOn(AliESDtrack::kMultInV0)) continue; | |
1816 | if (t->IsOn(AliESDtrack::kITSpureSA)) trITSSApure++; | |
1817 | else trITSTPC++; | |
1818 | } | |
1819 | // | |
1820 | } | |
b46ff4b0 | 1821 | |
1822 | Bool_t AliESDEvent::IsPileupFromSPDInMultBins() const { | |
1823 | Int_t nTracklets=GetMultiplicity()->GetNumberOfTracklets(); | |
1824 | if(nTracklets<20) return IsPileupFromSPD(3,0.8); | |
1825 | else if(nTracklets<50) return IsPileupFromSPD(4,0.8); | |
1826 | else return IsPileupFromSPD(5,0.8); | |
1827 | } | |
1828 | ||
f858b00e | 1829 | void AliESDEvent::SetTOFHeader(const AliTOFHeader *header) |
1830 | { | |
1831 | // | |
1832 | // Set the TOF event_time | |
1833 | // | |
1834 | ||
1835 | if (fTOFHeader) { | |
1836 | *fTOFHeader=*header; | |
1837 | //fTOFHeader->SetName(fgkESDListName[kTOFHeader]); | |
1838 | } | |
1839 | else { | |
1840 | // for analysis of reconstructed events | |
1841 | // when this information is not avaliable | |
1842 | fTOFHeader = new AliTOFHeader(*header); | |
1843 | //AddObject(fTOFHeader); | |
1844 | } | |
1845 | ||
1846 | } | |
cb62947d | 1847 | |
fba4b2e2 | 1848 | AliCentrality* AliESDEvent::GetCentrality() |
cb62947d | 1849 | { |
fba4b2e2 | 1850 | if (!fCentrality) fCentrality = new AliCentrality(); |
cb62947d | 1851 | return fCentrality; |
1852 | } | |
ce7adfe9 | 1853 | |
1854 | AliEventplane* AliESDEvent::GetEventplane() | |
1855 | { | |
1856 | if (!fEventplane) fEventplane = new AliEventplane(); | |
1857 | return fEventplane; | |
1858 | } |