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