00001
00002
00003
00004
00005
00006
00007 def main():
00008 import sys, getopt
00009 opts,args = getopt.getopt(sys.argv[1:],"f:s:n:")
00010 neutronFraction = 0.005
00011 seed = "0"
00012 nEvents = 10000
00013 for opt,arg in opts:
00014 if opt == "-f":
00015 neutronFraction = float(arg)
00016 if opt == "-s":
00017 seed = arg
00018 if opt == "-n":
00019 nEvents = int(arg)
00020
00021 import os
00022 co60HepEvts = os.popen("Co60.exe -n %d -seed %s" % (nEvents, seed))
00023 import random, math
00024 random.seed(int(seed))
00025 MeV = 1.0
00026 GeV = 1000.0
00027 minNeutronKE = 0.1 * MeV
00028 for evtIdx in range(nEvents):
00029 if random.random() < neutronFraction:
00030
00031 mass = 939.565 * MeV
00032 meanKE = 4.25 * MeV
00033 sigmaKE = 0.6 * MeV
00034 kinEnergy = random.gauss(meanKE, sigmaKE)
00035 while kinEnergy < minNeutronKE:
00036
00037 kinEnergy = random.gauss(meanKE, sigmaKE)
00038 totEnergy = kinEnergy + mass
00039 momentum = math.sqrt( (totEnergy+mass) * (totEnergy-mass) )
00040 cosTheta = random.random()
00041 sinTheta = math.sqrt( 1 - cosTheta*cosTheta )
00042 phi = 2*math.pi*random.random()
00043 mom = [ momentum*sinTheta*math.cos(phi),
00044 momentum*sinTheta*math.sin(phi),
00045 momentum*cosTheta ]
00046 print "1"
00047 print "1 2112 0 0 %f %f %f %f 0.0" % (mom[0]/GeV,
00048 mom[1]/GeV,
00049 mom[2]/GeV,
00050 mass/GeV)
00051 else:
00052
00053 headLine = co60HepEvts.readline().strip()
00054 while headLine[0] == '#':
00055 headLine = co60HepEvts.readline().strip()
00056 nParticles = int(headLine)
00057 event = [headLine]
00058 for particle in range(nParticles):
00059 event.append(co60HepEvts.readline().strip())
00060 for line in event:
00061 print line
00062
00063 if __name__ == "__main__":
00064 main()