ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/scripts/makeSinglePlot.py
(Generate patch)

Comparing UserCode/OSUT3Analysis/Configuration/scripts/makeSinglePlot.py (file contents):
Revision 1.3 by lantonel, Wed Mar 13 09:27:11 2013 UTC vs.
Revision 1.10 by wulsin, Thu Mar 28 09:06:24 2013 UTC

# Line 10 | Line 10 | from OSUT3Analysis.Configuration.configu
10   from OSUT3Analysis.Configuration.processingUtilities import *
11  
12  
13
14
15
16
13   ##set default plotting options
14   line_width = 2
15   plotting_options = ""
# Line 22 | Line 18 | parser = OptionParser()
18   parser = set_commandline_arguments(parser)
19  
20  
21 < parser.add_argument("--hist", action="store_true", dest="plot_hist", default=False,
21 > parser.add_option("--hist", action="store_true", dest="plot_hist", default=False,
22                    help="plot as hollow histograms instead of error bar crosses")
23 < parser.add_argument("--line-width", dest="line_width",
23 > parser.add_option("--line-width", dest="line_width",
24                    help="set line width (default is 2)")
25 + parser.add_option("--pdf", action="store_true", dest="plot_savePdf", default=False,
26 +                  help="save plot as pdf in addition")
27      
28  
29   (arguments, args) = parser.parse_args()
30  
31   if arguments.localConfig:
32 <    sys.path.append(os.getcwd())
32 >    sys.path.insert(0,os.getcwd())
33      exec("from " + arguments.localConfig.rstrip('.py') + " import *")
34 +    print arguments.localConfig.rstrip('.py')
35  
36   outputFileName = "simple_plot.root"
37   if arguments.outputFileName:
# Line 69 | Line 68 | gROOT.ForceStyle()
68  
69   outputFile = TFile(outputFileName, "RECREATE")
70  
72
71   datasets_needed = []
72   for histogram in input_histograms:
73      if histogram['dataset'] not in datasets_needed:
# Line 77 | Line 75 | for histogram in input_histograms:
75  
76   weight = intLumi / 10000.0
77   for dataset in datasets_needed:
78 +
79      dataset_file = "%s/%s.root" % (condor_dir,dataset)
80      if types[dataset] != "data":
81          os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight))
# Line 103 | Line 102 | for histogram in input_histograms:
102      if inputFile.IsZombie() or not inputFile.GetNkeys():
103          continue
104      
106    print "OSUAnalysis/"+histogram['channel']+"/"+histogram['name']
105      Histogram = inputFile.Get("OSUAnalysis/"+histogram['channel']+"/"+histogram['name']).Clone()
106      Histogram.SetDirectory(0)
107      inputFile.Close()
# Line 131 | Line 129 | counter = 0
129   for Histogram in Histograms:
130      if counter is 0:
131          Histogram.SetMaximum(1.1*finalMax)
132 +        Histogram.SetMinimum(0.0001)
133          Histogram.Draw(plotting_options)
134          
135      else:
# Line 148 | Line 147 | if arguments.normalizeToUnitArea:
147  
148   outputFile.cd()
149   Canvas.Write()
150 <        
150 >
151 > if arguments.plot_savePdf:
152 >    pdfFileName = outputFileName.replace(".root", ".pdf")  
153 >    Canvas.SaveAs(pdfFileName)
154 >    print "Saved file:  " + pdfFileName  
155  
156  
157   for dataset in datasets_needed:
# Line 156 | Line 159 | for dataset in datasets_needed:
159      os.remove(dataset_file)
160  
161   outputFile.Close()        
162 + print "Saved plot in file: " + outputFileName  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines