77author: Fabrizio Grosa <[email protected] >, CERN 88"""
99
10-
1110import argparse
1211import os
1312import sys
1413
15- import numpy as np
16- import yaml
14+ import numpy as np # pylint: disable=import-error
15+ import yaml # pylint: disable=import-error
1716from hf_analysis_utils import (
1817 compute_crosssection ,
1918 compute_fraction_fc ,
2019 compute_fraction_nb ,
2120 get_hist_binlimits ,
2221)
23- from hfplot .plot_spec_root import ROOTFigure
24- from hfplot .style import StyleObject1D
2522from ROOT import ( # pylint: disable=import-error,no-name-in-module
2623 TH1 ,
2724 TH1F ,
25+ TCanvas ,
2826 TFile ,
2927 TGraphAsymmErrors ,
28+ TStyle ,
29+ gPad ,
3030 gROOT ,
3131 kAzure ,
3232 kFullCircle ,
@@ -190,6 +190,22 @@ def main():
190190 if args .batch :
191191 gROOT .SetBatch (True )
192192
193+ # final plots style settings
194+ style_hist = TStyle ('style_hist' ,'Histo graphics style' )
195+ style_hist .SetOptStat ("n" )
196+ style_hist .SetMarkerColor (kAzure + 4 )
197+ style_hist .SetMarkerStyle (kFullCircle )
198+ style_hist .SetMarkerSize (1 )
199+ style_hist .SetHistLineColor (kAzure + 4 )
200+ style_hist .SetHistLineWidth (2 )
201+ style_hist .SetLabelSize (0.030 )
202+ style_hist .SetLabelOffset (0.010 )
203+ style_hist .SetTitleXOffset (1.3 )
204+ style_hist .SetTitleYOffset (1.3 )
205+ style_hist .SetDrawOption ("AP" )
206+ gROOT .SetStyle ("style_hist" )
207+ gROOT .ForceStyle ()
208+
193209 # load info from config file
194210 with open (args .configfile_name , "r" ) as yml_configfile :
195211 cfg = yaml .safe_load (yml_configfile )
@@ -213,8 +229,9 @@ def main():
213229 axistit_cross_times_br = "d#sigma/d#it{p}_{T} #times BR (pb GeV^{-1} #it{c})"
214230 axistit_pt = "#it{p}_{T} (GeV/#it{c})"
215231 axistit_fprompt = "#if{f}_{prompt}"
216- gfraction = TGraphAsymmErrors (0 )
232+ gfraction = TGraphAsymmErrors ()
217233 gfraction .SetNameTitle ("gfraction" , f";{ axistit_pt } ;{ axistit_fprompt } " )
234+
218235 hptspectrum = TH1F (
219236 "hptspectrum" ,
220237 f";{ axistit_pt } ;{ axistit_cross } " ,
@@ -252,6 +269,7 @@ def main():
252269 ]
253270
254271 # compute prompt fraction
272+ frac = [0. , 0. , 0. ]
255273 if frac_method == "Nb" :
256274 frac = compute_fraction_nb ( # BR already included in FONLL prediction
257275 rawy ,
@@ -272,7 +290,7 @@ def main():
272290 / (ptmax - ptmin )
273291 for pred in histos ["FONLL" ]["prompt" ]
274292 ]
275- frac = compute_fraction_fc (
293+ frac , _ = compute_fraction_fc (
276294 eff_times_acc_prompt ,
277295 eff_times_acc_nonprompt ,
278296 crosssec_prompt_fonll ,
@@ -298,33 +316,24 @@ def main():
298316 hptspectrum_wo_br .SetBinContent (i_pt + 1 , crosssec )
299317 hptspectrum_wo_br .SetBinError (i_pt + 1 , crosssec_unc )
300318 gfraction .SetPoint (i_pt , pt_cent , frac [0 ])
301- gfraction .SetPointError (
302- i_pt , pt_delta / 2 , pt_delta / 2 , frac [0 ] - frac [1 ], frac [2 ] - frac [0 ]
303- )
304-
305- # create plots
306- style_hist = StyleObject1D ()
307- style_hist .markercolor = kAzure + 4
308- style_hist .markerstyle = kFullCircle
309- style_hist .markersize = 1
310- style_hist .linecolor = kAzure + 4
311- style_hist .linewidth = 2
312- style_hist .draw_options = "P"
313-
314- fig_crosssec = ROOTFigure (
315- 1 , 1 , column_margin = (0.14 , 0.035 ), row_margin = (0.1 , 0.035 ), size = (600 , 800 )
316- )
317- fig_crosssec .axes (label_size = 0.025 , title_size = 0.030 )
318- fig_crosssec .axes ("x" , title = axistit_pt , title_offset = 1.5 )
319- fig_crosssec .axes ("y" , title = axistit_cross_times_br , title_offset = 1.8 )
320- fig_crosssec .define_plot (0 , 0 , y_log = True )
321- fig_crosssec .add_object (hptspectrum_wo_br , style = style_hist )
322- fig_crosssec .create ()
319+ #gfraction.SetPointError(
320+ # i_pt, pt_delta / 2, pt_delta / 2, frac[0] - frac[1], frac[2] - frac[0]
321+ #)
322+
323+ c = TCanvas ("c" , "c" , 600 , 800 )
324+ c .Divide (1 , 2 )
325+ c .cd (1 )
326+ gPad .SetLogy (True )
327+ hptspectrum .Draw ()
328+ c .cd (2 )
329+ gPad .SetLogy (True )
330+ hptspectrum_wo_br .Draw ()
323331
324332 output_dir = cfg ["output" ]["directory" ]
325333 if not os .path .exists (output_dir ):
326334 os .makedirs (output_dir )
327- fig_crosssec .save (os .path .join (output_dir , f'{ cfg ["output" ]["filename" ]} .pdf' ))
335+
336+ c .Print (os .path .join (output_dir , f'{ cfg ["output" ]["filename" ]} .pdf' ))
328337
329338 # save output file
330339 output_file = TFile (
0 commit comments