4545parser .add_argument (
4646 "-v" ,
4747 "--add-variance" ,
48- type = str ,
49- default = " False" ,
48+ type = bool ,
49+ default = False ,
5050 help = "Enable or disable variance (True/False)" ,
5151)
5252
5353args = parser .parse_args ()
5454
55- # --- Convert to boolean ---
56- if args .add_variance .lower () in ("true" , "1" , "t" , "yes" ):
57- add_variance = True
58- elif args .add_variance .lower () in ("false" , "0" , "f" , "no" ):
59- add_variance = False
60- else :
61- raise ValueError (
62- f"Invalid value for -v/--add-variance: { args .add_variance } . Use True or False."
63- )
64-
6555# --- Assign other variables ---
6656run_number = args .run_number
6757run_spe_number = args .spe_run_number
10595 print (f"[INFO] File { run_path } already exists, skipping computation." )
10696
10797print (f"[INFO] Starting analysis on { filename_ps } " )
108- print (f"[DEBUG] ADD_VARIANCE = { add_variance } " )
98+ print (f"[DEBUG] ADD_VARIANCE = { args . add_variance } " )
10999
110- if add_variance :
100+ if args . add_variance :
111101 print ("[INFO] Running analysis with variance ..." )
112102
113103else :
@@ -751,7 +741,7 @@ def compute_ff_coefs_model(data, data_std, model, model_std):
751741 pdf .savefig (fig_pie )
752742
753743 # Second fit with variance
754- if add_variance == True :
744+ if args . add_variance :
755745 (
756746 data_varinace ,
757747 fit_variance ,
@@ -826,7 +816,7 @@ def compute_ff_coefs_model(data, data_std, model, model_std):
826816 y0_1_err = np .arctan (minuit_vals_errors_1 [2 ] / 12 )
827817 width_1_err = np .arctan (minuit_vals_errors_1 [3 ] / 12 )
828818
829- if add_variance == True :
819+ if args . add_variance :
830820 x0_v = np .arctan (minuit_values_variance [1 ] / 12 )
831821 y0_v = np .arctan (minuit_values_variance [2 ] / 12 )
832822 width_v = np .arctan (minuit_values_variance [3 ] / 12 )
@@ -841,7 +831,7 @@ def compute_ff_coefs_model(data, data_std, model, model_std):
841831 f"{ minuit_vals_errors_1 [0 ]} ,{ x0_1_err } ,"
842832 f"{ y0_1_err } ,{ width_1_err } ,{ np .mean (yerr_prop_1 / y_1 )* 100 } \n "
843833 )
844- if add_variance == True :
834+ if args . add_variance :
845835 f .write (
846836 f"{ run_number } ,With_v_int,{ minuit_values_variance [0 ]} ,"
847837 f"{ x0_v } ,{ y0_v } ,{ width_v } ,"
0 commit comments