1111
1212import numpy as np # pylint: disable=import-error
1313import ROOT # pylint: disable=import-error
14- from style_formatter import set_global_style , set_object_style
14+ sys .path .insert (0 , '..' )
15+ from utils .style_formatter import set_global_style , set_object_style
1516
1617
1718# pylint: disable=too-many-instance-attributes
@@ -295,6 +296,49 @@ def get_raw_prompt_fraction(self, effacc_p, effacc_np):
295296
296297 return f_p , f_p_unc
297298
299+ def get_raw_prompt_fraction_ext (self , corry_p , corry_np , unc_corry_p ,
300+ unc_corry_np , cov_p_np , effacc_p , effacc_np ):
301+ """
302+ Helper function to get the raw prompt fraction given the efficiencies
303+
304+ Parameters
305+ -----------------------------------------------------
306+ - corry_p: float
307+ corrected yield for prompt signal
308+ - corry_np: float
309+ corrected yield for non-prompt signal
310+ - unc_corry_np: float
311+ uncertainty on corrected yield for prompt signal
312+ - unc_corry_np: float
313+ uncertainty on corrected yield for non-prompt signal
314+ - cov_p_np: float
315+ covariance between prompt and non-prompt signal
316+ - effacc_p: float
317+ eff x acc for prompt signal
318+ - effacc_np: float
319+ eff x acc for non-prompt signal
320+
321+ Returns
322+ -----------------------------------------------------
323+ - f_p, f_p_unc: (float, float)
324+ raw prompt fraction with its uncertainty
325+ """
326+
327+ rawy_p = effacc_p * corry_p
328+ rawy_np = effacc_np * corry_np
329+ f_p = rawy_p / (rawy_p + rawy_np )
330+
331+ # derivatives of prompt fraction wrt corr yields
332+ d_p = (effacc_p * (rawy_p + rawy_np ) - effacc_p ** 2 * corry_p ) / (rawy_p + rawy_np ) ** 2
333+ d_np = - effacc_np * rawy_p / (rawy_p + rawy_np ) ** 2
334+ f_p_unc = np .sqrt (
335+ d_p ** 2 * unc_corry_p ** 2
336+ + d_np ** 2 * unc_corry_np ** 2
337+ + 2 * d_p * d_np * cov_p_np
338+ )
339+
340+ return f_p , f_p_unc
341+
298342 def get_raw_nonprompt_fraction (self , effacc_p , effacc_np ):
299343 """
300344 Helper function to get the raw non-prompt fraction given the efficiencies
@@ -318,6 +362,41 @@ def get_raw_nonprompt_fraction(self, effacc_p, effacc_np):
318362
319363 return f_np , f_np_unc
320364
365+ def get_raw_nonprompt_fraction_ext (self , corry_p , corry_np , unc_corry_p ,
366+ unc_corry_np , cov_p_np , effacc_p , effacc_np ):
367+ """
368+ Helper function to get the raw non-prompt fraction given the efficiencies
369+
370+ Parameters
371+ -----------------------------------------------------
372+ - corry_p: float
373+ corrected yield for prompt signal
374+ - corry_np: float
375+ corrected yield for non-prompt signal
376+ - unc_corry_np: float
377+ uncertainty on corrected yield for prompt signal
378+ - unc_corry_np: float
379+ uncertainty on corrected yield for non-prompt signal
380+ - cov_p_np: float
381+ covariance between prompt and non-prompt signal
382+ - effacc_p: float
383+ eff x acc for prompt signal
384+ - effacc_np: float
385+ eff x acc for non-prompt signal
386+
387+ Returns
388+ -----------------------------------------------------
389+ - f_np, f_np_unc: (float, float)
390+ raw non-prompt fraction with its uncertainty
391+
392+ """
393+
394+ f_p , f_np_unc = self .get_raw_prompt_fraction_ext (corry_p , corry_np , unc_corry_p ,
395+ unc_corry_np , cov_p_np , effacc_p , effacc_np )
396+ f_np = 1 - f_p
397+
398+ return f_np , f_np_unc
399+
321400 def get_corr_prompt_fraction (self ):
322401 """
323402 Helper function to get the corrected prompt fraction
@@ -365,7 +444,7 @@ def plot_result(self, suffix=""):
365444 needed otherwise it is destroyed
366445 """
367446
368- set_global_style (padleftmargin = 0.16 , padbottommargin = 0.12 , titleoffsety = 1.6 )
447+ set_global_style (padleftmargin = 0.16 , padbottommargin = 0.12 , padtopmargin = 0.075 , titleoffsety = 1.6 )
369448
370449 hist_raw_yield = ROOT .TH1F (
371450 f"hRawYieldVsCut{ suffix } " ,
@@ -435,7 +514,7 @@ def plot_result(self, suffix=""):
435514 hist_raw_yield .GetMaximum () * 1.2 ,
436515 ";cut set;raw yield" ,
437516 )
438- leg = ROOT .TLegend (0.6 , 0.65 , 0.8 , 0.9 )
517+ leg = ROOT .TLegend (0.6 , 0.65 , 0.8 , 0.85 )
439518 leg .SetBorderSize (0 )
440519 leg .SetFillStyle (0 )
441520 leg .SetTextSize (0.04 )
0 commit comments