]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Enable use iof GDB in PROOF sessions, and some updates to QA scripts
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Oct 2011 08:18:13 +0000 (08:18 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 19 Oct 2011 08:18:13 +0000 (08:18 +0000)
PWG2/FORWARD/analysis2/MakeAOD.C
PWG2/FORWARD/analysis2/qa/MakeTrendTree.C [new file with mode: 0644]
PWG2/FORWARD/analysis2/qa/getQAResults.sh
PWG2/FORWARD/analysis2/trains/TrainSetup.C

index 51a7e1d4e30cae847448cdd596683081cd9e41be..13b7d8ef11a51bdbde6ccc535f4f1004153fd224 100644 (file)
@@ -43,7 +43,8 @@ void MakeAOD(const char* esddir,
             Int_t       proof      = 0,
             Bool_t      mc         = false,
             Bool_t      centrality = true,
-            const char* name       = 0)
+            const char* name       = 0,
+            bool        debug      = false)
 {
   // --- Possibly use plug-in for this -------------------------------
   if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
@@ -57,6 +58,7 @@ void MakeAOD(const char* esddir,
     t.SetDataDir(esddir);
     t.SetDataSet("");
     t.SetProofServer(Form("workers=%d",proof));
+    t.SetUseGDB(debug);
     t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, mc, proof > 0);
     return;
   }
diff --git a/PWG2/FORWARD/analysis2/qa/MakeTrendTree.C b/PWG2/FORWARD/analysis2/qa/MakeTrendTree.C
new file mode 100644 (file)
index 0000000..192eb1a
--- /dev/null
@@ -0,0 +1,127 @@
+#ifndef __CINT__
+# include <TSystemDirectory.h>
+# include <TObjArray.h>
+# include <TString.h>
+# include <TList.h>
+# include <TSystem.h>
+#else 
+class TSystemDirectory;
+class TList;
+class TString;
+#endif
+
+//__________________________________________________________________
+/** 
+ * Scan directory @a dir (possibly recursive) for tree files to add
+ * to the chain.    This does not follow sym-links
+ * 
+ * @param dir        Directory to scan
+ * @param chain      Chain to add to
+ * @param type       Type of tree (ESD or AOD)
+ * @param recursive  Whether to scan recursively 
+ * @param mc         Look also for MC files if true 
+ *
+ * @return true if any files where added 
+ */
+Bool_t ScanDirectory(const TString& pattern, TSystemDirectory* dir, TList& list,
+                    Bool_t recursive=false)
+{
+  // Assume failure 
+  Bool_t ret = false;
+
+  // Get list of files, and go back to old working directory
+  TString oldDir(gSystem->WorkingDirectory());
+  TList*  files = dir->GetListOfFiles();
+  if (!gSystem->ChangeDirectory(oldDir)) { 
+    Error("ScanDirectory", "Failed to go back to %s", oldDir.Data());
+    return false;
+  }
+  if (!files) return false;
+
+  // Sort list of files and check if we should add it 
+  files->Sort();
+  TIter next(files);
+  TSystemFile* file = 0;
+  while ((file = static_cast<TSystemFile*>(next()))) {
+    TString name(file->GetName());
+    TString title(file->GetTitle());
+    TString full(gSystem->ConcatFileName(file->GetTitle(), name.Data()));
+    Bool_t  isFile(!file->IsDirectory());
+    if (isFile) full = title;
+    // Ignore special links 
+    if (name == "." || name == "..") { 
+      // Info("ScanDirectory", "Ignoring %s", name.Data());
+      continue;
+    }
+
+    FileStat_t fs;
+    if (gSystem->GetPathInfo(full.Data(), fs)) {
+      Warning("ScanDirectory", "Cannot stat %s (%s)", full.Data(),
+             gSystem->WorkingDirectory());
+      continue;
+    }
+    // Check if this is a directory 
+    if (!isFile) { 
+      if (recursive) {
+       // if (title[0] == '/') 
+       TSystemDirectory* d = new TSystemDirectory(file->GetName(),
+                                                  full.Data());
+       if (ScanDirectory(pattern, d, list, recursive))
+         ret = true;
+       delete d;
+      }
+      continue;
+    }
+    
+    // If this is not a root file, ignore 
+    if (!name.EndsWith(".root")) continue;
+
+    // If this file does not contain AliESDs, ignore 
+    if (!name.Contains(pattern)) { 
+      // Info("ScanDirectory", "%s does not match pattern %s", 
+      //      name.Data(), fnPattern.Data());
+      continue;
+    }
+    
+    // Add 
+    // Info("ScanDirectory", "Adding %s", full.Data());
+    list.Add(new TObjString(full));
+  }
+
+  if (list.GetEntries() > 0) ret = true;
+
+  gSystem->ChangeDirectory(oldDir);
+  return ret;
+}
+
+//__________________________________________________________________
+struct EventInfo
+{
+  int fRunNo;
+} event;
+
+
+//__________________________________________________________________
+void MakeTrendTree(const char* dir=".", const char* pattern="trending")
+{
+  TList files;
+  
+  TSystemDirectory* top = new TSystemDirectory(dir, dir);
+  if (!ScanDirectory(pattern, top, files)) { 
+    return;
+  }
+  
+  TFile* out = TFile::Open("trending_tree.root", "RECREATE");
+  if (!out) { 
+    Error("MakeTrendTree", "Failed to open output file");
+    return;
+  }
+
+  TTree* tree = new TTree("T", "T");
+  tree->Branch("event", "runno/I", &event);
+}
+
+//__________________________________________________________________
+//
+// EOF
+// 
index 40b412aec91da9b1d4205633997c77557f77c807..1efd019155372e17c107164c7766c6c3a45d9462 100755 (executable)
@@ -1,19 +1,5 @@
 #!/bin/bash
 
