Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:50

0001 #!/bin/bash
0002 #
0003 # Automatically extracts all histograms
0004 # from a root file and saves them as image files.
0005 # Creates a directory structure exactly as found
0006 # in the root file itself.
0007 #
0008 # Michael Anderson
0009 # May 22, 2008
0010 
0011 plotMacro=./saveHistograms.C
0012 defaultXsize=480
0013 defaultYsize=360
0014 
0015 printUsage() {
0016  echo
0017  echo "Saves all histograms from a root file into images"
0018  echo "Usage:  saveHistograms file.root"
0019  echo "        saveHistograms file.root imageType"
0020  echo "        saveHistograms file.root imageType xSize ySize"
0021  echo "example:"
0022  echo "        saveHistograms jets.root gif $defaultXsize $defaultYsize"
0023 }
0024 
0025 saveHistFromRootFile() {
0026   rootFile=$1
0027   imageType=$2
0028   xSize=$3
0029   ySize=$4
0030 
0031   echo "Saving histograms from $rootFile as $xSize x $ySize $imageType images."
0032   # call the root macro in batch mode and tell it to quit when it's done
0033   root -b -l -q "$plotMacro(\"$rootFile\",\"$imageType\",$xSize,$ySize)"
0034 }
0035 
0036 # Main method
0037 if [ $# -eq 0 ]; then
0038   #for a in `ls | grep .root`; do
0039   #  saveHistFromRootFile $a gif $defaultXsize $defaultYsize
0040   #done
0041   #exit
0042   printUsage
0043   exit 2
0044 else
0045   rootFile=$1
0046   imageType="gif"
0047   xSize=$defaultXsize
0048   ySize=$defaultYsize
0049 fi
0050 
0051 if [ $# -gt 0 ]; then
0052   rootFile=$1
0053 fi
0054 if [ $# -gt 1 ]; then
0055   imageType=$2
0056 fi
0057 if [ $# -gt 3 ]; then
0058   xSize=$3
0059   ySize=$4
0060 fi
0061 
0062 saveHistFromRootFile $rootFile $imageType $xSize $ySize