Moving the previously hard-wired parameters for matching of trigger tracks
[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>
26
ec4af4c1 27#include "AliAODHandler.h"
28#include "AliAODEvent.h"
29
30ClassImp(AliAODHandler)
31
32//______________________________________________________________________________
33AliAODHandler::AliAODHandler() :
f3214a54 34 AliVEventHandler(),
78f7f935 35 fIsStandard(kTRUE),
ec4af4c1 36 fAODEvent(NULL),
e910dd36 37 fTreeA(NULL),
38 fFileA(NULL),
39 fName("")
ec4af4c1 40{
41 // default constructor
42}
43
44//______________________________________________________________________________
45AliAODHandler::AliAODHandler(const char* name, const char* title):
f3214a54 46 AliVEventHandler(name, title),
78f7f935 47 fIsStandard(kTRUE),
ec4af4c1 48 fAODEvent(NULL),
e910dd36 49 fTreeA(NULL),
50 fFileA(NULL),
51 fName("")
ec4af4c1 52{
53}
54
55//______________________________________________________________________________
56AliAODHandler::~AliAODHandler()
57{
6989bff3 58 delete fAODEvent;
59 if(fFileA){
60 // is already handled in TerminateIO
61 fFileA->Close();
62 delete fFileA;
63 }
64 delete fTreeA;
65 delete fName;
66 // destructor
ec4af4c1 67}
68
69
300d5701 70Bool_t AliAODHandler::Init(Option_t* opt)
ec4af4c1 71{
6989bff3 72 // Initialize IO
73 //
74 // Create the AODevent object
75 if(!fAODEvent){
ec4af4c1 76 fAODEvent = new AliAODEvent();
78f7f935 77 if (fIsStandard) fAODEvent->CreateStdContent();
6989bff3 78 }
79 //
80 // File opening according to execution mode
81
82 if (!(strcmp(opt, "proof"))) {
83 // proof
84 CreateTree(0);
85 } else {
86 // local and grid
26b9ac7a 87 TDirectory *owd = gDirectory;
6989bff3 88 fFileA = new TFile(fName, "RECREATE");
89 CreateTree(1);
26b9ac7a 90 owd->cd();
6989bff3 91 }
92 return kTRUE;
ec4af4c1 93}
94
5f380da9 95Bool_t AliAODHandler::FinishEvent()
ec4af4c1 96{
97 // Fill data structures
f4e5f8d5 98 fAODEvent->MakeEntriesReferencable();
ec4af4c1 99 FillTree();
78f7f935 100 if (fIsStandard) fAODEvent->ResetStd();
ec4af4c1 101 return kTRUE;
102}
103
104Bool_t AliAODHandler::Terminate()
105{
106 // Terminate
107 AddAODtoTreeUserInfo();
108 return kTRUE;
109}
110
111Bool_t AliAODHandler::TerminateIO()
112{
113 // Terminate IO
21501411 114 if (fFileA) {
115 fFileA->Close();
116 delete fFileA;
117 }
ec4af4c1 118 return kTRUE;
119}
120
121
954526ed 122void AliAODHandler::CreateTree(Int_t flag)
ec4af4c1 123{
124 // Creates the AOD Tree
f3214a54 125 fTreeA = new TTree("aodTree", "AliAOD tree");
ec4af4c1 126 fTreeA->Branch(fAODEvent->GetList());
954526ed 127 if (flag == 0) fTreeA->SetDirectory(0);
ec4af4c1 128}
129
130void AliAODHandler::FillTree()
131{
132 // Fill the AOD Tree
133 fTreeA->Fill();
134}
135
136
137void AliAODHandler::AddAODtoTreeUserInfo()
138{
139 // Add aod event to tree user info
140 fTreeA->GetUserInfo()->Add(fAODEvent);
141}
490e9023 142
78f7f935 143void AliAODHandler::AddBranch(const char* cname, TObject* addobj)
490e9023 144{
145 // Add a new branch to the aod
146 TDirectory *owd = gDirectory;
147 if (fFileA) {
148 fFileA->cd();
149 }
78f7f935 150 fTreeA->Branch(addobj->GetName(), cname, &addobj);
490e9023 151 fAODEvent->AddObject(addobj);
152 owd->cd();
153}