00001
00002
00003 '''
00004 usage example:
00005
00006 By default, gammas are generated uniformly in the MO of AD#1
00007 "-k argument specifies energy of gamma in MeV"
00008 "-v argument specifies volume in which gammas are generated"
00009
00010 1. 2000 1 MeV gamma events in the mineral oil and inward of AD#1
00011
00012 nuwa.py -n 2000 -o output.root -m "MDC09b.runGamma -k 1.0"
00013
00014 2. 2000 6 MeV gamma events in Gd-LS of AD#1
00015
00016 nuwa.py -n 2000 -o output.root -m "MDC09b.runGamma -k 6.0 -v /dd/Structure/AD/db-gds1"
00017
00018 '''
00019
00020 DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
00021
00022 import os, math
00023 from GaudiKernel.Constants import *
00024 from GaudiKernel import SystemOfUnits
00025
00026 def configure(argv = []):
00027 """Configure this module with gamma energy"""
00028
00029 import sys, getopt
00030 from time import localtime, gmtime, mktime, strftime, strptime, timezone
00031 opts,args = getopt.getopt(argv,"p:w:k:v:")
00032 wallTime = 0
00033 gammaE = 1.0
00034 pmtDataPath = None
00035 tagVolume = "/dd/Structure/AD/db-oil1"
00036 for opt,arg in opts:
00037 if opt == "-p":
00038 pmtDataPath = arg
00039 if opt == "-w":
00040 if -1 != arg.find('T'):
00041 wallTime = int(mktime(strptime(arg,
00042 DATETIME_FORMAT)) - timezone)
00043 else:
00044 wallTime = int(arg)
00045
00046 if opt == "-k":
00047 gammaE = float(arg)
00048 print "======================================================"
00049 print "Photon energy = ", gammaE, " MeV"
00050 print "======================================================"
00051
00052 if opt == "-v":
00053 tagVolume = arg
00054 print "======================================================"
00055 print "Photon energy = ", gammaE, " MeV"
00056 print "======================================================"
00057
00058 print "======================================================"
00059 print "Begin JOB TIME = ", strftime(DATETIME_FORMAT,
00060 gmtime())
00061 print "======================================================"
00062
00063
00064 import GaudiKernel.SystemOfUnits as units
00065 from GenTools.Helpers import Gun
00066 from GenTools.GenToolsConf import GtGunGenTool, GtPositionerTool
00067 gun = Gun(name = "gammaGun",
00068 volume = tagVolume,
00069 gun = GtGunGenTool("gun",
00070 ParticlesPerEvent = 1,
00071 ParticleName = "gamma",
00072 Momentum = gammaE*units.MeV,
00073 MomentumMode = "Fixed",
00074 MomentumSpread = 0.*units.MeV,
00075 DirectionMode = "Uniform",
00076 Direction = [ 1, 0, 0 ],
00077 DirectionSpread = 3),
00078 positioner = GtPositionerTool("pos",
00079 Strategy = "FullVolume",
00080 Mode = "Uniform",
00081 Spread = 2.5*units.meter,
00082 Position = [0,0,0*units.meter])
00083 )
00084 gun.timerator.LifeTime = 0.020*units.second
00085 import GenTools
00086 GenTools.Configure().register(gun)
00087
00088
00089 import DetSim
00090 detsim = DetSim.Configure(site="dayabay", \
00091 physlist = DetSim.physics_list_basic)
00092 detsim.historian(trackSelection="(pdg == 22)",\
00093 vertexSelection="(pdg == 22)")
00094 params = {
00095 'start' :"(start > 0)",
00096 'track1':"(id==1)",
00097 'track2':"(id==2)",
00098 'GD': "MaterialName == '/dd/Materials/GdDopedLS'",
00099 'LS': "MaterialName == '/dd/Materials/LiquidScintillator'",
00100 'MO': "MaterialName == '/dd/Materials/MineralOil'",
00101 'IAV': "DetectorElementName == 'db-iav1'",
00102 'OAV': "DetectorElementName == 'db-oav1'",
00103 'IWS': "MaterialName == '/dd/Materials/IwsWater'",
00104 'OWS': "MaterialName == '/dd/Materials/OwsWater'",
00105 'lastvtx': "IsStopping == 1",
00106 'firstvtx': "IsStarting == 1",
00107 'Neutron': "pdg == 2112",
00108 'NeutronMom': "creator == 2112",
00109 'Gamma': "pdg == 22",
00110 'Muon': "(pdg == 13 or pdg == -13)"
00111 }
00112
00113 detsim.unobserver(stats=[
00114 ["EDepInGdLS", "dE", "%(GD)s"%params],
00115 ["EDepInLS", "dE", "%(LS)s"%params],
00116 ["EDepInIAV", "dE", "%(IAV)s"%params],
00117 ["EDepInOAV", "dE", "%(OAV)s"%params],
00118 ["EDepInOIL", "dE", "%(MO)s"%params],
00119
00120 ["QEDepInGdLS", "qdE", "%(GD)s"%params],
00121 ["QEDepInLS", "qdE", "%(LS)s"%params],
00122 ["QEDepInIAV", "qdE", "%(IAV)s"%params],
00123 ["QEDepInOAV", "qdE", "%(OAV)s"%params],
00124 ["QEDepInOIL", "qdE", "%(MO)s"%params],
00125
00126 ["tQESumGdLS", "qEt", "%(GD)s"%params],
00127 ["xQESumGdLS", "qEx", "%(GD)s"%params],
00128 ["yQESumGdLS", "qEy", "%(GD)s"%params],
00129 ["zQESumGdLS", "qEz", "%(GD)s"%params],
00130
00131 ["tQESumLS", "qEt", "%(LS)s"%params],
00132 ["xQESumLS", "qEx", "%(LS)s"%params],
00133 ["yQESumLS", "qEy", "%(LS)s"%params],
00134 ["zQESumLS", "qEz", "%(LS)s"%params],
00135
00136 ["tQESumMO", "qEt", "%(MO)s"%params],
00137 ["xQESumMO", "qEx", "%(MO)s"%params],
00138 ["yQESumMO", "qEy", "%(MO)s"%params],
00139 ["zQESumMO", "qEz", "%(MO)s"%params],
00140
00141
00142 ["pdgId_Trk1","pdg","%(track1)s and %(start)s"%params],
00143 ["t_Trk1", "t" , "%(track1)s and %(start)s"%params],
00144 ["x_Trk1", "x", "%(track1)s and %(start)s"%params],
00145 ["y_Trk1", "y", "%(track1)s and %(start)s"%params],
00146 ["z_Trk1", "z", "%(track1)s and %(start)s"%params],
00147 ["tEnd_Trk1", "t" , "%(track1)s and %(lastvtx)s"%params],
00148 ["xEnd_Trk1", "x", "%(track1)s and %(lastvtx)s"%params],
00149 ["yEnd_Trk1", "y", "%(track1)s and %(lastvtx)s"%params],
00150 ["zEnd_Trk1", "z", "%(track1)s and %(lastvtx)s"%params],
00151 ["e_Trk1", "E", "%(track1)s and %(start)s"%params],
00152 ["p_Trk1", "p", "%(track1)s and %(start)s"%params],
00153 ["ke_Trk1", "KE", "%(track1)s and %(start)s"%params],
00154 ["vx_Trk1", "lvx","%(track1)s and %(start)s"%params],
00155 ["vy_Trk1", "lvy","%(track1)s and %(start)s"%params],
00156 ["vz_Trk1", "lvz","%(track1)s and %(start)s"%params],
00157 ["TrkLength_GD_Trk1", "dx","%(track1)s and %(GD)s"%params],
00158 ["TrkLength_iAV_Trk1", "dx","%(track1)s and %(IAV)s"%params],
00159 ["TrkLength_LS_Trk1", "dx","%(track1)s and %(LS)s"%params],
00160 ["TrkLength_oAV_Trk1", "dx","%(track1)s and %(OAV)s"%params],
00161 ["TrkLength_Oil_Trk1", "dx","%(track1)s and %(MO)s"%params]
00162 ])
00163
00164 import ElecSim
00165 elecsim = ElecSim.Configure()
00166 if pmtDataPath != None:
00167
00168 elecsim.dataSvc.setPmtSimData( pmtDataPath )
00169
00170 import TrigSim
00171 trigsim = TrigSim.Configure()
00172
00173
00174 import TrigSim.TrigSimConf as TsConf
00175 TsConf.TsTriggerAlg().TrigTools=["TsESumTriggerTool"]
00176 TsConf.TsESumTriggerTool().OutputLevel=VERBOSE
00177 TsConf.TsESumTriggerTool().ADThreshold=0.07*SystemOfUnits.volt
00178
00179 import ReadoutSim
00180 rosim = ReadoutSim.Configure()
00181
00182 def run(app):
00183 pass
00184