]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliAODHandler.h
Patch for the tracker
[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;
23class TMap;
24class AliAnalysisFilter;
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 // Extra outputs as a string separated by commas
35 virtual const char* GetExtraOutputs() const;
36 virtual Bool_t Init(Option_t* option);
37 virtual Bool_t Init(TTree* /*tree*/, Option_t* /*option*/) {return kTRUE;}
38 virtual Bool_t GetEntry() {return kTRUE;}
39
40 virtual Bool_t BeginEvent(Long64_t /*entry*/) {fFillAOD=kFALSE; return kTRUE;}
41 virtual Bool_t Notify() { return AliVEventHandler::Notify(); };
42 virtual Bool_t Notify(const char * /* path */) {return kTRUE;}
43 virtual Bool_t FinishEvent();
44 virtual Bool_t Terminate();
45 virtual Bool_t TerminateIO();
46 //
47 virtual void SetCreateNonStandardAOD() {fIsStandard = kFALSE;}
48 virtual void SetFillAOD(Bool_t b) {fFillAOD = b;}
49 virtual void SetFillAODforRun(Bool_t b) {fFillAODRun = b;}
50 virtual void SetNeedsHeaderReplication() {fNeedsHeaderReplication = kTRUE;}
51 virtual void SetNeedsTracksBranchReplication() {fNeedsTracksBranchReplication = kTRUE;}
52 virtual void SetNeedsVerticesBranchReplication() {fNeedsVerticesBranchReplication = kTRUE;}
53 virtual void SetNeedsV0sBranchReplication() {fNeedsV0sBranchReplication = kTRUE;}
54 virtual void SetNeedsCascadesBranchReplication() {fNeedsCascadesBranchReplication = kTRUE;}
55 virtual void SetNeedsTrackletsBranchReplication() {fNeedsTrackletsBranchReplication = kTRUE;}
56 virtual void SetNeedsPMDClustersBranchReplication() {fNeedsPMDClustersBranchReplication = kTRUE;}
57 virtual void SetNeedsJetsBranchReplication() {fNeedsJetsBranchReplication = kTRUE;}
58 virtual void SetNeedsFMDClustersBranchReplication() {fNeedsFMDClustersBranchReplication = kTRUE;}
59 virtual void SetNeedsCaloClustersBranchReplication() {fNeedsCaloClustersBranchReplication = kTRUE;}
60 virtual void SetNeedsMCParticlesBranchReplication() {fNeedsMCParticlesBranchReplication = kTRUE;}
61 virtual void SetNeedsDimuonsBranchReplication() {fNeedsDimuonsBranchReplication = kTRUE;}
62 virtual void SetAODIsReplicated() {fAODIsReplicated = kTRUE;}
63 //
64 AliAODEvent* GetAOD() {return fAODEvent;}
65 virtual TTree* GetTree() const {return fTreeA;}
66 TObjArray* GetExtensions() const {return fExtensions;}
67 AliAODExtension* GetExtension(const char *filename) const;
68 TObjArray* GetFilters() const {return fFilters;}
69 AliAODExtension* GetFilteredAOD(const char *filename) const;
70 void CreateTree(Int_t flag);
71 void FillTree();
72 void AddAODtoTreeUserInfo();
73 void AddBranch(const char* cname, void* addobj, const char *fname="");
74 AliAODExtension* AddExtension(const char *filename, const char *title="");
75 AliAODExtension* AddFilteredAOD(const char *filename, const char *filtername);
76 Bool_t IsStandard() const {return fIsStandard;}
77 Bool_t GetFillAOD() const {return fFillAOD;}
78 Bool_t NeedsHeaderReplication() const {return fNeedsHeaderReplication;}
79 Bool_t NeedsTracksBranchReplication() const {return fNeedsTracksBranchReplication;}
80 Bool_t NeedsVerticesBranchReplication() const {return fNeedsVerticesBranchReplication;}
81 Bool_t NeedsV0sBranchReplication() const {return fNeedsV0sBranchReplication;}
82 Bool_t NeedsCascadesBranchReplication() const {return fNeedsCascadesBranchReplication;}
83 Bool_t NeedsTrackletsBranchReplication() const {return fNeedsTrackletsBranchReplication;}
84 Bool_t NeedsPMDClustersBranchReplication() const {return fNeedsPMDClustersBranchReplication;}
85 Bool_t NeedsJetsBranchReplication() const {return fNeedsJetsBranchReplication;}
86 Bool_t NeedsFMDClustersBranchReplication() const {return fNeedsFMDClustersBranchReplication;}
87 Bool_t NeedsCaloClustersBranchReplication() const {return fNeedsCaloClustersBranchReplication;}
88 Bool_t NeedsMCParticlesBranchReplication() const {return fNeedsMCParticlesBranchReplication;}
89 Bool_t NeedsDimuonsBranchReplication() const {return fNeedsDimuonsBranchReplication;}
90 Bool_t AODIsReplicated() const {return fAODIsReplicated;}
91 //
92 void SetInputTree(TTree* /*tree*/) {;}
93 void SetMCEventHandler(AliMCEventHandler* mcH) {fMCEventH = mcH;} // For internal use
94 void StoreMCParticles(); // Store MC particles, only to be called from AliAnalyisTaskMCParticleFilter
95
96 void Print(Option_t* opt="") const;
97
98 private:
99 void SetMCHeaderInfo(AliAODMCHeader *mcHeader,AliGenEventHeader *genHeader); // Utility function t catch different types of eventheaders
100 AliAODHandler(const AliAODHandler&); // Not implemented
101 AliAODHandler& operator=(const AliAODHandler&); // Not implemented
102 void PrintExtensions(const TObjArray& array) const;
103
104 private:
105 Bool_t fIsStandard; // Flag for standard aod creation
106 Bool_t fFillAOD; // Flag for filling of the AOD tree at the end (all or nothing evt by evt)
107 Bool_t fFillAODRun; // Flag for filling of the AOD tree at the end (run)
108 Bool_t fNeedsHeaderReplication; // Flag for header replication
109 Bool_t fNeedsTracksBranchReplication; // Flag for tracks replication
110 Bool_t fNeedsVerticesBranchReplication; // Flag for vertices replication
111 Bool_t fNeedsV0sBranchReplication; // Flag for V0s replication
112 Bool_t fNeedsCascadesBranchReplication; // Flag for Cascade replication
113 Bool_t fNeedsTrackletsBranchReplication; // Flag for Tracklets replication
114 Bool_t fNeedsPMDClustersBranchReplication; // Flag for PMDClusters replication
115 Bool_t fNeedsJetsBranchReplication; // Flag for Jets replication
116 Bool_t fNeedsFMDClustersBranchReplication; // Flag for FMDClusters replication
117 Bool_t fNeedsCaloClustersBranchReplication; // Flag for CaloClusters replication
118 Bool_t fNeedsMCParticlesBranchReplication; // Flag for MCParticles replication
119 Bool_t fNeedsDimuonsBranchReplication; // Flag for Dimuons replication
120 Bool_t fAODIsReplicated; // Flag true if replication as been executed
121 AliAODEvent *fAODEvent; //! Pointer to the AOD event
122 AliMCEventHandler *fMCEventH; //! Pointer to mc event handler needed not to depend on the manager
123 TTree *fTreeA; //! tree for AOD persistency
124 TFile *fFileA; //! Output file
125 TString fFileName; // Output file name
126 TObjArray *fExtensions; // List of extensions
127 TObjArray *fFilters; // List of filtered AOD's
128 ClassDef(AliAODHandler, 6)
129};
130
131//-------------------------------------------------------------------------
132// Support class for AOD extensions. This is created by the user analysis
133// that requires a separate file for some AOD branches. The name of the
134// AliAODExtension object is the file name where the AOD branches will be
135// stored.
136// Author: Andrei Gheata, CERN
137//-------------------------------------------------------------------------
138
139class AliAODBranchReplicator;
140
141class AliAODExtension : public TNamed {
142
143public:
144
145enum EAliAODExtensionFlags {
146 kFilteredAOD = BIT(14),
147 kDropUnspecifiedBranches = BIT(15)
148};
149
150 AliAODExtension();
151 AliAODExtension(const char* name, const char* title, Bool_t isfilter=kFALSE);
152 virtual ~AliAODExtension();
153 void AddBranch(const char* cname, void* addobj);
154 Bool_t FinishEvent();
155 Int_t GetNtotal() const {return fNtotal;}
156 Int_t GetNpassed() const {return fNpassed;}
157 const char* GetOutputFileName() const {return TNamed::GetName();}
158 AliAODEvent* GetAOD() const {return fAODEvent;}
159 TTree* GetTree() const {return fTreeE;}
160 Bool_t Init(Option_t *option);
161 Bool_t IsFilteredAOD() const {return TObject::TestBit(kFilteredAOD);}
162 Bool_t IsEventSelected() const {return fSelected;}
163 void SelectEvent(Bool_t flag=kTRUE) {fSelected = flag;}
164 void SetEvent(AliAODEvent *event);
165 void SetOutputFileName(const char* fname) {TNamed::SetName(fname);}
166 Bool_t TerminateIO();
167
168 void Print(Option_t* opt="") const;
169
170 // Branches not specified in any FilterBranch call will be dropped by default
171 void DropUnspecifiedBranches() { TObject::SetBit(kDropUnspecifiedBranches); }
172
173 // Branches not specified in any FilterBranch call will be kept by default
174 void KeepUnspecifiedBranches() { TObject::ResetBit(kDropUnspecifiedBranches); }
175
176 void FilterBranch(const char* branchName, AliAODBranchReplicator* replicator=0x0);
177
178 /* Use DisableReferences if and only if the output AOD contains no TRef or TRefArray,
179 otherwise the produced AOD won't be valid.
180 */
181 void DisableReferences() { fEnableReferences=kFALSE; }
182
183 void EnableReferences() { fEnableReferences=kTRUE; }
184
185 private:
186 AliAODExtension(const AliAODExtension&); // Not implemented
187 AliAODExtension& operator=(const AliAODExtension&); // Not implemented
188
189 private:
190 AliAODEvent *fAODEvent; //! Pointer to the AOD event
191 TTree *fTreeE; //! tree for AOD persistency
192 TFile *fFileE; //! Output file
193 Int_t fNtotal; //! Number of processed events
194 Int_t fNpassed; //! Number of events that passed the filter
195 Bool_t fSelected; //! Select current event for filtered AOD's. Made false at event start.
196
197 TMap* fRepFiMap; // which branch(es) to filter out / and or replicate
198 TList* fRepFiList; // list of unique filter/replicator
199
200 Bool_t fEnableReferences; // whether or not to enable the TRefTable branch
201 TList* fObjectList; //! internal list of which objects to keep
202
203 ClassDef(AliAODExtension, 2) // Support for extra AOD branches in a separate AOD file
204};
205#endif