AliRoot Core  ee782a0 (ee782a0)
AliAODHandler.cxx
Go to the documentation of this file.
1 
2 /**************************************************************************
3  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4  * *
5  * Author: The ALICE Off-line Project. *
6  * Contributors are mentioned in the code where appropriate. *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
17 /* $Id$ */
18 
19 
20 #include <TTree.h>
21 #include <TFile.h>
22 #include <TString.h>
23 #include <TList.h>
24 #include <TROOT.h>
25 
26 #include "AliLog.h"
27 #include "AliAODHandler.h"
28 #include "AliAODEvent.h"
29 #include "AliAODExtension.h"
30 #include "AliAODTracklets.h"
31 #include "AliStack.h"
32 #include "AliAODMCParticle.h"
33 #include "AliAODMCHeader.h"
34 #include "AliMCEventHandler.h"
35 #include "AliMCEvent.h"
36 #include "AliGenEventHeader.h"
41 #include "AliCodeTimer.h"
42 #include "AliAODBranchReplicator.h"
43 #include "Riostream.h"
44 
45 using std::endl;
46 using std::cout;
47 ClassImp(AliAODHandler)
48 
49 //______________________________________________________________________________
52  fIsStandard(kTRUE),
53  fFillAOD(kTRUE),
54  fFillAODRun(kTRUE),
55  fFillExtension(kTRUE),
56  fNeedsHeaderReplication(kFALSE),
57  fNeedsTOFHeaderReplication(kFALSE),
58  fNeedsVZEROReplication(kFALSE),
59  fNeedsTracksBranchReplication(kFALSE),
60  fNeedsVerticesBranchReplication(kFALSE),
61  fNeedsV0sBranchReplication(kFALSE),
62  fNeedsCascadesBranchReplication(kFALSE),
63  fNeedsTrackletsBranchReplication(kFALSE),
64  fNeedsPMDClustersBranchReplication(kFALSE),
65  fNeedsJetsBranchReplication(kFALSE),
66  fNeedsFMDClustersBranchReplication(kFALSE),
67  fNeedsCaloClustersBranchReplication(kFALSE),
68  fNeedsCaloTriggerBranchReplication(kFALSE),
69  fNeedsMCParticlesBranchReplication(kFALSE),
70  fNeedsDimuonsBranchReplication(kFALSE),
71  fNeedsHMPIDBranchReplication(kFALSE),
72  fAODIsReplicated(kFALSE),
73  fTreeBuffSize(30000000),
74  fMemCountAOD(0),
75  fAODEvent(NULL),
76  fMCEventH(NULL),
77  fTreeA(NULL),
78  fFileA(NULL),
79  fFileName(""),
80  fExtensions(NULL),
81  fFilters(NULL)
82 {
83  // default constructor
84 }
85 
86 //______________________________________________________________________________
87 AliAODHandler::AliAODHandler(const char* name, const char* title):
88  AliVEventHandler(name, title),
89  fIsStandard(kTRUE),
90  fFillAOD(kTRUE),
91  fFillAODRun(kTRUE),
92  fFillExtension(kTRUE),
93  fNeedsHeaderReplication(kFALSE),
94  fNeedsTOFHeaderReplication(kFALSE),
95  fNeedsVZEROReplication(kFALSE),
96  fNeedsTracksBranchReplication(kFALSE),
97  fNeedsVerticesBranchReplication(kFALSE),
98  fNeedsV0sBranchReplication(kFALSE),
99  fNeedsCascadesBranchReplication(kFALSE),
100  fNeedsTrackletsBranchReplication(kFALSE),
101  fNeedsPMDClustersBranchReplication(kFALSE),
102  fNeedsJetsBranchReplication(kFALSE),
103  fNeedsFMDClustersBranchReplication(kFALSE),
104  fNeedsCaloClustersBranchReplication(kFALSE),
105  fNeedsCaloTriggerBranchReplication(kFALSE),
106  fNeedsMCParticlesBranchReplication(kFALSE),
107  fNeedsDimuonsBranchReplication(kFALSE),
108  fNeedsHMPIDBranchReplication(kFALSE),
109  fAODIsReplicated(kFALSE),
110  fTreeBuffSize(30000000),
111  fMemCountAOD(0),
112  fAODEvent(NULL),
113  fMCEventH(NULL),
114  fTreeA(NULL),
115  fFileA(NULL),
116  fFileName(""),
117  fExtensions(NULL),
118  fFilters(NULL)
119 {
121 
122 }
123 
124 //______________________________________________________________________________
126 {
128 
129  delete fAODEvent;
130 
131  if (fFileA) fFileA->Close();
132 
133  delete fFileA;
134  delete fTreeA;
135  delete fExtensions;
136  delete fFilters;
137 }
138 
139 //______________________________________________________________________________
140 Bool_t AliAODHandler::Init(Option_t* opt)
141 {
145 
146  Bool_t createStdAOD = fIsStandard || fFillAOD;
147  if(!fAODEvent && createStdAOD){
148  fAODEvent = new AliAODEvent();
149  if (fIsStandard)
151  }
152  //
153  // File opening according to execution mode
154  TString option(opt);
155  option.ToLower();
156  if (createStdAOD) {
157  TDirectory *owd = gDirectory;
158  if (option.Contains("proof")) {
159  // proof
160  // Merging via files. Need to access analysis manager via interpreter.
161  gROOT->ProcessLine(Form("AliAnalysisDataContainer *c_common_out = AliAnalysisManager::GetAnalysisManager()->GetCommonOutputContainer();"));
162  gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->OpenProofFile(c_common_out, \"RECREATE\");"));
163  fFileA = gFile;
164  } else {
165  // local and grid
166  fFileA = new TFile(fFileName.Data(), "RECREATE");
167  }
168  CreateTree(1);
169  owd->cd();
170  }
171  if (fExtensions) {
172  TIter next(fExtensions);
173  AliAODExtension *ext;
174  while ((ext=(AliAODExtension*)next())) ext->Init(option);
175  }
176  if (fFilters) {
177  TIter nextf(fFilters);
178  AliAODExtension *filteredAOD;
179  while ((filteredAOD=(AliAODExtension*)nextf())) {
180  filteredAOD->SetEvent(fAODEvent);
181  filteredAOD->Init(option);
182  }
183  }
184 
185  return kTRUE;
186 }
187 
188 //______________________________________________________________________________
189 void AliAODHandler::Print(Option_t* opt) const
190 {
192 
193  cout << opt << Form("IsStandard %d filename=%s",fIsStandard,fFileName.Data()) << endl;
194 
195  if ( fExtensions )
196  {
197  cout << opt << fExtensions->GetEntries() << " extensions :" << endl;
199  }
200  if ( fFilters )
201  {
202  cout << opt << fFilters->GetEntries() << " filters :" << endl;
204  }
205 }
206 
207 //______________________________________________________________________________
209 {
211 
212  TIter next(&array);
213  AliAODExtension* ext(0x0);
214  while ( ( ext = static_cast<AliAODExtension*>(next()) ) )
215  {
216  ext->Print(" ");
217  }
218 }
219 
220 //______________________________________________________________________________
222 
238 
239  if (!fAODEvent) return;
240  TClonesArray *mcarray = (TClonesArray*)fAODEvent->FindListObject(AliAODMCParticle::StdBranchName());
241  if(!mcarray)return;
242 
244  if(!mcHeader)return;
245 
246  // Get the MC Infos.. Handler needs to be set before
247  // while adding the branch
248  // This needs to be done, not to depend on the AnalysisManager
249 
250  if(!fMCEventH)return;
251  if(!fMCEventH->MCEvent())return;
252  AliStack *pStack = fMCEventH->MCEvent()->Stack();
253  if(!pStack)return;
254 
256 
257  //
258  // Get the Event Header
259  //
260 
261  AliHeader* header = fMCEventH->MCEvent()->Header();
262  // get the MC vertex
263  AliGenEventHeader* genHeader = 0;
264  if (header) genHeader = header->GenEventHeader();
265  if (genHeader) {
266  TArrayF vtxMC(3);
267  genHeader->PrimaryVertex(vtxMC);
268  mcHeader->SetVertex(vtxMC[0],vtxMC[1],vtxMC[2]);
269  // we search the MCEventHeaders first
270  // Two cases, cocktail or not...
271  AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader);
272  if(genCocktailHeader){
273  // we have a coktail header add the name once
274  mcHeader->AddGeneratorName(genHeader->GetName());
275  TList* headerList = genCocktailHeader->GetHeaders();
276  // the first entry defines some extra general settings
277  AliGenEventHeader *headerEntry = dynamic_cast<AliGenEventHeader*>(headerList->At(0));
278  if (!headerEntry) {
279  AliFatal("AliGenEventHeader entry not found in the header list");
280  } else {
281  SetMCHeaderInfo(mcHeader,headerEntry);
282  }
283  }
284  else{
285  // No Cocktail just take the first one
286  SetMCHeaderInfo(mcHeader,genHeader);
287  }
288  // Add all the headers and names, if no cocktail header
289  // there will be only one entry
290  mcHeader->AddCocktailHeaders(genHeader);
291  }
292 
293 
294 
295 
296 
297  // Store the AliAODParticlesMC
298  AliMCEvent* mcEvent = fMCEventH->MCEvent();
299 
300  Int_t np = mcEvent->GetNumberOfTracks();
301  Int_t nprim = mcEvent->GetNumberOfPrimaries();
302 
303 
304  Int_t j = 0;
305  TClonesArray& l = *mcarray;
306 
307  for(int i = 0; i < np; ++i){
309  Int_t flag = 0;
310  AliMCParticle* mcpart = (AliMCParticle*) mcEvent->GetTrack(i);
311  if(i<nprim)flag |= AliAODMCParticle::kPrimary;
312 
313  if(mcEvent->IsPhysicalPrimary(i))flag |= AliAODMCParticle::kPhysicalPrim;
316 
317  if(fMCEventH->GetNewLabel(i)!=j){
318  AliError(Form("MISMATCH New label %d j: %d",fMCEventH->GetNewLabel(i),j));
319  }
320 
321  AliAODMCParticle mcpartTmp(mcpart,i,flag);
322 
323  mcpartTmp.SetStatus(mcpart->Particle()->GetStatusCode());
324  mcpartTmp.SetMCProcessCode(mcpart->Particle()->GetUniqueID());
325  //
326  Int_t d0 = mcpartTmp.GetDaughter(0);
327  Int_t d1 = mcpartTmp.GetDaughter(1);
328  Int_t m = mcpartTmp.GetMother();
329 
330  // other than for the track labels, negative values mean
331  // no daughter/mother so preserve it
332 
333  if(d0<0 && d1<0){
334  // no first daughter -> no second daughter
335  // nothing to be done
336  // second condition not needed just for sanity check at the end
337  mcpartTmp.SetDaughter(0,d0);
338  mcpartTmp.SetDaughter(1,d1);
339  } else if(d1 < 0 && d0 >= 0) {
340  // Only one daughter
341  // second condition not needed just for sanity check at the end
342  if(fMCEventH->IsParticleSelected(d0)){
343  mcpartTmp.SetDaughter(0,fMCEventH->GetNewLabel(d0));
344  } else {
345  mcpartTmp.SetDaughter(0,-1);
346  }
347  mcpartTmp.SetDaughter(1,d1);
348  }
349  else if (d0 > 0 && d1 > 0 ){
350  // we have two or more daughters loop on the stack to see if they are
351  // selected
352  Int_t d0Tmp = -1;
353  Int_t d1Tmp = -1;
354  for(int id = d0; id<=d1;++id){
355  if(fMCEventH->IsParticleSelected(id)){
356  if(d0Tmp==-1){
357  // first time
358  d0Tmp = fMCEventH->GetNewLabel(id);
359  d1Tmp = d0Tmp; // this is to have the same schema as on the stack i.e. with one daugther d0 and d1 are the same
360  }
361  else d1Tmp = fMCEventH->GetNewLabel(id);
362  }
363  }
364  mcpartTmp.SetDaughter(0,d0Tmp);
365  mcpartTmp.SetDaughter(1,d1Tmp);
366  } else {
367  AliError(Form("Unxpected indices %d %d",d0,d1));
368  }
369 
370  if(m<0){
371  mcpartTmp.SetMother(m);
372  } else {
374  else AliError(Form("PROBLEM Mother not selected %d \n", m));
375  }
376 
377  new (l[j++]) AliAODMCParticle(mcpartTmp);
378 
379  }
380  }
381  AliInfo(Form("AliAODHandler::StoreMCParticles: Selected %d (Primaries %d / total %d) after validation \n",
382  j,nprim,np));
383 
384  // Set the labels in the AOD output...
385  // Remapping
386 
387  // AODTracks
388  TClonesArray* tracks = fAODEvent->GetTracks();
389  Int_t tofLabel[3];
390  if(tracks){
391  for(int it = 0; it < fAODEvent->GetNumberOfTracks();++it){
392  AliAODTrack *track = dynamic_cast<AliAODTrack*>(fAODEvent->GetTrack(it));
393  if(!track) AliFatal("Not a standard AOD");
394 
395  Int_t sign = 1;
396  Int_t label = track->GetLabel();
397  int labelT = label;
398  if(label<0){ // preserve the sign for later usage
399  label *= -1;
400  sign = -1;
401  }
402 
403  if (label >= AliMCEvent::BgLabelOffset()) label = mcEvent->BgLabelToIndex(label);
404  if(label > np || track->GetLabel() == 0){
405  AliWarning(Form("Wrong ESD track label %5d (%5d)",track->GetLabel(), label));
406  }
407  int labelN = fMCEventH->GetNewLabel(label);
408  if(labelN == 0) {
409  AliWarning(Form("New label not found for %5d (%5d)",track->GetLabel(), label));
410  }
411  track->SetLabel(sign*labelN);
412 
413  track->GetTOFLabel(tofLabel);
414 
415  for (Int_t i = 0; i < 3; i++) {
416  label = tofLabel[i]; // esd label
417  Int_t nlabel = label; // new label
418  if (label < 0) continue;
419  if (label >= AliMCEvent::BgLabelOffset()) nlabel = mcEvent->BgLabelToIndex(label);
420  if(nlabel > np || label == 0) {
421  AliWarning(Form("Wrong TOF label %5d (%5d)", label, nlabel));
422  }
423  labelN = fMCEventH->GetNewLabel(label);
424  if(labelN == 0){
425  AliWarning(Form("New TOF label not found for %5d %5d, Track label was: %5d",i, label, labelT));
426  tofLabel[i] = -label;
427  } else {
428  tofLabel[i] = labelN;
429  }
430  }
431  track->SetTOFLabel(tofLabel);
432  }
433  }
434 
435  // AOD calo cluster
436  TClonesArray *clusters = fAODEvent->GetCaloClusters();
437  if(clusters){
438  for (Int_t iClust = 0;iClust < fAODEvent->GetNumberOfCaloClusters(); ++iClust) {
439  AliAODCaloCluster * cluster = fAODEvent->GetCaloCluster(iClust);
440  UInt_t nLabel = cluster->GetNLabels();
441  // Ugly but do not want to fragment memory by creating
442  // new Int_t (nLabel)
443  Int_t* labels = const_cast<Int_t*>(cluster->GetLabels());
444  if (labels){
445  for(UInt_t i = 0;i < nLabel;++i){
446  labels[i] = fMCEventH->GetNewLabel(cluster->GetLabelAt(i));
447  }
448  }
449  // cluster->SetLabels(labels,nLabel);
450  }// iClust
451  }// clusters
452 
453  // AOD calo cells MC label re-index
454  Int_t iCell, nCell, cellMCLabel, cellMCLabelNew;;
455  Short_t cellAbsId;
456  Double_t cellE, cellT, cellEFrac;
457  AliAODCaloCells *cells;
458 
459  // EMCal
460  cells = fAODEvent->GetEMCALCells();
461  if( cells ){
462  nCell = cells->GetNumberOfCells() ;
463  for( iCell = 0; iCell < nCell; iCell++ ){
464  cells->GetCell( iCell, cellAbsId, cellE, cellT, cellMCLabel, cellEFrac );
465  // GetNewLabel returns 1 in case when -1 is supplied
466  if( cellMCLabel < 0 )
467  cellMCLabelNew = cellMCLabel;
468  else
469  cellMCLabelNew = fMCEventH->GetNewLabel( cellMCLabel );
470 
471  cells->SetCell( iCell, cellAbsId, cellE, cellT, cellMCLabelNew, cellEFrac );
472  }
473  }
474  // PHOS
475  cells = fAODEvent->GetPHOSCells();
476  if( cells ){
477  nCell = cells->GetNumberOfCells() ;
478  for( iCell = 0; iCell < nCell; iCell++ ){
479  cells->GetCell( iCell, cellAbsId, cellE, cellT, cellMCLabel, cellEFrac );
480  // GetNewLabel returns 1 in case when -1 is supplied
481  if( cellMCLabel < 0 )
482  cellMCLabelNew = cellMCLabel;
483  else
484  cellMCLabelNew = fMCEventH->GetNewLabel( cellMCLabel );
485 
486  cells->SetCell( iCell, cellAbsId, cellE, cellT, cellMCLabelNew, cellEFrac );
487  }
488  }
489 
490  // AOD tracklets
491  AliAODTracklets *tracklets = fAODEvent->GetTracklets();
492  if(tracklets){
493  for(int it = 0;it < tracklets->GetNumberOfTracklets();++it){
494  int label0 = tracklets->GetLabel(it,0);
495  int label1 = tracklets->GetLabel(it,1);
496  if(label0>=0)label0 = fMCEventH->GetNewLabel(label0);
497  if(label1>=0)label1 = fMCEventH->GetNewLabel(label1);
498  tracklets->SetLabel(it,0,label0);
499  tracklets->SetLabel(it,1,label1);
500  }
501  }
502 
503 }
504 
505 //______________________________________________________________________________
507 {
509 
510  if(fFillAOD && fFillAODRun && fAODEvent){
512  fTreeA->BranchRef();
513  FillTree();
514  }
515 
516  if ((fFillAOD && fFillAODRun) || fFillExtension) {
517  if (fExtensions && fFillExtension) {
518  // fFillExtension can be set by the ESD filter or by a delta filter in case of AOD inputs
519  TIter next(fExtensions);
520  AliAODExtension *ext;
521  while ((ext=(AliAODExtension*)next())) ext->FinishEvent();
522  }
523  if (fFilters && fFillAOD && fFillAODRun) {
524  TIter nextf(fFilters);
525  AliAODExtension *ext;
526  while ((ext=(AliAODExtension*)nextf())) {
527  ext->FinishEvent();
528  }
529  }
530  }
531 
532  if (fIsStandard && fAODEvent)
533  {
534  fAODEvent->ResetStd();
535  }
536 
537  if (fAODEvent)
538  {
539  TClonesArray *mcarray = static_cast<TClonesArray*>(fAODEvent->FindListObject(AliAODMCParticle::StdBranchName()));
540  if(mcarray) mcarray->Delete();
541 
543  if(mcHeader) mcHeader->Reset();
544  }
545 
546  // Reset AOD replication flag
547  fAODIsReplicated = kFALSE;
548  return kTRUE;
549 }
550 
551 //______________________________________________________________________________
553 {
555 
557 
558  TIter nextF(fFilters);
559  AliAODExtension *ext;
560  while ((ext=static_cast<AliAODExtension*>(nextF())))
561  {
562  ext->AddAODtoTreeUserInfo();
563  }
564 
565  TIter nextE(fExtensions);
566  while ((ext=static_cast<AliAODExtension*>(nextE())))
567  {
568  ext->AddAODtoTreeUserInfo();
569  }
570 
571  return kTRUE;
572 }
573 
574 //______________________________________________________________________________
576 {
578 
579  if (fFileA) {
580  fFileA->Write();
581  fFileA->Close();
582  delete fFileA;
583  fFileA = 0;
584  // When closing the file, the tree is also deleted.
585  fTreeA = 0;
586  }
587 
588  TIter nextF(fFilters);
589  AliAODExtension *ext;
590  while ((ext=static_cast<AliAODExtension*>(nextF())))
591  {
592  ext->TerminateIO();
593  }
594 
595  TIter nextE(fExtensions);
596  while ((ext=static_cast<AliAODExtension*>(nextE())))
597  {
598  ext->TerminateIO();
599  }
600 
601  return kTRUE;
602 }
603 
604 //______________________________________________________________________________
606 {
608 
609  fTreeA = new TTree("aodTree", "AliAOD tree");
610  fTreeA->Branch(fAODEvent->GetList());
611  if (flag == 0) fTreeA->SetDirectory(0);
612  fMemCountAOD = 0;
613 }
614 
615 //______________________________________________________________________________
617 {
618 
620 
621  Long64_t nbf = fTreeA->Fill();
622  if (fTreeBuffSize>0 && fTreeA->GetAutoFlush()<0 && (fMemCountAOD += nbf)>fTreeBuffSize ) { // default limit is still not reached
623  nbf = fTreeA->GetZipBytes();
624  if (nbf>0) nbf = -nbf;
625  else nbf = fTreeA->GetEntries();
626  fTreeA->SetAutoFlush(nbf);
627  AliInfo(Form("Calling fTreeA->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
628  nbf,fMemCountAOD,fTreeA->GetTotBytes(),fTreeA->GetZipBytes()));
629  }
630 
631 }
632 
633 //______________________________________________________________________________
635 {
637 
638  if (fTreeA) fTreeA->GetUserInfo()->Add(fAODEvent);
639  // Now the tree owns our fAODEvent...
640  fAODEvent = 0;
641 }
642 
643 //______________________________________________________________________________
644 void AliAODHandler::AddBranch(const char* cname, void* addobj, const char* filename)
645 {
648 
649  if (strlen(filename))
650  {
651  AliAODExtension *ext = AddExtension(filename);
652  ext->AddBranch(cname, addobj);
653  return;
654  }
655 
656  // Add branch to all filters
657  // Add branch to all filters
658  if (fFilters) {
659  TIter next(fFilters);
660  AliAODExtension *ext;
661  while ((ext=(AliAODExtension*)next())) ext->AddBranch(cname, addobj);
662  }
663 
664  TDirectory *owd = gDirectory;
665  if (fFileA)
666  {
667  fFileA->cd();
668  }
669 
670  char** apointer = (char**) addobj;
671  TObject* obj = (TObject*) *apointer;
672 
673  fAODEvent->AddObject(obj);
674 
675  const Int_t kSplitlevel = 99; // default value in TTree::Branch()
676  const Int_t kBufsize = 32000; // default value in TTree::Branch()
677 
678  if (!fTreeA->FindBranch(obj->GetName()))
679  {
680  // Do the same as if we book via
681  // TTree::Branch(TCollection*)
682 
683  fTreeA->Bronch(obj->GetName(), cname, fAODEvent->GetList()->GetObjectRef(obj),
684  kBufsize, kSplitlevel - 1);
685  }
686  owd->cd();
687 }
688 
689 //______________________________________________________________________________
690 AliAODExtension *AliAODHandler::AddExtension(const char *filename, const char *title, Bool_t tomerge)
691 {
693 
694  TString fname(filename);
695  if (!fname.EndsWith(".root")) fname += ".root";
696  if (!fExtensions) {
697  fExtensions = new TObjArray();
698  fExtensions->SetOwner();
699  }
700  AliAODExtension *ext = (AliAODExtension*)fExtensions->FindObject(fname);
701  if (!ext) {
702  ext = new AliAODExtension(fname, title);
703  fExtensions->Add(ext);
704  }
705  ext->SetToMerge(tomerge);
706  return ext;
707 }
708 
709 //______________________________________________________________________________
710 AliAODExtension *AliAODHandler::GetExtension(const char *filename) const
711 {
713 
714  if (!fExtensions) return NULL;
715  return (AliAODExtension*)fExtensions->FindObject(filename);
716 }
717 
718 //______________________________________________________________________________
719 AliAODExtension *AliAODHandler::AddFilteredAOD(const char *filename, const char *filtername, Bool_t tomerge)
720 {
722 
723  if (!fFilters) {
724  fFilters = new TObjArray();
725  fFilters->SetOwner();
726  }
727  AliAODExtension *filter = (AliAODExtension*)fFilters->FindObject(filename);
728  if (!filter) {
729  filter = new AliAODExtension(filename, filtername, kTRUE);
730  fFilters->Add(filter);
731  }
732  filter->SetToMerge(tomerge);
733  return filter;
734 }
735 
736 //______________________________________________________________________________
737 AliAODExtension *AliAODHandler::GetFilteredAOD(const char *filename) const
738 {
740 
741  if (!fFilters) return NULL;
742  return (AliAODExtension*)fFilters->FindObject(filename);
743 }
744 
745 //______________________________________________________________________________
747 {
749 
750  fFileName = fname;
751 }
752 
753 //______________________________________________________________________________
755 {
757 
758  return fFileName.Data();
759 }
760 
761 //______________________________________________________________________________
762 const char *AliAODHandler::GetExtraOutputs(Bool_t merge) const
763 {
765 
766  static TString eoutputs;
767  eoutputs = "";
768  AliAODExtension *obj;
769  if (fExtensions) {
770  TIter next1(fExtensions);
771  while ((obj=(AliAODExtension*)next1())) {
772  if (merge && !obj->IsToMerge()) continue;
773  if (!eoutputs.IsNull()) eoutputs += ",";
774  eoutputs += obj->GetName();
775  }
776  }
777  if (fFilters) {
778  TIter next2(fFilters);
779  while ((obj=(AliAODExtension*)next2())) {
780  if (merge && !obj->IsToMerge()) continue;
781  if (!eoutputs.IsNull()) eoutputs += ",";
782  eoutputs += obj->GetName();
783  }
784  }
785  return eoutputs.Data();
786 }
787 
788 //______________________________________________________________________________
790 {
792 
793  if ( fExtensions && fExtensions->GetEntries()>0 ) return kTRUE;
794 
795  return kFALSE;
796 }
797 
798 //______________________________________________________________________________
800 
801 
805 
806  if(!genHeader)return;
807  AliGenPythiaEventHeader *pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
808  if (pythiaGenHeader) {
809  mcHeader->SetEventType(pythiaGenHeader->ProcessType());
810  mcHeader->SetPtHard(pythiaGenHeader->GetPtHard());
811  return;
812  }
813 
814  AliGenDPMjetEventHeader* dpmJetGenHeader = dynamic_cast<AliGenDPMjetEventHeader*>(genHeader);
815 
816  if (dpmJetGenHeader){
817  mcHeader->SetEventType(dpmJetGenHeader->ProcessType());
818  return;
819  }
820 
821  AliGenHijingEventHeader* hijingGenHeader = dynamic_cast<AliGenHijingEventHeader*>(genHeader);
822  if(hijingGenHeader){
823  mcHeader->SetImpactParameter(hijingGenHeader->ImpactParameter());
824  return;
825  }
826 
827  // AliWarning(Form("MC Eventheader not known: %s",genHeader->GetName()));
828 
829 }
830 
Class for calorimeter cluster, EMCal and PHOS, data handling.
virtual Int_t GetMother() const
virtual const char * GetExtraOutputs(Bool_t merge=kTRUE) const
void CreateTree(Int_t flag)
void PrintExtensions(const TObjArray &array) const
Implementation of the Event Handler Interface for AOD.
Definition: AliAODHandler.h:27
virtual Bool_t IsPhysicalPrimary(Int_t i) const
Definition: AliMCEvent.cxx:782
virtual void Reset()
virtual void SetVertex(Double_t *vtx)
void AddBranch(const char *cname, void *addobj)
virtual Int_t GetNumberOfPrimaries() const
Definition: AliMCEvent.h:128
Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel, Double_t &efrac) const
virtual void PrimaryVertex(TArrayF &o) const
void MakeEntriesReferencable()
Bool_t HasExtensions() const
void SetEvent(AliAODEvent *event)
Bool_t fAODIsReplicated
Flag true if replication as been executed.
AliHeader * Header()
Definition: AliMCEvent.h:115
#define TObjArray
Int_t GetNumberOfCaloClusters() const
Definition: AliAODEvent.h:216
Class for calorimeter cell AOD data handling.
Bool_t IsParticleSelected(Int_t i)
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)
UInt_t GetNLabels() const
Definition: AliAODCluster.h:67
void CreateStdContent()
virtual Bool_t IsSecondaryFromMaterial(Int_t index)
Definition: AliMCEvent.cxx:810
AliAODTracklets * GetTracklets() const
Definition: AliAODEvent.h:263
TClonesArray * GetTracks() const
Definition: AliAODEvent.h:164
TROOT * gROOT
void SetMCProcessCode(UInt_t mcProcess)
AliAODExtension * GetFilteredAOD(const char *filename) const
Int_t GetLabelAt(UInt_t i) const
TList * GetList() const
Definition: AliAODEvent.h:85
TString fFileName
Output file name.
Float_t ImpactParameter() const
AliTPCfastTrack * track
virtual Int_t BgLabelToIndex(Int_t label)
Definition: AliMCEvent.cxx:766
virtual Int_t GetNumberOfTracklets() const
virtual const char * GetOutputFileName() const
Bool_t fIsStandard
Flag for standard aod creation.
static const char * StdBranchName()
#define AliWarning(message)
Definition: AliLog.h:541
AliAODExtension * AddExtension(const char *filename, const char *title="", Bool_t tomerge=kFALSE)
virtual Bool_t FinishEvent()
AliVParticle realisation for MC Particles in the AOD.
AliAODExtension * GetExtension(const char *filename) const
virtual Int_t GetDaughter(Int_t i) const
TObjArray * array
Definition: AnalyzeLaser.C:12
Int_t GetLabel() const
Definition: AliAODTrack.h:197
AOD class to store tracklets.
virtual Int_t GetLabel(Int_t i, Int_t layer) const
virtual void SetLabel(Int_t i, Int_t layer, Int_t label)
void SetMCHeaderInfo(AliAODMCHeader *mcHeader, AliGenEventHeader *genHeader)
void AddObject(TObject *obj)
void SetTOFLabel(const Int_t *p)
virtual ~AliAODHandler()
AliAODCaloCluster * GetCaloCluster(Int_t nCluster) const
Definition: AliAODEvent.h:217
virtual Bool_t Init(Option_t *option)
AliStack * Stack()
Definition: AliMCEvent.h:114
virtual AliVParticle * GetTrack(Int_t i) const
Definition: AliMCEvent.cxx:538
#define AliInfo(message)
Definition: AliLog.h:484
Bool_t IsToMerge() const
static Int_t BgLabelOffset()
Definition: AliMCEvent.h:138
TObject * FindListObject(const char *objName) const
void SetLabel(Int_t label)
Definition: AliAODTrack.h:382
virtual void AddCocktailHeaders(AliGenEventHeader *header)
AliAODEvent * fAODEvent
! Pointer to the AOD event
AliAODCaloCells * GetPHOSCells() const
Definition: AliAODEvent.h:267
TTree * fTreeA
! tree for AOD persistency
AliMCEventHandler * fMCEventH
! Pointer to mc event handler needed not to depend on the manager
virtual void SetMother(Int_t im)
Short_t GetNumberOfCells() const
TObjArray * fExtensions
List of extensions.
Int_t * GetLabels() const
Definition: AliAODCluster.h:66
Long64_t fMemCountAOD
! accumulated AOD size before AutoSave
virtual void SetPtHard(Double_t f)
#define AliFatal(message)
Definition: AliLog.h:640
void AddAODtoTreeUserInfo()
void Print(Option_t *opt="") const
void SetStatus(Int_t status)
virtual Int_t GetNumberOfTracks() const
Definition: AliMCEvent.h:98
AOD base class.
Definition: AliAODEvent.h:48
void GetTOFLabel(Int_t *p) const
Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time, Int_t mclabel=-1, Double_t efrac=0., Bool_t isHG=kFALSE)
virtual void SetDaughter(Int_t i, Int_t id)
virtual void AddGeneratorName(const char *c)
Int_t GetNewLabel(Int_t i)
void Print(Option_t *opt="") const
Bool_t Init(Option_t *option)
virtual AliGenEventHeader * GenEventHeader() const
Definition: AliHeader.cxx:244
virtual TParticle * Particle() const
Definition: AliMCParticle.h:63
virtual void SetEventType(UInt_t eventType)
TClonesArray * GetCaloClusters() const
Definition: AliAODEvent.h:215
AliMCEvent * MCEvent() const
void AddBranch(const char *cname, void *addobj, const char *fname="")
virtual void SetOutputFileName(const char *fname)
virtual Bool_t Terminate()
AliAODCaloCells * GetEMCALCells() const
Definition: AliAODEvent.h:266
Bool_t fFillExtension
Flag for filling or the delta AOD tree at the end.
Implementation of Class AliAODMCHeader.
virtual void SetImpactParameter(Double_t b)
virtual Bool_t TerminateIO()
Bool_t fFillAOD
Flag for filling of the AOD tree at the end (all or nothing evt by evt)
#define AliError(message)
Definition: AliLog.h:591
void SetToMerge(Bool_t flag)
AliAODExtension * AddFilteredAOD(const char *filename, const char *filtername, Bool_t tomerge=kFALSE)
AliVTrack * GetTrack(Int_t nTrack) const
Definition: AliAODEvent.h:167
Bool_t fFillAODRun
Flag for filling of the AOD tree at the end (run)
void StoreMCParticles()
char * fname
static const char * StdBranchName()
virtual Bool_t IsSecondaryFromWeakDecay(Int_t index)
Definition: AliMCEvent.cxx:797
TFile * fFileA
! Output file
AOD track implementation of AliVTrack.
Definition: AliAODTrack.h:29
Long64_t fTreeBuffSize
allowed uncompressed buffer size per tree
Int_t GetNumberOfTracks() const
Definition: AliAODEvent.h:166
TObjArray * fFilters
List of filtered AOD&#39;s.
Support class for AOD extensions. This is created by the user analysis.