]>
Commit | Line | Data |
---|---|---|
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 | 17 | ClassImp(AliSelectorRL) |
18 | ||
19 | AliSelectorRL::AliSelectorRL() : | |
20 | AliSelector(), | |
25db2d85 | 21 | fRunLoader(0), |
22 | fKinematicsLoaded(kFALSE), | |
23 | fHeaderLoaded(kFALSE) | |
0c7e8af2 | 24 | { |
25 | // | |
26 | // Constructor. Initialization of pointers | |
27 | // | |
28 | } | |
29 | ||
30 | AliSelectorRL::~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 | ||
40 | Bool_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 | ||
53 | Bool_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) | |
0bd1f8a0 | 61 | { |
62 | if (fRunLoader->GetEvent(entry) != 0) | |
63 | return kFALSE; | |
64 | } | |
0c7e8af2 | 65 | |
66 | return kTRUE; | |
67 | } | |
68 | ||
69 | void AliSelectorRL::SlaveTerminate() | |
70 | { | |
71 | // removes runloader | |
72 | ||
73 | AliSelector::SlaveTerminate(); | |
74 | ||
75 | DeleteRunLoader(); | |
76 | } | |
77 | ||
04a7657f | 78 | AliRunLoader* AliSelectorRL::GetRunLoader() |
0c7e8af2 | 79 | { |
16e24ca3 | 80 | // Returns AliRun instance corresponding to current ESD active in fTree |
0c7e8af2 | 81 | // Loads galice.root, the file is identified by replacing "AliESDs" to |
82 | // "galice" in the file path of the ESD file. This is a hack, to be changed! | |
83 | ||
84 | if (!fRunLoader) | |
85 | { | |
16e24ca3 | 86 | if (!fTree->GetCurrentFile()) |
0c7e8af2 | 87 | return 0; |
88 | ||
16e24ca3 | 89 | TString fileName(fTree->GetCurrentFile()->GetName()); |
0c7e8af2 | 90 | fileName.ReplaceAll("AliESDs", "galice"); |
91 | ||
2bfd0c8f | 92 | // temporary workaround for PROOF bug #18505 |
93 | fileName.ReplaceAll("#galice.root#galice.root", "#galice.root"); | |
94 | ||
0c7e8af2 | 95 | fRunLoader = AliRunLoader::Open(fileName); |
96 | if (!fRunLoader) | |
97 | return 0; | |
98 | ||
04a7657f | 99 | fRunLoader->GetEvent(fTree->GetTree()->GetReadEntry()); |
0c7e8af2 | 100 | } |
101 | ||
dfe1bf7e | 102 | return fRunLoader; |
0c7e8af2 | 103 | } |
104 | ||
105 | void AliSelectorRL::DeleteRunLoader() | |
106 | { | |
107 | // | |
108 | // deletes the runloader | |
109 | // | |
110 | ||
111 | if (fRunLoader) | |
112 | { | |
113 | fRunLoader->Delete(); | |
114 | fRunLoader = 0; | |
115 | } | |
25db2d85 | 116 | |
117 | fKinematicsLoaded = kFALSE; | |
118 | fHeaderLoaded = kFALSE; | |
0c7e8af2 | 119 | } |
16e24ca3 | 120 | |
121 | AliHeader* AliSelectorRL::GetHeader() | |
122 | { | |
04a7657f | 123 | // Returns header retrieved from RunLoader |
16e24ca3 | 124 | |
04a7657f | 125 | AliRunLoader* runLoader = GetRunLoader(); |
126 | if (!runLoader) | |
127 | return 0; | |
16e24ca3 | 128 | |
25db2d85 | 129 | if (fHeaderLoaded == kFALSE) |
130 | if (runLoader->LoadHeader() != 0) | |
131 | return 0; | |
132 | ||
133 | fHeaderLoaded = kTRUE; | |
16e24ca3 | 134 | |
04a7657f | 135 | return runLoader->GetHeader(); |
16e24ca3 | 136 | } |
137 | ||
04a7657f | 138 | AliStack* AliSelectorRL::GetStack() |
16e24ca3 | 139 | { |
04a7657f | 140 | // Returns stack retrieved from RunLoader |
16e24ca3 | 141 | |
04a7657f | 142 | AliRunLoader* runLoader = GetRunLoader(); |
143 | if (!runLoader) | |
144 | return 0; | |
145 | ||
25db2d85 | 146 | if (fKinematicsLoaded == kFALSE) |
147 | if (runLoader->LoadKinematics() != 0) | |
148 | return 0; | |
149 | ||
150 | fKinematicsLoaded = kTRUE; | |
04a7657f | 151 | |
152 | return runLoader->Stack(); | |
16e24ca3 | 153 | } |