]>
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(), | |
04a7657f | 21 | fRunLoader(0) |
0c7e8af2 | 22 | { |
23 | // | |
24 | // Constructor. Initialization of pointers | |
25 | // | |
26 | } | |
27 | ||
28 | AliSelectorRL::~AliSelectorRL() | |
29 | { | |
30 | // | |
31 | // Destructor | |
32 | // | |
33 | ||
34 | // histograms are in the output list and deleted when the output | |
35 | // list is deleted by the TSelector dtor | |
36 | } | |
37 | ||
38 | Bool_t AliSelectorRL::Notify() | |
39 | { | |
40 | // Calls base class Notify | |
41 | // On top of that run loader is closed, because we change the input file | |
42 | ||
43 | if (AliSelector::Notify() == kFALSE) | |
44 | return kFALSE; | |
45 | ||
46 | DeleteRunLoader(); | |
04a7657f | 47 | |
48 | return kTRUE; | |
49 | } | |
50 | ||
51 | Bool_t AliSelectorRL::Process(Long64_t entry) | |
52 | { | |
53 | // Call the baseclass Process and set event number in runLoader (if loaded) | |
54 | ||
55 | if (AliSelector::Process(entry) == kFALSE) | |
56 | return kFALSE; | |
57 | ||
58 | if (fRunLoader) | |
59 | fRunLoader->GetEvent(entry); | |
0c7e8af2 | 60 | |
61 | return kTRUE; | |
62 | } | |
63 | ||
64 | void AliSelectorRL::SlaveTerminate() | |
65 | { | |
66 | // removes runloader | |
67 | ||
68 | AliSelector::SlaveTerminate(); | |
69 | ||
70 | DeleteRunLoader(); | |
71 | } | |
72 | ||
04a7657f | 73 | AliRunLoader* AliSelectorRL::GetRunLoader() |
0c7e8af2 | 74 | { |
16e24ca3 | 75 | // Returns AliRun instance corresponding to current ESD active in fTree |
0c7e8af2 | 76 | // Loads galice.root, the file is identified by replacing "AliESDs" to |
77 | // "galice" in the file path of the ESD file. This is a hack, to be changed! | |
78 | ||
79 | if (!fRunLoader) | |
80 | { | |
16e24ca3 | 81 | if (!fTree->GetCurrentFile()) |
0c7e8af2 | 82 | return 0; |
83 | ||
16e24ca3 | 84 | TString fileName(fTree->GetCurrentFile()->GetName()); |
0c7e8af2 | 85 | fileName.ReplaceAll("AliESDs", "galice"); |
86 | ||
87 | fRunLoader = AliRunLoader::Open(fileName); | |
88 | if (!fRunLoader) | |
89 | return 0; | |
90 | ||
91 | fRunLoader->LoadgAlice(); | |
04a7657f | 92 | fRunLoader->GetEvent(fTree->GetTree()->GetReadEntry()); |
0c7e8af2 | 93 | } |
94 | ||
dfe1bf7e | 95 | return fRunLoader; |
0c7e8af2 | 96 | } |
97 | ||
98 | void AliSelectorRL::DeleteRunLoader() | |
99 | { | |
100 | // | |
101 | // deletes the runloader | |
102 | // | |
103 | ||
104 | if (fRunLoader) | |
105 | { | |
106 | fRunLoader->Delete(); | |
107 | fRunLoader = 0; | |
108 | } | |
109 | } | |
16e24ca3 | 110 | |
111 | AliHeader* AliSelectorRL::GetHeader() | |
112 | { | |
04a7657f | 113 | // Returns header retrieved from RunLoader |
16e24ca3 | 114 | |
04a7657f | 115 | AliRunLoader* runLoader = GetRunLoader(); |
116 | if (!runLoader) | |
117 | return 0; | |
16e24ca3 | 118 | |
04a7657f | 119 | if (runLoader->GetHeader() == 0) |
120 | runLoader->LoadHeader(); | |
16e24ca3 | 121 | |
04a7657f | 122 | return runLoader->GetHeader(); |
16e24ca3 | 123 | } |
124 | ||
04a7657f | 125 | AliStack* AliSelectorRL::GetStack() |
16e24ca3 | 126 | { |
04a7657f | 127 | // Returns stack retrieved from RunLoader |
16e24ca3 | 128 | |
04a7657f | 129 | AliRunLoader* runLoader = GetRunLoader(); |
130 | if (!runLoader) | |
131 | return 0; | |
132 | ||
133 | if (runLoader->Stack() == 0) | |
134 | runLoader->LoadKinematics(); | |
135 | ||
136 | return runLoader->Stack(); | |
16e24ca3 | 137 | } |