00001
00002
00003 '''
00004 usage example:
00005
00006 nuwa.py -A -n 2 -o output.root -m "ElecTutorial.GenKinematics -i 3500 -n DayaBayAD1_ACU_A_Center_LED -z 400.0"
00007
00008 The LED names are:
00009 [Site][Det]_[Location]_LED
00010
00011 Examples:
00012 DayaBayAD1_ACU_A_Center_LED
00013 DayaBayAD1_ACU_B_GdlsEdge_LED
00014 DayaBayAD1_ACU_C_GammaCatcher_LED
00015 DayaBayAD1_AD_WallUpper_LED
00016 DayaBayAD1_AD_WallCenter_LED
00017 DayaBayAD1_AD_WallLower_LED
00018 '''
00019
00020 DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
00021
00022 import os, math
00023
00024 def configure(argv = []):
00025 """Configure this module with LED position"""
00026
00027 import GaudiKernel.SystemOfUnits as units
00028 import sys, getopt
00029 from time import gmtime, mktime, strftime, strptime, timezone
00030 opts,args = getopt.getopt(argv,
00031 "p:w:z:n:i:f:m:s:",["no-geometry"])
00032 wallTime = 0
00033 axis = 0
00034 xpos = 0.0
00035 ypos = 0.0
00036 zpos = 0.0
00037 intensity = 35000
00038 intensityMode = "Gaus"
00039 intensitySpread = 350
00040 ledName = "DayaBayAD1_ACU_A_Center_LED"
00041 ledFrequency = 500.0 * units.hertz
00042 pmtDataPath = None
00043 placeGeometry = True
00044 for opt,arg in opts:
00045 if opt == "-p":
00046 pmtDataPath = arg
00047 if opt == "-i":
00048 intensity = int(arg)
00049 print "======================================================"
00050 print "Diffuser Ball intensity = ",intensity," photons per flash"
00051 print "======================================================"
00052 if opt == "-m":
00053 intensityMode = arg
00054 print "======================================================"
00055 print "Diffuser Ball intensity is spread using a ",intensityMode," distribution"
00056 print "======================================================"
00057 if opt == "-s":
00058 intensitySpread = int(arg)
00059 print "======================================================"
00060 print "Diffuser Ball intensity is spread with sigma/FWHM = ",intensitySpread," photons"
00061 print "======================================================"
00062 if opt == "-f":
00063 ledFrequency = float(arg)
00064 print "======================================================"
00065 print "Diffuser Ball frequency = ",ledFrequency," hertz"
00066 print "======================================================"
00067 if opt == "-z":
00068 zpos = float(arg)
00069 print "======================================================"
00070 print "Diffuser Ball Z position = ", zpos, " cm"
00071 print "======================================================"
00072 zpos *= units.cm
00073 if opt == "-n":
00074 ledName = arg
00075 print "======================================================"
00076 print "LED Source = ", ledName
00077 print "======================================================"
00078 if opt == "--no-geometry":
00079 placeGeometry = False
00080 print "======================================================"
00081 print "Photons only; ACU diffuser ball geometry will not be added."
00082 print "======================================================"
00083
00084 detectorMap = {"DayaBayAD1":"/dd/Structure/AD/db-oil1",
00085 "DayaBayAD2":"/dd/Structure/AD/db-oil2",
00086 "LingAoAD1":"/dd/Structure/AD/la-oil1",
00087 "LingAoAD2":"/dd/Structure/AD/la-oil2",
00088 "FarAD1":"/dd/Structure/AD/far-oil1",
00089 "FarAD2":"/dd/Structure/AD/far-oil2",
00090 "FarAD3":"/dd/Structure/AD/far-oil3",
00091 "FarAD4":"/dd/Structure/AD/far-oil4"
00092 }
00093
00094
00095 from GaudiPython import gbl
00096 CalibSourceId = gbl.DayaBay.CalibSourceId
00097 ledId = CalibSourceId( ledName )
00098 xpos = ledId.nominalX()
00099 ypos = ledId.nominalY()
00100 volume = None
00101 if detectorMap.has_key( ledId.detName() ):
00102
00103 volume = detectorMap[ ledId.detName() ]
00104 else:
00105 print "ERROR: Unknown detector: ", ledId.detName()
00106 sys.exit(1)
00107
00108 if ledId.isWallMounted():
00109 zpos = ledId.nominalZ()
00110 placeGeometry = False
00111
00112 import GenTools
00113 from GenTools.Helpers import DiffuserBall
00114 ball = DiffuserBall( name=ledName,
00115 useGeometry = placeGeometry )
00116 ball.setVolume( volume )
00117 ball.setPosition( [xpos, ypos, zpos] )
00118 ball.ball.PhotonsPerEvent = intensity
00119 ball.ball.PhotonsPerEventMode = intensityMode
00120 ball.ball.PhotonsPerEventSpread = intensitySpread
00121 ball.timerator.LifeTime = 1.0 / ledFrequency
00122 gtc = GenTools.Configure()
00123 gtc.generator.TimeStamp = int(wallTime)
00124 gtc.register(ball)
00125
00126
00127 from RunDataSvc.RunDataSvcConf import RunDataSvc
00128 runDataSvc = RunDataSvc()
00129 runDataSvc.SimRunType = "Calibration"
00130 runDataSvc.SimCalibSources = [ ledName ]
00131 runDataSvc.SimLedFrequency = { ledName : ledFrequency }
00132 runDataSvc.SimCalibZPosition = { ledName : zpos }
00133
00134 import DetSim
00135 detsim = DetSim.Configure(physlist = DetSim.physics_list_basic)
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 from DybAlg.DybAlgConf import DybGenPrune
00147 genPrune = DybGenPrune()
00148 from Gaudi.Configuration import ApplicationMgr
00149 appMgr = ApplicationMgr()
00150 appMgr.TopAlg += [genPrune]
00151
00152 def run(app):
00153 pass