-# --------------------------------------------------------------------
-uid=`id -u`
-genv_file=/tmp/gclient_env_${uid}
-
-if test ! -f ${genv_file} ; then 
-    echo "No such file: ${genv_file}, please do alien-token-init" >/dev/stderr
-    exit 1
-fi
-alien-token-info | grep -q "Token is still valid"
-if test $? -ne 0 ; then 
-    echo "Token not valid, please re-new" > /dev/stderr 
-    exit 1
-fi
-
 # --------------------------------------------------------------------
 verb=0
 
@@ -35,6 +21,8 @@ Options:
        -p,--production  IDENTIFIER   Production identifier [$prod]
        -y,--year        YEAR         Year of production [$year]
        -P,--pass        NUMBER       Reconstruction pass number [$pass]
+       -Q,--pre-pass    STRING       Prefix to pass identifier [${prep}]
+       -R,--post-pass   STRING       Postfix to pass identifier [$post]
        -d,--destination DIRECTORY    Directory to store result in [$dest] 
        -r,--run         NUMBER       Run number [$runn]
        -q,--qa          NUMBER       QA number 
@@ -54,6 +42,7 @@ check_file()
     cat <<EOF > ${scr}.C  
 void ${scr}() 
 {
+  int ret = 0;
   gSystem->Load("libANALYSIS");
   gSystem->Load("libANALYSISalice");
   gSystem->Load("libTENDER");
@@ -64,20 +53,18 @@ void ${scr}()
   if (!file) { 
     Error("${scr}", "No such file ${inp}");
     exit(1);
-    return false;
   }
   TObject* forward1 = file->Get("Forward");
   if (!forward1) {
     Error("${scr}", "No Forward object found in ${inp}");
-    exit(2);
-    ret = false;
+    ret |= 2;
   } 
   TObject* forward2 = file->Get("ForwardResults");
   if (!forward2) {
     Error("${scr}", "No ForwardResults object found in ${inp}");
-    exit(4);
+    ret |= 4;
   } 
-  exit(0);
+  exit(ret);
 }
 EOF
     # cat ${scr}.C 
