SND@LHC Software
Loading...
Searching...
No Matches
genie_interface Namespace Reference

Functions

 get_1D_flux_name (nupdg)
 
 get_2D_flux_name (nupdg)
 
 make_splines (nupdglist, targetcode, emax, nknots, outputfile)
 
 generate_genie_events (nevents, nupdg, emin, emax, targetcode, inputflux, spline, process=None, seed=None, irun=None)
 
 make_ntuples (inputfile, outputfile)
 
 add_hists (inputflux, simfile, nupdg)
 

Function Documentation

◆ add_hists()

genie_interface.add_hists (   inputflux,
  simfile,
  nupdg 
)
add histogram with p-pt flux to simulation file
inputflux = path of neutrino inputflux
simfile = path of simulation file to UPDATE
nupdg = neutrino pdg

Definition at line 127 of file genie_interface.py.

127def add_hists(inputflux, simfile, nupdg):
128 """add histogram with p-pt flux to simulation file
129 inputflux = path of neutrino inputflux
130 simfile = path of simulation file to UPDATE
131 nupdg = neutrino pdg
132 """
133 inputfile = ROOT.TFile(inputflux, "read")
134 simfile = ROOT.TFile(simfile, "update")
135 # adding 2D histogram
136 inputfile.Get(get_2D_flux_name(nupdg)).Write()
137 # closinsg files
138 inputfile.Close()
139 simfile.Close()

◆ generate_genie_events()

genie_interface.generate_genie_events (   nevents,
  nupdg,
  emin,
  emax,
  targetcode,
  inputflux,
  spline,
  process = None,
  seed = None,
  irun = None 
)
make Genie simulation, parameters:
events = number of events to generate
nupdg = neutrino pdg
targetcode = string with target material in GENIE code
emin, emax = min and max neutrino energy to generate
process = simulate a specific neutrino process (CCDIS, CCQE, CC, NC, CCRES, NCRES, etc.),
          if not set, GENIE's comprehensive collection of event generators will be used.
inputflux = input neutrino flux
spline = input neutrino spline

Definition at line 58 of file genie_interface.py.

69):
70 """make Genie simulation, parameters:
71 events = number of events to generate
72 nupdg = neutrino pdg
73 targetcode = string with target material in GENIE code
74 emin, emax = min and max neutrino energy to generate
75 process = simulate a specific neutrino process (CCDIS, CCQE, CC, NC, CCRES, NCRES, etc.),
76 if not set, GENIE's comprehensive collection of event generators will be used.
77 inputflux = input neutrino flux
78 spline = input neutrino spline
79 """
80 # prepare command functions
81 cmd = (
82 "gevgen -n "
83 + str(nevents)
84 + " -p "
85 + str(nupdg)
86 + " -t "
87 + targetcode
88 + " -e "
89 + str(emin)
90 + ","
91 + str(emax)
92 )
93 cmd = (
94 cmd
95 + " -f "
96 + inputflux
97 + ","
98 + get_1D_flux_name(nupdg)
99 + " --cross-sections "
100 + spline
101 )
102 # optional additional arguments
103 if process is not None:
104 cmd = cmd + " --event-generator-list " + process # add a specific process
105 if seed is not None:
106 cmd = cmd + " --seed " + str(seed) # set a seed for the generator
107 if irun is not None:
108 cmd = cmd + " --run " + str(irun)
109
110 print("Starting GENIE with the following command: ")
111 print(cmd)
112 call(cmd, shell=True)
113
114

◆ get_1D_flux_name()

genie_interface.get_1D_flux_name (   nupdg)
returns name of TH1D p spectrum as stored in input files:
example: nue: 12 -> 1012, anue: -12 -> 2012

Definition at line 7 of file genie_interface.py.

7def get_1D_flux_name(nupdg):
8 """returns name of TH1D p spectrum as stored in input files:
9 example: nue: 12 -> 1012, anue: -12 -> 2012
10 """
11 x = ROOT.TMath.Abs(nupdg)
12 if nupdg > 0:
13 return "10" + str(x)
14 else:
15 return "20" + str(x)
16
17

◆ get_2D_flux_name()

genie_interface.get_2D_flux_name (   nupdg)
returns name of TH2D p-pt flux as stored in input files:
ie for nue: 12 -> 1212, anue: -12 -> 2212
nupdg: neutrino pdg

Definition at line 18 of file genie_interface.py.

18def get_2D_flux_name(nupdg):
19 """returns name of TH2D p-pt flux as stored in input files:
20 ie for nue: 12 -> 1212, anue: -12 -> 2212
21 nupdg: neutrino pdg
22 """
23 x = ROOT.TMath.Abs(nupdg)
24 if nupdg > 0:
25 return "12" + str(x)
26 else:
27 return "22" + str(x)
28
29

◆ make_ntuples()

genie_interface.make_ntuples (   inputfile,
  outputfile 
)
convert gntp GENIE file to gst general ROOT file
inputfile = path of gntp inputfile (gntp.0.ghep.root)
outputfile = path of gst outputfile

Definition at line 115 of file genie_interface.py.

115def make_ntuples(inputfile, outputfile):
116 """convert gntp GENIE file to gst general ROOT file
117 inputfile = path of gntp inputfile (gntp.0.ghep.root)
118 outputfile = path of gst outputfile
119 """
120
121 cmd = "gntpc -i " + inputfile + " -f gst -o " + outputfile
122 print("Starting GENIE conversion with the following command: ")
123 print(cmd)
124 call(cmd, shell=True)
125
126

◆ make_splines()

genie_interface.make_splines (   nupdglist,
  targetcode,
  emax,
  nknots,
  outputfile 
)
prepare splines with neutrino interaction cross sections
nupdg = list of input neutrino pdgs
targetcode = string with target material in GENIE code
outputfile = path of outputfile

Definition at line 30 of file genie_interface.py.

30def make_splines(nupdglist, targetcode, emax, nknots, outputfile):
31 """prepare splines with neutrino interaction cross sections
32 nupdg = list of input neutrino pdgs
33 targetcode = string with target material in GENIE code
34 outputfile = path of outputfile
35 """
36 inputnupdg = ""
37 for ipdg, nupdg in enumerate(nupdglist):
38 if ipdg > 0:
39 inputnupdg = inputnupdg + ","
40 inputnupdg = inputnupdg + str(nupdg)
41 cmd = (
42 "gmkspl -p "
43 + inputnupdg
44 + " -t "
45 + targetcode
46 + " -n "
47 + str(nknots)
48 + " -e "
49 + str(emax)
50 + " -o "
51 + outputfile
52 )
53 print("Starting GENIE with the following command: ")
54 print(cmd)
55 call(cmd, shell=True)
56
57