ROOT logo
#ifndef ALIAODHANDLER_H
#define ALIAODHANDLER_H
/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

//-------------------------------------------------------------------------
//     Implementation of the Event Handler Interface for AOD
//     Author: Andreas Morsch, CERN
//-------------------------------------------------------------------------

#include "AliVEventHandler.h"
#include "AliAODExtension.h"

class AliAODEvent;
class TFile;
class TTree;
class TObjArray;
class AliMCEventHandler;
class AliAODMCHeader;
class AliGenEventHeader;
class TMap;
class AliAnalysisFilter;

class AliAODHandler : public AliVEventHandler {
    
 public:
    AliAODHandler();
    AliAODHandler(const char* name, const char* title);
    virtual ~AliAODHandler();
    virtual void         SetOutputFileName(const char* fname);
    virtual const char*  GetOutputFileName() const;
    // Extra outputs as a string separated by commas
    virtual const char*  GetExtraOutputs(Bool_t merge=kTRUE) const;
    virtual Bool_t       Init(Option_t* option);
    virtual Bool_t       Init(TTree* /*tree*/, Option_t* /*option*/)  {return kTRUE;}
    virtual Bool_t       GetEntry() {return kTRUE;}
	    
    virtual Bool_t       BeginEvent(Long64_t /*entry*/) {fFillAOD=kFALSE; fFillExtension=kFALSE; return kTRUE;}
    virtual Bool_t       Notify() { return AliVEventHandler::Notify(); };
    virtual Bool_t       Notify(const char * /* path */) {return kTRUE;}
    virtual Bool_t       FinishEvent();
    virtual Bool_t       Terminate();
    virtual Bool_t       TerminateIO();
    //
    virtual void         SetCreateNonStandardAOD()               {Changed(); fIsStandard = kFALSE;}
    virtual void         SetFillAOD(Bool_t b)                    {Changed(); fFillAOD = b;}
    virtual void         SetFillExtension(Bool_t b)              {Changed(); fFillExtension = b;}
    virtual void         SetFillAODforRun(Bool_t b)              {Changed(); fFillAODRun = b;}
    virtual void         SetNeedsHeaderReplication()             {fNeedsHeaderReplication             = kTRUE;}
    virtual void         SetNeedsTOFHeaderReplication()          {fNeedsTOFHeaderReplication          = kTRUE;}
    virtual void         SetNeedsVZEROReplication()              {fNeedsVZEROReplication              = kTRUE;}
    virtual void         SetNeedsTracksBranchReplication()       {fNeedsTracksBranchReplication       = kTRUE;}
    virtual void         SetNeedsVerticesBranchReplication()     {fNeedsVerticesBranchReplication     = kTRUE;}
    virtual void         SetNeedsV0sBranchReplication()          {fNeedsV0sBranchReplication          = kTRUE;}
    virtual void         SetNeedsCascadesBranchReplication()     {fNeedsCascadesBranchReplication     = kTRUE;}
    virtual void         SetNeedsTrackletsBranchReplication()    {fNeedsTrackletsBranchReplication    = kTRUE;}
    virtual void         SetNeedsPMDClustersBranchReplication()  {fNeedsPMDClustersBranchReplication  = kTRUE;}
    virtual void         SetNeedsJetsBranchReplication()         {fNeedsJetsBranchReplication         = kTRUE;}
    virtual void         SetNeedsFMDClustersBranchReplication()  {fNeedsFMDClustersBranchReplication  = kTRUE;}
    virtual void         SetNeedsCaloClustersBranchReplication() {fNeedsCaloClustersBranchReplication = kTRUE;}
    virtual void         SetNeedsCaloTriggerBranchReplication()  {fNeedsCaloTriggerBranchReplication  = kTRUE;}
    virtual void         SetNeedsMCParticlesBranchReplication()  {fNeedsMCParticlesBranchReplication  = kTRUE;}
    virtual void         SetNeedsDimuonsBranchReplication()      {fNeedsDimuonsBranchReplication      = kTRUE;}
    virtual void         SetNeedsHMPIDBranchReplication()        {fNeedsHMPIDBranchReplication        = kTRUE;}
    virtual void         SetAODIsReplicated()                    {Changed(); fAODIsReplicated = kTRUE;}
    virtual void         SetAODExtensionMode()                   {Changed(); fIsStandard=kFALSE; fFillAOD=kFALSE; fFillAODRun=kFALSE; fFillExtension=kTRUE;}
    //
    AliAODEvent*         GetAOD()  {return fAODEvent;}
    virtual TTree*       GetTree() const {return fTreeA;}
    TObjArray*           GetExtensions() const {return fExtensions;}
    AliAODExtension*     GetExtension(const char *filename) const;
    TObjArray*           GetFilters() const {return fFilters;}
    AliAODExtension*     GetFilteredAOD(const char *filename) const;
    void                 CreateTree(Int_t flag);
    void                 FillTree();
    void                 AddAODtoTreeUserInfo();
    void                 AddBranch(const char* cname, void* addobj, const char *fname="");
  
