53 """Read ntuple from the Geant4 simulation and calculate FCal sampling
56 Returns (E_init, samp_frac, samp_frac_err)
59 print(
"Reading tree '{}' from file '{}'...".
format(tree_name, args.infile))
61 aan_chain = root.TChain(tree_name)
62 aan_chain.Add(args.infile)
64 n_event = aan_chain.GetEntries()
67 for event
in aan_chain:
68 E_init =
round(event.E, 2) / 1000
78 print(
"Event Active E [MeV] Total E [MeV]")
81 for event
in aan_chain:
82 if args.module.lower() ==
"fcal1":
83 totalE = event.Calib_FCal1Active + event.Calib_FCal1Inactive
84 activeE = event.FCal1_E
85 elif args.module.lower() ==
"fcal2":
86 totalE = event.Calib_FCal2Active + event.Calib_FCal2Inactive
87 activeE = event.FCal2_E
88 elif args.module.lower() ==
"fcal3":
89 totalE = event.Calib_FCal3Active + event.Calib_FCal3Inactive
90 activeE = event.FCal3_E
92 samp_frac += activeE / totalE
93 samp_frac_sq += (activeE / totalE)**2
95 min_eta=
min(min_eta,event.Vertex_Eta)
96 max_eta=
max(max_eta,event.Vertex_Eta)
99 print(
"{:<6} {:<15g} {:<15g}".
format(event.Event, activeE, totalE))
106 samp_frac_sq /= n_event
109 samp_frac_err = math.sqrt(samp_frac_sq - samp_frac**2) / math.sqrt(n_event)
111 print(
"{} sampling fraction (E = {:g} GeV): {:g} +/- {:g}".
format(args.module, E_init, samp_frac, samp_frac_err))
114 outfile=root.TFile.Open(
"SF_LAr.root",
"UPDATE")
115 func=root.TF1(
"SF_{}_eta_{:4.2f}_{:4.2f}".
format(args.module,min_eta,max_eta),
"pol0",min_eta,max_eta)
116 func.SetParameter(0,samp_frac);
117 func.SetParError(0,samp_frac_err);
121 return E_init, samp_frac, samp_frac_err