]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG0/AliSelectorRL.cxx
removal of effective c++ warnings (C.Zampolli)+ use of additional calib parameters...
[u/mrichter/AliRoot.git] / PWG0 / AliSelectorRL.cxx
CommitLineData
dc740de4 1/* $Id$ */
2
0c7e8af2 3#include "AliSelectorRL.h"
4
5#include <AliLog.h>
0c7e8af2 6#include <AliRunLoader.h>
7
04a7657f 8#include <TTree.h>
dfe1bf7e 9#include <TFile.h>
10
11//
12// This selector depends on the RunLoader, therefore to use it you have to have the whole AliRoot available
13// The benefit is that you can use the RunLoader to access everything in the data structure
14// If you only have the ESD library use AliSelector instead
15//
16
0c7e8af2 17ClassImp(AliSelectorRL)
18
19AliSelectorRL::AliSelectorRL() :
20 AliSelector(),
25db2d85 21 fRunLoader(0),
22 fKinematicsLoaded(kFALSE),
23 fHeaderLoaded(kFALSE)
0c7e8af2 24{
25 //
26 // Constructor. Initialization of pointers
27 //
28}
29
30AliSelectorRL::~AliSelectorRL()
31{
32 //
33 // Destructor
34 //
35
36 // histograms are in the output list and deleted when the output
37 // list is deleted by the TSelector dtor
38}
39
40Bool_t AliSelectorRL::Notify()
41{
42 // Calls base class Notify
43 // On top of that run loader is closed, because we change the input file
44
45 if (AliSelector::Notify() == kFALSE)
46 return kFALSE;
47
48 DeleteRunLoader();
04a7657f 49
50 return kTRUE;
51}
52
53Bool_t AliSelectorRL::Process(Long64_t entry)
54{
55 // Call the baseclass Process and set event number in runLoader (if loaded)
56
57 if (AliSelector::Process(entry) == kFALSE)
58 return kFALSE;
59
60 if (fRunLoader)
61 fRunLoader->GetEvent(entry);
0c7e8af2 62
63 return kTRUE;
64}
65
66void AliSelectorRL::SlaveTerminate()
67{
68 // removes runloader
69
70 AliSelector::SlaveTerminate();
71
72 DeleteRunLoader();
73}
74
04a7657f 75AliRunLoader* AliSelectorRL::GetRunLoader()
0c7e8af2 76{
16e24ca3 77 // Returns AliRun instance corresponding to current ESD active in fTree
0c7e8af2 78 // Loads galice.root, the file is identified by replacing "AliESDs" to
79 // "galice" in the file path of the ESD file. This is a hack, to be changed!
80
81 if (!fRunLoader)
82 {
16e24ca3 83 if (!fTree->GetCurrentFile())
0c7e8af2 84 return 0;
85
16e24ca3 86 TString fileName(fTree->GetCurrentFile()->GetName());
0c7e8af2 87 fileName.ReplaceAll("AliESDs", "galice");
88
2bfd0c8f 89 // temporary workaround for PROOF bug #18505
90 fileName.ReplaceAll("#galice.root#galice.root", "#galice.root");
91
0c7e8af2 92 fRunLoader = AliRunLoader::Open(fileName);
93 if (!fRunLoader)
94 return 0;
95
25db2d85 96 if (fRunLoader->LoadgAlice() != 0)
97 {
98 delete fRunLoader;
99 fRunLoader = 0;
100 return 0;
101 }
04a7657f 102 fRunLoader->GetEvent(fTree->GetTree()->GetReadEntry());
0c7e8af2 103 }
104
dfe1bf7e 105 return fRunLoader;
0c7e8af2 106}
107
108void AliSelectorRL::DeleteRunLoader()
109{
110 //
111 // deletes the runloader
112 //
113
114 if (fRunLoader)
115 {
116 fRunLoader->Delete();
117 fRunLoader = 0;
118 }
25db2d85 119
120 fKinematicsLoaded = kFALSE;
121 fHeaderLoaded = kFALSE;
0c7e8af2 122}
16e24ca3 123
124AliHeader* AliSelectorRL::GetHeader()
125{
04a7657f 126 // Returns header retrieved from RunLoader
16e24ca3 127
04a7657f 128 AliRunLoader* runLoader = GetRunLoader();
129 if (!runLoader)
130 return 0;
16e24ca3 131
25db2d85 132 if (fHeaderLoaded == kFALSE)
133 if (runLoader->LoadHeader() != 0)
134 return 0;
135
136 fHeaderLoaded = kTRUE;
16e24ca3 137
04a7657f 138 return runLoader->GetHeader();
16e24ca3 139}
140
04a7657f 141AliStack* AliSelectorRL::GetStack()
16e24ca3 142{
04a7657f 143 // Returns stack retrieved from RunLoader
16e24ca3 144
04a7657f 145 AliRunLoader* runLoader = GetRunLoader();
146 if (!runLoader)
147 return 0;
148
25db2d85 149 if (fKinematicsLoaded == kFALSE)
150 if (runLoader->LoadKinematics() != 0)
151 return 0;
152
153 fKinematicsLoaded = kTRUE;
04a7657f 154
155 return runLoader->Stack();
16e24ca3 156}