00001
00002
00003 '''
00004
00005 usage:
00006 nuwa.py -n 2 -o test.root -m "runDoublePulse -I 10000 -i 6000 -D 3000"
00007
00008 Options:
00009
00010 -T TOP_STAGE, --top-stage=TOP_STAGE
00011 Kinematic,Detector,Electronic,TrigRead,SingleLoader
00012
00013 -I PRIMARY_LED_INTENSITY, --Primary-LED-intensity=PRIMARY_LED_INTENSITY
00014 Number of photons per LED flash for primary LED. If <=
00015 0 then no LED flashing enabled.
00016 -i SECONDARY_LED_INTENSITY, --Secondary-LED-intensity=SECONDARY_LED_INTENSITY
00017 Number of photons per LED flash for secondary LED. If
00018 <= 0 then SECONDARY LED flashing is DISABLED.
00019 -D DOUBLE_PULSE_DELAY, --Double-pulse-delay=DOUBLE_PULSE_DELAY
00020 Delay in nanoseconds of Secondary LED with respect to
00021 Primary LED for double-pulse
00022
00023 '''
00024 import GaudiKernel.SystemOfUnits as units
00025
00026 class ConfigureDoublePulse:
00027
00028 '''
00029 Configure a Full Chain of pull simulations for cosmics and LEDs.
00030 '''
00031
00032 def __init__(self,argv):
00033
00034 self.parse_args(argv)
00035
00036 return
00037
00038 def parse_args(self,argv):
00039 from optparse import OptionParser
00040 import time
00041 import sys
00042 parser = OptionParser(usage=self.__doc__)
00043
00044 parser.add_option("-T","--top-stage",
00045 help="Kinematic,Detector,Electronic,TrigRead,SingleLoader",
00046 default="SingleLoader")
00047
00048
00049 parser.add_option("-I","--Primary-LED-intensity",
00050 help="Number of photons per LED flash for primary LED. If <= 0 then no LED flashing enabled.",
00051 default=3500, type="int")
00052
00053
00054 parser.add_option("-i","--Secondary-LED-intensity",
00055 help="Number of photons per LED flash for secondary LED. If <= 0 then SECONDARY LED flashing is DISABLED.",
00056 default=-1, type="int")
00057
00058
00059 parser.add_option("-D","--Double-pulse-delay",
00060 help="Delay in nanoseconds of Secondary LED with respect to Primary LED for double-pulse",
00061 default=30.e3,
00062 type="float")
00063
00064
00065
00066 (options,args) = parser.parse_args(args=argv)
00067 self.opts = options
00068 self.args = args
00069
00070 print 'Top stage =',self.opts.top_stage
00071
00072 print "ACU A LED intensity/flash (photons) = ", self.opts.Primary_LED_intensity
00073 print "ACU B LED intensity/flash (photons) = ", self.opts.Secondary_LED_intensity
00074 print 'Double-pulse separation (ns) = ',self.opts.Double_pulse_delay
00075
00076 return
00077
00078 def configureKinematic(self):
00079
00080
00081 from MDC10b.runLED_Muon import LED
00082 led1=LED.LED(stage=self.stage_cfg,
00083 name='PrimaryLED',
00084 intensity=self.opts.Primary_LED_intensity,
00085 time_offset_in_nanosec=0,
00086 ledName='DayaBayAD1_ACU_A_Center_LED')
00087
00088 led2=LED.LED(stage=self.stage_cfg,
00089 name='SecondaryLED',
00090 intensity=self.opts.Secondary_LED_intensity,
00091 time_offset_in_nanosec= self.opts.Double_pulse_delay,
00092 ledName= 'DayaBayAD1_ACU_B_GdlsEdge_LED')
00093
00094 return
00095
00096 def configureDetector(self):
00097 '''Configure the Detector stage'''
00098
00099
00100
00101 import DetSim
00102 from DetSim import Configure
00103
00104 Configure.giga_dayabay_items = ["/dd/Structure/AD/db-ade1"]
00105
00106 ds = Configure(physlist=DetSim.physics_list_basic,
00107 use_push_algs = False,
00108 site = 'dayabay')
00109
00110
00111
00112 from DetSim.DetSimConf import DsPhysConsOptical
00113 optical = DsPhysConsOptical("GiGa.GiGaPhysListModular.DsPhysConsOptical")
00114 optical.UseScintillation = False
00115
00116
00117 optical.CerenPhotonScaleWeight = 3.5
00118
00119
00120
00121 optical.ApplyWaterQe = True
00122 from DetSim.DetSimConf import DsPmtSensDet
00123 pmtsd = DsPmtSensDet("GiGaGeo.DsPmtSensDet")
00124 pmtsd.WaterCerenQeApplied = optical.ApplyWaterQe
00125
00126
00127 from DetSimProc.DetSimProcConf import DetSimProc
00128 dsp = DetSimProc()
00129 dsp.ThisStageName = "Detector"
00130 dsp.LowerStageName = "Kinematic"
00131
00132 self.stage_cfg.DetectorSequence.Members.append(dsp)
00133
00134
00135 return
00136
00137 def configureElectronic(self):
00138 '''Configure the Electronics stage'''
00139
00140 import ElecSim
00141 es = ElecSim.Configure(use_push_algs = False)
00142
00143
00144 from ElecSim.ElecSimConf import EsPmtEffectPulseTool
00145 pmtTool = EsPmtEffectPulseTool()
00146 pmtTool.AfterPulseAmpMode="PDF"
00147 pmtTool.EnablePrePulse=True
00148 pmtTool.EnableAfterPulse=True
00149
00150 from ElecSim.ElecSimConf import EsIdealFeeTool
00151 feeTool = EsIdealFeeTool()
00152 feeTool.EnableNonlinearity=True
00153 feeTool.EnableOvershoot=True
00154 feeTool.EnableRinging=True
00155
00156 from ElecSimProc.ElecSimProcConf import ElecSimProc
00157 esp = ElecSimProc()
00158 esp.ThisStageName = "Electronic"
00159 esp.LowerStageName = "Detector"
00160 self.stage_cfg.ElectronicSequence.Members.append(esp)
00161
00162
00163 from StatisticsSvc.StatisticsSvcConf import StatisticsSvc
00164 statsSvc = StatisticsSvc()
00165 statsSvc.Output ={"file1":"waveforms.root"}
00166
00167 return
00168
00169 def configureTrigRead(self):
00170 '''Configure the Trigger and Readout stage'''
00171 from TrigReadProc.TrigReadProcConf import TrigReadProc
00172 tsp = TrigReadProc()
00173 tsp.ThisStageName = "TrigRead"
00174 tsp.LowerStageName = "Electronic"
00175
00176
00177 from TrigSim.TrigSimConf import TsMultTriggerTool
00178 mtt = TsMultTriggerTool()
00179 mtt.ADThreshold = 25
00180 mtt.DetectorsToProcess = ["DayaBayAD1"]
00181
00182 tsp.TrigTools = [mtt]
00183
00184 self.stage_cfg.TrigReadSequence.Members.append(tsp)
00185 return
00186
00187 def configureSingleLoader(self):
00188 '''Configure the SingleLoader stage'''
00189 from SingleLoader.SingleLoaderConf import SingleLoader
00190 sll = SingleLoader()
00191 sll.ThisStageName = "SingleLoader"
00192 sll.LowerStageName = "TrigRead"
00193
00194 self.stage_cfg.SingleLoaderSequence.Members.append(sll)
00195
00196 def configureSim15(self):
00197 from Stage.StageConf import Sim15
00198 sim15=Sim15()
00199 sim15.TopStage=self.opts.top_stage
00200
00201 from Gaudi.Configuration import ApplicationMgr
00202 theApp = ApplicationMgr()
00203 theApp.TopAlg.append(sim15)
00204
00205
00206
00207 def configure(self):
00208
00209 from Stage import Configure as StageConfigure
00210 self.stage_cfg = StageConfigure()
00211
00212 stagedic={'Kinematic':1,'Detector':2,'Electronic':3,'TrigRead':4,'SingleLoader':5}
00213
00214 if not self.opts.top_stage in stagedic:
00215 print 'Error, wrong top stage parameter.', self.opts.top_stage
00216 print 'Valid stage is Kinematic, Detector, Electronic, TrigRead or SingleLoader'
00217
00218 for stg,idx in stagedic.iteritems():
00219 if idx <= stagedic[self.opts.top_stage]:
00220 self.stage_cfg.addStages([stg])
00221
00222 for stg in self.stage_cfg.stages:
00223
00224 pass
00225
00226 if stagedic[self.opts.top_stage]>=1:
00227 self.configureKinematic()
00228 if stagedic[self.opts.top_stage]>=2:
00229 self.configureDetector()
00230 if stagedic[self.opts.top_stage]>=3:
00231 self.configureElectronic()
00232 if stagedic[self.opts.top_stage]>=4:
00233 self.configureTrigRead()
00234 if stagedic[self.opts.top_stage]>=5:
00235 self.configureSingleLoader()
00236
00237 self.configureSim15()
00238
00239 return
00240
00241 def configure(argv=[]):
00242
00243 cdp = ConfigureDoublePulse(argv)
00244 cdp.configure()
00245
00246 return
00247
00248 def run(app):
00249 app.ExtSvc += ["StatisticsSvc"]
00250
00251 from ElecTutorial import WaveDumper
00252
00253 wavealg = WaveDumper.WaveDumperAlg("WaveDumper")
00254 app.addAlgorithm(wavealg)
00255
00256 pass
00257
00258 if __name__ == "__main__":
00259 configure()
00260 pass
00261