~c-e-pidcott/maus/devel

« back to all changes in this revision

Viewing changes to tests/integration/test_simulation/test_physics_model_full/physics_model_test/plotter.py

  • Committer: Chris Rogers
  • Date: 2012-10-03 07:19:33 UTC
  • mfrom: (659.1.40 release-candidate)
  • Revision ID: chris.rogers@stfc.ac.uk-20121003071933-kgrhvl1ec6w2jmug
Tags: MAUS-v0.3.3
MAUS-v0.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
                    test_dict[test] = geo
122
122
    return (test_lists, test_dict)
123
123
 
124
 
def build_legend(canvas, histograms, legends):
 
124
def build_legend(canvas, tests, test_dict, histograms):
125
125
    """
126
126
    Build a legend for the canvas
127
127
    """
 
128
    legends = [code_name(test_dict[a_test]) for a_test in tests]
 
129
    for index, leg in enumerate(legends):
 
130
        rms = str("RMS %.4g" % histograms[index].GetRMS())
 
131
        mean = str("Mean %.6g" % histograms[index].GetMean())
 
132
        legends[index] = '#splitline{'+legends[index]+'}'+'{'+mean+' '+rms+'}'
128
133
    canvas.cd()
129
 
    leg_min =  0.89-0.07*len(histograms)
 
134
    leg_min =  0.89-0.08*len(histograms)
130
135
    if leg_min < 0.1:
131
136
        leg_min = 0.1
132
 
    leg = ROOT.TLegend(0.13, leg_min, 0.5, 0.89) # pylint: disable=E1101
 
137
    leg = ROOT.TLegend(0.0, leg_min, 0.4, 0.90) # pylint: disable=E1101
 
138
    leg.SetEntrySeparation(0.6)
133
139
    for i, hist in enumerate(histograms):
134
140
        leg.AddEntry(hist, legends[i])
135
141
    leg.SetFillColor(10)
138
144
    canvas.Update()
139
145
    LEGENDS.append(leg)
140
146
 
 
147
def set_margins(canvas):
 
148
    """
 
149
    Make some clearance for the legend
 
150
    """
 
151
    canvas.SetLeftMargin(0.4)
 
152
    canvas.SetRightMargin(0.05)
 
153
    canvas.Update()
 
154
    
 
155
 
141
156
def build_title(canvas, name):
142
157
    """
143
158
    Build a title for the canvas
151
166
    canvas.Update()
152
167
    LEGENDS.append(leg2)
153
168
 
154
 
 
155
169
def plot(file_list):
156
170
    """
157
171
    Main loop - load geometry and tests, sort geometry by name, then sort 
167
181
        (test_group, test_dict) = group_tests(geo_list)
168
182
        for test_list in test_group:
169
183
            (canv, h_list) = KSTest.make_plots(test_list)
170
 
            legends = [code_name(test_dict[test]) for test in test_list]
171
 
            build_legend(canv, h_list[1:], legends)
 
184
            build_legend(canv, test_list, test_dict, h_list[1:])
172
185
            build_title(canv, test_dict[test_list[0]])
 
186
            set_margins(canv)
173
187
            fname = file_name(test_dict[test_list[0]], test_list[0])
174
188
            for form in PLOT_FORMATS:
175
189
                plot_path = os.path.join(PLOT_DIR, fname+'.'+form)