]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODExtension.h
Updates for embedding on AOD level
[u/mrichter/AliRoot.git] / STEER / AliAODExtension.h
1 #ifndef ALIAODEXTENSION_H
2 #define ALIAODEXTENSION_H
3
4 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //-------------------------------------------------------------------------
10 //     Support class for AOD extensions. This is created by the user analysis
11 //     that requires a separate file for some AOD branches. The name of the 
12 //     AliAODExtension object is the file name where the AOD branches will be
13 //     stored.
14 //     Author: Andrei Gheata, CERN
15 //-------------------------------------------------------------------------
16
17 #ifndef ROOT_TNamed
18 #  include "TNamed.h"
19 #endif
20
21 class AliAODBranchReplicator;
22 class AliAODEvent;
23 class TFile;
24 class TList;
25 class TMap;
26 class TTree;
27
28 class AliAODExtension : public TNamed {
29   
30 public:
31   
32   enum EAliAODExtensionFlags {
33     kFilteredAOD      = BIT(14),
34     kDropUnspecifiedBranches = BIT(15)
35   };
36   
37   AliAODExtension();
38   AliAODExtension(const char* name, const char* title, Bool_t isfilter=kFALSE);
39   virtual ~AliAODExtension();
40   void                 AddBranch(const char* cname, void* addobj);
41   Bool_t               FinishEvent();
42   Int_t                GetNtotal() const         {return fNtotal;}
43   Int_t                GetNpassed() const        {return fNpassed;}
44   const char*          GetOutputFileName() const {return TNamed::GetName();}
45   AliAODEvent*         GetAOD() const            {return fAODEvent;}
46   TTree*               GetTree() const           {return fTreeE;}
47   Bool_t               Init(Option_t *option);
48   Bool_t               IsFilteredAOD() const     {return TObject::TestBit(kFilteredAOD);}
49   Bool_t               IsEventSelected() const   {return fSelected;}
50   void                 SelectEvent(Bool_t flag=kTRUE)  {fSelected = flag;}
51   void                 SetEvent(AliAODEvent* event);
52   void                 SetOutputFileName(const char* fname) {TNamed::SetName(fname);}
53   Bool_t               TerminateIO();
54   
55   void Print(Option_t* opt="") const;
56   
57   // Branches not specified in any FilterBranch call will be dropped by default
58   void DropUnspecifiedBranches() { TObject::SetBit(kDropUnspecifiedBranches); }
59   
60   // Branches not specified in any FilterBranch call will be kept by default
61   void KeepUnspecifiedBranches() { TObject::ResetBit(kDropUnspecifiedBranches); }
62   
63   void FilterBranch(const char* branchName, AliAODBranchReplicator* replicator=0x0);
64   
65   /* Use DisableReferences if and only if the output AOD contains no TRef or TRefArray,
66    otherwise the produced AOD won't be valid.
67    */
68   void DisableReferences() { fEnableReferences=kFALSE; }
69   
70   void EnableReferences() { fEnableReferences=kTRUE; }
71   
72   void AddAODtoTreeUserInfo();
73   
74 private:
75   AliAODExtension(const AliAODExtension&);             // Not implemented
76   AliAODExtension& operator=(const AliAODExtension&);  // Not implemented
77   
78 private:
79   AliAODEvent             *fAODEvent;               //! Pointer to the AOD event
80   TTree                   *fTreeE;                  //! tree for AOD persistency
81   TFile                   *fFileE;                  //! Output file
82   Int_t                    fNtotal;                 //! Number of processed events
83   Int_t                    fNpassed;                //! Number of events that passed the filter
84   Bool_t                   fSelected;               //! Select current event for filtered AOD's. Made false at event start.
85   
86   TMap*                    fRepFiMap; // which branch(es) to filter out / and or replicate
87   TList*                   fRepFiList; // list of unique filter/replicator
88   
89   Bool_t                   fEnableReferences; // whether or not to enable the TRefTable branch
90   TList*                   fObjectList; //! internal list of which objects to keep 
91   
92   ClassDef(AliAODExtension, 2) // Support for extra AOD branches in a separate AOD file
93 };
94
95 #endif