00001
00002
00003 '''
00004 usage example:
00005
00006 nuwa.py -A -n 2 -o output.root -m "MDC09a.runLED -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:",["no-geometry"])
00032 wallTime = 0
00033 axis = 0
00034 xpos = 0.0
00035 ypos = 0.0
00036 zpos = 0.0
00037 intensity = 3500
00038 ledName = "DayaBayAD1_ACU_A_Center_LED"
00039 ledFrequency = 500.0 * units.hertz
00040 pmtDataPath = None
00041 placeGeometry = True
00042 for opt,arg in opts:
00043 if opt == "-p":
00044 pmtDataPath = arg
00045 if opt == "-i":
00046 intensity = int(arg)
00047 print "======================================================"
00048 print "Diffuser Ball intensity = ",intensity," photons per flash"
00049 print "======================================================"
00050 if opt == "-f":
00051 ledFrequency = float(arg)
00052 print "======================================================"
00053 print "Diffuser Ball frequency = ",ledFrequency," hertz"
00054 print "======================================================"
00055 if opt == "-z":
00056 zpos = float(arg)
00057 print "======================================================"
00058 print "Diffuser Ball Z position = ", zpos, " cm"
00059 print "======================================================"
00060 zpos *= units.cm
00061 if opt == "-n":
00062 ledName = arg
00063 print "======================================================"
00064 print "LED Source = ", ledName
00065 print "======================================================"
00066 if opt == "--no-geometry":
00067 placeGeometry = False
00068 print "======================================================"
00069 print "Photons only; ACU diffuser ball geometry will not be added."
00070 print "======================================================"
00071
00072 detectorMap = {"DayaBayAD1":"/dd/Structure/AD/db-oil1",
00073 "DayaBayAD2":"/dd/Structure/AD/db-oil2",
00074 "LingAoAD1":"/dd/Structure/AD/la-oil1",
00075 "LingAoAD2":"/dd/Structure/AD/la-oil2",
00076 "FarAD1":"/dd/Structure/AD/far-oil1",
00077 "FarAD2":"/dd/Structure/AD/far-oil2",
00078 "FarAD3":"/dd/Structure/AD/far-oil3",
00079 "FarAD4":"/dd/Structure/AD/far-oil4"
00080 }
00081
00082
00083 from GaudiPython import gbl
00084 CalibSourceId = gbl.DayaBay.CalibSourceId
00085 ledId = CalibSourceId( ledName )
00086 xpos = ledId.nominalX()
00087 ypos = ledId.nominalY()
00088 volume = None
00089 if detectorMap.has_key( ledId.detName() ):
00090
00091 volume = detectorMap[ ledId.detName() ]
00092 else:
00093 print "ERROR: Unknown detector: ", ledId.detName()
00094 sys.exit(1)
00095
00096 if ledId.isWallMounted():
00097 zpos = ledId.nominalZ()
00098 placeGeometry = False
00099
00100 import GenTools
00101 from GenTools.Helpers import DiffuserBall
00102 ball = DiffuserBall( name=ledName,
00103 useGeometry = placeGeometry )
00104 ball.setVolume( volume )
00105 ball.setPosition( [xpos, ypos, zpos] )
00106 ball.ball.PhotonsPerEvent = intensity
00107 ball.timerator.LifeTime = 1.0 / ledFrequency
00108 gtc = GenTools.Configure()
00109 gtc.generator.TimeStamp = int(wallTime)
00110 gtc.register(ball)
00111
00112
00113 from RunDataSvc.RunDataSvcConf import RunDataSvc
00114 runDataSvc = RunDataSvc()
00115 runDataSvc.SimRunType = "Calibration"
00116 runDataSvc.SimCalibSources = [ ledName ]
00117 runDataSvc.SimLedFrequency = { ledName : ledFrequency }
00118 runDataSvc.SimCalibZPosition = { ledName : zpos }
00119
00120 import DetSim
00121 detsim = DetSim.Configure(physlist = DetSim.physics_list_basic)
00122
00123 import ElecSim
00124 elecsim = ElecSim.Configure()
00125 if pmtDataPath != None:
00126
00127 elecsim.dataSvc.setPmtSimData( pmtDataPath )
00128
00129 import TrigSim
00130 trigsim = TrigSim.Configure()
00131
00132 import ReadoutSim
00133 rosim = ReadoutSim.Configure()
00134
00135
00136
00137 from DybAlg.DybAlgConf import DybGenPrune
00138 genPrune = DybGenPrune()
00139 from Gaudi.Configuration import ApplicationMgr
00140 appMgr = ApplicationMgr()
00141 appMgr.TopAlg += [genPrune]
00142
00143 def run(app):
00144 pass