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