]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliSelectorRL.cxx
Leak detected by Coverity fixed
[u/mrichter/AliRoot.git] / STEER / AliSelectorRL.cxx
CommitLineData
4c1380cd 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
a03b623a 16/* $Id$ */
17
18#include "AliSelectorRL.h"
19
20#include <AliLog.h>
21#include <AliRunLoader.h>
22
23#include <TTree.h>
24#include <TFile.h>
25
4c1380cd 26// Selector base class for analysis based on whole AliRoot
27// Please derive your selector-based analysis from this class, if you need to access the
28// RunLoader or anything provided by it.
a03b623a 29//
30// This selector depends on the RunLoader, therefore to use it you have to have the whole AliRoot available
31// The benefit is that you can use the RunLoader to access everything in the data structure
a03b623a 32//
4c1380cd 33// The class has functions to return the stack (GetStack()), the RunLoader (GetRunLoader()), and
34// the event header (GetHeader()).
35//
36// Author: Jan.Fiete.Grosse-Oetringhaus@cern.ch
a03b623a 37
38ClassImp(AliSelectorRL)
39
40AliSelectorRL::AliSelectorRL() :
41 AliSelector(),
42 fRunLoader(0),
43 fKinematicsLoaded(kFALSE),
44 fHeaderLoaded(kFALSE)
45{
46 //
47 // Constructor. Initialization of pointers
48 //
49}
50
51AliSelectorRL::~AliSelectorRL()
52{
53 //
54 // Destructor
55 //
56
57 // histograms are in the output list and deleted when the output
58 // list is deleted by the TSelector dtor
59}
60
61Bool_t AliSelectorRL::Notify()
62{
63 // Calls base class Notify
64 // On top of that run loader is closed, because we change the input file
65
66 if (AliSelector::Notify() == kFALSE)
67 return kFALSE;
68
69 DeleteRunLoader();
70
71 return kTRUE;
72}
73
74Bool_t AliSelectorRL::Process(Long64_t entry)
75{
76 // Call the baseclass Process and set event number in runLoader (if loaded)
77
78 if (AliSelector::Process(entry) == kFALSE)
79 return kFALSE;
80
81 if (fRunLoader)
82 {
80ebf966 83 if (fRunLoader->GetEvent((Int_t)entry) != 0)
a03b623a 84 return kFALSE;
85 }
86
87 return kTRUE;
88}
89
90void AliSelectorRL::SlaveTerminate()
91{
92 // removes runloader
93
94 AliSelector::SlaveTerminate();
95
96 DeleteRunLoader();
97}
98
99AliRunLoader* AliSelectorRL::GetRunLoader()
100{
101 // Returns AliRun instance corresponding to current ESD active in fTree
102 // Loads galice.root, the file is identified by replacing "AliESDs" to
103 // "galice" in the file path of the ESD file.
104
105 if (!fRunLoader)
106 {
107 if (!fTree->GetCurrentFile())
108 return 0;
109
110 TString fileName(fTree->GetCurrentFile()->GetName());
111 fileName.ReplaceAll("AliESDs", "galice");
112
113 // temporary workaround for PROOF bug #18505
114 fileName.ReplaceAll("#galice.root#galice.root", "#galice.root");
115
116 fRunLoader = AliRunLoader::Open(fileName);
117 if (!fRunLoader)
118 return 0;
119
80ebf966 120 fRunLoader->GetEvent((Int_t)(fTree->GetTree()->GetReadEntry()));
a03b623a 121 }
122
123 return fRunLoader;
124}
125
126void AliSelectorRL::DeleteRunLoader()
127{
128 //
129 // deletes the runloader
130 //
131
132 if (fRunLoader)
133 {
134 fRunLoader->Delete();
135 fRunLoader = 0;
136 }
137
138 fKinematicsLoaded = kFALSE;
139 fHeaderLoaded = kFALSE;
140}
141
142AliHeader* AliSelectorRL::GetHeader()
143{
144 // Returns header retrieved from RunLoader
145
146 AliRunLoader* runLoader = GetRunLoader();
147 if (!runLoader)
148 return 0;
149
150 if (fHeaderLoaded == kFALSE)
151 if (runLoader->LoadHeader() != 0)
152 return 0;
153
154 fHeaderLoaded = kTRUE;
155
156 return runLoader->GetHeader();
157}
158
159AliStack* AliSelectorRL::GetStack()
160{
161 // Returns stack retrieved from RunLoader
162
163 AliRunLoader* runLoader = GetRunLoader();
164 if (!runLoader)
165 return 0;
166
167 if (fKinematicsLoaded == kFALSE)
168 if (runLoader->LoadKinematics() != 0)
169 return 0;
170
171 fKinematicsLoaded = kTRUE;
172
173 return runLoader->Stack();
174}