]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliAODHandler.h
fix memory leak signalled in bug 72189
[u/mrichter/AliRoot.git] / STEER / AliAODHandler.h
... / ...
CommitLineData
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
15class AliAODEvent;
16class TFile;
17class TTree;
18class TObjArray;
19class AliMCEventHandler;
20class AliAODMCHeader;
21class AliAODExtension;
22class AliGenEventHeader;
23
24
25
26class 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*/) {fFillAOD=kFALSE; 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 SetFillAODforRun(Bool_t b) {fFillAODRun = b;}
46 virtual void SetNeedsHeaderReplication() {fNeedsHeaderReplication = kTRUE;}
47 virtual void SetNeedsTracksBranchReplication() {fNeedsTracksBranchReplication = kTRUE;}
48 virtual void SetNeedsVerticesBranchReplication() {fNeedsVerticesBranchReplication = kTRUE;}
49 virtual void SetNeedsV0sBranchReplication() {fNeedsV0sBranchReplication = kTRUE;}
50 virtual void SetNeedsCascadesBranchReplication() {fNeedsCascadesBranchReplication = kTRUE;}
51 virtual void SetNeedsTrackletsBranchReplication() {fNeedsTrackletsBranchReplication = kTRUE;}
52 virtual void SetNeedsPMDClustersBranchReplication() {fNeedsPMDClustersBranchReplication = kTRUE;}
53 virtual void SetNeedsJetsBranchReplication() {fNeedsJetsBranchReplication = kTRUE;}
54 virtual void SetNeedsFMDClustersBranchReplication() {fNeedsFMDClustersBranchReplication = kTRUE;}
55 virtual void SetNeedsCaloClustersBranchReplication() {fNeedsCaloClustersBranchReplication = kTRUE;}
56 virtual void SetNeedsMCParticlesBranchReplication() {fNeedsMCParticlesBranchReplication = kTRUE;}
57 virtual void SetNeedsDimuonsBranchReplication() {fNeedsDimuonsBranchReplication = kTRUE;}
58 virtual void SetAODIsReplicated() {fAODIsReplicated = kTRUE;}
59 //
60 AliAODEvent* GetAOD() {return fAODEvent;}
61 virtual TTree* GetTree() const {return fTreeA;}
62 TObjArray* GetExtensions() const {return fExtensions;}
63 AliAODExtension* GetExtension(const char *filename) const;
64 TObjArray* GetFilters() const {return fFilters;}
65 AliAODExtension* GetFilteredAOD(const char *filename) const;
66 void CreateTree(Int_t flag);
67 void FillTree();
68 void AddAODtoTreeUserInfo();
69 void AddBranch(const char* cname, void* addobj, const char *fname="");
70 AliAODExtension* AddExtension(const char *filename, const char *title="");
71 AliAODExtension* AddFilteredAOD(const char *filename, const char *filtername);
72 Bool_t IsStandard() const {return fIsStandard;}
73 Bool_t GetFillAOD() const {return fFillAOD;}
74 Bool_t NeedsHeaderReplication() const {return fNeedsHeaderReplication;}
75 Bool_t NeedsTracksBranchReplication() const {return fNeedsTracksBranchReplication;}
76 Bool_t NeedsVerticesBranchReplication() const {return fNeedsVerticesBranchReplication;}
77 Bool_t NeedsV0sBranchReplication() const {return fNeedsV0sBranchReplication;}
78 Bool_t NeedsCascadesBranchReplication() const {return fNeedsCascadesBranchReplication;}
79 Bool_t NeedsTrackletsBranchReplication() const {return fNeedsTrackletsBranchReplication;}
80 Bool_t NeedsPMDClustersBranchReplication() const {return fNeedsPMDClustersBranchReplication;}
81 Bool_t NeedsJetsBranchReplication() const {return fNeedsJetsBranchReplication;}
82 Bool_t NeedsFMDClustersBranchReplication() const {return fNeedsFMDClustersBranchReplication;}
83 Bool_t NeedsCaloClustersBranchReplication() const {return fNeedsCaloClustersBranchReplication;}
84 Bool_t NeedsMCParticlesBranchReplication() const {return fNeedsMCParticlesBranchReplication;}
85 Bool_t NeedsDimuonsBranchReplication() const {return fNeedsDimuonsBranchReplication;}
86 Bool_t AODIsReplicated() const {return fAODIsReplicated;}
87 //
88 void SetInputTree(TTree* /*tree*/) {;}
89 void SetMCEventHandler(AliMCEventHandler* mcH) {fMCEventH = mcH;} // For internal use
90 void StoreMCParticles(); // Store MC particles, only to be called from AliAnalyisTaskMCParticleFilter
91
92 private:
93 void SetMCHeaderInfo(AliAODMCHeader *mcHeader,AliGenEventHeader *genHeader); // Utility function t catch different types of eventheaders
94 AliAODHandler(const AliAODHandler&); // Not implemented
95 AliAODHandler& operator=(const AliAODHandler&); // Not implemented
96 private:
97 Bool_t fIsStandard; // Flag for standard aod creation
98 Bool_t fFillAOD; // Flag for filling of the AOD tree at the end (all or nothing evt by evt)
99 Bool_t fFillAODRun; // Flag for filling of the AOD tree at the end (run)
100 Bool_t fNeedsHeaderReplication; // Flag for header replication
101 Bool_t fNeedsTracksBranchReplication; // Flag for tracks replication
102 Bool_t fNeedsVerticesBranchReplication; // Flag for vertices replication
103 Bool_t fNeedsV0sBranchReplication; // Flag for V0s replication
104 Bool_t fNeedsCascadesBranchReplication; // Flag for Cascade replication
105 Bool_t fNeedsTrackletsBranchReplication; // Flag for Tracklets replication
106 Bool_t fNeedsPMDClustersBranchReplication; // Flag for PMDClusters replication
107 Bool_t fNeedsJetsBranchReplication; // Flag for Jets replication
108 Bool_t fNeedsFMDClustersBranchReplication; // Flag for FMDClusters replication
109 Bool_t fNeedsCaloClustersBranchReplication; // Flag for CaloClusters replication
110 Bool_t fNeedsMCParticlesBranchReplication; // Flag for MCParticles replication
111 Bool_t fNeedsDimuonsBranchReplication; // Flag for Dimuons replication
112 Bool_t fAODIsReplicated; // Flag true if replication as been executed
113 AliAODEvent *fAODEvent; //! Pointer to the AOD event
114 AliMCEventHandler *fMCEventH; //! Pointer to mc event handler needed not to depend on the manager
115 TTree *fTreeA; //! tree for AOD persistency
116 TFile *fFileA; //! Output file
117 TString fFileName; // Output file name
118 TObjArray *fExtensions; // List of extensions
119 TObjArray *fFilters; // List of filtered AOD's
120 ClassDef(AliAODHandler, 6)
121};
122
123//-------------------------------------------------------------------------
124// Support class for AOD extensions. This is created by the user analysis
125// that requires a separate file for some AOD branches. The name of the
126// AliAODExtension object is the file name where the AOD branches will be
127// stored.
128// Author: Andrei Gheata, CERN
129//-------------------------------------------------------------------------
130
131class AliAODExtension : public TNamed {
132
133public:
134
135enum EAliAODExtensionFlags {
136 kFilteredAOD = BIT(14)
137};
138
139 AliAODExtension() : TNamed(), fAODEvent(0), fTreeE(0), fFileE(0), fNtotal(0), fNpassed(0), fSelected(kFALSE) {}
140 AliAODExtension(const char* name, const char* title, Bool_t isfilter=kFALSE);
141 virtual ~AliAODExtension();
142 void AddBranch(const char* cname, void* addobj);
143 Bool_t FinishEvent();
144 Int_t GetNtotal() const {return fNtotal;}
145 Int_t GetNpassed() const {return fNpassed;}
146 const char* GetOutputFileName() const {return TNamed::GetName();}
147 AliAODEvent* GetAOD() const {return fAODEvent;}
148 TTree* GetTree() const {return fTreeE;}
149 Bool_t Init(Option_t *option);
150 Bool_t IsFilteredAOD() const {return TObject::TestBit(kFilteredAOD);}
151 Bool_t IsEventSelected() const {return fSelected;}
152 void SelectEvent(Bool_t flag=kTRUE) {fSelected = flag;}
153 void SetEvent(AliAODEvent *event);
154 void SetOutputFileName(const char* fname) {TNamed::SetName(fname);}
155 Bool_t TerminateIO();
156 private:
157 AliAODExtension(const AliAODExtension&); // Not implemented
158 AliAODExtension& operator=(const AliAODExtension&); // Not implemented
159
160 private:
161 AliAODEvent *fAODEvent; //! Pointer to the AOD event
162 TTree *fTreeE; //! tree for AOD persistency
163 TFile *fFileE; //! Output file
164 Int_t fNtotal; //! Number of processed events
165 Int_t fNpassed; //! Number of events that passed the filter
166 Bool_t fSelected; //! Select current event for filtered AOD's. Made false at event start.
167 ClassDef(AliAODExtension, 1) // Support for extra AOD branches in a separate AOD file
168};
169#endif