Re: Create a bash-script that runs C-files in ROOT

From: Sebastien Binet <binet_at_cern.ch>
Date: Wed, 7 Apr 2010 17:48:28 +0200


hi,

it seems to me like all of this could be trivially done and with minimal (if any) hassle in pyroot.

$ cat fooscript.C
void dostuff(const char* fname)
{
  // do stuff
}

$ cat doit.py
import glob
import ROOT
ROOT.gROOT.SetBatch(True)
ROOT.gROOT.LoadMacro("fooscript.C")

fnames = glob.glob("folder?/*.root")

for fname in fnames:

   ROOT.dostuff(fname)
# EOF # the obvious advantage being that you only load ROOT once. the obvious disadvantage being that you (may) retain state between the various calls to dostuff.

hth,
sebastien.

Excerpts from Brett Viren's message of 2010-04-07 17:29:10 +0200:
> Ida H\xc3\xa4ggstr\xc3\xb6m <ida.haggstrom_at_radfys.umu.se> writes:
>
> > --------------------------------------
> > for (j=0;j<=$N,j++)
> > do
> > \xc2\xa0\xc2\xa0 cd folder$j
> > \xc2\xa0\xc2\xa0 root -q -b myScript1.C("rootFile_$j") myScript2.C
> > \xc2\xa0\xc2\xa0 cd ..
> > done
> > --------------------------------------
>
> Are you using pseudo-code in this example? Because it is not valid
> shell (bash) code. Try cut-and-pasting this to a file "loop.sh":
>
> ----------------------------------------
> #!/bin/bash
> for file in $*
> do
> root -l -q -b myScript1.C\(\"$file\"\) myScript2.C
> done

-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################
Received on Wed Apr 07 2010 - 17:48:45 CEST

This archive was generated by hypermail 2.2.0 : Thu Apr 08 2010 - 11:50:02 CEST