]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODHandler.cxx
- Modified the class AliMUONRecoParam to inherit from the new bass
[u/mrichter/AliRoot.git] / STEER / AliAODHandler.cxx
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
24 #include <TTree.h>
25 #include <TFile.h>
26
27 #include "AliAODHandler.h"
28 #include "AliAODEvent.h"
29
30 ClassImp(AliAODHandler)
31
32 //______________________________________________________________________________
33 AliAODHandler::AliAODHandler() :
34     AliVEventHandler(),
35     fAODEvent(NULL),
36     fTreeA(NULL),
37     fFileA(NULL),
38     fName("")
39 {
40   // default constructor
41 }
42
43 //______________________________________________________________________________
44 AliAODHandler::AliAODHandler(const char* name, const char* title):
45     AliVEventHandler(name, title),
46     fAODEvent(NULL),
47     fTreeA(NULL),
48     fFileA(NULL),
49     fName("")
50 {
51 }
52
53 //______________________________________________________________________________
54 AliAODHandler::~AliAODHandler() 
55 {
56   delete fAODEvent;
57   if(fFileA){
58     // is already handled in TerminateIO
59     fFileA->Close();
60     delete fFileA;
61   }
62   delete fTreeA;
63   delete fName;
64  // destructor
65 }
66
67
68 Bool_t AliAODHandler::Init(Option_t* opt)
69 {
70   // Initialize IO
71   //
72   // Create the AODevent object
73   if(!fAODEvent){
74     fAODEvent = new AliAODEvent();
75     fAODEvent->CreateStdContent();
76   }
77   //
78   // File opening according to execution mode
79   
80   if (!(strcmp(opt, "proof"))) {
81     // proof
82     CreateTree(0);
83   } else {
84     // local and grid
85     fFileA = new TFile(fName, "RECREATE");
86     CreateTree(1);
87   }
88   return kTRUE;
89 }
90
91 Bool_t AliAODHandler::FinishEvent()
92 {
93     // Fill data structures
94     FillTree();
95     fAODEvent->ResetStd();
96     return kTRUE;
97 }
98
99 Bool_t AliAODHandler::Terminate()
100 {
101     // Terminate 
102     AddAODtoTreeUserInfo();
103     return kTRUE;
104 }
105
106 Bool_t AliAODHandler::TerminateIO()
107 {
108     // Terminate IO
109     if (fFileA) {
110         fFileA->Close();
111         delete fFileA;
112     }
113     return kTRUE;
114 }
115
116
117 void AliAODHandler::CreateTree(Int_t flag)
118 {
119     // Creates the AOD Tree
120     fTreeA = new TTree("aodTree", "AliAOD tree");
121     fTreeA->Branch(fAODEvent->GetList());
122     if (flag == 0) fTreeA->SetDirectory(0);
123 }
124
125 void AliAODHandler::FillTree()
126 {
127     // Fill the AOD Tree
128     fTreeA->Fill();
129 }
130
131
132 void AliAODHandler::AddAODtoTreeUserInfo()
133 {
134     // Add aod event to tree user info
135     fTreeA->GetUserInfo()->Add(fAODEvent);
136 }