00001 import GaudiKernel.SystemOfUnits as units
00002
00003 from DybPython.Tools import unitify
00004
00005 class WillItBlend:
00006
00007 '''
00008 Class to configure mixing of different files.
00009 '''
00010
00011 def __init__(self):
00012 self.stage_cfg = None
00013 return
00014
00015 def configureMixing(self,streams):
00016 'Configure mixing'
00017
00018 from Gaudi.Configuration import ApplicationMgr
00019 theApp = ApplicationMgr()
00020 from LoadingProc.LoadingProcConf import LoadingProc, HsAssembler
00021 from RootIOSvc.RootIOSvcConf import RootIOCnvSvc
00022 from DybIO.DybIOConf import DybInputLoadTool
00023 from DybIO.DybIOConf import DybNextEntryPolicyTool
00024
00025 for name,rate,filelist in streams:
00026
00027 lpname = 'LoadingProcFor_'+name
00028 assname = 'AssemblerFor_'+name
00029 iltname = 'LoadToolFor_'+name
00030 nepname = 'NextEntryPolicyFor_'+name
00031 rioname = 'RootIOCnvSvcFor_'+name
00032
00033 lp = LoadingProc(lpname)
00034 lp.StartSec = 0
00035 lp.StartNano = 0
00036
00037 lp.Distribution = "Periodic"
00038 lp.Rate = rate
00039 lp.HsAssembler = assname
00040 lp.OutputLevel = 2
00041 lp.ThisStageName = "Detector"
00042 lp.LowerStageName = ""
00043 self.stage_cfg.DetectorSequence.Members.append(lp)
00044
00045
00046 ass = HsAssembler(assname)
00047
00048 ass.OutputLevel = 2
00049 ass.DybInputLoadTool = iltname
00050 ass.DybNextEntryPolicyTool = nepname
00051
00052 rio = RootIOCnvSvc(rioname)
00053 theApp.ExtSvc.append(rio)
00054
00055 inputstream = {'default': filelist}
00056 from RootIOSvc import wash_streams
00057 rio.InputStreams = wash_streams( inputstream )
00058
00059
00060 ilt = DybInputLoadTool(iltname)
00061 ilt.RootIOSvc = rio
00062 ilt.ConversionSvc = rio
00063
00064 pol = DybNextEntryPolicyTool(nepname)
00065 pol.Mode = "sequential"
00066
00067 continue
00068 return
00069
00070
00071 def configureElectronic(self):
00072 '''Configure the Electronics stage'''
00073
00074 import ElecSim
00075 es = ElecSim.Configure(use_push_algs = False)
00076
00077
00078
00079
00080
00081 from ElecSimProc.ElecSimProcConf import ElecSimProc
00082 esp = ElecSimProc()
00083 esp.ThisStageName = "Electronic"
00084 esp.LowerStageName = "Detector"
00085 esp.OutputLevel = 2
00086 self.stage_cfg.ElectronicSequence.Members.append(esp)
00087 return
00088
00089 def configureTrigRead(self):
00090 '''Configure the Trigger and Readout stage'''
00091 from TrigReadProc.TrigReadProcConf import TrigReadProc
00092 tsp = TrigReadProc()
00093 tsp.ThisStageName = "TrigRead"
00094 tsp.LowerStageName = "Electronic"
00095
00096
00097 tsp.OutputLevel = 2
00098 self.stage_cfg.TrigReadSequence.Members.append(tsp)
00099 return
00100
00101 def configureSingleLoader(self):
00102 '''Configure the SingleLoader stage'''
00103 from SingleLoader.SingleLoaderConf import SingleLoader
00104 sll = SingleLoader()
00105 sll.ThisStageName = "SingleLoader"
00106 sll.LowerStageName = "TrigRead"
00107 sll.OutputLevel = 2
00108 self.stage_cfg.SingleLoaderSequence.Members.append(sll)
00109
00110 def configureSim15(self):
00111 from Stage.StageConf import Sim15
00112 sim15=Sim15()
00113 sim15.TopStage = "SingleLoader"
00114
00115
00116 from Gaudi.Configuration import ApplicationMgr
00117 theApp = ApplicationMgr()
00118 theApp.TopAlg.append(sim15)
00119
00120 def configure(self,streams):
00121 from Stage import Configure as StageConfigure
00122 self.stage_cfg = StageConfigure()
00123 self.stage_cfg.addStages(['Detector','Electronic','TrigRead','SingleLoader'])
00124
00125 self.configureMixing(streams)
00126 self.configureElectronic()
00127 self.configureTrigRead()
00128 self.configureSingleLoader()
00129 self.configureSim15()
00130
00131 return
00132
00133 def configure(argv=None):
00134 assert argv,'Got no arguments.\n' + WillItBlend.__doc__
00135 streams = unitify(argv[0])
00136 print 'Configured with streams =',streams
00137 cfc = WillItBlend()
00138 cfc.configure(streams)
00139 return
00140
00141 if __name__ == "__main__":
00142 configure()
00143 pass