]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODHandler.cxx
Additional flags for AOD replication (Roberta Arnaldi, AM)
[u/mrichter/AliRoot.git] / STEER / AliAODHandler.cxx
CommitLineData
ec4af4c1 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// Implementation of the Virtual Event Handler Interface for AOD
20// Author: Andreas Morsch, CERN
21//-------------------------------------------------------------------------
22
052994fb 23
ec4af4c1 24#include <TTree.h>
e910dd36 25#include <TFile.h>
7970f4ac 26#include <TString.h>
e910dd36 27
ec4af4c1 28#include "AliAODHandler.h"
29#include "AliAODEvent.h"
30
31ClassImp(AliAODHandler)
32
33//______________________________________________________________________________
34AliAODHandler::AliAODHandler() :
f3214a54 35 AliVEventHandler(),
78f7f935 36 fIsStandard(kTRUE),
7c3a9fbf 37 fNeedsHeaderReplication(kFALSE),
75754ba8 38 fNeedsTracksBranchReplication(kFALSE),
39 fNeedsVerticesBranchReplication(kFALSE),
40 fNeedsV0sBranchReplication(kFALSE),
41 fNeedsTrackletsBranchReplication(kFALSE),
42 fNeedsPMDClustersBranchReplication(kFALSE),
43 fNeedsJetsBranchReplication(kFALSE),
44 fNeedsFMDClustersBranchReplication(kFALSE),
45 fNeedsCaloClustersBranchReplication(kFALSE),
46 fAODIsReplicated(kFALSE),
ec4af4c1 47 fAODEvent(NULL),
e910dd36 48 fTreeA(NULL),
49 fFileA(NULL),
7970f4ac 50 fFileName("")
ec4af4c1 51{
52 // default constructor
53}
54
55//______________________________________________________________________________
56AliAODHandler::AliAODHandler(const char* name, const char* title):
f3214a54 57 AliVEventHandler(name, title),
78f7f935 58 fIsStandard(kTRUE),
7c3a9fbf 59 fNeedsHeaderReplication(kFALSE),
75754ba8 60 fNeedsTracksBranchReplication(kFALSE),
61 fNeedsVerticesBranchReplication(kFALSE),
62 fNeedsV0sBranchReplication(kFALSE),
63 fNeedsTrackletsBranchReplication(kFALSE),
64 fNeedsPMDClustersBranchReplication(kFALSE),
65 fNeedsJetsBranchReplication(kFALSE),
66 fNeedsFMDClustersBranchReplication(kFALSE),
67 fNeedsCaloClustersBranchReplication(kFALSE),
68 fAODIsReplicated(kFALSE),
ec4af4c1 69 fAODEvent(NULL),
e910dd36 70 fTreeA(NULL),
71 fFileA(NULL),
7970f4ac 72 fFileName("")
ec4af4c1 73{
74}
75
76//______________________________________________________________________________
77AliAODHandler::~AliAODHandler()
78{
6989bff3 79 delete fAODEvent;
80 if(fFileA){
81 // is already handled in TerminateIO
82 fFileA->Close();
83 delete fFileA;
84 }
85 delete fTreeA;
6989bff3 86 // destructor
ec4af4c1 87}
88
7970f4ac 89//______________________________________________________________________________
300d5701 90Bool_t AliAODHandler::Init(Option_t* opt)
ec4af4c1 91{
6989bff3 92 // Initialize IO
93 //
94 // Create the AODevent object
95 if(!fAODEvent){
ec4af4c1 96 fAODEvent = new AliAODEvent();
78f7f935 97 if (fIsStandard) fAODEvent->CreateStdContent();
6989bff3 98 }
99 //
100 // File opening according to execution mode
7970f4ac 101 TString option(opt);
102 option.ToLower();
103 if (option.Contains("proof")) {
6989bff3 104 // proof
7970f4ac 105 if (option.Contains("special")) {
106 // File for tree already opened on slave -> merging via files
107 fFileA = gFile;
108 CreateTree(1);
109 } else {
110 // Merging in memory
111 CreateTree(0);
112 }
6989bff3 113 } else {
114 // local and grid
26b9ac7a 115 TDirectory *owd = gDirectory;
7970f4ac 116 fFileA = new TFile(fFileName.Data(), "RECREATE");
6989bff3 117 CreateTree(1);
26b9ac7a 118 owd->cd();
6989bff3 119 }
120 return kTRUE;
ec4af4c1 121}
122
5f380da9 123Bool_t AliAODHandler::FinishEvent()
ec4af4c1 124{
125 // Fill data structures
f4e5f8d5 126 fAODEvent->MakeEntriesReferencable();
ec4af4c1 127 FillTree();
78f7f935 128 if (fIsStandard) fAODEvent->ResetStd();
75754ba8 129 // Reset AOD replication flag
130 fAODIsReplicated = kFALSE;
131
ec4af4c1 132 return kTRUE;
133}
134
7970f4ac 135//______________________________________________________________________________
ec4af4c1 136Bool_t AliAODHandler::Terminate()
137{
138 // Terminate
139 AddAODtoTreeUserInfo();
140 return kTRUE;
141}
142
7970f4ac 143//______________________________________________________________________________
ec4af4c1 144Bool_t AliAODHandler::TerminateIO()
145{
146 // Terminate IO
21501411 147 if (fFileA) {
148 fFileA->Close();
149 delete fFileA;
150 }
ec4af4c1 151 return kTRUE;
152}
153
7970f4ac 154//______________________________________________________________________________
954526ed 155void AliAODHandler::CreateTree(Int_t flag)
ec4af4c1 156{
157 // Creates the AOD Tree
f3214a54 158 fTreeA = new TTree("aodTree", "AliAOD tree");
ec4af4c1 159 fTreeA->Branch(fAODEvent->GetList());
954526ed 160 if (flag == 0) fTreeA->SetDirectory(0);
ec4af4c1 161}
162
7970f4ac 163//______________________________________________________________________________
ec4af4c1 164void AliAODHandler::FillTree()
165{
166 // Fill the AOD Tree
167 fTreeA->Fill();
168}
169
7970f4ac 170//______________________________________________________________________________
ec4af4c1 171void AliAODHandler::AddAODtoTreeUserInfo()
172{
173 // Add aod event to tree user info
174 fTreeA->GetUserInfo()->Add(fAODEvent);
175}
490e9023 176
7970f4ac 177//______________________________________________________________________________
0134949d 178void AliAODHandler::AddBranch(const char* cname, void* addobj)
490e9023 179{
180 // Add a new branch to the aod
181 TDirectory *owd = gDirectory;
182 if (fFileA) {
183 fFileA->cd();
184 }
0134949d 185 char** apointer = (char**) addobj;
186 TObject* obj = (TObject*) *apointer;
187 fTreeA->Branch(obj->GetName(), cname, addobj);
188 fAODEvent->AddObject(obj);
490e9023 189 owd->cd();
190}
7970f4ac 191
192//______________________________________________________________________________
193void AliAODHandler::SetOutputFileName(const char* fname)
194{
195// Set file name.
196 fFileName = fname;
197}
198
199//______________________________________________________________________________
200const char *AliAODHandler::GetOutputFileName()
201{
202// Get file name.
203 return fFileName.Data();
204}