1"""from the neutrinos produced by the FLUKA simulation, extract a subsample of interacting according to the GENIE cross section"""
6parser = argparse.ArgumentParser(description=
"Extract interacting neutrinos")
12 help=
"Path of Genie simulated neutrinos interactions, where also to store the subsample of interacting Fluka neutrinos",
19 help=
"Path of Fluka produced neutrinos",
22options = parser.parse_args()
25geniefile = r.TFile.Open(options.geniepath,
"UPDATE")
26flukafile = r.TFile.Open(options.flukapath,
"READ")
31 """the actual name of the histograms depend on the neutrino we are reading,
32 i loop over all possible candidates"""
33 nup_histnames = [
"1012",
"1014",
"1016",
"2012",
"2014",
"2016"]
35 for name
in nup_histnames:
36 temphist = flukafile.Get(name)
43nbins = hfluka_nuE.GetNbinsX()
44minE = hfluka_nuE.GetXaxis().GetBinLowEdge(1)
45maxE = hfluka_nuE.GetXaxis().GetBinUpEdge(nbins)
48df = r.RDataFrame(
"gst", geniefile)
49hgenie_nuE = df.Histo1D(
52 "Energy of muon neutrinos from genie spectrum;E[GeV]",
63hfluka_nuE.Draw(
"histo")
66hgenie_nuE.DrawClone(
"histo")
76 "ratio between Genie and Fluka energies, proportional to the cross section",
82hnuratio.Divide(hgenie_nuE.GetPtr(), hfluka_nuE)
88maxratio = hnuratio.GetMaximum()
91flukatree = flukafile.Get(
"t")
92output_nutree = flukatree.CloneTree(0)
93output_nutree.SetName(
"fluka_neutrinos_selected")
94output_nutree.SetTitle(
"Neutrinos from Fluka simulation after hit and miss selection")
96nneutrinos = flukatree.GetEntries()
97print(
"Starting loop over {} neutrinos".format(nneutrinos))
99for nuevent
in flukatree:
102 randomratio = r.gRandom.Uniform(0, maxratio)
104 matchingratio = hnuratio.GetBinContent(hnuratio.FindBin(Ekin))
106 if matchingratio > randomratio:
112output_nutree.Write(
"fluka_neutrinos_selected",r.TFile.kOverwrite)