    AliAODExtension*     AddExtension(const char *filename, const char *title="", Bool_t tomerge=kFALSE);
    AliAODExtension*     AddFilteredAOD(const char *filename, const char *filtername, Bool_t tomerge=kFALSE);
//    AliAODExtension*     FindExtensionContainingBranch(const char* bname) const;
    Bool_t               IsStandard()                         const {return fIsStandard;}
    Bool_t               GetFillAOD()                         const {return fFillAOD;} 
    Bool_t               GetFillExtension()                   const {return fFillExtension;} 
    Bool_t               NeedsHeaderReplication()             const {return  fNeedsHeaderReplication;}
    Bool_t               NeedsTOFHeaderReplication()          const {return  fNeedsTOFHeaderReplication;}
    Bool_t               NeedsVZEROReplication()              const {return  fNeedsVZEROReplication;}
    Bool_t               NeedsTracksBranchReplication()       const {return  fNeedsTracksBranchReplication;}
    Bool_t               NeedsVerticesBranchReplication()     const {return  fNeedsVerticesBranchReplication;}
    Bool_t               NeedsV0sBranchReplication()          const {return  fNeedsV0sBranchReplication;}
    Bool_t               NeedsCascadesBranchReplication()     const {return  fNeedsCascadesBranchReplication;}
    Bool_t               NeedsTrackletsBranchReplication()    const {return  fNeedsTrackletsBranchReplication;}
    Bool_t               NeedsPMDClustersBranchReplication()  const {return  fNeedsPMDClustersBranchReplication;}
    Bool_t               NeedsJetsBranchReplication()         const {return  fNeedsJetsBranchReplication;}
    Bool_t               NeedsFMDClustersBranchReplication()  const {return  fNeedsFMDClustersBranchReplication;}
    Bool_t               NeedsCaloClustersBranchReplication() const {return  fNeedsCaloClustersBranchReplication;}
    Bool_t               NeedsCaloTriggerBranchReplication()  const {return  fNeedsCaloTriggerBranchReplication;}
    Bool_t               NeedsMCParticlesBranchReplication()  const {return  fNeedsMCParticlesBranchReplication;}
    Bool_t               NeedsDimuonsBranchReplication()      const {return  fNeedsDimuonsBranchReplication;}
    Bool_t               NeedsHMPIDBranchReplication()        const {return  fNeedsHMPIDBranchReplication;}
    Bool_t               AODIsReplicated()                    const {return  fAODIsReplicated;}
    //
    void                 SetInputTree(TTree* /*tree*/) {;}
    void                 SetMCEventHandler(AliMCEventHandler* mcH) {fMCEventH = mcH;} // For internal use
    void StoreMCParticles(); // Store MC particles, only to be called from AliAnalyisTaskMCParticleFilter
    void                 SetTreeBuffSize(Long64_t sz=30000000) {fTreeBuffSize = sz;}
  Bool_t HasExtensions() const;
  
  void Print(Option_t* opt="") const;
  
