3 from __future__
import print_function
4 from builtins
import range
5 from os.path
import join
6 from math
import sqrt, cos, sin
13 from optparse
import OptionParser
14 usage =
"usage: %prog [options] <trigger file>" 15 parser = OptionParser(usage=usage)
16 parser.add_option(
"-p",
"--momentum", default=
"10.0", help=
"Momentum in GeV (%default)", metavar=
"P")
17 parser.add_option(
"-t",
"--time", default=
"0.0", help=
"Start Time (%default)", metavar=
"T")
18 parser.add_option(
"--pdg", default=
"13", help=
"Particle PDG code (%default, mu-)")
19 parser.add_option(
"-n",
"--number", default=
"0", help=
"Number of particles", metavar=
"N")
20 parser.add_option(
"--direction",default=
"y", help=
"Direction of the scan")
21 parser.add_option(
"--min", default=
"0", help=
"Minimum value")
22 parser.add_option(
"--max", default=
"220", help=
"Maximum value")
23 (options, args) = parser.parse_args()
27 massref = { 11:0.000511, 13:0.105 }
34 pdg =
int(options.pdg),
35 mother1 = 0, mother2 = 0, daughter1 = 0, daughter2 = 0,
36 momentum =
float(options.momentum),
37 direction = (0.0, 0.0, 1.0),
38 position = (50., 0.0, 0.0),
42 momx, momy, momz = tuple([ momentum*x
for x
in direction ])
43 mass = massref[
abs(pdg)]
44 energy = sqrt(momentum**2 + mass**2)
45 posx, posy, posz = position
47 print(eventno, 1, file=outfile)
48 print(status, pdg, end=
' ', file=outfile)
49 print(mother1, mother2, daughter1, daughter2, end=
' ', file=outfile)
50 print(momx, momy, momz, energy, mass, end=
' ', file=outfile)
51 print(posx, posy, posz, time, file=outfile)
56 vecfile =
open(options.direction+
"scan.vec",
"w")
58 N =
int(options.number)
61 step = (maximum - minimum)/(N - 1)
64 for eventno
in range(N):
65 val = minimum + eventno * step
67 if options.direction ==
"x":
70 elif options.direction ==
"y":
73 elif options.direction ==
"z":
74 pos = (50., 115., val)
77 print(
"Unknown direction", options.direction)
int open(const char *, int)
Opens a file descriptor.
def MakeEvent(outfile, status=1, pdg=int(options.pdg), mother1=0, mother2=0, daughter1=0, daughter2=0, momentum=float(options.momentum), direction=(0.0, 0.0, 1.0), position=(50., 0.0, 0.0), time=float(options.time))
Function which creates events.