I’d like to merge hundreds of root files sitting in a castor directory. They contain histograms and ntuples.
My naive guess didn’t work,
Is there another simple way? Or do I need to copy the files to a tmp directory and hadd those? I know that “hadd out.root *” works for merging files in the current directory.
This is because “/castor/…” is not a standard mount point, so the wildcarding is not working.
You have to create a text file with the list of files the you want to merge, with the full path that you would use to access them in ROOT, e.g. something like this
(You can get the list with, for example, ‘nsls /castor/cern.ch/user/g/gaultney/SergueiTrees/New_MinBiasMC/ > list.txt’ and then editing list.txt) .
Once you have the list, you can do:
hadd example.root @list.txt
Alternatively, you can tailor your own merger using the class TFileMerger.
Great! An automatic way to create the list of text files in the format needed would be:
After further use, I think it’s safer to copy all the files to a local dir and hadd from there.
I use a script:
for afile in `nsls $tempdir`; do
rfcp $tempdir/$afile .
Which I call with nohup so it runs even if I disconnect:
$ nohup ~/bin/castor_cp_dir
/castor/cern.ch/user/g/gaultney/SergueiTrees/New_MinBiasMC/ >& log.txt
then when it’s done hadd the files in my local dir: