]>
Commit | Line | Data |
---|---|---|
8d169fb2 | 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //----------------------------------------------------------------- | |
19 | // AliAnalysisTaskRL class | |
20 | // Task that gives access to the run loader | |
21 | // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch | |
22 | //----------------------------------------------------------------- | |
23 | ||
24 | #include "AliAnalysisTaskRL.h" | |
25 | #include "AliRunLoader.h" | |
26 | #include "AliStack.h" | |
27 | #include "AliHeader.h" | |
28 | ||
29 | ||
30 | #include <TTree.h> | |
31 | #include <TFile.h> | |
32 | ||
33 | ClassImp(AliAnalysisTaskRL) | |
34 | ||
35 | //___________________________________________________________________________ | |
36 | AliAnalysisTaskRL::AliAnalysisTaskRL() : | |
37 | AliAnalysisTask(), | |
38 | fTree(0), fRunLoader(0), | |
39 | fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) { | |
40 | // | |
41 | // Constructor. Initialization of pointers | |
42 | // | |
43 | } | |
44 | ||
45 | //___________________________________________________________________________ | |
46 | AliAnalysisTaskRL::AliAnalysisTaskRL(const char *name, const char *title) : | |
47 | AliAnalysisTask(name,title), | |
48 | fTree(0), fRunLoader(0), | |
49 | fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) { | |
50 | // Constructor. | |
51 | } | |
52 | ||
53 | //___________________________________________________________________________ | |
54 | AliAnalysisTaskRL::~AliAnalysisTaskRL() { | |
55 | // | |
56 | // Destructor | |
57 | // | |
58 | DeleteRunLoader(); | |
59 | } | |
60 | ||
61 | //___________________________________________________________________________ | |
62 | Bool_t AliAnalysisTaskRL::GetEntry(Long64_t ientry) { | |
63 | //returns the entry of the run loader | |
64 | if(fRunLoader) { | |
65 | if(fRunLoader->GetEvent((Int_t)ientry) != 0) | |
66 | return kFALSE; | |
67 | } | |
68 | return kTRUE; | |
69 | } | |
70 | ||
71 | //___________________________________________________________________________ | |
72 | AliRunLoader *AliAnalysisTaskRL::GetRunLoader() { | |
73 | // Returns AliRun instance corresponding to current ESD active in fTree | |
74 | // Loads galice.root, the file is identified by replacing "AliESDs" to | |
75 | // "galice" in the file path of the ESD file. | |
76 | ||
77 | fTree = (TTree *)AliAnalysisTask::GetInputData(0); | |
78 | if (!fRunLoader) { | |
79 | if (!fTree->GetCurrentFile()) | |
80 | return 0; | |
81 | ||
82 | TString fileName(fTree->GetCurrentFile()->GetName()); | |
83 | fileName.ReplaceAll("AliESDs", "galice"); | |
84 | ||
85 | // temporary workaround for PROOF bug #18505 | |
86 | fileName.ReplaceAll("#galice.root#galice.root", "#galice.root"); | |
87 | ||
88 | fRunLoader = AliRunLoader::Open(fileName); | |
89 | if (!fRunLoader) | |
90 | return 0; | |
91 | fRunLoader->GetEvent((Int_t)(fTree->GetTree()->GetReadEntry())); | |
92 | } | |
93 | ||
94 | return fRunLoader; | |
95 | } | |
96 | ||
97 | //___________________________________________________________________________ | |
98 | void AliAnalysisTaskRL::DeleteRunLoader() { | |
99 | // | |
100 | // deletes the runloader | |
101 | // | |
102 | if (fRunLoader) { | |
103 | fRunLoader->Delete(); | |
104 | fRunLoader = 0; | |
105 | } | |
106 | ||
107 | fKinematicsLoaded = kFALSE; | |
108 | fHeaderLoaded = kFALSE; | |
109 | } | |
110 | ||
111 | //___________________________________________________________________________ | |
112 | AliHeader* AliAnalysisTaskRL::GetHeader() { | |
113 | // Returns header retrieved from RunLoader | |
114 | ||
115 | AliRunLoader* runLoader = GetRunLoader(); | |
116 | if (!runLoader) | |
117 | return 0; | |
118 | ||
119 | if (fHeaderLoaded == kFALSE) | |
120 | if (runLoader->LoadHeader() != 0) | |
121 | return 0; | |
122 | ||
123 | fHeaderLoaded = kTRUE; | |
124 | ||
125 | return runLoader->GetHeader(); | |
126 | } | |
127 | ||
128 | //___________________________________________________________________________ | |
129 | AliStack* AliAnalysisTaskRL::GetStack() { | |
130 | // Returns stack retrieved from RunLoader | |
131 | ||
132 | AliRunLoader* runLoader = GetRunLoader(); | |
133 | if (!runLoader) | |
134 | return 0; | |
135 | ||
136 | if (fKinematicsLoaded == kFALSE) | |
137 | if (runLoader->LoadKinematics() != 0) | |
138 | return 0; | |
139 | ||
140 | fKinematicsLoaded = kTRUE; | |
141 | ||
142 | return runLoader->Stack(); | |
143 | } |