00001
00002
00003 '''
00004 usage example:
00005
00006 nuwa.py -n NEvents -o output.root -m " Detsim.OpStack Whichsite MuonRandomseed"
00007
00008 '''
00009
00010 DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
00011
00012 import os, math
00013
00014 test=False
00015
00016 def configure(argv=[]):
00017 """ script for fast neutron background study"""
00018
00019 site=argv[0]
00020 seed=argv[1]
00021
00022 volume = "/dd/Structure/Pool/db-ows"
00023 musicsite = 'DYB'
00024 if 'far' == site:
00025 volume = "/dd/Structure/Pool/far-ows"
00026 musicsite = 'Far'
00027 if 'dayabay' == site:
00028 volume = "/dd/Structure/Pool/db-ows"
00029 musicsite = 'DYB'
00030 if 'lingao' == site:
00031 volume = "/dd/Structure/Pool/la-ows"
00032 musicsite = 'LA'
00033
00034 import GaudiKernel.SystemOfUnits as units
00035
00036 if test:
00037 import GenTools
00038 from GenTools.Helpers import Gun
00039 mygun = Gun()
00040 mygun.gun.ParticleName = 'mu-'
00041 mygun.gun.Momentum = 3.0*units.GeV
00042 mygun.setVolume(volume)
00043 mygun.positioner.Position = [300*units.cm, 300*units.cm, 0*units.cm]
00044 mygun.timerator.LifeTime = 1*units.second
00045 gtc = GenTools.Configure()
00046 gtc.register(mygun)
00047
00048 else:
00049 MuonDataPath = os.getenv('MuonDataPath')
00050 if MuonDataPath is None :
00051 print "DetSim.OpStack Muon data path ($MuonDataPath) is not defined."
00052 print "Might need to get data file from http://dayabay.ihep.ac.cn/svn/dybsvn/data/trunk/NewMuonGenerator/data/"
00053 sys.exit()
00054 else:
00055 print "Read muon data from ",MuonDataPath
00056
00057
00058 source = "Muon.exe -n 1000 -s %s -seed %s -r Yes -music_dir %s |"%(musicsite, seed, MuonDataPath)
00059
00060 print " musicSite: %s, and RandomSeed: %s"%(musicsite,seed)
00061
00062 from GenTools.Helpers import HepEVT
00063 hepevt = HepEVT(source)
00064 hepevt.positioner.Volume = volume
00065 hepevt.positioner.Mode = "Relative"
00066 hepevt.positioner.Position = [0,0,0]
00067 hepevt.timerator.LifeTime = 1*units.second
00068 hepevt.transformer.Volume = volume
00069 hepevt.transformer.Offset = [0., 0., (0.042)*units.meter]
00070
00071 import GenTools
00072 gt = GenTools.Configure(helper=hepevt)
00073
00074
00075
00076
00077 import DetSim
00078 detsim = DetSim.Configure(site=site)
00079
00080 from DetSim.DetSimConf import DsPhysConsOptical
00081 optical = DsPhysConsOptical("GiGa.GiGaPhysListModular.DsPhysConsOptical")
00082 optical.CerenPhotonScaleWeight = 3.0
00083 optical.ScintPhotonScaleWeight = 3.0
00084 optical.UseScintillation = False
00085
00086
00087 from DetSim.DetSimConf import DsOpStackAction
00088 opstack = DsOpStackAction("GiGa.DsOpStackAction")
00089 detsim.giga.StackingAction=opstack
00090 opstack.TightCut = False
00091 opstack.PhotonCut = False
00092 opstack.MaxPhoton = 1e6
00093
00094
00095
00096
00097
00098
00099 ts="(pdg!=20022)"
00100
00101 detsim.historian(trackSelection=ts,vertexSelection= ts )
00102
00103
00104
00105
00106
00107 params = {
00108 'ismuon':"(pdg==13 or pdg==-13)",
00109 'isneutron': "(pdg==2112)",
00110 'isstop': "(IsStopping>0)",
00111 'start' :"(start > 0)",
00112 'track1':"(id==1 and ProcessType==1)",
00113 'track2':"(id==2 and ProcessType==1)",
00114 'GD': "MaterialName == '/dd/Materials/GdDopedLS'",
00115 'LS': "MaterialName == '/dd/Materials/LiquidScintillator'",
00116 'Oil': "MaterialName == '/dd/Materials/MineralOil'",
00117 'AV': "MaterialName == '/dd/Materials/Acrylic'",
00118 'OW': "MaterialName == '/dd/Materials/OwsWater'",
00119 'IW': "MaterialName == '/dd/Materials/IwsWater'"
00120 }
00121
00122 stat = [
00123
00124 ["pdgId_Trk1","pdg","%(track1)s and %(start)s"%params],
00125 ["t_Trk1", "t" , "%(track1)s and %(start)s"%params],
00126 ["x_Trk1", "x", "%(track1)s and %(start)s"%params],
00127 ["y_Trk1", "y", "%(track1)s and %(start)s"%params],
00128 ["z_Trk1", "z", "%(track1)s and %(start)s"%params],
00129 ["e_Trk1", "E", "%(track1)s and %(start)s"%params],
00130 ["p_Trk1", "p", "%(track1)s and %(start)s"%params],
00131 ["ke_Trk1", "KE", "%(track1)s and %(start)s"%params],
00132 ["vx_Trk1", "lvx","%(track1)s and %(start)s"%params],
00133 ["vy_Trk1", "lvy","%(track1)s and %(start)s"%params],
00134 ["vz_Trk1", "lvz","%(track1)s and %(start)s"%params],
00135 ["TrkLength_GD_Trk1", "dx","%(track1)s and %(GD)s"%params],
00136 ["TrkLength_LS_Trk1", "dx","%(track1)s and %(LS)s"%params],
00137 ["TrkLength_AV_Trk1", "dx","%(track1)s and %(AV)s"%params],
00138 ["TrkLength_Oil_Trk1", "dx","%(track1)s and %(Oil)s"%params],
00139
00140 ["pdgId_Trk2","pdg","%(track2)s and %(start)s"%params],
00141 ["t_Trk2", "t" , "%(track2)s and %(start)s"%params],
00142 ["x_Trk2", "x", "%(track2)s and %(start)s"%params],
00143 ["y_Trk2", "y", "%(track2)s and %(start)s"%params],
00144 ["z_Trk2", "z", "%(track2)s and %(start)s"%params],
00145 ["e_Trk2", "E", "%(track2)s and %(start)s"%params],
00146 ["p_Trk2", "p", "%(track2)s and %(start)s"%params],
00147 ["ke_Trk2", "KE", "%(track2)s and %(start)s"%params],
00148 ["vx_Trk2", "lvx","%(track2)s and %(start)s"%params],
00149 ["vy_Trk2", "lvy","%(track2)s and %(start)s"%params],
00150 ["vz_Trk2", "lvz","%(track2)s and %(start)s"%params],
00151 ["TrkLength_GD_Trk2", "dx","%(track2)s and %(GD)s"%params],
00152 ["TrkLength_LS_Trk2", "dx","%(track2)s and %(LS)s"%params],
00153 ["TrkLength_AV_Trk2", "dx","%(track2)s and %(AV)s"%params],
00154 ["TrkLength_Oil_Trk2", "dx","%(track2)s and %(Oil)s"%params],
00155 ["MuonTrkLengthInOws","dx","%(ismuon)s and %(OW)s"%params],
00156 ["MuonTrkLengthInIws", "dx","%(ismuon)s and %(IW)s"%params],
00157 ["MuonTrkLengthInLS", "dx", "%(ismuon)s and %(LS)s"%params],
00158 ["MuonTrkLengthInGdLS","dx","%(ismuon)s and %(GD)s"%params],
00159 ["MuonTrkLengthInOil","dx", "%(ismuon)s and %(Oil)s"%params],
00160 ["MuonTrkLengthInAV","dx", "%(ismuon)s and %(AV)s"%params],
00161 ["MuonStop", "dx", "%(ismuon)s and %(isstop)s"%params],
00162 ["NeutronTrkLengthInOws","dx","%(isneutron)s and %(OW)s"%params],
00163 ["NeutronTrkLengthInIws", "dx", "%(isneutron)s and %(IW)s"%params],
00164 ["NeutronTrkLengthInLS", "dx", "%(isneutron)s and %(LS)s"%params],
00165 ["NeutronTrkLengthInGdLS","dx", "%(isneutron)s and %(GD)s"%params],
00166 ["NeutronTrkLengthInOil","dx", "%(isneutron)s and %(Oil)s"%params],
00167 ["NeutronTrkLengthInAV","dx", "%(isneutron)s and %(AV)s"%params],
00168 ["NeutronStop", "dx", "%(isneutron)s and %(isstop)s"%params]
00169 ]
00170
00171 detsim.unobserver(stats=stat)
00172
00173
00174
00175
00176
00177
00178
00179 return
00180
00181 def run(app):
00182 pass
00183
00184
00185
00186