]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Some more train stuff
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Oct 2012 12:12:52 +0000 (12:12 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Oct 2012 12:12:52 +0000 (12:12 +0000)
PWGLF/FORWARD/analysis2/AddTaskCentralMult.C
PWGLF/FORWARD/analysis2/AddTaskForwardMult.C
PWGLF/FORWARD/trains/AAFHelper.C
PWGLF/FORWARD/trains/GridHelper.C
PWGLF/FORWARD/trains/MakeAODTrain.C
PWGLF/FORWARD/trains/MakeFMDELossTrain.C
PWGLF/FORWARD/trains/MakeMCCorrTrain.C

index f3c4880a43aad137f3736c97b0be7d6553061735..7ec9a0f23ee46c21b3330a68dfac6ac886923805 100644 (file)
@@ -27,7 +27,8 @@ AddTaskCentralMult(Bool_t      mc=false,
                   UShort_t    sys=0, 
                   UShort_t    sNN=0, 
                   Short_t     field=0, 
-                  const char* config="CentralAODConfig.C")
+                  const char* config="CentralAODConfig.C", 
+                  const char* corrs=0)
 {
   // --- Load libraries ----------------------------------------------
   gROOT->LoadClass("AliAODForwardMult", "libPWGLFforward2");
@@ -39,20 +40,28 @@ AddTaskCentralMult(Bool_t      mc=false,
     return NULL;
   }   
 
-  // --- Make the task and add it to the manager ---------------------
+  // --- Make the task -----------------------------------------------
   AliCentralMultiplicityTask* task = 0;
   if (!mc) task = new AliCentralMultiplicityTask("Central");
   else     task = new AliCentralMCMultiplicityTask("Central");
+  task->Configure(config);
+  mgr->AddTask(task);
+
+  // --- Set optional corrections path -------------------------------
+  AliCentralMultiplicityTask::Manager& cm = task->GetManager();
+  if (corrs && corrs[0] != '\0') { 
+    cm->SetAcceptancePath(Form("%s/CentralAcceptance", corrs));
+    cm->SetSecMapPath(Form("%s/CentralSecMap", corrs));
+  }
+
+  // --- Prime the corrections ---------------------------------------
   if(sys>0 && sNN > 0) {
-    task->GetManager().Init(sys, sNN, field);
-    if (!task->GetManager().HasSecondaryCorrection()) 
+    cm.Init(sys, sNN, field);
+    if (!cm.HasSecondaryCorrection()) 
       Fatal("AddTaskCentralMult", "No secondary correction defined!");
-    if (!task->GetManager().HasAcceptanceCorrection()) 
+    if (!cm.HasAcceptanceCorrection()) 
       Fatal("AddTaskCentralMult", "No acceptance correction defined!");
   }
-  task->Configure(config);
-  mgr->AddTask(task);
-
 
   // --- Make the output container and connect it --------------------
   TString outputfile = AliAnalysisManager::GetCommonFileName();
index a32cf3b2a22b637eed43b0c3bc94551d0719ec57..fecd0f23612ebd4d01c01290bf28103b78f1602a 100644 (file)
@@ -40,7 +40,8 @@ AddTaskForwardMult(Bool_t   mc,
                   UShort_t sys=0, 
                   UShort_t sNN=0, 
                   Short_t  field=0, 
-                  const char* config="ForwardAODConfig.C")
+                  const char* config="ForwardAODConfig.C",
+                  const char* corrs=0)
 {
   // --- Load libraries ----------------------------------------------
   gROOT->LoadClass("AliAODForwardMult", "libPWGLFforward2");
@@ -59,13 +60,17 @@ AddTaskForwardMult(Bool_t   mc,
   task->Configure(config);
   mgr->AddTask(task);
   
+  // --- Set alternative corrections path ----------------------------
+  AliForwardCorrectionManager& cm = AliForwardCorrectionManager::Instance();
+  if (corrs && corrs[0] != '\0') cm.SetPrefix(corrs);
+    
   // --- Do a local initialisation with assumed values ---------------
   if (sys > 0 && sNN > 0) {
     UInt_t what = AliForwardCorrectionManager::kAll;
     what ^= AliForwardCorrectionManager::kDoubleHit;
     what ^= AliForwardCorrectionManager::kVertexBias;
     what ^= AliForwardCorrectionManager::kMergingEfficiency;
-    if (!AliForwardCorrectionManager::Instance().Init(sys,sNN,field,mc,what))
+    if (!cm.Init(sys,sNN,field,mc,what))
       Fatal("AddTaskForwardMult", "Failed to initialize corrections");
   }
   
index cfdaba5c6a4ac6546382335c65d7facc38114633..9eca5d19d009279217feca182b89a7abd5a3aa54 100644 (file)
@@ -82,6 +82,7 @@ struct AAFHelper : public ProofHelper
   {
     fOptions.Add("aliroot", "VERSION", "AliROOT version", "last");
     fOptions.Add("root",    "VERISON", "ROOT version", "last");
+    fOptions.Add("nocache", "Disable tree cache");
   }
   virtual ~AAFHelper() {}
   /** 
@@ -122,7 +123,11 @@ struct AAFHelper : public ProofHelper
     TProof::Mgr(fUrl.GetHost())
       ->SetROOTVersion(Form("VO_ALICE@ROOT::%s", root.Data()));
 
-    return ProofHelper::PreSetup();
+    if (!ProofHelper::PreSetup()) return false;
+
+    if (fOptions.Has("nocache")) 
+      gProof->SetParameter("PROOF_UseTreeCache", 0);
+    return true;
   }
   /** 
    * @return URI help string 
index 66ddbc337e1d5d1a27132df56bb3f3bfd2fc35f5..cffb124d0d15e06c9a77da1e922a80bf83f45c54 100644 (file)
@@ -81,7 +81,7 @@ struct GridHelper : public PluginHelper
    * @param opts Options 
    */
   GridHelper(const TUrl& url, Int_t verbose)
-    : PluginHelper(url, verbose)
+    : PluginHelper(url, verbose), fRuns()
   {
     fOptions.Add("oper", "FULL|TERMINATE|SUBMIT", "Analysis operation", "FULL");
     fOptions.Add("split",  "N|max",  "Max number of files before split","max");
@@ -92,6 +92,15 @@ struct GridHelper : public PluginHelper
     fOptions.Add("concat", "Concatenate all runs");
     fOptions.Add("mc",     "Assume MC input");
   }
+  GridHelper(const GridHelper& o)
+    : PluginHelper(o), fRuns()
+  {}
+  GridHelper& operator=(const GridHelper& o)
+  {
+    if (&o == this) return *this;
+    PluginHelper::operator=(o);
+    return *this;
+  }
   virtual ~GridHelper() {}
   /** 
    * Get the mode identifier 
@@ -119,6 +128,12 @@ struct GridHelper : public PluginHelper
     else if (oper.EqualTo("TEST",      TString::kIgnoreCase)) return kTest;
     return kFull;
   }
+  void StoreRun(Int_t r)
+  {
+    TObject* o = new TObject;
+    o->SetUniqueID(r);
+    fRuns.Add(o);
+  }
   /**
    * Read run numbers 
    *
@@ -167,6 +182,7 @@ struct GridHelper : public PluginHelper
        fHandler->SetRunRange(first, last);
        ranges->Delete();
        range = true;
+       for (Int_t r = first; r <= last; r++) StoreRun(r);
        continue;
       }
       if (s.IsDigit()) { // single run
@@ -177,7 +193,8 @@ struct GridHelper : public PluginHelper
          continue;
        }
        Info("GridHandler::RegisterRuns", "Adding run %s", s.Data());
-       fHandler->AddRunNumber(s.Data());
+       fHandler->AddRunNumber(s.Atoi());
+       StoreRun(s.Atoi());
        nRuns++;
        individual = true;
        continue;
@@ -200,6 +217,7 @@ struct GridHelper : public PluginHelper
        in >> r;
        Info("GridHelper::RegisterRuns", "Read %d, adding", r);
        fHandler->AddRunNumber(r);
+       StoreRun(r);
        nRuns++;
        Char_t c;
        in >> c;
@@ -258,7 +276,7 @@ struct GridHelper : public PluginHelper
     fHandler->SetRunMode(operation);
 
     // --- Add the run numbers ---------------------------------------
-    fHandler->SetRunPrefix(mgr->GetMCtruthEventHandler() ? "%d" : "%09d");
+    fHandler->SetRunPrefix(mgr->GetMCtruthEventHandler() ? "" : "000");
     Int_t nRun = RegisterRuns();
 
     // --- Do not test copying ---------------------------------------
@@ -472,13 +490,13 @@ struct GridHelper : public PluginHelper
     fHandler->Write("plugin");
     plug->Close();
     
-    std::ofstream o("Terminate.C");
-    if (!o) { 
+    std::ofstream t("Terminate.C");
+    if (!t) { 
       Error("GridHelper::AuxSave", "Failed to make terminate ROOT script");
       return;
     }
     
-    o << "// Generated by GridHelper\n"
+    t << "// Generated by GridHelper\n"
       << "Bool_t LoadLib(const char* libName)\n"
       << "{\n"
       << "  if (gSystem->Load(libName) < 0) {\n"
@@ -516,7 +534,7 @@ struct GridHelper : public PluginHelper
       << "  if (gSystem->Load(\"libOADB\")          < 0) return false;\n"
       << "  if (gSystem->Load(\"libANALYSISalice\") < 0) return false;\n\n";
     // Now load libraries 
-    o << " // Load libraries\n";
+    t << " // Load libraries\n";
     TIter nextLib(&fExtraLibs);
     TObjString* lib = 0;
     while ((lib = static_cast<TObjString*>(nextLib()))) {
@@ -527,11 +545,11 @@ struct GridHelper : public PluginHelper
          libName.Contains("libANALYSIS") ||
          libName.Contains("libOADB") ||
          libName.Contains("libANALYSISalice")) continue;
-      if (libName.Contains(".so")) continue;
-      o << "  if(!LoadLib(\"" << libName << "\")) return false;\n";
+      if (!libName.Contains(".so")) continue;
+      t << "  if(!LoadLib(\"" << libName << "\")) return false;\n";
     }
     // Now load PARs
-    o << "\n"
+    t << "\n"
       << "  // Load packages\n";
     TIter nextPar(&fExtraPars);
     TObjString* par = 0;
@@ -544,20 +562,20 @@ struct GridHelper : public PluginHelper
          parName.Contains("ANALYSIS") ||
          parName.Contains("OADB") ||
          parName.Contains("ANALYSISalice")) continue;
-      o << "  if (!LoadPar(\"" << parName << "\")) return false;\n";
+      t << "  if (!LoadPar(\"" << parName << "\")) return false;\n";
     }
     // Now load scripts 
-    o << "\n"
+    t << "\n"
       << "  // Load sources\n";
     TIter nextSrc(&fExtraSrcs);
     TObjString* src = 0;
     while ((src = static_cast<TObjString*>(nextSrc()))) {
       const TString& srcName = src->String();
-      o << "  gROOT->ProcessLine(\".L " << srcName << "+g\");\n";
+      t << "  gROOT->ProcessLine(\".L " << srcName << "+g\");\n";
     }
        
     // We're ready to load the analysis manager.  
-    o << "  \n"
+    t << "  \n"
       << "  // Load the analysis manager from file\n"
       << "  TString base(name);\n"
       << "  base.Append(\".root\");\n"
@@ -610,7 +628,7 @@ struct GridHelper : public PluginHelper
       << "// EOF\n"
       << "//\n"
       << std::endl;
-    o.close();
+    t.close();
 
     if (!asShellScript) return;
 
@@ -623,15 +641,15 @@ struct GridHelper : public PluginHelper
       << "# Generated by GridHelper\n"
       << "nam=" << escaped << "\n"
       << "scr=Terminate.C\n"
-      << "mgr=$name.root\n"
+      << "mgr=$nam.root\n"
       << "\n"
       << "if test ! -f $scr || test ! -f $mgr ; then\n"
       << "  if test ! -d $nam ; then\n"
       << "    echo \"Directory $nam not found\"\n"
       << "    exit 1\n"
       << "  fi\n\n"
-      << "  if test ! -f $nam/$scr || test -f $nam/$scr ; then\n"
-      << "    echo \"Script $nam/$scr, manager $nam/$scr not found\"\n"
+      << "  if test ! -f $nam/$scr || test ! -f $nam/$mgr ; then\n"
+      << "    echo \"Script $scr, manager $mgr not found in $nam\"\n"
       << "    exit 1\n"
       << "  fi\n\n"
       << "  (cd $nam && aliroot -l $scr)\n"
@@ -643,7 +661,54 @@ struct GridHelper : public PluginHelper
       << std::endl;
     s.close();
     gSystem->Exec("chmod a+x terminate.sh");
+
+    std::ofstream d("Download.C");
+    if (!d) { 
+      Error("GridHelper::AuxSave", "Failed to make ROOT script Download.C");
+      return;
+    }
+    d << "// Generated by GridHelper\n"
+      << "Bool_t GetOne(const TString& base, const TString& dir)\n"
+      << "{\n"
+      << "  TString src(gSystem->ConcatFileName(base,dir));\n"
+      << "  src = gSystem->ConcatFileName(src,\"root_archive.zip\");\n"
+      << "  TString dest;\n"
+      << "  dest.Form(\"root_archive_%s.zip\",dir.Data()));\n\n"
+      << "  if (!TFile::Cp(src, dest)) {\n"
+      << "    Error(\"GetOne\",\"Failed to download %s -> %s\",\n"
+      << "          src.Data(), dest.Data());\n"
+      << "    return false;\n"
+      << "  }\n"
+      << "  return true;\n"
+      << "}\n\n"
+      << "void Download()\n"
+      << "{\n"
+      << "  TString base(\"" << fUrl.GetProtocol() << "://" 
+      << OutputPath() << "\");\n\n";
+    TString format(fOptions.Has("mc") ? "%d" : "%09d");
+    if (fOptions.Has("concat")) {
+      Int_t first = fRuns.First()->GetUniqueID();
+      Int_t last  = fRuns.Last()->GetUniqueID();
+      TString fmt(format); fmt.Append("_"); fmt.Append(format);
+      d << "  GetOne(base, \"" << TString::Format(fmt, first, last)
+       << "\");\n";
+    }
+    else {
+      d << "  const char*  runs[] = { ";
+      TIter next(&fRuns);
+      TObject* o = 0;
+      while ((o = next())) 
+       d << "\"" << Form(format, o->GetUniqueID()) 
+         << "\",\n                         ";
+      d << "0 };\n"
+       << "  const char** run    = runs;\n"
+       << "  while (*run) { GetOne(base, *run); run++ }\n";
+    }
+    d << "}\n"
+      << std::endl;
+    d.close();
   }
+  TList fRuns;
 };
 #endif
 //
index 2b4b91a06c89a2c22be1e27ac9a884e447223f5f..ebfe6799201a4de9510560c7ffa8022d49de1e22 100644 (file)
@@ -39,6 +39,7 @@ public:
     fOptions.Add("cent",  "Use centrality");
     fOptions.Add("tpc-ep", "Use TPC event plane");
     fOptions.Add("satelitte", "Use satelitte interactions");
+    fOptions.Add("corr", "DIR", "Corrections dir", "");
     fOptions.Set("type", "ESD");
   }
 protected:
@@ -75,17 +76,19 @@ protected:
     UShort_t sys = fOptions.AsInt("sys", 0);
     UShort_t sNN = fOptions.AsInt("snn", 0);
     UShort_t fld = fOptions.AsInt("field", 0);
+    TString  cor = "";
+    if (fOptions.Has("corr")) cor = fOptions.Get("corr"); 
     
     // --- Add the task ----------------------------------------------
     TString fwdConfig = fOptions.Get("forward-config");
-    gROOT->Macro(Form("AddTaskForwardMult.C(%d,%d,%d,%d,\"%s\")", 
-                     mc, sys, sNN, fld, fwdConfig.Data()));
+    gROOT->Macro(Form("AddTaskForwardMult.C(%d,%d,%d,%d,\"%s\",\"%s\")", 
+                     mc, sys, sNN, fld, fwdConfig.Data(), cor.Data()));
     fHelper->LoadAux(gSystem->Which(gROOT->GetMacroPath(), fwdConfig));
 
     // --- Add the task ----------------------------------------------
     TString cenConfig = fOptions.Get("central-config");
-    gROOT->Macro(Form("AddTaskCentralMult.C(%d,%d,%d,%d,\"%s\")", 
-                     mc, sys, sNN, fld, cenConfig.Data()));
+    gROOT->Macro(Form("AddTaskCentralMult.C(%d,%d,%d,%d,\"%s\",\"%s\")", 
+                     mc, sys, sNN, fld, cenConfig.Data(), cor.Data()));
     fHelper->LoadAux(gSystem->Which(gROOT->GetMacroPath(), cenConfig));
 
     // --- Add MC particle task --------------------------------------
index 278b51e8c20c97a400ae049e1e0cb185e9998941..0cc93d8c771959fbed561f35bbb341552f6ef97e 100644 (file)
@@ -58,7 +58,7 @@ protected:
     AliAnalysisManager::SetCommonFileName("forward_eloss.root");
 
     // --- Load libraries/pars ---------------------------------------
-    LoadLibrary("PWGLFforward2");
+    fHelper->LoadLibrary("PWGLFforward2");
     
     // --- Set load path ---------------------------------------------
     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",
index 9065243284da58266851fabda6f63af3f2e051db..069a5e8410ed7b2ae15455ea1215d29e3d674ce7 100644 (file)
@@ -44,7 +44,7 @@ protected:
     AliAnalysisManager::SetCommonFileName("forward_mccorr.root");
 
     // --- Load libraries/pars ---------------------------------------
-    LoadLibrary("PWGLFforward2");
+    fHelper->LoadLibrary("PWGLFforward2");
     
     // --- Set load path ---------------------------------------------
     gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2",