]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGJE/EMCALJetTasks/macros/AddTaskScale.C
Split: fix refs to AddTaskCentrality.C
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / macros / AddTaskScale.C
index 3e43dcd9b25daaf6e8997e549e98cf0e9655014d..6dc90772697a53fc82893bc61c210a116a6c2025 100644 (file)
@@ -1,12 +1,11 @@
-// $Id$
-
 AliAnalysisTaskScale* AddTaskScale(
   const char *nTracks        = "Tracks",
   const char *nClusters      = "CaloClustersCorr",
   Double_t    trackptcut     = 0.150,
   Double_t    clusptcut      = 0.150,
   const char *taskname       = "Scale",
-  const char *outfilename    = "AnalysisResults.root"
+  const char *sfuncPath      = 0,
+  const char *sfuncName      = 0
 )
 {  
   // Get the pointer to the existing analysis manager via the static access method.
@@ -40,6 +39,28 @@ AliAnalysisTaskScale* AddTaskScale(
   AliClusterContainer  *ccont = scaletask->AddClusterContainer(nClusters);
   if(ccont) ccont->SetClusPtCut(clusptcut);
 
+  if (sfuncPath != 0 && sfuncName != 0) {
+    TFile *file = TFile::Open(sfuncPath);
+    if (file && !file->IsZombie()) {
+      TF1* sfunc = dynamic_cast<TF1*>(file->Get(sfuncName));
+
+      if (sfunc) {
+        scaletask->SetScaleFunction(sfunc);
+        ::Info("AddTaskScale", Form("Scale function %s loaded from file %s.", sfuncName, sfuncPath));
+      }
+      else {
+        ::Error("AddTaskScale", Form("Scale function %s not found in file %s.", sfuncName, sfuncPath));
+      }
+      
+      file->Close();
+      delete file;
+      file = 0;
+    }
+    else {
+      ::Warning("AddTaskScale", "Could not open scale function file");
+    }
+  }
+
   //-------------------------------------------------------
   // Final settings, pass to manager and set the containers
   //-------------------------------------------------------
@@ -53,7 +74,7 @@ AliAnalysisTaskScale* AddTaskScale(
   AliAnalysisDataContainer *coscale = mgr->CreateContainer(contname,
                                                            TList::Class(),
                                                            AliAnalysisManager::kOutputContainer,
-                                                           outfilename);
+                                                           Form("%s", AliAnalysisManager::GetCommonFileName()));
   mgr->ConnectOutput(scaletask,1,coscale);
 
   return scaletask;