VirtualEventHandler interface and its implementation AliAODHandler.
[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
23#include <TFile.h>
24#include <TTree.h>
25#include "AliAODHandler.h"
26#include "AliAODEvent.h"
27
28ClassImp(AliAODHandler)
29
30//______________________________________________________________________________
31AliAODHandler::AliAODHandler() :
32 AliVirtualEventHandler(),
33 fAODEvent(NULL),
34 fAODFile(NULL)
35{
36 // default constructor
37}
38
39//______________________________________________________________________________
40AliAODHandler::AliAODHandler(const char* name, const char* title):
41 AliVirtualEventHandler(name, title),
42 fAODEvent(NULL),
43 fAODFile(NULL)
44{
45}
46
47//______________________________________________________________________________
48AliAODHandler::~AliAODHandler()
49{
50// destructor
51}
52
53
54Bool_t AliAODHandler::InitIO()
55{
56 // Initialize IO
57 fAODEvent = new AliAODEvent();
58 fAODEvent->CreateStdContent();
59// fAODFile = new TFile("aod.root", "recreate");
60 CreateTree();
61
62 return kTRUE;
63}
64
65Bool_t AliAODHandler::Fill()
66{
67 // Fill data structures
68 printf(">>>>>>>>>>> AliAODHandler::Fill()\n");
69
70 FillTree();
71 fAODEvent->ClearStd();
72
73 return kTRUE;
74}
75
76Bool_t AliAODHandler::Terminate()
77{
78 // Terminate
79 AddAODtoTreeUserInfo();
80 return kTRUE;
81}
82
83Bool_t AliAODHandler::TerminateIO()
84{
85 // Terminate IO
86
87// fAODFile->cd();
88// fTreeA->Write();
89// fAODFile->Close();
90
91 return kTRUE;
92}
93
94
95void AliAODHandler::CreateTree()
96{
97 // Creates the AOD Tree
98 fTreeA = new TTree("AOD", "AliAOD tree");
99 fTreeA->Branch(fAODEvent->GetList());
100}
101
102void AliAODHandler::FillTree()
103{
104 // Fill the AOD Tree
105 fTreeA->Fill();
106}
107
108
109void AliAODHandler::AddAODtoTreeUserInfo()
110{
111 // Add aod event to tree user info
112 fTreeA->GetUserInfo()->Add(fAODEvent);
113}