00001
00002
00003 '''
00004 Script to simulate Ge68 events at the center without background sources and without the source geometry.
00005
00006 usage example:
00007
00008 nuwa.py -n 2 -o output.root -m "Calibration.SimGe68wBG -z 0.0 -a A"
00009
00010 '''
00011
00012 from DybPython.DybPythonAlg import DybPythonAlg
00013 from DetHelpers.DetHelpersConf import AutoPositionerTool
00014
00015 import os, math
00016
00017 def configure(argv = []):
00018 """Configure this module with source position"""
00019
00020 import sys, getopt
00021 import GaudiKernel.SystemOfUnits as units
00022 from time import gmtime, mktime, strftime, strptime, timezone
00023 opts,args = getopt.getopt(argv,
00024 "z:a:")
00025 from DybPython.Control import nuwa
00026 wallTime = nuwa.opts.time
00027 runNumber = nuwa.opts.run
00028
00029 axis = 'A'
00030 acuName = 'ACU_A_Center'
00031 xpos = 0.0
00032 ypos = 0.0
00033 zpos = 0.0
00034 pmtDataPath = None
00035 for opt,arg in opts:
00036 if opt == "-z":
00037 zpos = float(arg) * units.cm
00038 print "======================================================"
00039 print "Source Z position = ", zpos / units.cm, " cm"
00040 print "======================================================"
00041 if opt == "-a":
00042 axis = arg
00043 print "======================================================"
00044 print "ACU Axis = ", axis
00045 print "======================================================"
00046 if axis == 'B':
00047 xpos = 135.0 * math.cos(112.5 * math.pi / 180.) * units.cm
00048 ypos = 135.0 * math.sin(112.5 * math.pi / 180.) * units.cm
00049 acuName = 'ACU_B_GdlsEdge'
00050 elif axis == 'C':
00051 xpos = 177.25*math.cos( (112.5 + 180) * math.pi / 180.)*units.cm
00052 ypos = 177.25*math.sin( (112.5 + 180) * math.pi / 180.)*units.cm
00053 acuName = 'ACU_C_GammaCatcher'
00054
00055
00056 from RunDataSvc.RunDataSvcConf import RunDataSvc
00057 runDataSvc = RunDataSvc()
00058 runDataSvc.SimRunType = "Calibration"
00059 sourceName = "DayaBayAD1_"+acuName+"_Germanium_68"
00060 runDataSvc.SimCalibSources = [ sourceName ]
00061 runDataSvc.SimCalibZPosition = { sourceName : zpos }
00062
00063
00064 from Stage import Configure as StageConfigure
00065 stageCfg = StageConfigure()
00066 stageCfg.addStages( ['Kinematic','Detector','Electronic','TrigRead',
00067 'SingleLoader'] )
00068
00069
00070 from Gnrtr.GnrtrConf import Gnrtr
00071 from GenTools.Helpers import Gun
00072 from GenTools.Helpers import HepEVT
00073
00074 SimTime=nuwa.opts.executions * 2 * 0.020
00075
00076
00077
00078 seed = runNumber
00079 Ge68lifetime=0.020
00080 Ge68events= SimTime // Ge68lifetime
00081
00082 mygenGe68 = HepEVT("Ge68.exe -n %d -seed %d |" % (Ge68events,seed), name = "Ge68")
00083 mygenGe68.positioner.Volume = "/dd/Structure/AD/db-oil1"
00084 mygenGe68.transformer.Volume = "/dd/Structure/AD/db-oil1"
00085 mygenGe68.positioner.Position = [xpos, ypos, zpos]
00086 mygenGe68.positioner.Strategy = "FullVolume"
00087 mygenGe68.positioner.Mode = "Fixed"
00088 mygenGe68.positioner.Spread = 3.0 * units.cm
00089 mygenGe68.timerator.LifeTime = Ge68lifetime*units.second
00090
00091 gnrtrGe68 = Gnrtr("gnrtrGe68");
00092 gnrtrGe68.GenTools = mygenGe68.tools()
00093 gnrtrGe68.ThisStageName = "Kinematic"
00094 gnrtrGe68.TimeStamp = int(wallTime)
00095 stageCfg.KinematicSequence.Members.append(gnrtrGe68)
00096
00097
00098 import DetSim
00099 detsim = DetSim.Configure(use_push_algs = False)
00100 detsim.historian(trackSelection="(pdg == -11)",\
00101 vertexSelection="(pdg == -11)")
00102 params = {
00103 'start' :"(start > 0)",
00104 'track1':"(id==1)",
00105 'track2':"(id==2)",
00106 'GD': "MaterialName == '/dd/Materials/GdDopedLS'",
00107 'LS': "MaterialName == '/dd/Materials/LiquidScintillator'",
00108 'MO': "MaterialName == '/dd/Materials/MineralOil'",
00109 'IAV': "DetectorElementName == 'db-iav1'",
00110 'OAV': "DetectorElementName == 'db-oav1'",
00111 'IWS': "MaterialName == '/dd/Materials/IwsWater'",
00112 'OWS': "MaterialName == '/dd/Materials/OwsWater'",
00113 'lastvtx': "IsStopping == 1",
00114 'firstvtx': "IsStarting == 1",
00115 'Neutron': "pdg == 2112",
00116 'NeutronMom': "creator == 2112",
00117 'Gamma': "pdg == 22",
00118 'Positron': "pdg == -11",
00119 'Muon': "(pdg == 13 or pdg == -13)"
00120 }
00121
00122 detsim.unobserver(stats=[
00123 ["EDepInGdLS", "dE", "%(GD)s"%params],
00124 ["EDepInLS", "dE", "%(LS)s"%params],
00125 ["EDepInIAV", "dE", "%(IAV)s"%params],
00126 ["EDepInOAV", "dE", "%(OAV)s"%params],
00127 ["EDepInOIL", "dE", "%(MO)s"%params],
00128
00129 ["QEDepInGdLS", "qdE", "%(GD)s"%params],
00130 ["QEDepInLS", "qdE", "%(LS)s"%params],
00131 ["QEDepInIAV", "qdE", "%(IAV)s"%params],
00132 ["QEDepInOAV", "qdE", "%(OAV)s"%params],
00133 ["QEDepInOIL", "qdE", "%(MO)s"%params],
00134
00135 ["tQESumGdLS", "qEt", "%(GD)s"%params],
00136 ["xQESumGdLS", "qEx", "%(GD)s"%params],
00137 ["yQESumGdLS", "qEy", "%(GD)s"%params],
00138 ["zQESumGdLS", "qEz", "%(GD)s"%params],
00139
00140 ["tQESumLS", "qEt", "%(LS)s"%params],
00141 ["xQESumLS", "qEx", "%(LS)s"%params],
00142 ["yQESumLS", "qEy", "%(LS)s"%params],
00143 ["zQESumLS", "qEz", "%(LS)s"%params],
00144
00145 ["tQESumMO", "qEt", "%(MO)s"%params],
00146 ["xQESumMO", "qEx", "%(MO)s"%params],
00147 ["yQESumMO", "qEy", "%(MO)s"%params],
00148 ["zQESumMO", "qEz", "%(MO)s"%params],
00149
00150
00151 ["pdgId_Trk1","pdg","%(track1)s and %(start)s"%params],
00152 ["t_Trk1", "t" , "%(track1)s and %(start)s"%params],
00153 ["x_Trk1", "x", "%(track1)s and %(start)s"%params],
00154 ["y_Trk1", "y", "%(track1)s and %(start)s"%params],
00155 ["z_Trk1", "z", "%(track1)s and %(start)s"%params],
00156 ["tEnd_Trk1", "t" , "%(track1)s and %(lastvtx)s"%params],
00157 ["xEnd_Trk1", "x", "%(track1)s and %(lastvtx)s"%params],
00158 ["yEnd_Trk1", "y", "%(track1)s and %(lastvtx)s"%params],
00159 ["zEnd_Trk1", "z", "%(track1)s and %(lastvtx)s"%params],
00160 ["e_Trk1", "E", "%(track1)s and %(start)s"%params],
00161 ["p_Trk1", "p", "%(track1)s and %(start)s"%params],
00162 ["ke_Trk1", "KE", "%(track1)s and %(start)s"%params],
00163 ["vx_Trk1", "vx","%(track1)s and %(start)s"%params],
00164 ["vy_Trk1", "vy","%(track1)s and %(start)s"%params],
00165 ["vz_Trk1", "vz","%(track1)s and %(start)s"%params],
00166 ["TrkLength_GD_Trk1", "dx","%(track1)s and %(GD)s"%params],
00167 ["TrkLength_iAV_Trk1", "dx","%(track1)s and %(IAV)s"%params],
00168 ["TrkLength_LS_Trk1", "dx","%(track1)s and %(LS)s"%params],
00169 ["TrkLength_oAV_Trk1", "dx","%(track1)s and %(OAV)s"%params],
00170 ["TrkLength_Oil_Trk1", "dx","%(track1)s and %(MO)s"%params]
00171 ])
00172
00173 from DetSimProc.DetSimProcConf import DetSimProc
00174 dsp = DetSimProc()
00175 dsp.ThisStageName = "Detector"
00176 dsp.LowerStageName = "Kinematic"
00177 stageCfg.DetectorSequence.Members.append(dsp)
00178
00179 import ElecSim
00180 elecsim = ElecSim.Configure(use_push_algs = False)
00181 from ElecSimProc.ElecSimProcConf import ElecSimProc
00182 esp = ElecSimProc()
00183 esp.ThisStageName = "Electronic"
00184 esp.LowerStageName = "Detector"
00185 stageCfg.ElectronicSequence.Members.append(esp)
00186
00187
00188
00189 from TrigReadProc.TrigReadProcConf import TrigReadProc
00190 tsp = TrigReadProc()
00191 tsp.ThisStageName = "TrigRead"
00192 tsp.LowerStageName = "Electronic"
00193 stageCfg.TrigReadSequence.Members.append(tsp)
00194
00195
00196
00197 from SingleLoader.SingleLoaderConf import SingleLoader
00198 sll = SingleLoader()
00199 sll.ThisStageName = "SingleLoader"
00200 sll.LowerStageName = "TrigRead"
00201 stageCfg.SingleLoaderSequence.Members.append(sll)
00202
00203 from Stage.StageConf import Sim15
00204 sim15=Sim15()
00205 sim15.TopStage="SingleLoader"
00206
00207 from Gaudi.Configuration import ApplicationMgr
00208 theApp = ApplicationMgr()
00209 theApp.TopAlg.append(sim15)
00210
00211 def run(app):
00212 pass