 private:
  void SetMCHeaderInfo(AliAODMCHeader *mcHeader,AliGenEventHeader *genHeader); // Utility function t catch different types of eventheaders
  AliAODHandler(const AliAODHandler&);             // Not implemented
  AliAODHandler& operator=(const AliAODHandler&);  // Not implemented
  void PrintExtensions(const TObjArray& array) const;

 private:
    Bool_t                   fIsStandard;                         // Flag for standard aod creation
    Bool_t                   fFillAOD;                            // Flag for filling of the AOD tree at the end (all or nothing evt by evt)
    Bool_t                   fFillAODRun;                         // Flag for filling of the AOD tree at the end (run)
    Bool_t                   fFillExtension;                      // Flag for filling or the delta AOD tree at the end
    Bool_t                   fNeedsHeaderReplication;             // Flag for header replication
    Bool_t                   fNeedsTOFHeaderReplication;          // Flag for header replication
    Bool_t                   fNeedsVZEROReplication;              // Flag for header replication
    Bool_t                   fNeedsTracksBranchReplication;       // Flag for tracks replication
    Bool_t                   fNeedsVerticesBranchReplication;     // Flag for vertices replication
    Bool_t                   fNeedsV0sBranchReplication;          // Flag for V0s replication
    Bool_t                   fNeedsCascadesBranchReplication;     // Flag for Cascade replication
    Bool_t                   fNeedsTrackletsBranchReplication;    // Flag for Tracklets replication
    Bool_t                   fNeedsPMDClustersBranchReplication;  // Flag for PMDClusters replication
    Bool_t                   fNeedsJetsBranchReplication;         // Flag for Jets replication
    Bool_t                   fNeedsFMDClustersBranchReplication;  // Flag for FMDClusters replication
    Bool_t                   fNeedsCaloClustersBranchReplication; // Flag for CaloClusters replication
    Bool_t                   fNeedsCaloTriggerBranchReplication;  // Flag for Calo Trigger replication
    Bool_t                   fNeedsMCParticlesBranchReplication;  // Flag for MCParticles replication
    Bool_t                   fNeedsDimuonsBranchReplication;      // Flag for Dimuons replication
    Bool_t                   fNeedsHMPIDBranchReplication;        // Flag for HMPID replication
    Bool_t                   fAODIsReplicated;                    // Flag true if replication as been executed
    // Counters for SetAutoFlush configuration
    Long64_t                 fTreeBuffSize;           //  allowed uncompressed buffer size per tree
    Long64_t                 fMemCountAOD;            //! accumulated AOD size before AutoSave 
    AliAODEvent             *fAODEvent;               //! Pointer to the AOD event
    AliMCEventHandler       *fMCEventH;               //! Pointer to mc event handler needed not to depend on the manager
    TTree                   *fTreeA;                  //! tree for AOD persistency
    TFile                   *fFileA;                  //! Output file
    TString                  fFileName;               //  Output file name
    TObjArray               *fExtensions;             //  List of extensions
    TObjArray               *fFilters;                //  List of filtered AOD's

  ClassDef(AliAODHandler, 8)
};

