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) {
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 Bool_t AliAnalysisTaskRL::Notify() {
74 // The file has changed or there is a new tree. Delete the run loader.
79 //___________________________________________________________________________
80 AliRunLoader *AliAnalysisTaskRL::GetRunLoader() {
81 // Returns AliRun instance corresponding to current ESD active in fTree
82 // Loads galice.root, the file is identified by replacing "AliESDs" to
83 // "galice" in the file path of the ESD file.
85 fTree = (TTree *)AliAnalysisTask::GetInputData(0);
88 if (!fTree->GetCurrentFile())
91 TString fileName(fTree->GetCurrentFile()->GetName());
92 printf("Current file %s \n", fileName.Data());
94 fileName.ReplaceAll("AliESDs", "galice");
96 // temporary workaround for PROOF bug #18505
97 fileName.ReplaceAll("#galice.root#galice.root", "#galice.root");
99 fRunLoader = AliRunLoader::Open(fileName);
102 fRunLoader->GetEvent((Int_t)(fTree->GetTree()->GetReadEntry()));
108 //___________________________________________________________________________
109 void AliAnalysisTaskRL::DeleteRunLoader() {
111 // deletes the runloader
114 fRunLoader->Delete();
118 fKinematicsLoaded = kFALSE;
119 fHeaderLoaded = kFALSE;
122 //___________________________________________________________________________
123 AliHeader* AliAnalysisTaskRL::GetHeader() {
124 // Returns header retrieved from RunLoader
126 AliRunLoader* runLoader = GetRunLoader();
130 if (fHeaderLoaded == kFALSE)
131 if (runLoader->LoadHeader() != 0)
134 fHeaderLoaded = kTRUE;
136 return runLoader->GetHeader();
139 //___________________________________________________________________________
140 AliStack* AliAnalysisTaskRL::GetStack() {
141 // Returns stack retrieved from RunLoader
143 AliRunLoader* runLoader = GetRunLoader();
147 if (fKinematicsLoaded == kFALSE)
148 if (runLoader->LoadKinematics() != 0)
151 fKinematicsLoaded = kTRUE;
153 return runLoader->Stack();