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