]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding the base task that gives access to the run loader
authorpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Mar 2007 16:14:01 +0000 (16:14 +0000)
committerpanos <panos@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Mar 2007 16:14:01 +0000 (16:14 +0000)
ANALYSIS/ANALYSISRLLinkDef.h [new file with mode: 0644]
ANALYSIS/AliAnalysisTaskRL.cxx [new file with mode: 0644]
ANALYSIS/AliAnalysisTaskRL.h [new file with mode: 0644]
ANALYSIS/libANALYSISRL.pkg [new file with mode: 0644]

diff --git a/ANALYSIS/ANALYSISRLLinkDef.h b/ANALYSIS/ANALYSISRLLinkDef.h
new file mode 100644 (file)
index 0000000..8915778
--- /dev/null
@@ -0,0 +1,9 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class  AliAnalysisTaskRL+;
+
+#endif
diff --git a/ANALYSIS/AliAnalysisTaskRL.cxx b/ANALYSIS/AliAnalysisTaskRL.cxx
new file mode 100644 (file)
index 0000000..ccc8c53
--- /dev/null
@@ -0,0 +1,143 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+//-----------------------------------------------------------------
+//           AliAnalysisTaskRL class
+//     Task that gives access to the run loader
+//   Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
+//-----------------------------------------------------------------
+
+#include "AliAnalysisTaskRL.h"
+#include "AliRunLoader.h"
+#include "AliStack.h"
+#include "AliHeader.h"
+
+
+#include <TTree.h>
+#include <TFile.h>
+
+ClassImp(AliAnalysisTaskRL)
+
+//___________________________________________________________________________
+AliAnalysisTaskRL::AliAnalysisTaskRL() :
+  AliAnalysisTask(),
+  fTree(0), fRunLoader(0),
+  fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) {
+  //
+  // Constructor. Initialization of pointers
+  //
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskRL::AliAnalysisTaskRL(const char *name, const char *title) :
+  AliAnalysisTask(name,title),
+  fTree(0), fRunLoader(0),
+  fKinematicsLoaded(kFALSE), fHeaderLoaded(kFALSE) {
+  // Constructor.
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskRL::~AliAnalysisTaskRL() {
+  //
+  // Destructor
+  //
+  DeleteRunLoader();
+}
+
+//___________________________________________________________________________
+Bool_t AliAnalysisTaskRL::GetEntry(Long64_t ientry) {
+  //returns the entry of the run loader
+  if(fRunLoader) {
+    if(fRunLoader->GetEvent((Int_t)ientry) != 0)
+      return kFALSE;
+  }
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+AliRunLoader *AliAnalysisTaskRL::GetRunLoader() {
+  // Returns AliRun instance corresponding to current ESD active in fTree
+  // Loads galice.root, the file is identified by replacing "AliESDs" to
+  // "galice" in the file path of the ESD file. 
+
+  fTree = (TTree *)AliAnalysisTask::GetInputData(0);
+  if (!fRunLoader) {
+    if (!fTree->GetCurrentFile())
+      return 0;
+    
+    TString fileName(fTree->GetCurrentFile()->GetName());
+    fileName.ReplaceAll("AliESDs", "galice");
+    
+    // temporary workaround for PROOF bug #18505
+    fileName.ReplaceAll("#galice.root#galice.root", "#galice.root");
+    
+    fRunLoader = AliRunLoader::Open(fileName);
+    if (!fRunLoader)
+      return 0;
+    fRunLoader->GetEvent((Int_t)(fTree->GetTree()->GetReadEntry()));
+  }
+  
+  return fRunLoader;
+}
+
+//___________________________________________________________________________
+void AliAnalysisTaskRL::DeleteRunLoader() {
+  //
+  // deletes the runloader
+  //
+  if (fRunLoader) {
+    fRunLoader->Delete();
+    fRunLoader = 0;
+  }
+  
+  fKinematicsLoaded = kFALSE;
+  fHeaderLoaded = kFALSE;
+}
+
+//___________________________________________________________________________
+AliHeader* AliAnalysisTaskRL::GetHeader() {
+  // Returns header retrieved from RunLoader
+  
+  AliRunLoader* runLoader = GetRunLoader();
+  if (!runLoader)
+    return 0;
+  
+  if (fHeaderLoaded == kFALSE)
+    if (runLoader->LoadHeader() != 0)
+      return 0;
+  
+  fHeaderLoaded = kTRUE;
+  
+  return runLoader->GetHeader();
+}
+
+//___________________________________________________________________________
+AliStack* AliAnalysisTaskRL::GetStack() {
+  // Returns stack retrieved from RunLoader
+  
+  AliRunLoader* runLoader = GetRunLoader();
+  if (!runLoader)
+    return 0;
+  
+  if (fKinematicsLoaded == kFALSE)
+    if (runLoader->LoadKinematics() != 0)
+      return 0;
+  
+  fKinematicsLoaded = kTRUE;
+  
+  return runLoader->Stack();
+}
diff --git a/ANALYSIS/AliAnalysisTaskRL.h b/ANALYSIS/AliAnalysisTaskRL.h
new file mode 100644 (file)
index 0000000..4931618
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef ALIANALYSISTASKRL_H
+#define ALIANALYSISTASKRL_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+// Author: Panos Christakoglou, 31/05/2006
+
+//============================================================================
+//   AliAnalysysTaskRL - Class representing a basic analysis task. 
+//   Access to the run loader
+//============================================================================
+
+#include "AliAnalysisTask.h"
+
+class TTree;
+
+class AliRunLoader;
+class AliHeader;
+class AliStack;
+
+class AliAnalysisTaskRL : public AliAnalysisTask {
+ public:  
+  AliAnalysisTaskRL();
+  AliAnalysisTaskRL(const char *name, const char *title);
+  virtual ~AliAnalysisTaskRL();
+
+ protected:
+  Bool_t        GetEntry(Long64_t ientry);
+
+  AliRunLoader *GetRunLoader();
+  AliHeader    *GetHeader();
+  AliStack     *GetStack();
+
+ private:
+  void DeleteRunLoader();
+
+  TTree        *fTree; //pointer to the ESD tree
+  AliRunLoader *fRunLoader; //! pointer to the RunLoader if galice.root was opened
+  Bool_t        fKinematicsLoaded; // determines if the stack is properly loaded (AliRunLoader::LoadKinematics() succeeded), this is needed because the GetStack returnes a invalid stack object when the function failed
+  Bool_t fHeaderLoaded; // determines if the header is properly loaded
+
+  AliAnalysisTaskRL(const AliAnalysisTaskRL&);
+  AliAnalysisTaskRL& operator=(const AliAnalysisTaskRL&);
+  ClassDef(AliAnalysisTaskRL,1);  // Class describing an analysis task
+};
+#endif
diff --git a/ANALYSIS/libANALYSISRL.pkg b/ANALYSIS/libANALYSISRL.pkg
new file mode 100644 (file)
index 0000000..eb3189a
--- /dev/null
@@ -0,0 +1,13 @@
+SRCS = AliAnalysisTaskRL.cxx
+
+HDRS:= $(SRCS:.cxx=.h) 
+
+DHDR= ANALYSISRLLinkDef.h
+
+CHECKALIEN = $(shell root-config --has-alien)
+ifeq (yes,$(CHECKALIEN))
+PACKCXXFLAGS := $(CXXFLAGS) -DWITHALIEN
+endif
+EXPORT:=$(SRCS:.cxx=.h)
+
+