]>
Commit | Line | Data |
---|---|---|
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 | |
15 | class AliAODEvent; | |
16 | class TFile; | |
17 | class TTree; | |
9066c676 | 18 | class TObjArray; |
da97a08a | 19 | class AliMCEventHandler; |
dce1b636 | 20 | class AliAODMCHeader; |
9066c676 | 21 | class AliAODExtension; |
dce1b636 | 22 | class AliGenEventHeader; |
26ba01d4 | 23 | class TMap; |
24 | class AliAnalysisFilter; | |
ec4af4c1 | 25 | |
f3214a54 | 26 | class 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(); | |
90d50a8c | 34 | // Extra outputs as a string separated by commas |
35 | virtual const char* GetExtraOutputs() const; | |
300d5701 | 36 | virtual Bool_t Init(Option_t* option); |
37 | virtual Bool_t Init(TTree* /*tree*/, Option_t* /*option*/) {return kTRUE;} | |
0d6a82a5 | 38 | virtual Bool_t GetEntry() {return kTRUE;} |
39 | ||
5b173801 | 40 | virtual Bool_t BeginEvent(Long64_t /*entry*/) {fFillAOD=kFALSE; return kTRUE;} |
276be602 | 41 | virtual Bool_t Notify() { return AliVEventHandler::Notify(); }; |
890126ab | 42 | virtual Bool_t Notify(const char * /* path */) {return kTRUE;} |
5f380da9 | 43 | virtual Bool_t FinishEvent(); |
ec4af4c1 | 44 | virtual Bool_t Terminate(); |
45 | virtual Bool_t TerminateIO(); | |
ec4af4c1 | 46 | // |
41b01ae4 | 47 | virtual void SetCreateNonStandardAOD() {fIsStandard = kFALSE;} |
48 | virtual void SetFillAOD(Bool_t b) {fFillAOD = b;} | |
49 | virtual void SetFillAODforRun(Bool_t b) {fFillAODRun = b;} | |
3549c522 | 50 | virtual void SetNeedsHeaderReplication() {fNeedsHeaderReplication = kTRUE;} |
51 | virtual void SetNeedsTracksBranchReplication() {fNeedsTracksBranchReplication = kTRUE;} | |
52 | virtual void SetNeedsVerticesBranchReplication() {fNeedsVerticesBranchReplication = kTRUE;} | |
53 | virtual void SetNeedsV0sBranchReplication() {fNeedsV0sBranchReplication = kTRUE;} | |
e0107012 | 54 | virtual void SetNeedsCascadesBranchReplication() {fNeedsCascadesBranchReplication = kTRUE;} |
3549c522 | 55 | virtual void SetNeedsTrackletsBranchReplication() {fNeedsTrackletsBranchReplication = kTRUE;} |
56 | virtual void SetNeedsPMDClustersBranchReplication() {fNeedsPMDClustersBranchReplication = kTRUE;} | |
57 | virtual void SetNeedsJetsBranchReplication() {fNeedsJetsBranchReplication = kTRUE;} | |
58 | virtual void SetNeedsFMDClustersBranchReplication() {fNeedsFMDClustersBranchReplication = kTRUE;} | |
75754ba8 | 59 | virtual void SetNeedsCaloClustersBranchReplication() {fNeedsCaloClustersBranchReplication = kTRUE;} |
fa8b0e56 | 60 | virtual void SetNeedsMCParticlesBranchReplication() {fNeedsMCParticlesBranchReplication = kTRUE;} |
866d8d78 | 61 | virtual void SetNeedsDimuonsBranchReplication() {fNeedsDimuonsBranchReplication = kTRUE;} |
75754ba8 | 62 | virtual void SetAODIsReplicated() {fAODIsReplicated = kTRUE;} |
78f7f935 | 63 | // |
ec4af4c1 | 64 | AliAODEvent* GetAOD() {return fAODEvent;} |
11326411 | 65 | virtual TTree* GetTree() const {return fTreeA;} |
9066c676 | 66 | TObjArray* GetExtensions() const {return fExtensions;} |
582cfeb5 | 67 | AliAODExtension* GetExtension(const char *filename) const; |
68 | TObjArray* GetFilters() const {return fFilters;} | |
69 | AliAODExtension* GetFilteredAOD(const char *filename) const; | |
954526ed | 70 | void CreateTree(Int_t flag); |
ec4af4c1 | 71 | void FillTree(); |
72 | void AddAODtoTreeUserInfo(); | |
9066c676 | 73 | void AddBranch(const char* cname, void* addobj, const char *fname=""); |
74 | AliAODExtension* AddExtension(const char *filename, const char *title=""); | |
582cfeb5 | 75 | AliAODExtension* AddFilteredAOD(const char *filename, const char *filtername); |
3549c522 | 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;} | |
e0107012 | 82 | Bool_t NeedsCascadesBranchReplication() const {return fNeedsCascadesBranchReplication;} |
3549c522 | 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;} | |
866d8d78 | 89 | Bool_t NeedsDimuonsBranchReplication() const {return fNeedsDimuonsBranchReplication;} |
3549c522 | 90 | Bool_t AODIsReplicated() const {return fAODIsReplicated;} |
933fd60f | 91 | // |
92 | void SetInputTree(TTree* /*tree*/) {;} | |
da97a08a | 93 | void SetMCEventHandler(AliMCEventHandler* mcH) {fMCEventH = mcH;} // For internal use |
522aca31 | 94 | void StoreMCParticles(); // Store MC particles, only to be called from AliAnalyisTaskMCParticleFilter |
95 | ||
26ba01d4 | 96 | void Print(Option_t* opt="") const; |
97 | ||
ec4af4c1 | 98 | private: |
dce1b636 | 99 | void SetMCHeaderInfo(AliAODMCHeader *mcHeader,AliGenEventHeader *genHeader); // Utility function t catch different types of eventheaders |
ec4af4c1 | 100 | AliAODHandler(const AliAODHandler&); // Not implemented |
101 | AliAODHandler& operator=(const AliAODHandler&); // Not implemented | |
b5b9155e | 102 | void PrintExtensions(const TObjArray& array) const; |
26ba01d4 | 103 | |
ec4af4c1 | 104 | private: |
75754ba8 | 105 | Bool_t fIsStandard; // Flag for standard aod creation |
41b01ae4 | 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) | |
75754ba8 | 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 | |
e0107012 | 112 | Bool_t fNeedsCascadesBranchReplication; // Flag for Cascade replication |
75754ba8 | 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 | |
3549c522 | 118 | Bool_t fNeedsMCParticlesBranchReplication; // Flag for MCParticles replication |
866d8d78 | 119 | Bool_t fNeedsDimuonsBranchReplication; // Flag for Dimuons replication |
75754ba8 | 120 | Bool_t fAODIsReplicated; // Flag true if replication as been executed |
7c3a9fbf | 121 | AliAODEvent *fAODEvent; //! Pointer to the AOD event |
da97a08a | 122 | AliMCEventHandler *fMCEventH; //! Pointer to mc event handler needed not to depend on the manager |
7c3a9fbf | 123 | TTree *fTreeA; //! tree for AOD persistency |
124 | TFile *fFileA; //! Output file | |
125 | TString fFileName; // Output file name | |
9066c676 | 126 | TObjArray *fExtensions; // List of extensions |
e0107012 | 127 | TObjArray *fFilters; // List of filtered AOD's |
866d8d78 | 128 | ClassDef(AliAODHandler, 6) |
ec4af4c1 | 129 | }; |
130 | ||
9066c676 | 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 | ||
26ba01d4 | 139 | class AliAODBranchReplicator; |
140 | ||
9066c676 | 141 | class AliAODExtension : public TNamed { |
582cfeb5 | 142 | |
143 | public: | |
144 | ||
145 | enum EAliAODExtensionFlags { | |
146 | kFilteredAOD = BIT(14) | |
147 | }; | |
9066c676 | 148 | |
26ba01d4 | 149 | AliAODExtension(); |
582cfeb5 | 150 | AliAODExtension(const char* name, const char* title, Bool_t isfilter=kFALSE); |
9066c676 | 151 | virtual ~AliAODExtension(); |
152 | void AddBranch(const char* cname, void* addobj); | |
582cfeb5 | 153 | Bool_t FinishEvent(); |
154 | Int_t GetNtotal() const {return fNtotal;} | |
155 | Int_t GetNpassed() const {return fNpassed;} | |
9066c676 | 156 | const char* GetOutputFileName() const {return TNamed::GetName();} |
157 | AliAODEvent* GetAOD() const {return fAODEvent;} | |
158 | TTree* GetTree() const {return fTreeE;} | |
159 | Bool_t Init(Option_t *option); | |
582cfeb5 | 160 | Bool_t IsFilteredAOD() const {return TObject::TestBit(kFilteredAOD);} |
161 | Bool_t IsEventSelected() const {return fSelected;} | |
162 | void SelectEvent(Bool_t flag=kTRUE) {fSelected = flag;} | |
163 | void SetEvent(AliAODEvent *event); | |
9066c676 | 164 | void SetOutputFileName(const char* fname) {TNamed::SetName(fname);} |
165 | Bool_t TerminateIO(); | |
26ba01d4 | 166 | |
167 | void Print(Option_t* opt="") const; | |
168 | ||
169 | void FilterBranch(const char* branchName, AliAODBranchReplicator* replicator=0x0); | |
b5b9155e | 170 | |
171 | /* Use DisableReferences if and only if the output AOD contains no TRef or TRefArray, | |
172 | otherwise the produced AOD won't be valid. | |
173 | */ | |
26ba01d4 | 174 | void DisableReferences() { fEnableReferences=kFALSE; } |
b5b9155e | 175 | |
26ba01d4 | 176 | void EnableReferences() { fEnableReferences=kTRUE; } |
177 | ||
9066c676 | 178 | private: |
179 | AliAODExtension(const AliAODExtension&); // Not implemented | |
180 | AliAODExtension& operator=(const AliAODExtension&); // Not implemented | |
181 | ||
182 | private: | |
183 | AliAODEvent *fAODEvent; //! Pointer to the AOD event | |
184 | TTree *fTreeE; //! tree for AOD persistency | |
185 | TFile *fFileE; //! Output file | |
582cfeb5 | 186 | Int_t fNtotal; //! Number of processed events |
187 | Int_t fNpassed; //! Number of events that passed the filter | |
188 | Bool_t fSelected; //! Select current event for filtered AOD's. Made false at event start. | |
26ba01d4 | 189 | |
190 | TMap* fRepFiMap; // which branch(es) to filter out / and or replicate | |
191 | TList* fRepFiList; // list of unique filter/replicator | |
192 | ||
193 | Bool_t fEnableReferences; // whether or not to enable the TRefTable branch | |
194 | TList* fObjectList; //! internal list of which objects to keep | |
195 | ||
196 | ClassDef(AliAODExtension, 2) // Support for extra AOD branches in a separate AOD file | |
9066c676 | 197 | }; |
ec4af4c1 | 198 | #endif |