#endif
 AliAODHandler.h:1
 AliAODHandler.h:2
 AliAODHandler.h:3
 AliAODHandler.h:4
 AliAODHandler.h:5
 AliAODHandler.h:6
 AliAODHandler.h:7
 AliAODHandler.h:8
 AliAODHandler.h:9
 AliAODHandler.h:10
 AliAODHandler.h:11
 AliAODHandler.h:12
 AliAODHandler.h:13
 AliAODHandler.h:14
 AliAODHandler.h:15
 AliAODHandler.h:16
 AliAODHandler.h:17
 AliAODHandler.h:18
 AliAODHandler.h:19
 AliAODHandler.h:20
 AliAODHandler.h:21
 AliAODHandler.h:22
 AliAODHandler.h:23
 AliAODHandler.h:24
 AliAODHandler.h:25
 AliAODHandler.h:26
 AliAODHandler.h:27
 AliAODHandler.h:28
 AliAODHandler.h:29
 AliAODHandler.h:30
 AliAODHandler.h:31
 AliAODHandler.h:32
 AliAODHandler.h:33
 AliAODHandler.h:34
 AliAODHandler.h:35
 AliAODHandler.h:36
 AliAODHandler.h:37
 AliAODHandler.h:38
 AliAODHandler.h:39
 AliAODHandler.h:40
 AliAODHandler.h:41
 AliAODHandler.h:42
 AliAODHandler.h:43
 AliAODHandler.h:44
 AliAODHandler.h:45
 AliAODHandler.h:46
 AliAODHandler.h:47
 AliAODHandler.h:48
 AliAODHandler.h:49
 AliAODHandler.h:50
 AliAODHandler.h:51
 AliAODHandler.h:52
 AliAODHandler.h:53
 AliAODHandler.h:54
 AliAODHandler.h:55
 AliAODHandler.h:56
 AliAODHandler.h:57
 AliAODHandler.h:58
 AliAODHandler.h:59
 AliAODHandler.h:60
 AliAODHandler.h:61
 AliAODHandler.h:62
 AliAODHandler.h:63
 AliAODHandler.h:64
 AliAODHandler.h:65
 AliAODHandler.h:66
 AliAODHandler.h:67
 AliAODHandler.h:68
 AliAODHandler.h:69
 AliAODHandler.h:70
 AliAODHandler.h:71
 AliAODHandler.h:72
 AliAODHandler.h:73
 AliAODHandler.h:74
 AliAODHandler.h:75
 AliAODHandler.h:76
 AliAODHandler.h:77
 AliAODHandler.h:78
 AliAODHandler.h:79
 AliAODHandler.h:80
 AliAODHandler.h:81
 AliAODHandler.h:82
 AliAODHandler.h:83
 AliAODHandler.h:84
 AliAODHandler.h:85
 AliAODHandler.h:86
 AliAODHandler.h:87
 AliAODHandler.h:88
 AliAODHandler.h:89
 AliAODHandler.h:90
 AliAODHandler.h:91
 AliAODHandler.h:92
 AliAODHandler.h:93
 AliAODHandler.h:94
 AliAODHandler.h:95
 AliAODHandler.h:96
 AliAODHandler.h:97
 AliAODHandler.h:98
 AliAODHandler.h:99
 AliAODHandler.h:100
 AliAODHandler.h:101
 AliAODHandler.h:102
 AliAODHandler.h:103
 AliAODHandler.h:104
 AliAODHandler.h:105
 AliAODHandler.h:106
 AliAODHandler.h:107
 AliAODHandler.h:108
 AliAODHandler.h:109
 AliAODHandler.h:110
 AliAODHandler.h:111
 AliAODHandler.h:112
 AliAODHandler.h:113
 AliAODHandler.h:114
 AliAODHandler.h:115
 AliAODHandler.h:116
 AliAODHandler.h:117
 AliAODHandler.h:118
 AliAODHandler.h:119
 AliAODHandler.h:120
 AliAODHandler.h:121
 AliAODHandler.h:122
 AliAODHandler.h:123
 AliAODHandler.h:124
 AliAODHandler.h:125
 AliAODHandler.h:126
 AliAODHandler.h:127
 AliAODHandler.h:128
 AliAODHandler.h:129
 AliAODHandler.h:130
 AliAODHandler.h:131
 AliAODHandler.h:132
 AliAODHandler.h:133
 AliAODHandler.h:134
 AliAODHandler.h:135
 AliAODHandler.h:136
 AliAODHandler.h:137
 AliAODHandler.h:138
 AliAODHandler.h:139
 AliAODHandler.h:140
 AliAODHandler.h:141
 AliAODHandler.h:142
 AliAODHandler.h:143
 AliAODHandler.h:144
 AliAODHandler.h:145
 AliAODHandler.h:146
 AliAODHandler.h:147
 AliAODHandler.h:148
 AliAODHandler.h:149
 AliAODHandler.h:150
 AliAODHandler.h:151
 AliAODHandler.h:152
 AliAODHandler.h:153
 AliAODHandler.h:154
 AliAODHandler.h:155