AliRoot Core  ee782a0 (ee782a0)
AliAODEvent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 #include <TROOT.h>
19 #include <TTree.h>
20 #include <TFolder.h>
21 #include <TFriendElement.h>
22 #include <TProcessID.h>
23 #include <TCollection.h>
24 #include "Riostream.h"
25 #include "AliAODEvent.h"
26 #include "AliAODHeader.h"
27 #include "AliAODTrack.h"
28 #include "AliAODDimuon.h"
29 #include "AliAODTrdTrack.h"
30 #include "event.h"
31 
32 ClassImp(AliAODEvent)
33 
34 // definition of std AOD member names
35  const char* AliAODEvent::fAODListName[kAODListN] = {"header",
36  "tracks",
37  "vertices",
38  "v0s",
39  "cascades",
40  "tracklets",
41  "jets",
42  "emcalCells",
43  "phosCells",
44  "caloClusters",
45  "emcalTrigger",
46  "phosTrigger",
47  "fmdClusters",
48  "pmdClusters",
49  "hmpidRings",
50  "dimuons",
51  "AliAODTZERO",
52  "AliAODVZERO",
53  "AliAODZDC",
54  "AliAODAD",
55  "AliTOFHeader",
56  "trdTracks"
57 
58 };
59 //______________________________________________________________________________
61  AliVEvent(),
62  fAODObjects(0),
63  fAODFolder(0),
64  fConnected(kFALSE),
65  fTracksConnected(kFALSE),
66  fHeader(0),
67  fTracks(0),
68  fVertices(0),
69  fV0s(0),
70  fCascades(0),
71  fTracklets(0),
72  fJets(0),
73  fEmcalCells(0),
74  fPhosCells(0),
75  fCaloClusters(0),
76  fEMCALTrigger(0),
77  fPHOSTrigger(0),
78  fFmdClusters(0),
79  fPmdClusters(0),
80  fHMPIDrings(0),
81  fDimuons(0),
82  fAODTZERO(0),
83  fAODVZERO(0),
84  fAODZDC(0),
85  fAODAD(0),
86  fTOFHeader(0),
87  fTrdTracks(0)
88 {
90 
91  if (TClass::IsCallingNew() != TClass::kDummyNew) fAODObjects = new TList();
92 }
93 
94 //______________________________________________________________________________
96  AliVEvent(aod),
97  fAODObjects(new TList()),
98  fAODFolder(0),
99  fConnected(kFALSE),
100  fTracksConnected(kFALSE),
101  // fHeader(new AliAODHeader(*aod.fHeader)),
102  fHeader(0),
103  fTracks(new TClonesArray(*aod.fTracks)),
104  fVertices(new TClonesArray(*aod.fVertices)),
105  fV0s(new TClonesArray(*aod.fV0s)),
106  fCascades(new TClonesArray(*aod.fCascades)),
108  fJets(new TClonesArray(*aod.fJets)),
111  fCaloClusters(new TClonesArray(*aod.fCaloClusters)),
114  fFmdClusters(new TClonesArray(*aod.fFmdClusters)),
115  fPmdClusters(new TClonesArray(*aod.fPmdClusters)),
116  fHMPIDrings(new TClonesArray(*aod.fHMPIDrings)),
117  fDimuons(new TClonesArray(*aod.fDimuons)),
118  fAODTZERO(new AliAODTZERO(*aod.fAODTZERO)),
119  fAODVZERO(new AliAODVZERO(*aod.fAODVZERO)),
120  fAODZDC(new AliAODZDC(*aod.fAODZDC)),
121  fAODAD(new AliAODAD(*aod.fAODAD)),
123  fTrdTracks(new TClonesArray(*aod.fTrdTracks))
124 {
126 
131  AddObject(fV0s);
134  AddObject(fJets);
147  AddObject(fAODAD);
150  fConnected = aod.fConnected;
151  ConnectTracks();
152  GetStdContent();
154 }
155 
156 //______________________________________________________________________________
158 
160 
161  if(&aod == this) return *this;
163 
164  // This assumes that the list is already created
165  // and that the virtual void Copy(Tobject&) function
166  // is correctly implemented in the derived class
167  // otherwise only TObject::Copy() will be used
168 
169  if((fAODObjects->GetSize()==0)&&(aod.fAODObjects->GetSize()>=kAODListN)){
170  // We cover the case that we do not yet have the
171  // standard content but the source has it
173  }
174 
175  // Here we have the standard content without user additions, but the content is
176  // not matching the aod source.
177 
178  // Iterate the list of source objects
179  TIter next(aod.GetList());
180  TObject *its = 0;
181  TString name;
182  while ((its = next())) {
183  name = its->GetName();
184  // Check if we have this object type in out list
185  TObject *mine = fAODObjects->FindObject(name);
186  if(!mine) {
187  // We have to create the same type of object.
188  TClass* pClass=TClass::GetClass(its->ClassName());
189  if (!pClass) {
190  AliWarning(Form("Can not find class description for entry %s (%s)\n",
191  its->ClassName(), name.Data()));
192  continue;
193  }
194  mine=(TObject*)pClass->New();
195  if(!mine){
196  // not in this: can be added to list
197  AliWarning(Form("%s:%d Could not find %s for copying \n",
198  (char*)__FILE__,__LINE__,name.Data()));
199  continue;
200  }
201  if(mine->InheritsFrom("TNamed")) {
202  ((TNamed*)mine)->SetName(name);
203  } else if(mine->InheritsFrom("TCollection")){
204  if(mine->InheritsFrom("TClonesArray")) {
205  TClonesArray *itscl = dynamic_cast<TClonesArray*>(its);
206  if (!itscl) {
207  AliWarning(Form("Class description for entry %s (%s) not TClonesArray\n",
208  its->ClassName(), name.Data()));
209  continue;
210 
211  }
212  dynamic_cast<TClonesArray*>(mine)->SetClass(itscl->GetClass(), itscl->GetSize());
213  }
214  dynamic_cast<TCollection*>(mine)->SetName(name);
215  }
216  AliDebug(1, Form("adding object %s of type %s", mine->GetName(), mine->ClassName()));
217  AddObject(mine);
218  }
219  // Now we have an object of the same type and name, but different content.
220  if(!its->InheritsFrom("TCollection")){
221  // simple objects (do they have a Copy method that calls operator= ?)
222  its->Copy(*mine);
223  } else if (its->InheritsFrom("TClonesArray")) {
224  // Create or expand the tclonesarray pointers
225  // so we can directly copy to the object
226  TClonesArray *its_tca = (TClonesArray*)its;
227  TClonesArray *mine_tca = (TClonesArray*)mine;
228  // this leaves the capacity of the TClonesArray the same
229  // except for a factor of 2 increase when size > capacity
230  // does not release any memory occupied by the tca
231  Int_t its_entries = its_tca->GetEntriesFast();
232  mine_tca->ExpandCreate(its_entries);
233  for(int i=0; i<its_entries; i++){
234  // copy
235  TObject *mine_tca_obj = mine_tca->At(i);
236  TObject *its_tca_obj = its_tca->At(i);
237  // no need to delete first
238  // pointers within the class should be handled by Copy()...
239  // Can there be Empty slots?
240  its_tca_obj->Copy(*mine_tca_obj);
241  }
242  } else {
243  AliWarning(Form("%s:%d cannot copy TCollection \n",
244  (char*)__FILE__,__LINE__));
245  }
246  }
247  fConnected = aod.fConnected;
248  fTracksConnected = kFALSE;
249  ConnectTracks();
250  return *this;
251 }
252 
253 
254 //______________________________________________________________________________
256 {
258 
259  delete fAODFolder;
260  fAODFolder = 0;
261  if(!fConnected) {
262 // fAODObjects->Delete("slow");
263  delete fAODObjects;
264  }
265 }
266 
267 //______________________________________________________________________________
268 void AliAODEvent::AddObject(TObject* obj)
269 {
273 
274 // if ( !fAODObjects ) {
275 // fAODObjects = new TList();
276 // fAODObjects->SetOwner();
277 // }
278  if ( !fAODObjects->FindObject(obj) )
279  {
280  fAODObjects->AddLast(obj);
281  }
282 }
283 
284 //______________________________________________________________________________
286 {
288 
289  AliAODTrack *track = new((*fTracks)[fTracks->GetEntriesFast()]) AliAODTrack(*trk);
290  track->SetAODEvent(this);
291  return fTracks->GetEntriesFast()-1;
292 }
293 
294 //______________________________________________________________________________
295 void AliAODEvent::RemoveObject(TObject* obj)
296 {
298 
299  fAODObjects->Remove(obj);
300 }
301 
302 //______________________________________________________________________________
303 TObject *AliAODEvent::FindListObject(const char *objName) const
304 {
306 
307  return fAODObjects->FindObject(objName);
308 }
309 
310 //______________________________________________________________________________
312 {
314 
315  // create standard objects and add them to the TList of objects
316  AddObject(new AliAODHeader());
317  AddObject(new TClonesArray("AliAODTrack", 0));
318  AddObject(new TClonesArray("AliAODVertex", 0));
319  AddObject(new TClonesArray("AliAODv0", 0));
320  AddObject(new TClonesArray("AliAODcascade", 0));
321  AddObject(new AliAODTracklets());
322  AddObject(new TClonesArray("AliAODJet", 0));
323  AddObject(new AliAODCaloCells());
324  AddObject(new AliAODCaloCells());
325  AddObject(new TClonesArray("AliAODCaloCluster", 0));
326  AddObject(new AliAODCaloTrigger()); // EMCAL
327  AddObject(new AliAODCaloTrigger()); // PHOS
328  AddObject(new TClonesArray("AliAODFmdCluster", 0));
329  AddObject(new TClonesArray("AliAODPmdCluster", 0));
330  AddObject(new TClonesArray("AliAODHMPIDrings", 0));
331  AddObject(new TClonesArray("AliAODDimuon", 0));
332  AddObject(new AliAODTZERO());
333  AddObject(new AliAODVZERO());
334  AddObject(new AliAODZDC());
335  AddObject(new AliAODAD());
336  AddObject(new AliTOFHeader());
337  AddObject(new TClonesArray("AliAODTrdTrack", 0));
338  // set names
339  SetStdNames();
340 
341  // read back pointers
342  GetStdContent();
344  return;
345 }
346 
348 {
350 
351  TIter next(fAODObjects);
352  TObject* obj;
353  while ((obj = next()))
354  {
355  if(obj->InheritsFrom("TCollection"))
356  {
357  AssignIDtoCollection((TCollection*)obj);
358  }
359  }
360 }
361 
362 //______________________________________________________________________________
364 {
366 
367  if(fAODObjects->GetEntries()==kAODListN){
368  for(int i = 0;i < fAODObjects->GetEntries();i++){
369  TObject *fObj = fAODObjects->At(i);
370  if(fObj->InheritsFrom("TNamed")){
371  ((TNamed*)fObj)->SetName(fAODListName[i]);
372  }
373  else if(fObj->InheritsFrom("TClonesArray")){
374  ((TClonesArray*)fObj)->SetName(fAODListName[i]);
375  }
376  }
377  }
378  else{
379  printf("%s:%d SetStdNames() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
380  }
381 }
382 
383 //______________________________________________________________________________
385 {
387 
388  if(fAODFolder)delete fAODFolder;
389  fAODFolder = gROOT->GetRootFolder()->AddFolder("AOD", "AOD");
390  if(fAODObjects->GetEntries()==kAODListN){
391  for(int i = 0;i < fAODObjects->GetEntries();i++){
392  TObject *fObj = fAODObjects->At(i);
393  if(fObj->InheritsFrom("TClonesArray")){
394  fAODFolder->AddFolder(fAODListName[i], fAODListName[i], (TCollection*) fObj);
395  } else {
396  fAODFolder->AddFolder(fAODListName[i], fAODListName[i], 0);
397  }
398  }
399  }
400  else{
401  printf("%s:%d CreateStdFolders() Wrong number of Std Entries \n",(char*)__FILE__,__LINE__);
402  }
403 }
404 
405 //______________________________________________________________________________
407 {
409 
410  fHeader = (AliVAODHeader*)fAODObjects->FindObject("header");
411  fTracks = (TClonesArray*)fAODObjects->FindObject("tracks");
412  fVertices = (TClonesArray*)fAODObjects->FindObject("vertices");
413  fV0s = (TClonesArray*)fAODObjects->FindObject("v0s");
414  fCascades = (TClonesArray*)fAODObjects->FindObject("cascades");
415  fTracklets = (AliAODTracklets*)fAODObjects->FindObject("tracklets");
416  fJets = (TClonesArray*)fAODObjects->FindObject("jets");
417  fEmcalCells = (AliAODCaloCells*)fAODObjects->FindObject("emcalCells");
418  fPhosCells = (AliAODCaloCells*)fAODObjects->FindObject("phosCells");
419  fCaloClusters = (TClonesArray*)fAODObjects->FindObject("caloClusters");
420  fEMCALTrigger = (AliAODCaloTrigger*)fAODObjects->FindObject("emcalTrigger");
421  fPHOSTrigger = (AliAODCaloTrigger*)fAODObjects->FindObject("phosTrigger");
422  fFmdClusters = (TClonesArray*)fAODObjects->FindObject("fmdClusters");
423  fPmdClusters = (TClonesArray*)fAODObjects->FindObject("pmdClusters");
424  fHMPIDrings = (TClonesArray*)fAODObjects->FindObject("hmpidRings");
425  fDimuons = (TClonesArray*)fAODObjects->FindObject("dimuons");
426  fAODTZERO = (AliAODTZERO*)fAODObjects->FindObject("AliAODTZERO");
427  fAODVZERO = (AliAODVZERO*)fAODObjects->FindObject("AliAODVZERO");
428  fAODZDC = (AliAODZDC*)fAODObjects->FindObject("AliAODZDC");
429  fAODAD = (AliAODAD*)fAODObjects->FindObject("AliAODAD");
430  fTOFHeader = (AliTOFHeader*)fAODObjects->FindObject("AliTOFHeader");
431  fTrdTracks = (TClonesArray*)fAODObjects->FindObject("trdTracks");
432 }
433 
434 //______________________________________________________________________________
435 void AliAODEvent::ResetStd(Int_t trkArrSize,
436  Int_t vtxArrSize,
437  Int_t v0ArrSize,
438  Int_t cascadeArrSize,
439  Int_t jetSize,
440  Int_t caloClusSize,
441  Int_t fmdClusSize,
442  Int_t pmdClusSize,
443  Int_t hmpidRingsSize,
444  Int_t dimuonArrSize,
445  Int_t nTrdTracks
446  )
447 {
449 
450  fTracksConnected = kFALSE;
451  if (fTracks) {
452  fTracks->Delete();
453  if (trkArrSize > fTracks->GetSize())
454  fTracks->Expand(trkArrSize);
455  }
456  if (fVertices) {
457  fVertices->Delete();
458  if (vtxArrSize > fVertices->GetSize())
459  fVertices->Expand(vtxArrSize);
460  }
461  if (fV0s) {
462  fV0s->Delete();
463  if (v0ArrSize > fV0s->GetSize())
464  fV0s->Expand(v0ArrSize);
465  }
466  if (fCascades) {
467  fCascades->Delete();
468  if (cascadeArrSize > fCascades->GetSize())
469  fCascades->Expand(cascadeArrSize);
470  }
471  if (fJets) {
472  fJets->Delete();
473  if (jetSize > fJets->GetSize())
474  fJets->Expand(jetSize);
475  }
476  if (fCaloClusters) {
477  fCaloClusters->Delete();
478  if (caloClusSize > fCaloClusters->GetSize())
479  fCaloClusters->Expand(caloClusSize);
480  }
481  if (fFmdClusters) {
482  fFmdClusters->Delete();
483  if (fmdClusSize > fFmdClusters->GetSize())
484  fFmdClusters->Expand(fmdClusSize);
485  }
486  if (fPmdClusters) {
487  fPmdClusters->Delete();
488  if (pmdClusSize > fPmdClusters->GetSize())
489  fPmdClusters->Expand(pmdClusSize);
490  }
491  if (fHMPIDrings) {
492  fHMPIDrings->Delete();
493  if (hmpidRingsSize > fHMPIDrings->GetSize())
494  fHMPIDrings->Expand(hmpidRingsSize);
495  }
496  if (fDimuons) {
497  fDimuons->Delete();
498  if (dimuonArrSize > fDimuons->GetSize())
499  fDimuons->Expand(dimuonArrSize);
500  }
501  if (fTrdTracks) {
502  // no pointers in there, so cheaper Clear suffices
503 // fTrdTracks->Clear("C");
504  // Not quite: AliAODTrdTrack has a clones array of tracklets inside
505  fTrdTracks->Delete();
506  if (nTrdTracks > fTrdTracks->GetSize())
507  fTrdTracks->Expand(nTrdTracks);
508  }
509 
510  if (fTracklets)
512  if (fPhosCells)
514  if (fEmcalCells)
516 
517  if (fEMCALTrigger)
519  if (fPHOSTrigger)
521 
522 }
523 
524 //______________________________________________________________________________
526 {
528 
529  if (fHeader){
530  // FIXME: this if-else patch was introduced by Michele Floris on 17/03/14 to test nano AOD. To be removed.
531  if(fHeader->InheritsFrom("AliAODHeader")){
532  fHeader ->Clear();
533  }
534  else {
535  AliVHeader * head = 0;
536  head = dynamic_cast<AliVHeader*>((TObject*)fHeader);
537  if(head) head->Clear();
538  }
539  }
540  fTracksConnected = kFALSE;
541  if (fTracks)
542  fTracks ->Delete();
543  if (fVertices)
544  fVertices ->Delete();
545  if (fV0s)
546  fV0s ->Delete();
547  if (fCascades)
548  fCascades ->Delete();
549  if (fTracklets)
551  if (fJets)
552  fJets ->Delete();
553  if (fEmcalCells)
555  if (fPhosCells)
557  if (fCaloClusters)
558  fCaloClusters ->Delete();
559  if (fFmdClusters)
560  fFmdClusters ->Clear();
561  if (fPmdClusters)
562  fPmdClusters ->Clear();
563  if (fHMPIDrings)
564  fHMPIDrings ->Clear();
565  if (fDimuons)
566  fDimuons ->Clear("C");
567  if (fTrdTracks)
568  fTrdTracks ->Clear();
569 
570  if (fEMCALTrigger)
572  if (fPHOSTrigger)
574 }
575 
576 //_________________________________________________________________
577 Int_t AliAODEvent::GetPHOSClusters(TRefArray *clusters) const
578 {
580 
581  clusters->Clear();
582 
583  AliAODCaloCluster *cl = 0;
584  Bool_t first = kTRUE;
585  for (Int_t i = 0; i < GetNumberOfCaloClusters() ; i++) {
586  if ( (cl = GetCaloCluster(i)) ) {
587  if (cl->IsPHOS()){
588  if(first) {
589  new (clusters) TRefArray(TProcessID::GetProcessWithUID(cl));
590  first=kFALSE;
591  }
592  clusters->Add(cl);
593  //printf("IsPHOS cluster %d, E %2.3f Size: %d \n",i,cl->E(),clusters->GetEntriesFast());
594  }
595  }
596  }
597  return clusters->GetEntriesFast();
598 }
599 
600 //_________________________________________________________________
601 Int_t AliAODEvent::GetEMCALClusters(TRefArray *clusters) const
602 {
604 
605  clusters->Clear();
606  AliAODCaloCluster *cl = 0;
607  Bool_t first = kTRUE;
608  for (Int_t i = 0; i < GetNumberOfCaloClusters(); i++) {
609  if ( (cl = GetCaloCluster(i)) ) {
610  if (cl->IsEMCAL()){
611  if(first) {
612  new (clusters) TRefArray(TProcessID::GetProcessWithUID(cl));
613  first=kFALSE;
614  }
615  clusters->Add(cl);
616  //printf("IsEMCal cluster %d, E %2.3f Size: %d \n",i,cl->E(),clusters->GetEntriesFast());
617  }
618  }
619  }
620  return clusters->GetEntriesFast();
621 }
622 
623 
624 //______________________________________________________________________________
625 Int_t AliAODEvent::GetMuonTracks(TRefArray *muonTracks) const
626 {
628 
629  muonTracks->Clear();
630 
631  AliAODTrack *track = 0;
632  for (Int_t iTrack = 0; iTrack < GetNumberOfTracks(); iTrack++) {
633  track = dynamic_cast<AliAODTrack*>(GetTrack(iTrack));
634  if(!track) AliFatal("Not a standard AOD");
635  if (track->IsMuonTrack()) {
636  muonTracks->Add(track);
637  }
638  }
639 
640  return muonTracks->GetEntriesFast();
641 }
642 
643 
644 //______________________________________________________________________________
646 {
648 
649  int ntr = GetNumberOfTracks();
650  if (!ntr) return 0;
651  Int_t nMuonTracks=0;
652  if(!dynamic_cast<AliAODTrack*>(GetTrack(0))) {
653  AliError("Not a standard AOD");
654  return 0;
655  }
656 
657  for (Int_t iTrack=ntr; iTrack--;) {
658  if (((AliAODTrack*)GetTrack(iTrack))->IsMuonTrack()) {
659  nMuonTracks++;
660  }
661  }
662 
663  return nMuonTracks;
664 }
665 
666 //______________________________________________________________________________
667 Int_t AliAODEvent::GetMuonGlobalTracks(TRefArray *muonGlobalTracks) const // AU
668 {
670 
671  muonGlobalTracks->Clear();
672 
673  AliAODTrack *track = 0;
674  for (Int_t iTrack = 0; iTrack < GetNumberOfTracks(); iTrack++) {
675  track = dynamic_cast<AliAODTrack*>(GetTrack(iTrack));
676  if(!track) AliFatal("Not a standard AOD");
677  if (track->IsMuonGlobalTrack()) {
678  muonGlobalTracks->Add(track);
679  }
680  }
681 
682  return muonGlobalTracks->GetEntriesFast();
683 }
684 
685 
686 //______________________________________________________________________________
688 {
690 
691  int ntr = GetNumberOfTracks();
692  if (!ntr) return 0;
693  Int_t nMuonGlobalTracks=0;
694  if(!dynamic_cast<AliAODTrack*>(GetTrack(0))) {
695  AliError("Not a standard AOD");
696  return 0;
697  }
698  for (Int_t iTrack=ntr; iTrack--;) {
699  if (((AliAODTrack*)GetTrack(iTrack))->IsMuonGlobalTrack()) {
700  nMuonGlobalTracks++;
701  }
702  }
703 
704  return nMuonGlobalTracks;
705 }
706 
707 //______________________________________________________________________________
708 void AliAODEvent::ReadFromTree(TTree *tree, Option_t* opt /*= ""*/)
709 {
711 
712  if(!tree){
713  AliWarning("Zero Pointer to Tree \n");
714  return;
715  }
716  // load the TTree
717  if(!tree->GetTree())tree->LoadTree(0);
718 
719  // Try to find AliAODEvent
720  AliAODEvent *aodEvent = 0;
721  aodEvent = (AliAODEvent*)tree->GetTree()->GetUserInfo()->FindObject("AliAODEvent");
722  if(aodEvent){
723  // This event is connected to the tree by definition, just say so
724  aodEvent->SetConnected();
725  // Check if already connected to tree
726  TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("AODObjectsConnectedToTree"));
727  if (connectedList && (!strcmp(opt, "reconnect"))) {
728  // If connected use the connected list of objects
729  if (fAODObjects != connectedList) {
730  delete fAODObjects;
731  fAODObjects = connectedList;
732  }
733  GetStdContent();
734  fConnected = kTRUE;
735  return;
736  }
737  // Connect to tree
738  // prevent a memory leak when reading back the TList
739 // if (!(strcmp(opt, "reconnect"))) fAODObjects->Delete();
740 
741  // create a new TList from the UserInfo TList...
742  // copy constructor does not work...
743  // fAODObjects = (TList*)(aodEvent->GetList()->Clone());
744  fAODObjects = (TList*)aodEvent->GetList();
745  fAODObjects->SetOwner(kTRUE);
746  if(fAODObjects->GetEntries()<kAODListN)
747  {
748  AliWarning(Form("AliAODEvent::ReadFromTree() TList contains less than the standard contents %d < %d"
749  " That might be fine though (at least for filtered AODs)",fAODObjects->GetEntries(),kAODListN));
750  }
751  //
752  // Let's find out whether we have friends
753  TList* friendL = tree->GetTree()->GetListOfFriends();
754  if (friendL)
755  {
756  TIter next(friendL);
757  TFriendElement* fe;
758  while ((fe = (TFriendElement*)next())){
759  aodEvent = (AliAODEvent*)(fe->GetTree()->GetUserInfo()->FindObject("AliAODEvent"));
760  if (!aodEvent) {
761  printf("No UserInfo on tree \n");
762  } else {
763 
764  // TList* objL = (TList*)(aodEvent->GetList()->Clone());
765  TList* objL = (TList*)aodEvent->GetList();
766  printf("Get list of object from tree %d !!\n", objL->GetEntries());
767  TIter nextobject(objL);
768  TObject* obj = 0;
769  while((obj = nextobject()))
770  {
771  printf("Adding object from friend %s !\n", obj->GetName());
772  fAODObjects->Add(obj);
773  } // object "branch" loop
774  } // has userinfo
775  } // friend loop
776  } // has friends
777  // set the branch addresses
778  TIter next(fAODObjects);
779  TNamed *el;
780  while((el=(TNamed*)next())){
781  TString bname(el->GetName());
782  // check if branch exists under this Name
783  TBranch *br = tree->GetTree()->GetBranch(bname.Data());
784  if(br){
785  tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
786  } else {
787  br = tree->GetBranch(Form("%s.",bname.Data()));
788  if(br){
789  tree->SetBranchAddress(Form("%s.",bname.Data()),fAODObjects->GetObjectRef(el));
790  }
791  else{
792  printf("%s %d AliAODEvent::ReadFromTree() No Branch found with Name %s. \n",
793  (char*)__FILE__,__LINE__,bname.Data());
794  }
795  }
796  }
797  GetStdContent();
798  // when reading back we are not owner of the list
799  // must not delete it
800  fAODObjects->SetOwner(kTRUE);
801  fAODObjects->SetName("AODObjectsConnectedToTree");
802  // we are not owner of the list objects
803  // must not delete it
804  tree->GetUserInfo()->Add(fAODObjects);
805  fConnected = kTRUE;
806  }// no aodEvent
807  else {
808  // we can't get the list from the user data, create standard content
809  // and set it by hand
811  TIter next(fAODObjects);
812  TNamed *el;
813  while((el=(TNamed*)next())){
814  TString bname(el->GetName());
815  tree->SetBranchAddress(bname.Data(),fAODObjects->GetObjectRef(el));
816  }
817  GetStdContent();
818  // when reading back we are not owner of the list
819  // must not delete it
820  fAODObjects->SetOwner(kTRUE);
821  }
822 }
823  //______________________________________________________________________________
826 
827  Int_t nVertices=GetNumberOfVertices();
828  Int_t nPileupVertices=0;
829  for(Int_t iVert=0; iVert<nVertices; iVert++){
830  AliAODVertex *v=GetVertex(iVert);
831  if(v->GetType()==AliAODVertex::kPileupSPD) nPileupVertices++;
832  }
833  return nPileupVertices;
834 }
835 //______________________________________________________________________________
838 
839  Int_t nVertices=GetNumberOfVertices();
840  Int_t nPileupVertices=0;
841  for(Int_t iVert=0; iVert<nVertices; iVert++){
842  AliAODVertex *v=GetVertex(iVert);
843  if(v->GetType()==AliAODVertex::kPileupTracks) nPileupVertices++;
844  }
845  return nPileupVertices;
846 }
847 //______________________________________________________________________________
850 
851  Int_t nVertices=GetNumberOfVertices();
852  for(Int_t iVert=0; iVert<nVertices; iVert++){
853  AliAODVertex *v=GetVertex(iVert);
854  if(v->GetType()==AliAODVertex::kMainSPD) return v;
855  }
856  return 0;
857 }
858 //______________________________________________________________________________
861 
862  Int_t nVertices=GetNumberOfVertices();
863  for(Int_t iVert=0; iVert<nVertices; iVert++){
864  AliAODVertex *v=GetVertex(iVert);
865  if(v->GetType()==AliAODVertex::kMainTPC) return v;
866  }
867  return 0;
868 }
869 //______________________________________________________________________________
872 
873  Int_t nVertices=GetNumberOfVertices();
874  Int_t counter=0;
875  for(Int_t iVert=0; iVert<nVertices; iVert++){
876  AliAODVertex *v=GetVertex(iVert);
878  if(counter==iV) return v;
879  ++counter;
880  }
881  }
882  return 0;
883 }
884 //______________________________________________________________________________
887 
888  Int_t nVertices=GetNumberOfVertices();
889  Int_t counter=0;
890  for(Int_t iVert=0; iVert<nVertices; iVert++){
891  AliAODVertex *v=GetVertex(iVert);
893  if(counter==iV) return v;
894  ++counter;
895  }
896  }
897  return 0;
898 }
899 //______________________________________________________________________________
900 Bool_t AliAODEvent::IsPileupFromSPD(Int_t minContributors,
901  Double_t minZdist,
902  Double_t nSigmaZdist,
903  Double_t nSigmaDiamXY,
904  Double_t nSigmaDiamZ) const{
907 
909  if(!mainV) return kFALSE;
910  Int_t nc1=mainV->GetNContributors();
911  if(nc1<1) return kFALSE;
912  Int_t nPileVert=GetNumberOfPileupVerticesSPD();
913  if(nPileVert==0) return kFALSE;
914  Int_t nVertices=GetNumberOfVertices();
915 
916  for(Int_t iVert=0; iVert<nVertices; iVert++){
917  AliAODVertex *pv=GetVertex(iVert);
918  if(pv->GetType()!=AliAODVertex::kPileupSPD) continue;
919  Int_t nc2=pv->GetNContributors();
920  if(nc2>=minContributors){
921  Double_t z1=mainV->GetZ();
922  Double_t z2=pv->GetZ();
923  Double_t distZ=TMath::Abs(z2-z1);
924  Double_t distZdiam=TMath::Abs(z2-GetDiamondZ());
925  Double_t cutZdiam=nSigmaDiamZ*TMath::Sqrt(GetSigma2DiamondZ());
926  if(GetSigma2DiamondZ()<0.0001)cutZdiam=99999.; //protection for missing z diamond information
927  if(distZ>minZdist && distZdiam<cutZdiam){
928  Double_t x2=pv->GetX();
929  Double_t y2=pv->GetY();
930  Double_t distXdiam=TMath::Abs(x2-GetDiamondX());
931  Double_t distYdiam=TMath::Abs(y2-GetDiamondY());
932  Double_t cov1[6],cov2[6];
933  mainV->GetCovarianceMatrix(cov1);
934  pv->GetCovarianceMatrix(cov2);
935  Double_t errxDist=TMath::Sqrt(cov2[0]+GetSigma2DiamondX());
936  Double_t erryDist=TMath::Sqrt(cov2[2]+GetSigma2DiamondY());
937  Double_t errzDist=TMath::Sqrt(cov1[5]+cov2[5]);
938  Double_t cutXdiam=nSigmaDiamXY*errxDist;
939  if(GetSigma2DiamondX()<0.0001)cutXdiam=99999.; //protection for missing diamond information
940  Double_t cutYdiam=nSigmaDiamXY*erryDist;
941  if(GetSigma2DiamondY()<0.0001)cutYdiam=99999.; //protection for missing diamond information
942  if( (distXdiam<cutXdiam) && (distYdiam<cutYdiam) && (distZ>nSigmaZdist*errzDist) ){
943  return kTRUE;
944  }
945  }
946  }
947  }
948  return kFALSE;
949 }
950 
951 //______________________________________________________________________________
952 void AliAODEvent::Print(Option_t *) const
953 {
955 
956  TIter next(fAODObjects);
957  TNamed *el;
958  Printf(">>>>> AOD Content <<<<<");
959  while((el=(TNamed*)next())){
960  Printf(">> %s ",el->GetName());
961  }
962  Printf(">>>>> <<<<<");
963 
964  return;
965 }
966 
967 //______________________________________________________________________________
968 void AliAODEvent::AssignIDtoCollection(const TCollection* col)
969 {
974 
975  TIter next(col);
976  TObject* obj;
977  while ((obj = next()))
978  TProcessID::AssignID(obj);
979 }
980 
981 //______________________________________________________________________________
983  Int_t nTracklets=GetTracklets()->GetNumberOfTracklets();
984  if(nTracklets<20) return IsPileupFromSPD(3,0.8);
985  else if(nTracklets<50) return IsPileupFromSPD(4,0.8);
986  else return IsPileupFromSPD(5,0.8);
987 }
988 
989 //______________________________________________________________________________
991 {
994 
995  ClearStd();
996 
997  if(fAODObjects->GetSize()>kAODListN){
998  // we have non std content
999  // this also covers aodfriends
1000  for(int i = kAODListN;i < fAODObjects->GetSize();++i){
1001  TObject *pObject = fAODObjects->At(i);
1002  // TClonesArrays
1003  if(pObject->InheritsFrom(TClonesArray::Class())){
1004  ((TClonesArray*)pObject)->Delete();
1005  }
1006  else if(!pObject->InheritsFrom(TCollection::Class())){
1007  TClass *pClass = TClass::GetClass(pObject->ClassName());
1008  if (pClass && pClass->GetListOfMethods()->FindObject("Clear")) {
1009  AliDebug(1, Form("Clear for object %s class %s", pObject->GetName(), pObject->ClassName()));
1010  pObject->Clear();
1011  }
1012  else {
1013  AliDebug(1, Form("ResetWithPlacementNew for object %s class %s", pObject->GetName(), pObject->ClassName()));
1014  Long_t dtoronly = TObject::GetDtorOnly();
1015  TObject::SetDtorOnly(pObject);
1016  delete pObject;
1017  pClass->New(pObject);
1018  TObject::SetDtorOnly((void*)dtoronly);
1019  }
1020  }
1021  else{
1022  AliWarning(Form("No reset for %s \n",
1023  pObject->ClassName()));
1024  }
1025  }
1026  }
1027 }
1028 
1029 // FIXME: Why is this in event and not in header?
1031 {
1036 
1037  if (!fAODVZERO || !fHeader) return -1;
1038 
1039  Int_t ring = i/8;
1040  Float_t factorSum = 0;
1041  for(Int_t j = 8*ring; j < (8*ring+8); ++j) {
1042  factorSum += fHeader->GetVZEROEqFactors(j);
1043  }
1044  Float_t factor = fHeader->GetVZEROEqFactors(i)*8./factorSum;
1045 
1046  return (fAODVZERO->GetMultiplicity(i)/factor);
1047 }
1048 
1049 //------------------------------------------------------------
1051 {
1053 
1054  if (fTOFHeader) {
1055  *fTOFHeader=*header;
1056  //fTOFHeader->SetName(fgkESDListName[kTOFHeader]);
1057  }
1058  else {
1059  // for analysis of reconstructed events
1060  // when this information is not avaliable
1061  fTOFHeader = new AliTOFHeader(*header);
1062  //AddObject(fTOFHeader);
1063  }
1064 
1065 }
1066 //------------------------------------------------------------
1068 {
1070 
1071  if(GetHMPIDrings())
1072  {
1073  for(Int_t ien = 0 ; ien < GetNHMPIDrings(); ien++)
1074  {
1075  if( GetHMPIDring(ien)->GetHmpTrkID() == trackID ) return GetHMPIDring(ien);
1076  }//rings loop
1077  }
1078  return 0;
1079 }
1080 //------------------------------------------------------------
1082 {
1084 
1085  if ( fHMPIDrings) return fHMPIDrings->GetEntriesFast();
1086  else return -1;
1087 }
1088 //------------------------------------------------------------
1090 {
1092 
1093  if(fHMPIDrings) {
1094  if( (AliAODHMPIDrings*)fHMPIDrings->UncheckedAt(nRings) ) {
1095  return (AliAODHMPIDrings*)fHMPIDrings->UncheckedAt(nRings);
1096  }
1097  else return 0x0;
1098  }
1099  else return 0x0;
1100 }
1101 //------------------------------------------------------------
1103  return *(new ((*fTrdTracks)[fTrdTracks->GetEntriesFast()]) AliAODTrdTrack(*track));
1104 }
1105 
1106 //______________________________________________________________________________
1109 
1110  if (fTracksConnected || !fTracks || !fTracks->GetEntriesFast()) return;
1111  AliAODTrack *track = 0;
1112  track = dynamic_cast<AliAODTrack*>(GetTrack(0));
1113  if(!track) {
1114  AliWarning("Not an AliAODTrack, this is not a standard AOD");
1115  return;
1116  }
1117 
1118  TIter next(fTracks);
1119  while ((track=(AliAODTrack*)next())) track->SetAODEvent(this);
1120  fTracksConnected = kTRUE;
1121 }
1122 
1123 //______________________________________________________________________________
1125 {
1127 
1128  UInt_t daqAttr = GetDAQAttributes();
1129  return (daqAttr&ATTR_2_B(ATTR_INCOMPLETE_EVENT))!=0
1130  || (daqAttr&ATTR_2_B(ATTR_FLUSHED_EVENT))!=0;
1131 
1132 }
1133 
1135 
1136 //______________________________________________________________________________
1137 TClonesArray* AliAODEvent::GetDimuons() const
1138 {
1139  return fDimuons;
1140 }
1141 
1142 //______________________________________________________________________________
1144 {
1145  return fDimuons ? fDimuons->GetEntriesFast() : 0;
1146 }
1147 
1148 //______________________________________________________________________________
1150 {
1151  return GetNDimuons();
1152 }
1153 
1154 //______________________________________________________________________________
1156 {
1157  if ( fDimuons )
1158  {
1159  return (AliAODDimuon*)fDimuons->UncheckedAt(nDimu);
1160  }
1161  return 0x0;
1162 }
1163 
1164 //______________________________________________________________________________
1166 {
1167  if ( fDimuons )
1168  {
1169  new((*fDimuons)[fDimuons->GetEntriesFast()]) AliAODDimuon(*dimu);
1170  return fDimuons->GetEntriesFast()-1;
1171  }
1172  return -1;
1173 }
AliAODCaloCells * fEmcalCells
! EMCAL calorimenter cells
Definition: AliAODEvent.h:355
Class for calorimeter cluster, EMCal and PHOS, data handling.
AliAODZDC * fAODZDC
! ZDC AOD
Definition: AliAODEvent.h:366
Int_t AddDimuon(const AliAODDimuon *dimu)
AliTOFHeader * fTOFHeader
! event times (and sigmas) as estimated by TOF
Definition: AliAODEvent.h:368
void ReadFromTree(TTree *tree, Option_t *opt="")
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
AliAODCaloCells * fPhosCells
! PHOS calorimenter cells
Definition: AliAODEvent.h:356
virtual const Float_t * GetVZEROEqFactors() const =0
Bool_t IsMuonTrack() const
Definition: AliAODTrack.h:438
Int_t GetHmpTrkID() const
Double_t GetSigma2DiamondZ() const
Definition: AliAODEvent.h:137
Class for AOD ZDC data.
Definition: AliAODZDC.h:13
void SetConnected(Bool_t conn=kTRUE)
Definition: AliAODEvent.h:86
void MakeEntriesReferencable()
virtual Float_t GetMultiplicity(Int_t i) const
Int_t GetPHOSClusters(TRefArray *clusters) const
Int_t GetNumberOfCaloClusters() const
Definition: AliAODEvent.h:216
static void AssignIDtoCollection(const TCollection *col)
Class for calorimeter cell AOD data handling.
UInt_t GetDAQAttributes() const
Definition: AliAODEvent.h:109
void ResetStd(Int_t trkArrSize=0, Int_t vtxArrSize=0, Int_t v0ArrSize=0, Int_t cascadeArrSize=0, Int_t jetSize=0, Int_t caloClusSize=0, Int_t fmdClusSize=0, Int_t pmdClusSize=0, Int_t hmpidRingsSize=0, Int_t dimuonArrsize=0, Int_t nTrdTracks=0)
TClonesArray * fCascades
! Cascades
Definition: AliAODEvent.h:352
Container class for AOD AD data.
Definition: AliAODAD.h:10
virtual AliAODVertex * GetPrimaryVertexSPD() const
Bool_t IsEMCAL() const
Definition: AliAODCluster.h:76
void CreateStdContent()
Int_t GetNumberOfPileupVerticesSPD() const
Bool_t IsIncompleteDAQ()
TClonesArray * fV0s
! V0s
Definition: AliAODEvent.h:351
Int_t GetNumberOfMuonTracks() const
Double_t GetZ() const
Definition: AliAODVertex.h:72
Container with calorimeter trigger information in the AOD event.
TClonesArray * GetHMPIDrings() const
Definition: AliAODEvent.h:246
void ConnectTracks()
AliAODTracklets * GetTracklets() const
Definition: AliAODEvent.h:263
TROOT * gROOT
AliAODHMPIDrings * GetHMPIDring(Int_t nRings) const
TClonesArray * fHMPIDrings
! HMPID signals
Definition: AliAODEvent.h:362
Double_t GetSigma2DiamondX() const
Definition: AliAODEvent.h:135
Int_t GetNumberOfMuonGlobalTracks() const
TList * GetList() const
Definition: AliAODEvent.h:85
AliTPCfastTrack * track
TClonesArray * fVertices
! vertices
Definition: AliAODEvent.h:350
AliAODCaloTrigger * fEMCALTrigger
! EMCAL Trigger information
Definition: AliAODEvent.h:358
virtual Int_t GetNumberOfTracklets() const
static const char * fAODListName[kAODListN]
!
Definition: AliAODEvent.h:374
virtual AliVEvent::EDataLayoutType GetDataLayoutType() const
#define AliWarning(message)
Definition: AliLog.h:541
virtual AliAODVertex * GetPileupVertexTracks(Int_t iV=0) const
Bool_t IsMuonGlobalTrack() const
Definition: AliAODTrack.h:440
TClonesArray * fPmdClusters
! PMDclusters
Definition: AliAODEvent.h:361
AliAODDimuon * GetDimuon(Int_t nDimu) const
AOD class to store tracklets.
void Print(Option_t *option="") const
AliAODTZERO * fAODTZERO
! TZERO AOD
Definition: AliAODEvent.h:364
TList * fAODObjects
list of AODObjects
Definition: AliAODEvent.h:343
Double_t GetY() const
Definition: AliAODVertex.h:71
void ClearStd()
TTree * tree
void AddObject(TObject *obj)
virtual AliAODVertex * GetPileupVertexSPD(Int_t iV=0) const
virtual Float_t GetVZEROEqMultiplicity(Int_t i) const
virtual AliAODVertex * GetPrimaryVertexTPC() const
AliAODCaloCluster * GetCaloCluster(Int_t nCluster) const
Definition: AliAODEvent.h:217
Bool_t fConnected
! flag if leaves are alreday connected
Definition: AliAODEvent.h:345
void RemoveObject(TObject *obj)
AOD event base class.
Definition: AliAODHeader.h:27
virtual Bool_t IsPileupFromSPDInMultBins() const
virtual Bool_t IsPileupFromSPD(Int_t minContributors=5, Double_t minZdist=0.8, Double_t nSigmaZdist=3., Double_t nSigmaDiamXY=2., Double_t nSigmaDiamZ=5.) const
AliAODAD * fAODAD
! AD AOD
Definition: AliAODEvent.h:367
Int_t GetNumberOfPileupVerticesTracks() const
TObject * FindListObject(const char *objName) const
AliAODTracklets * fTracklets
! SPD tracklets
Definition: AliAODEvent.h:353
Double_t GetDiamondX() const
Definition: AliAODEvent.h:131
Bool_t IsPHOS() const
Definition: AliAODCluster.h:79
Int_t AddTrack(const AliAODTrack *trk)
Double_t GetX() const
Definition: AliAODVertex.h:70
TFolder * fAODFolder
folder structure of branches
Definition: AliAODEvent.h:344
TClonesArray * fFmdClusters
! FMDclusters
Definition: AliAODEvent.h:360
Double_t GetSigma2DiamondY() const
Definition: AliAODEvent.h:136
AliAODTrdTrack & AddTrdTrack(const AliVTrdTrack *track)
Int_t GetNContributors() const
AliVEvent & operator=(const AliVEvent &vEvnt)
Definition: AliVEvent.cxx:29
TClonesArray * fCaloClusters
! calorimeter clusters
Definition: AliAODEvent.h:357
AliVAODHeader * fHeader
! event information
Definition: AliAODEvent.h:348
void SetStdNames()
Int_t GetNDimuons() const
#define AliFatal(message)
Definition: AliLog.h:640
AliAODHMPIDrings * GetHMPIDringForTrackID(Int_t trackID) const
void AddHeader(const AliVHeader *hdx)
Definition: AliAODEvent.h:92
Int_t GetNumberOfVertices() const
Definition: AliAODEvent.h:176
virtual AliAODVertex * GetVertex() const
Definition: AliAODEvent.h:187
AOD base class.
Definition: AliAODEvent.h:48
EDataLayoutType
Definition: AliVEvent.h:46
TClonesArray * fTrdTracks
! TRD AOD tracks (triggered)
Definition: AliAODEvent.h:372
void SetTOFHeader(const AliTOFHeader *tofEventTime)
Double_t GetDiamondY() const
Definition: AliAODEvent.h:132
#define AliDebug(logLevel, message)
Definition: AliLog.h:300
AliAODCaloTrigger * fPHOSTrigger
! PHOS Trigger information
Definition: AliAODEvent.h:359
Int_t GetMuonGlobalTracks(TRefArray *muonGlobalTracks) const
AliAODDimuon: a class for AODs for the MUON Arm of the ALICE Experiment.
Definition: AliAODDimuon.h:33
TClonesArray * fTracks
! charged tracks
Definition: AliAODEvent.h:349
Double_t GetDiamondZ() const
Definition: AliAODEvent.h:133
Bool_t fTracksConnected
! flag if tracks have already pointer to event set
Definition: AliAODEvent.h:346
void SetAODEvent(const AliAODEvent *ptr)
Definition: AliAODTrack.h:367
Container class for AOD TZERO data.
Definition: AliAODTZERO.h:14
Container class for AOD VZERO data.
Definition: AliAODVZERO.h:13
#define AliError(message)
Definition: AliLog.h:591
virtual ~AliAODEvent()
void GetStdContent()
AliAODVZERO * fAODVZERO
! VZERO AOD
Definition: AliAODEvent.h:365
TClonesArray * fJets
! jets
Definition: AliAODEvent.h:354
void GetCovarianceMatrix(Double_t covmatrix[6]) const
Definition: AliAODVertex.h:86
format for the TRD tracks calculated in the
void CreateStdFolders()
TClonesArray * fDimuons
! dimuons
Definition: AliAODEvent.h:363
AliVTrack * GetTrack(Int_t nTrack) const
Definition: AliAODEvent.h:167
Class to handle the AOD tracks with good HMPID rings.
AOD vertex base class.
Definition: AliAODVertex.h:23
Int_t GetMuonTracks(TRefArray *muonTracks) const
Int_t GetEMCALClusters(TRefArray *clusters) const
Int_t GetNHMPIDrings() const
Int_t GetNumberOfDimuons() const
AOD track implementation of AliVTrack.
Definition: AliAODTrack.h:29
Char_t GetType() const
Definition: AliAODVertex.h:99
TClonesArray * GetDimuons() const
AliAODEvent & operator=(const AliAODEvent &aodevent)
Int_t GetNumberOfTracks() const
Definition: AliAODEvent.h:166