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