1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------
19 // AliAnalysisTaskRL class
20 // Task that gives access to the run loader
21 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 //-----------------------------------------------------------------
24 #include "AliAnalysisTaskRL.h"
25 #include "AliRunLoader.h"
27 #include "AliHeader.h"
33 ClassImp(AliAnalysisTaskRL)
35 //___________________________________________________________________________
36 AliAnalysisTaskRL::AliAnalysisTaskRL() :
38 fTree(0), fRunLoader(0),
39 fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) {
41 // Constructor. Initialization of pointers
45 //___________________________________________________________________________
46 AliAnalysisTaskRL::AliAnalysisTaskRL(const char *name, const char *title) :
47 AliAnalysisTask(name,title),
48 fTree(0), fRunLoader(0),
49 fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) {
53 //___________________________________________________________________________
54 AliAnalysisTaskRL::~AliAnalysisTaskRL() {
61 //___________________________________________________________________________
62 Bool_t AliAnalysisTaskRL::GetEntry(Long64_t ientry) {
63 //returns the entry of the run loader
65 if(fRunLoader->GetEvent((Int_t)ientry) != 0)
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.
77 fTree = (TTree *)AliAnalysisTask::GetInputData(0);
79 if (!fTree->GetCurrentFile())
82 TString fileName(fTree->GetCurrentFile()->GetName());
83 fileName.ReplaceAll("AliESDs", "galice");
85 // temporary workaround for PROOF bug #18505
86 fileName.ReplaceAll("#galice.root#galice.root", "#galice.root");
88 fRunLoader = AliRunLoader::Open(fileName);
91 fRunLoader->GetEvent((Int_t)(fTree->GetTree()->GetReadEntry()));
97 //___________________________________________________________________________
98 void AliAnalysisTaskRL::DeleteRunLoader() {
100 // deletes the runloader
103 fRunLoader->Delete();
107 fKinematicsLoaded = kFALSE;
108 fHeaderLoaded = kFALSE;
111 //___________________________________________________________________________
112 AliHeader* AliAnalysisTaskRL::GetHeader() {
113 // Returns header retrieved from RunLoader
115 AliRunLoader* runLoader = GetRunLoader();
119 if (fHeaderLoaded == kFALSE)
120 if (runLoader->LoadHeader() != 0)
123 fHeaderLoaded = kTRUE;
125 return runLoader->GetHeader();
128 //___________________________________________________________________________
129 AliStack* AliAnalysisTaskRL::GetStack() {
130 // Returns stack retrieved from RunLoader
132 AliRunLoader* runLoader = GetRunLoader();
136 if (fKinematicsLoaded == kFALSE)
137 if (runLoader->LoadKinematics() != 0)
140 fKinematicsLoaded = kTRUE;
142 return runLoader->Stack();