7 __version__ = 
'$Revision: 505706 $' 
    8 __author__  = 
'Radist Morse radist.morse@gmail.com' 
    9 __doc__     = 
'Script for drawing LArG4Validation N tuples' 
   13     if   (hname == 
"hadrleak") :
 
   14         return event.ethad1/event.et
 
   15     elif (hname == 
"e237oe277") :
 
   17             return event.e237/event.e277
 
   20     elif (hname == 
"e2tsts1") :
 
   21         return event.e2tsts1/(1000. + 0.009 * event.et)
 
   22     elif (hname == 
"e2tsts1demins") :
 
   23         return event.e2tsts1 - event.emins1
 
   24     elif (hname == 
"erec") :
 
   26     elif (hname == 
"erecegen") :
 
   27         return event.energy / event.truth_energy
 
   28     elif (hname == 
"eta") :
 
   30     elif (hname == 
"pt") :
 
   32     elif (hname == 
"egen") :
 
   33         return event.truth_energy
 
   38     if   (hname == 
"hadrleak") :
 
   40     elif (hname == 
"e237oe277") :
 
   41         return "#frac{E_{237}}{E_{277}}" 
   42     elif (hname == 
"e2tsts1") :
 
   43         return "E_{2}tsts_{1}" 
   44     elif (hname == 
"e2tsts1demins") :
 
   45         return "e2tsts1demins" 
   46     elif (hname == 
"erec") :
 
   48     elif (hname == 
"erecegen") :
 
   49         return "#frac{E_{rec}}{E_{gen}}" 
   50     elif (hname == 
"eta") :
 
   52     elif (hname == 
"pt") :
 
   54     elif (hname == 
"egen") :
 
   60 from os.path 
import isfile
 
   61 from optparse 
import OptionParser
 
   63 usage = 
"usage: %prog [options] root1 [root2 ...]" 
   65 parser = OptionParser(usage=usage, version=
"%prog v1.0 $Id: LArG4AODNtuplePlotter.py 505706 2012-06-15 11:48:02Z gsedov $")
 
   67 parser.add_option(
"-s",
"--split",dest=
"split_canvas", help=
"Split canvas, format: 'HORIZ:VERT' (default = %default)")
 
   68 parser.add_option(
"-p",
"--plots",dest=
"plots", help=
"input file with histogram parameters")
 
   69 parser.add_option(
"-f",
"--files",dest=
"files", help=
"input file with files parameters")
 
   70 parser.add_option(
"-o",
"--output",dest=
"outputfile", help=
"output ps file")
 
   71 parser.add_option(
"-d",
"--divide",dest=
"divide",action=
"store_true", help=
"Calculate ratio between root files (divide all roots to first")
 
   72 parser.add_option(
"-m",
"--mean",dest=
"mean",action=
"store_true",help=
"Print mean value in the legend")
 
   73 parser.add_option(
"-z",
"--zero",dest=
"zero",action=
"store_true",help=
"Set minimums to zero")
 
   75 parser.set_defaults(split_canvas=
"1:1",plots=
"",files=
"",outputfile=
"DISPLAY",divide=
False, zero=
False)
 
   77 (options, args) = parser.parse_args()
 
   79 split_canv = options.split_canvas.split(
":")
 
   80 split_canv = map(int,split_canv)
 
   82 from LArG4Validation.LArG4PlottingScript 
import parseRoots, defaultRoots, \
 
   83     parsePlots, fillPlots, dividePlots, savePlots, drawPlots, PlotEntry, \
 
   86 if (len(split_canv) != 2) :
 
   87     print (
"ERROR: wrong split parameter")
 
   90 if (options.divide 
and len(args) < 2) :
 
   91     print (
"ERROR: must be at least two input files for ratio calculation")
 
   94 if isfile(options.files) :
 
   95     print (
"Parsing file with root parameters:",options.files)
 
   98     print (
"No root parameters provided, using default")
 
  101 if isfile(options.plots) :
 
  102     print (
"Parsing file with plots parameters:",options.plots)
 
  105     print (
"No plots parameters provided, using default")
 
  108     listvars = [
"hadrleak",
"e237oe277",
"weta2",
"f1",
"e2tsts1",
"e2tsts1demins",
"wtots1",
"fracs1",
"weta1"]
 
  110     for var 
in listvars :
 
  112     listmax = [0.02,1.0,0.015,0.7,3.0,1500.0,4.0,0.6,0.8]
 
  113     listmin = [-0.007,0.84,0.005,0.0,0.0,0.0,1.0,0.0,0.4]
 
  114     listlogy = [0,0,0,0,1,1,0,0,0]
 
  115     for var,mmax,mmin,logy 
in zip(listvars,listmax,listmin,listlogy) :
 
  117         pe.vars_to_draw.append(var)
 
  118         pe.axis_captions[var] = capvars[var]
 
  119         pe.display_name = var
 
  123         parsedPlots.append(pe)
 
  128 maxperlist = split_canv[0]*split_canv[1]
 
  131 numplots = len(parsedPlots)
 
  133 if (options.outputfile == 
"DISPLAY") 
and (numplots > maxperlist) :
 
  134     print (
"ERROR: too many hists to print to display")
 
  137 from ROOT 
import TFile
 
  140 for rootopt 
in parsedRoots :
 
  141     if not isfile(rootopt.filename) :
 
  142         print (
"ERROR: unexistent file:",rootopt.filename)
 
  144     root = TFile(rootopt.filename,
"read")
 
  145     if root.IsOpen() == 0 :
 
  146         print (
"ERROR: can't open the file:",rootopt.filename)
 
  148     rootopt.rootfile = root
 
  149     rootopt.tree = root.Get(
"AOD")
 
  151 print (
"Creating plots...")
 
  154 print (
"Filling plots...")
 
  155 fillPlots(plots,parsedPlots,parsedRoots,eventext)
 
  158 if (options.divide) :
 
  159     print (
"Calculating ratio")
 
  160     rootopt1 = parsedRoots.pop(0)
 
  162     for rootopt 
in parsedRoots :
 
  163         rootopt.legendname += 
" / " + rootopt1.legendname
 
  167 if options.outputfile.endswith(
".root") :
 
  170     canv,leg = 
drawPlots(plots,parsedPlots,parsedRoots,options.outputfile,options.zero,options.mean,split_canv[0],split_canv[1])
 
  172 if (options.outputfile == 
"DISPLAY") :
 
  173     from time 
import sleep
 
  174     while not not(canv) :