@@ -90,15 +77,17 @@ EOF
 }
 
 # --------------------------------------------------------------------
-year=
-prod=
-pass=1
-qual=
+year=""
+prod=""
+pass=-1
+prep=""
+post=""
 dest=.
 runn=0
 qano=0
 noac=0
 arch=0
+file=QAresults.root 
 
 while test $# -gt 0 ; do 
     case $1 in 
@@ -106,11 +95,13 @@ while test $# -gt 0 ; do
        -v|--verbose)     let verb=$verb+1  ;; 
        -p|--production)  prod=$2 ; shift ;; 
        -P|--pass)        pass=$2 ; shift ;; 
-       -Q|--prepass)     qual=$2 ; shift ;; 
+       -Q|--prepass)     prep=$2 ; shift ;; 
+       -R|--postpass)    post=$2 ; shift ;; 
        -y|--year)        year=$2 ; shift ;; 
        -d|--destination) dest=$2 ; shift ;; 
        -r|--run)         runn=$2 ; shift ;; 
        -q|--qa)          qano=$2 ; shift ;; 
+       -f|--file)        file=$2 ; shift ;; 
        -n|--no-action)   noac=1  ;; 
        -a|--archives)    arch=1  ;; 
        *) echo "$0: Unknown option $1" > /dev/stderr ; exit 2 ;; 
@@ -118,6 +109,22 @@ while test $# -gt 0 ; do
     shift
 done
 
+# --------------------------------------------------------------------
+uid=`id -u`
+genv_file=/tmp/gclient_env_${uid}
+
+if test ! -f ${genv_file} ; then 
+    echo "No such file: ${genv_file}, please do alien-token-init" >/dev/stderr
+    exit 1
+fi
+. ${genv_file}
+alien-token-info | grep -q "Token is still valid"
+if test $? -ne 0 ; then 
+    echo "Token not valid, please re-new" > /dev/stderr 
+    exit 1
+fi
+
+
 # --------------------------------------------------------------------
 if test "x$prod" = "x" ; then 
     echo "No production identifier given" > /dev/stderr 
@@ -131,40 +138,70 @@ if test "x$year" = "x" ; then
        exit 2
     fi
 fi
+lett=`echo $prod | sed -e "s/LHC${year}\(.\).*/\1/"`
+suff=`echo $prod | sed -e "s/LHC${year}${lett}//"`
 
 redir="/dev/null"
-if test $verb -gt 1 ; then redir1=/dev/stderr ; fi
+if test $verb -gt 1 ; then redir=/dev/stderr ; fi
 
 # --------------------------------------------------------------------
-path=/alice/data/20${year}/${prod}/
-store=${dest}/${prod}/${qual}pass${pass}
-search="ESDs/${qual}pass${pass}/"
+if test "x$post" != "x" ; then 
+    case $post in 
+       _*) ;; 
+       *) post="_${post}" ;; 
+    esac
+fi
+if test ${pass} -ge 0 ; then 
+    paid=pass${pass} 
+fi
+datd=data
+esdd=ESDs/
+if test "x${suff}" != "x" ; then 
+    datd=sim
+    esdd=
+fi
+path=/alice/${datd}/20${year}/${prod}/
+store=${dest}/${prod}/${prep}${paid}${post}
+search="${esdd}${prep}${paid}${post}"
 if test $runn -gt 0 ; then 
-    path=`printf "${path}%09d/ESDs/${qual}pass${pass}/" $runn` 
+    path=`printf "${path}%09d/ESDs/${prep}${paid}${pass}${post}/" $runn` 
     store=`printf "${store}/%09d" $runn` 
     search=
 fi
 if test $qano -gt 0 ; then 
