Bug fix. Removed delete statement
[u/mrichter/AliRoot.git] / STEER / AliAODHandler.h
1 #ifndef ALIAODHANDLER_H
2 #define ALIAODHANDLER_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //-------------------------------------------------------------------------
9 //     Implementation of the Event Handler Interface for AOD
10 //     Author: Andreas Morsch, CERN
11 //-------------------------------------------------------------------------
12
13 #include "AliVEventHandler.h"
14
15 class AliAODEvent;
16 class TFile;
17 class TTree;
18 class TObjArray;
19 class AliMCEventHandler;
20 class AliAODMCHeader;
21 class AliAODExtension;
22 class AliGenEventHeader;
23
24
25
26 class AliAODHandler : public AliVEventHandler {
27     
28  public:
29     AliAODHandler();
30     AliAODHandler(const char* name, const char* title);
31     virtual ~AliAODHandler();
32     virtual void         SetOutputFileName(const char* fname);
33     virtual const char*  GetOutputFileName();
34     virtual Bool_t       Init(Option_t* option);
35     virtual Bool_t       Init(TTree* /*tree*/, Option_t* /*option*/)  {return kTRUE;}
36     virtual Bool_t       BeginEvent(Long64_t /*entry*/){return kTRUE;}
37     virtual Bool_t       Notify() { return AliVEventHandler::Notify(); };
38     virtual Bool_t       Notify(const char * /* path */) {return kTRUE;}
39     virtual Bool_t       FinishEvent();
40     virtual Bool_t       Terminate();
41     virtual Bool_t       TerminateIO();
42     //
43     virtual void         SetCreateNonStandardAOD()   {fIsStandard = kFALSE;}
44     virtual void         SetFillAOD(Bool_t b)      {fFillAOD = b;}
45     virtual void         SetNeedsHeaderReplication() {fNeedsHeaderReplication = kTRUE;}
46     virtual void         SetNeedsTracksBranchReplication() {fNeedsTracksBranchReplication = kTRUE;}
47     virtual void         SetNeedsVerticesBranchReplication() {fNeedsVerticesBranchReplication = kTRUE;}
48     virtual void         SetNeedsV0sBranchReplication() {fNeedsV0sBranchReplication = kTRUE;}
49     virtual void         SetNeedsTrackletsBranchReplication() {fNeedsTrackletsBranchReplication = kTRUE;}
50     virtual void         SetNeedsPMDClustersBranchReplication() {fNeedsPMDClustersBranchReplication = kTRUE;}
51     virtual void         SetNeedsJetsBranchReplication() {fNeedsJetsBranchReplication = kTRUE;}
52     virtual void         SetNeedsFMDClustersBranchReplication() {fNeedsFMDClustersBranchReplication = kTRUE;}
53     virtual void         SetNeedsCaloClustersBranchReplication() {fNeedsCaloClustersBranchReplication = kTRUE;}
54     virtual void         SetAODIsReplicated() {fAODIsReplicated = kTRUE;}
55     //
56     AliAODEvent*         GetAOD()  {return fAODEvent;}
57     virtual TTree*       GetTree() const {return fTreeA;}
58     TObjArray*           GetExtensions() const {return fExtensions;}
59     void                 CreateTree(Int_t flag);
60     void                 FillTree();
61     void                 AddAODtoTreeUserInfo();
62     void                 AddBranch(const char* cname, void* addobj, const char *fname="");
63     AliAODExtension*     AddExtension(const char *filename, const char *title="");                 
64     Bool_t               IsStandard() {return fIsStandard;}
65     Bool_t               GetFillAOD(){return fFillAOD;} 
66     Bool_t               NeedsHeaderReplication() {return  fNeedsHeaderReplication;}
67     Bool_t               NeedsTracksBranchReplication() {return  fNeedsTracksBranchReplication;}
68     Bool_t               NeedsVerticesBranchReplication() {return  fNeedsVerticesBranchReplication;}
69     Bool_t               NeedsV0sBranchReplication() {return  fNeedsV0sBranchReplication;}
70     Bool_t               NeedsTrackletsBranchReplication() {return  fNeedsTrackletsBranchReplication;}
71     Bool_t               NeedsPMDClustersBranchReplication() {return  fNeedsPMDClustersBranchReplication;}
72     Bool_t               NeedsJetsBranchReplication() {return  fNeedsJetsBranchReplication;}
73     Bool_t               NeedsFMDClustersBranchReplication() {return  fNeedsFMDClustersBranchReplication;}
74     Bool_t               NeedsCaloClustersBranchReplication() {return  fNeedsCaloClustersBranchReplication;}
75     Bool_t               AODIsReplicated() {return fAODIsReplicated;}
76     //
77     void                 SetInputTree(TTree* /*tree*/) {;}
78     void                 SetMCEventHandler(AliMCEventHandler* mcH) {fMCEventH = mcH;} // For internal use
79  private:
80     void StoreMCParticles();
81     void SetMCHeaderInfo(AliAODMCHeader *mcHeader,AliGenEventHeader *genHeader); // Utility function t catch different types of eventheaders
82     AliAODHandler(const AliAODHandler&);             // Not implemented
83     AliAODHandler& operator=(const AliAODHandler&);  // Not implemented
84  private:
85     Bool_t                   fIsStandard;                         // Flag for standard aod creation
86     Bool_t                   fFillAOD;                          // Flag for filling of the AOD tree at the end (all or nothing)
87     Bool_t                   fNeedsHeaderReplication;             // Flag for header replication
88     Bool_t                   fNeedsTracksBranchReplication;       // Flag for tracks replication
89     Bool_t                   fNeedsVerticesBranchReplication;     // Flag for vertices replication
90     Bool_t                   fNeedsV0sBranchReplication;          // Flag for V0s replication
91     Bool_t                   fNeedsTrackletsBranchReplication;    // Flag for Tracklets replication
92     Bool_t                   fNeedsPMDClustersBranchReplication;  // Flag for PMDClusters replication
93     Bool_t                   fNeedsJetsBranchReplication;         // Flag for Jets replication
94     Bool_t                   fNeedsFMDClustersBranchReplication;  // Flag for FMDClusters replication
95     Bool_t                   fNeedsCaloClustersBranchReplication; // Flag for CaloClusters replication
96     Bool_t                   fAODIsReplicated;                    // Flag true if replication as been executed
97     AliAODEvent             *fAODEvent;               //! Pointer to the AOD event
98     AliMCEventHandler       *fMCEventH;               //! Pointer to mc event handler needed not to depend on the manager
99     TTree                   *fTreeA;                  //! tree for AOD persistency
100     TFile                   *fFileA;                  //! Output file
101     TString                  fFileName;               //  Output file name
102     TObjArray               *fExtensions;             //  List of extensions
103     ClassDef(AliAODHandler, 4)
104 };
105
106 //-------------------------------------------------------------------------
107 //     Support class for AOD extensions. This is created by the user analysis
108 //     that requires a separate file for some AOD branches. The name of the 
109 //     AliAODExtension object is the file name where the AOD branches will be
110 //     stored.
111 //     Author: Andrei Gheata, CERN
112 //-------------------------------------------------------------------------
113
114 class AliAODExtension : public TNamed {
115     
116  public:
117     AliAODExtension() : TNamed(), fAODEvent(0), fTreeE(0), fFileE(0)   {;}
118     AliAODExtension(const char* name, const char* title) : TNamed(name,title), fAODEvent(0), fTreeE(0), fFileE(0) {;}
119     virtual ~AliAODExtension();
120     void                 AddBranch(const char* cname, void* addobj);
121     const char*          GetOutputFileName() const {return TNamed::GetName();}
122     AliAODEvent*         GetAOD() const            {return fAODEvent;}
123     TTree*               GetTree() const           {return fTreeE;}
124     Bool_t               Init(Option_t *option);
125     void                 SetOutputFileName(const char* fname) {TNamed::SetName(fname);}
126     Bool_t               TerminateIO();
127  private:
128     AliAODExtension(const AliAODExtension&);             // Not implemented
129     AliAODExtension& operator=(const AliAODExtension&);  // Not implemented
130
131  private:
132     AliAODEvent             *fAODEvent;               //! Pointer to the AOD event
133     TTree                   *fTreeE;                  //! tree for AOD persistency
134     TFile                   *fFileE;                  //! Output file
135     ClassDef(AliAODExtension, 1)                      // Support for extra AOD branches in a separate AOD file
136 };
137 #endif