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"
34 ClassImp(AliAnalysisTaskRL)
36 //___________________________________________________________________________
37 AliAnalysisTaskRL::AliAnalysisTaskRL() :
39 fTree(0), fRunLoader(0),
40 fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE), fTreeNumber(-1) {
42 // Constructor. Initialization of pointers
46 //___________________________________________________________________________
47 AliAnalysisTaskRL::AliAnalysisTaskRL(const char *name, const char *title) :
48 AliAnalysisTask(name,title),
49 fTree(0), fRunLoader(0),
50 fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) {
54 //___________________________________________________________________________
55 AliAnalysisTaskRL::~AliAnalysisTaskRL() {
62 //___________________________________________________________________________
63 Bool_t AliAnalysisTaskRL::GetEntry(Long64_t ientry) {
64 //returns the entry of the run loader
66 if(fRunLoader->GetEvent((Int_t)ientry) != 0)
72 //___________________________________________________________________________
73 AliRunLoader *AliAnalysisTaskRL::GetRunLoader() {
74 // Returns AliRun instance corresponding to current ESD active in fTree
75 // Loads galice.root, the file is identified by replacing "AliESDs" to
76 // "galice" in the file path of the ESD file.
78 fTree = (TTree *)AliAnalysisTask::GetInputData(0);
79 Int_t iTree = ((TChain *)AliAnalysisTask::GetInputData(0))->GetTreeNumber();
80 if (iTree != fTreeNumber) {
87 if (!fTree->GetCurrentFile())
90 TString fileName(fTree->GetCurrentFile()->GetName());
91 printf("Current file %s \n", fileName.Data());
93 fileName.ReplaceAll("AliESDs", "galice");
95 // temporary workaround for PROOF bug #18505
96 fileName.ReplaceAll("#galice.root#galice.root", "#galice.root");
98 fRunLoader = AliRunLoader::Open(fileName);
101 fRunLoader->GetEvent((Int_t)(fTree->GetTree()->GetReadEntry()));
107 //___________________________________________________________________________
108 void AliAnalysisTaskRL::DeleteRunLoader() {
110 // deletes the runloader
113 fRunLoader->Delete();
117 fKinematicsLoaded = kFALSE;
118 fHeaderLoaded = kFALSE;
121 //___________________________________________________________________________
122 AliHeader* AliAnalysisTaskRL::GetHeader() {
123 // Returns header retrieved from RunLoader
125 AliRunLoader* runLoader = GetRunLoader();
129 if (fHeaderLoaded == kFALSE)
130 if (runLoader->LoadHeader() != 0)
133 fHeaderLoaded = kTRUE;
135 return runLoader->GetHeader();
138 //___________________________________________________________________________
139 AliStack* AliAnalysisTaskRL::GetStack() {
140 // Returns stack retrieved from RunLoader
142 AliRunLoader* runLoader = GetRunLoader();
146 if (fKinematicsLoaded == kFALSE)
147 if (runLoader->LoadKinematics() != 0)
150 fKinematicsLoaded = kTRUE;
152 return runLoader->Stack();