]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDHandler.cxx
Keep track of missing DCS points in DDL maps (flagged by 'x')
[u/mrichter/AliRoot.git] / STEER / AliESDHandler.cxx
CommitLineData
6d3a7bbf 1
2/**************************************************************************
3 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/*$Id$*/
18
19//-------------------------------------------------------------------------
20//
21// Implementation of the Virtual Event Handler Interface for ESD
22//
23//-------------------------------------------------------------------------
24
25
26#include <TTree.h>
27#include <TFile.h>
28#include <TString.h>
29#include <TROOT.h>
30
31#include "AliLog.h"
32#include "AliESDHandler.h"
33#include "AliESDEvent.h"
34#include "AliESDfriend.h"
35
36
37ClassImp(AliESDHandler)
38
39//______________________________________________________________________________
40AliESDHandler::AliESDHandler() :
41 AliVEventHandler(),
6d3a7bbf 42 fesdf(NULL),
03a8000a 43 fTreeEF(NULL),
6d3a7bbf 44 fFileEF(NULL),
03a8000a 45 fFileName("AliESDfriends_v2.root")
6d3a7bbf 46{
47 // default constructor
48}
49
50//______________________________________________________________________________
51AliESDHandler::AliESDHandler(const char* name, const char* title):
52 AliVEventHandler(name, title),
6d3a7bbf 53 fesdf(NULL),
03a8000a 54 fTreeEF(NULL),
6d3a7bbf 55 fFileEF(NULL),
03a8000a 56 fFileName("AliESDfriends_v2.root")
6d3a7bbf 57{
58
59 // constructor with name and title
60
61}
62
63//______________________________________________________________________________
64AliESDHandler::~AliESDHandler()
65{
66 // Destructor.
6d3a7bbf 67 delete fesdf;
6d3a7bbf 68 if(fFileEF){
69 // is already handled in TerminateIO
70 fFileEF->Close();
71 delete fFileEF;
72 }
03a8000a 73 delete fTreeEF;
6d3a7bbf 74}
75
76//______________________________________________________________________________
77Bool_t AliESDHandler::Init(Option_t* opt)
78{
79 //
80 // Initialize IO
81 //
82
83 // File opening according to execution mode
84 TString option(opt);
85 option.ToLower();
86 TDirectory *owd = gDirectory;
03a8000a 87
88 fesdf = new AliESDfriend();
89
90 // Open the file with friends
6d3a7bbf 91 if (option.Contains("proof")) {
92 // proof
93 // Merging via files. Need to access analysis manager via interpreter.
94 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->OpenProofFile(\"%s\", \"RECREATE\");", fFileName.Data()));
95 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->GetCommonOutputContainer()->SetFile((TFile*)0x%lx);", gFile));
03a8000a 96 fFileEF = gFile;
6d3a7bbf 97 } else {
98 // local and grid
03a8000a 99 fFileEF = new TFile(fFileName.Data(), "RECREATE");
6d3a7bbf 100 }
03a8000a 101
102 // Create the friends tree
103 fFileEF->cd();
104 fTreeEF = new TTree("esdFriendTree", "Tree with ESD friends");
105 fTreeEF->Branch("ESDfriend.","AliESDfriend", &fesdf);
106
6d3a7bbf 107 owd->cd();
108
109 return kTRUE;
110}
111
112
113//______________________________________________________________________________
114Bool_t AliESDHandler::FinishEvent()
115{
116 //
117 // Fill the tree
118 //
119
120 FillTree();
121
122 // resetting
6d3a7bbf 123 fesdf->~AliESDfriend();
124 new(fesdf) AliESDfriend();
125 return kTRUE;
126}
127
128//______________________________________________________________________________
129Bool_t AliESDHandler::Terminate()
130{
131 //
132 // Terminate
133 //
134
6d3a7bbf 135 return kTRUE;
136}
137
138//______________________________________________________________________________
139Bool_t AliESDHandler::TerminateIO()
140{
141 //
142 // Terminate IO
143 //
144
03a8000a 145 if (fFileEF) {
146 fFileEF->cd();
147 fTreeEF->Write();
148 fFileEF->Close();
149 delete fFileEF;
150 fFileEF = 0;
6d3a7bbf 151 }
152
153 return kTRUE;
154}
155
6d3a7bbf 156//______________________________________________________________________________
157void AliESDHandler::FillTree()
158{
159 //
160 // Fill the ESD Tree
161 //
162
163 AliDebug(2,Form("number of friend tracks = %d\n",fesdf->GetNumberOfTracks()));
164
03a8000a 165 fFileEF->cd();
166 fTreeEF->Fill();
6d3a7bbf 167}
168