49
49
type = "float" ,
50
50
help = "Only print values if yield is less than this threshold." ,
51
51
)
52
- parser .add_option (
53
- "" ,
54
- "--use-cms-histsum" ,
55
- dest = "use_cms_histsum" ,
56
- default = False ,
57
- action = "store_true" ,
58
- help = "Set to true if workspace built with --use-cms-histsum option." ,
59
- )
52
+ # parser.add_option(
53
+ # "",
54
+ # "--use-cms-histsum",
55
+ # dest="use_cms_histsum",
56
+ # default=False,
57
+ # action="store_true",
58
+ # help="Set to true if workspace built with --use-cms-histsum option.",
59
+ # )
60
60
parser .add_option (
61
61
"" ,
62
62
"--procFilter" ,
@@ -169,17 +169,24 @@ def find_chan_proc(name):
169
169
else :
170
170
chan_procs [chan ] = [[proc , norm , 0 , 0 ]]
171
171
172
+ use_cms_histsum = False
173
+
174
+ all_props = ws .allFunctions ().selectByName ("prop_bin*" )
175
+ if all_props .getSize () > 0 :
176
+ use_cms_histsum = True
177
+
172
178
# Look for cases where chan stored as CMSHistSum, set flag
173
- if options . use_cms_histsum :
179
+ if use_cms_histsum :
174
180
chan_CMSHistSum_norms = {}
175
- all_props = ws .allFunctions ().selectByName ("prop_bin*" )
181
+ # all_props = ws.allFunctions().selectByName("prop_bin*")
176
182
for chan in chan_procs .keys ():
177
183
prop_it = all_props .createIterator ()
178
184
for i in range (all_props .getSize ()):
179
185
prop = prop_it .Next ()
180
186
prop_name = prop .GetName ()
181
187
if chan == prop_name .split ("_bin" )[- 1 ]:
182
- if type (prop ) == ROOT .CMSHistSum :
188
+ types = [ROOT .CMSHistSum , ROOT .CMSHistErrorPropagator ]
189
+ if type (prop ) in types :
183
190
chan_CMSHistSum_norms [chan ] = dict (prop .getProcessNorms ())
184
191
185
192
@@ -243,7 +250,7 @@ def printEndExpand():
243
250
continue
244
251
print ("<hr>" )
245
252
print ("Top-level normalization for process {proc0} -> {proc1_name}<br>" .format (proc0 = proc [0 ], proc1_name = proc [1 ].GetName ()))
246
- if options . use_cms_histsum :
253
+ if use_cms_histsum :
247
254
if chan in chan_CMSHistSum_norms :
248
255
default_val = chan_CMSHistSum_norms [chan ][proc [1 ].GetName ()]
249
256
else :
@@ -253,7 +260,7 @@ def printEndExpand():
253
260
default_norms [chan ][proc [1 ].GetName ()] = default_val
254
261
255
262
if options .printValueOnly :
256
- print ("default value = {default_val}<br>" .format (default_val = default_val ))
263
+ print ("default value = {default_val:.5f }<br>" .format (default_val = default_val ))
257
264
else :
258
265
if proc [2 ]:
259
266
proc_norm_var = ws .function ("n_exp_bin%s_proc_%s" % (chan , proc [0 ]))
@@ -289,7 +296,7 @@ def printEndExpand():
289
296
print (" ... is a constant (RooRealVar)" )
290
297
printEndExpand ()
291
298
292
- print (" default value = " , default_val , "<br>" )
299
+ print (" default value = %.5f " % default_val , "<br>" )
293
300
print ("</tr>" )
294
301
295
302
print (
@@ -320,7 +327,7 @@ def printEndExpand():
320
327
print ("---------------------------------------------------------------------------" )
321
328
print (" Top-level normalization for process %s -> %s" % (proc [0 ], proc [1 ].GetName ()))
322
329
print ("---------------------------------------------------------------------------" )
323
- if options . use_cms_histsum :
330
+ if use_cms_histsum :
324
331
if chan in chan_CMSHistSum_norms :
325
332
default_val = chan_CMSHistSum_norms [chan ][proc [1 ].GetName ()]
326
333
else :
@@ -330,7 +337,7 @@ def printEndExpand():
330
337
default_norms [chan ][proc [1 ].GetName ()] = default_val
331
338
332
339
if options .printValueOnly :
333
- print (" default value = " , default_val )
340
+ print (" default value = %.5f " % default_val )
334
341
# if options.printValueOnly: print " --xcp %s:%s "%(chan,proc[0]),
335
342
else :
336
343
if proc [2 ]:
@@ -354,7 +361,7 @@ def printEndExpand():
354
361
proc [1 ].Print ()
355
362
print (" ... is a constant (RooRealVar)" )
356
363
print (" -------------------------------------------------------------------------" )
357
- print (" default value = " , default_val )
364
+ print (" default value = %.5f " % default_val )
358
365
359
366
# Save norms to json file
360
367
if options .output_json != "" :
0 commit comments