00001
00002
00003 '''
00004 usage example:
00005
00006 nuwa.py -n 2 -o output.root -m "UnderstandingEnergy.CalibrationAmCCo60 -z 4.0 -a A"
00007
00008 '''
00009
00010 DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
00011
00012 import os, math
00013
00014 def realPath(pathname):
00015 from os import path
00016 return path.normpath( path.realpath( path.expandvars(pathname) ) )
00017
00018 def configure(argv = []):
00019 """Configure this module with source position"""
00020
00021 import sys, getopt
00022 import GaudiKernel.SystemOfUnits as units
00023 from time import gmtime, mktime, strftime, strptime, timezone
00024 opts,args = getopt.getopt(argv,
00025 "z:a:")
00026
00027 from DybPython.Control import nuwa
00028 wallTime = nuwa.opts.time
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+"_Americium_Carbon_Cobalt_60"
00060 runDataSvc.SimCalibSources = [ sourceName ]
00061 runDataSvc.SimCalibZPosition = { sourceName : zpos }
00062
00063 import GenTools
00064 from GenTools.Helpers import HepEVT
00065 co60Rate = 100 * units.hertz
00066 neutronRate = 0.5 * units.hertz
00067 totalRate = neutronRate + co60Rate
00068 hepEvtExec = realPath( "${UNDERSTANDINGENERGYROOT}/share/AmC_Co60_Composite.py" )
00069 nEvents = nuwa.opts.executions
00070 hepEvtCommand = "%s -n %d -s %d -f %f |" % (hepEvtExec,
00071 nEvents,
00072 nuwa.opts.run,
00073 neutronRate/totalRate)
00074 myhep = HepEVT( hepEvtDataSource = hepEvtCommand)
00075 volume = "/dd/Structure/AD/db-oil1"
00076 myhep.positioner.Volume = volume
00077 myhep.transformer.Volume = volume
00078 myhep.positioner.Position = [xpos, ypos, zpos]
00079 myhep.timerator.LifeTime = 1.0 / totalRate
00080 gtc = GenTools.Configure()
00081 gtc.generator.TimeStamp = wallTime
00082 gtc.register(myhep)
00083
00084 import DetSim
00085 detsim = DetSim.Configure()
00086 detsim.historian(trackSelection="(pdg == -11) or (pdg == 2112)",\
00087 vertexSelection="(pdg == -11) or (pdg == 2112)")
00088 params = {
00089 'start' :"(start > 0)",
00090 'track1':"(id==1)",
00091 'track2':"(id==2)",
00092 'GD': "MaterialName == '/dd/Materials/GdDopedLS'",
00093 'LS': "MaterialName == '/dd/Materials/LiquidScintillator'",
00094 'MO': "MaterialName == '/dd/Materials/MineralOil'",
00095 'IAV': "DetectorElementName == 'db-iav1'",
00096 'OAV': "DetectorElementName == 'db-oav1'",
00097 'IWS': "MaterialName == '/dd/Materials/IwsWater'",
00098 'OWS': "MaterialName == '/dd/Materials/OwsWater'",
00099 'lastvtx': "IsStopping == 1",
00100 'firstvtx': "IsStarting == 1",
00101 'Neutron': "pdg == 2112",
00102 'NeutronMom': "creator == 2112",
00103 'Gamma': "pdg == 22",
00104 'Positron': "pdg == -11",
00105 'Muon': "(pdg == 13 or pdg == -13)"
00106 }
00107
00108 detsim.unobserver(stats=[
00109 ["EDepInGdLS", "dE", "%(GD)s"%params],
00110 ["EDepInLS", "dE", "%(LS)s"%params],
00111 ["EDepInIAV", "dE", "%(IAV)s"%params],
00112 ["EDepInOAV", "dE", "%(OAV)s"%params],
00113 ["EDepInOIL", "dE", "%(MO)s"%params],
00114
00115 ["QEDepInGdLS", "qdE", "%(GD)s"%params],
00116 ["QEDepInLS", "qdE", "%(LS)s"%params],
00117 ["QEDepInIAV", "qdE", "%(IAV)s"%params],
00118 ["QEDepInOAV", "qdE", "%(OAV)s"%params],
00119 ["QEDepInOIL", "qdE", "%(MO)s"%params],
00120
00121 ["tQESumGdLS", "qEt", "%(GD)s"%params],
00122 ["xQESumGdLS", "qEx", "%(GD)s"%params],
00123 ["yQESumGdLS", "qEy", "%(GD)s"%params],
00124 ["zQESumGdLS", "qEz", "%(GD)s"%params],
00125
00126 ["tQESumLS", "qEt", "%(LS)s"%params],
00127 ["xQESumLS", "qEx", "%(LS)s"%params],
00128 ["yQESumLS", "qEy", "%(LS)s"%params],
00129 ["zQESumLS", "qEz", "%(LS)s"%params],
00130
00131 ["tQESumMO", "qEt", "%(MO)s"%params],
00132 ["xQESumMO", "qEx", "%(MO)s"%params],
00133 ["yQESumMO", "qEy", "%(MO)s"%params],
00134 ["zQESumMO", "qEz", "%(MO)s"%params],
00135
00136
00137 ["pdgId_Trk1","pdg","%(track1)s and %(start)s"%params],
00138 ["t_Trk1", "t" , "%(track1)s and %(start)s"%params],
00139 ["x_Trk1", "x", "%(track1)s and %(start)s"%params],
00140 ["y_Trk1", "y", "%(track1)s and %(start)s"%params],
00141 ["z_Trk1", "z", "%(track1)s and %(start)s"%params],
00142 ["tEnd_Trk1", "t" , "%(track1)s and %(lastvtx)s"%params],
00143 ["xEnd_Trk1", "x", "%(track1)s and %(lastvtx)s"%params],
00144 ["yEnd_Trk1", "y", "%(track1)s and %(lastvtx)s"%params],
00145 ["zEnd_Trk1", "z", "%(track1)s and %(lastvtx)s"%params],
00146 ["e_Trk1", "E", "%(track1)s and %(start)s"%params],
00147 ["p_Trk1", "p", "%(track1)s and %(start)s"%params],
00148 ["ke_Trk1", "KE", "%(track1)s and %(start)s"%params],
00149 ["vx_Trk1", "vx","%(track1)s and %(start)s"%params],
00150 ["vy_Trk1", "vy","%(track1)s and %(start)s"%params],
00151 ["vz_Trk1", "vz","%(track1)s and %(start)s"%params],
00152 ["TrkLength_GD_Trk1", "dx","%(track1)s and %(GD)s"%params],
00153 ["TrkLength_iAV_Trk1", "dx","%(track1)s and %(IAV)s"%params],
00154 ["TrkLength_LS_Trk1", "dx","%(track1)s and %(LS)s"%params],
00155 ["TrkLength_oAV_Trk1", "dx","%(track1)s and %(OAV)s"%params],
00156 ["TrkLength_Oil_Trk1", "dx","%(track1)s and %(MO)s"%params]
00157 ])
00158
00159 import ElecSim
00160 elecsim = ElecSim.Configure()
00161
00162 import TrigSim
00163 trigsim = TrigSim.Configure()
00164
00165 import ReadoutSim
00166 rosim = ReadoutSim.Configure()
00167
00168 def run(app):
00169 pass