ROOT logo
#ifndef ALIAODEXTENSION_H
#define ALIAODEXTENSION_H

/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

//-------------------------------------------------------------------------
//     Support class for AOD extensions. This is created by the user analysis
//     that requires a separate file for some AOD branches. The name of the 
//     AliAODExtension object is the file name where the AOD branches will be
//     stored.
//     Author: Andrei Gheata, CERN
//-------------------------------------------------------------------------

#ifndef ROOT_TNamed
#  include "TNamed.h"
#endif

class AliAODBranchReplicator;
class AliAODEvent;
class TFile;
class TList;
class TMap;
class TTree;

class AliAODExtension : public TNamed {
  
public:
  
  enum EAliAODExtensionFlags {
    kFilteredAOD      = BIT(14),
    kDropUnspecifiedBranches = BIT(15),
    kToMerge          = BIT(16)
  };
  
  AliAODExtension();
  AliAODExtension(const char* name, const char* title, Bool_t isfilter=kFALSE);
  virtual ~AliAODExtension();
  void                 AddBranch(const char* cname, void* addobj);
  Bool_t               FinishEvent();
  Int_t                GetNtotal() const         {return fNtotal;}
  Int_t                GetNpassed() const        {return fNpassed;}
  const char*          GetOutputFileName() const {return TNamed::GetName();}
  AliAODEvent*         GetAOD() const            {return fAODEvent;}
  TTree*               GetTree() const           {return fTreeE;}
  Bool_t               Init(Option_t *option);
  Bool_t               IsFilteredAOD() const     {return TObject::TestBit(kFilteredAOD);}
  Bool_t               IsEventSelected() const   {return fSelected;}
  Bool_t               IsToMerge() const         {return TObject::TestBit(kToMerge);}
  void                 SelectEvent(Bool_t flag=kTRUE)  {fSelected = flag;}
  void                 SetEvent(AliAODEvent* event);
  void                 SetOutputFileName(const char* fname) {TNamed::SetName(fname);}
  void                 SetToMerge(Bool_t flag)   {TObject::SetBit(kToMerge,flag);}
  void                 SetTreeBuffSize(Long64_t sz=30000000) {fTreeBuffSize = sz;}
  Bool_t               TerminateIO();
  
  void Print(Option_t* opt="") const;
  
  // Branches not specified in any FilterBranch call will be dropped by default
  void DropUnspecifiedBranches() { TObject::SetBit(kDropUnspecifiedBranches); }
  
  // Branches not specified in any FilterBranch call will be kept by default
  void KeepUnspecifiedBranches() { TObject::ResetBit(kDropUnspecifiedBranches); }
  
  void FilterBranch(const char* branchName, AliAODBranchReplicator* replicator=0x0);
  
  /* Use DisableReferences if and only if the output AOD contains no TRef or TRefArray,
   otherwise the produced AOD won't be valid.
   */
  void DisableReferences() { fEnableReferences=kFALSE; }
  
  void EnableReferences() { fEnableReferences=kTRUE; }
  
  void AddAODtoTreeUserInfo();
  void FillTree();
  
private:
  AliAODExtension(const AliAODExtension&);             // Not implemented
  AliAODExtension& operator=(const AliAODExtension&);  // Not implemented
  
private:
  AliAODEvent             *fAODEvent;               //! Pointer to the AOD event
  TTree                   *fTreeE;                  //! tree for AOD persistency
  TFile                   *fFileE;                  //! Output file
  Int_t                    fNtotal;                 //! Number of processed events
  Int_t                    fNpassed;                //! Number of events that passed the filter
  Bool_t                   fSelected;               //! Select current event for filtered AOD's. Made false at event start.
  Long64_t                 fTreeBuffSize;            // Requested buffer size for AOD tree
  Long64_t                 fMemCountAOD;             // Number of bytes filled in tree (accumulates until requested bytes reached)
  
  TMap*                    fRepFiMap; // which branch(es) to filter out / and or replicate
  TList*                   fRepFiList; // list of unique filter/replicator
  
  Bool_t                   fEnableReferences; // whether or not to enable the TRefTable branch
  TList*                   fObjectList; //! internal list of which objects to keep 

  ClassDef(AliAODExtension, 3) // Support for extra AOD branches in a separate AOD file
};

#endif
 AliAODExtension.h:1
 AliAODExtension.h:2
 AliAODExtension.h:3
 AliAODExtension.h:4
 AliAODExtension.h:5
 AliAODExtension.h:6
 AliAODExtension.h:7
 AliAODExtension.h:8
 AliAODExtension.h:9
 AliAODExtension.h:10
 AliAODExtension.h:11
 AliAODExtension.h:12
 AliAODExtension.h:13
 AliAODExtension.h:14
 AliAODExtension.h:15
 AliAODExtension.h:16
 AliAODExtension.h:17
 AliAODExtension.h:18
 AliAODExtension.h:19
 AliAODExtension.h:20
 AliAODExtension.h:21
 AliAODExtension.h:22
 AliAODExtension.h:23
 AliAODExtension.h:24
 AliAODExtension.h:25
 AliAODExtension.h:26
 AliAODExtension.h:27
 AliAODExtension.h:28
 AliAODExtension.h:29
 AliAODExtension.h:30
 AliAODExtension.h:31
 AliAODExtension.h:32
 AliAODExtension.h:33
 AliAODExtension.h:34
 AliAODExtension.h:35
 AliAODExtension.h:36
 AliAODExtension.h:37
 AliAODExtension.h:38
 AliAODExtension.h:39
 AliAODExtension.h:40
 AliAODExtension.h:41
 AliAODExtension.h:42
 AliAODExtension.h:43
 AliAODExtension.h:44
 AliAODExtension.h:45
 AliAODExtension.h:46
 AliAODExtension.h:47
 AliAODExtension.h:48
 AliAODExtension.h:49
 AliAODExtension.h:50
 AliAODExtension.h:51
 AliAODExtension.h:52
 AliAODExtension.h:53
 AliAODExtension.h:54
 AliAODExtension.h:55
 AliAODExtension.h:56
 AliAODExtension.h:57
 AliAODExtension.h:58
 AliAODExtension.h:59
 AliAODExtension.h:60
 AliAODExtension.h:61
 AliAODExtension.h:62
 AliAODExtension.h:63
 AliAODExtension.h:64
 AliAODExtension.h:65
 AliAODExtension.h:66
 AliAODExtension.h:67
 AliAODExtension.h:68
 AliAODExtension.h:69
 AliAODExtension.h:70
 AliAODExtension.h:71
 AliAODExtension.h:72
 AliAODExtension.h:73
 AliAODExtension.h:74
 AliAODExtension.h:75
 AliAODExtension.h:76
 AliAODExtension.h:77
 AliAODExtension.h:78
 AliAODExtension.h:79
 AliAODExtension.h:80
 AliAODExtension.h:81
 AliAODExtension.h:82
 AliAODExtension.h:83
 AliAODExtension.h:84
 AliAODExtension.h:85
 AliAODExtension.h:86
 AliAODExtension.h:87
 AliAODExtension.h:88
 AliAODExtension.h:89
 AliAODExtension.h:90
 AliAODExtension.h:91
 AliAODExtension.h:92
 AliAODExtension.h:93
 AliAODExtension.h:94
 AliAODExtension.h:95
 AliAODExtension.h:96
 AliAODExtension.h:97
 AliAODExtension.h:98
 AliAODExtension.h:99
 AliAODExtension.h:100
 AliAODExtension.h:101
 AliAODExtension.h:102