-    path=`printf "%sQA%02d/" $path $qano` 
+    if test $runn -gt 0 ; then 
+       path=`printf "%sQA%02d/" $path $qano` 
+    else
+       if test "x$search" != "x" ; then search=${search}/ ; fi
+       search=${search}QA`printf %02d ${qano}`/ 
+    fi
 fi
 if test $arch -gt 0 ; then 
-    search="${search}QA_archive.zip"
-else
-    search="${search}QAresults.root"
+    file=QA_archive.zip
 fi
+base=`basename $file .root`
+if test "x$search" != "x" ; then search=${search}/ ; fi
+search="${search}${file}"
 
+# --------------------------------------------------------------------
 cat <<EOF
 Settings:
 
        Production:             $prod
        Year:                   $year
+       Letter:                 $lett
+       Suffix:                 $suff
        Pass:                   $pass
-       Pass qualifier:         $qual
+       Pass prefix:            $prep
+       Pass postfix:           $post
+       File:                   $file
        Path:                   $path
        Destination:            $dest
        Store:                  $store
        Run number:             $runn
        Search string:          $search
+       Verbosity:              $verb
+       Redirection:            $redir
 EOF
     
 # --------------------------------------------------------------------
@@ -179,15 +216,15 @@ for i in $files ; do
     if test $runn -gt 0 ; then 
        r=`echo $b | sed -e "s,[0-9]*${runn}\([0-9.]*\)/.*,\1," | tr '.' '_'`
        if test $arch -lt 1 ; then 
-           o=${store}/QAresults_${r}.zip
+           o=${store}/${base}_${r}.root
        else
            d=${store}/${r}
            mkdir -p $d
-           o=${d}/QAarchive.zip 
+           o=${d}/${file}
        fi
     else 
        r=`echo $b | sed -e "s,/.*,,"` 
-       o=${store}/QAresults_${r}.root
+       o=${store}/${base}_${r}.root
     fi
     runs="$runs $r" 
     mess "$i -> $o"
index 69e592460e27daf352834b7b0c19ffcbe54a6913..5601d2b77b688b3ca8ec6ae56620f23602f7b826 100644 (file)
@@ -203,7 +203,8 @@ struct TrainSetup
       fESDPass(3),
       fPassPostfix(""),
       fEscapedName(name),
-      fAllowOverwrite(kFALSE)
+      fAllowOverwrite(kFALSE),
+      fUseGDB(kFALSE)
   {
     char  c[] = { ' ', '/', '@', 0 };
     char* p   = c;
@@ -391,6 +392,13 @@ struct TrainSetup
    */
   void SetPassPostfix(const char* postfix) { fPassPostfix = postfix; }
   //__________________________________________________________________
+  /** 
+   * Use GDB to wrap PROOF slaves 
+   * 
+   * @param use Whether to use GDB or not 
+   */
+  void SetUseGDB(Bool_t use=kTRUE) { fUseGDB = use; }
+  //__________________________________________________________________
   /** 
    * Add a source file to be copied and byte compiled on slaves 
    * 
@@ -1098,6 +1106,10 @@ protected:
              fProofServer.Data(), userName.Data());
        return false;
       }
+      if (fUseGDB) { 
+       TProof::AddEnvVar("PROOF_WRAPPERCMD", 
+                         "gdb --batch -ex run -ex bt --args ");
+      }
       if (lite) return true;
     }
 
@@ -1544,10 +1556,11 @@ protected:
   TList   fListOfLibraries;  // List of libraries to load
   TList   fListOfExtras;     // List of extra files to upload
   Int_t   fNReplica;         // Storage replication
-  Int_t   fESDPass;
+  Int_t   fESDPass;          // ESD pass number 
   TString fPassPostfix;      // Possible pass postfix
-  TString fEscapedName;
-  Bool_t  fAllowOverwrite;
+  TString fEscapedName;      // Name escaped for special chars
+  Bool_t  fAllowOverwrite;   // Allow overwriting output dir
+  Bool_t  fUseGDB;           // Wrap PROOF slaves in GDB 
 };