00001
00002
00003 class VisDetConfig:
00004 def __init__(self,logvol="",detelem="",which="RawTracerX"):
00005 self.detelem = detelem
00006 self.logvol = logvol
00007 self.which = which
00008
00009 print "Using vis method: ",self.which
00010
00011 import gaudimodule as gm
00012 import units
00013 app = gm.AppMgr()
00014 app.ExtSvc += ["GiGa"]
00015
00016 modularPL = app.property("GiGa.GiGaPhysListModular")
00017
00018 modularPL.CutForElectron = 100*units.micrometer
00019 modularPL.CutForPositron = 100*units.micrometer
00020 modularPL.CutForGamma = 1*units.millimeter
00021 modularPL.PhysicsConstructors = [
00022 "DsPhysConsGeneral",
00023 "DsPhysConsOptical"
00024 ]
00025
00026 print "\tGetting property GiGaEventActionCommand:"
00027 viscmd = app.property("GiGa.GiGaEventActionCommand")
00028
00029
00030
00031
00032
00033
00034 print "\tSet EndOfEventCommands"
00035
00036 if self.which == "DAWNFILE":
00037 viscmd.BeginOfEventCommands = \
00038 [ "/vis/scene/create",
00039 "/vis/sceneHandler/create DAWNFILE",
00040 "/vis/viewer/create",
00041 "/vis/viewer/set/viewpointThetaPhi -90 -90",
00042 "/vis/scene/add/volume",
00043 "/vis/scene/add/trajectories" ]
00044 elif self.which == "HepRepFile":
00045 viscmd.BeginOfEventCommands = [
00046 "/vis/open HepRepFile",
00047
00048
00049
00050 "/vis/viewer/flush"
00051 ]
00052 elif self.which == "HepRepXML":
00053 viscmd.BeginOfEventCommands = \
00054 [ "/vis/open HepRepXML",
00055 "/vis/scene/create far.heprep",
00056 "/vis/scene/add/volume",
00057 "/vis/sceneHandler/attach",
00058
00059 "/vis/viewer/flush"
00060 ]
00061 elif self.which == "OGLIXm" or self.which == "OGLSXm":
00062 viscmd.BeginOfEventCommands = [
00063 "/vis/open "+self.which,
00064 "/vis/drawVolume",
00065 ]
00066 elif self.which == "OGLIX" or self.which == "OGLSX":
00067 viscmd.BeginOfEventCommands = [
00068 "/vis/open "+self.which,
00069 "/vis/drawVolume",
00070 ]
00071 elif self.which == "OIX":
00072 viscmd.BeginOfEventCommands = [
00073 "/vis/open OIX",
00074 "/vis/drawVolume",
00075 ]
00076 elif self.which == "RayTracer" or self.which == "RayTracerX":
00077 viscmd.BeginOfEventCommands = [
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 ]
00090 elif self.which == "ATree":
00091 viscmd.BeginOfEventCommands = [
00092 "/vis/open ATree",
00093 "/vis/ASCIITree/Verbose 15",
00094 "/vis/scene/create",
00095 "/vis/scene/add/volume "+self.detelem,
00096 "/vis/sceneHandler/attach",
00097 "/vis/drawTree",
00098 "/vis/viewer/flush",
00099 ]
00100 elif self.which == "GAGTree":
00101 viscmd.BeginOfEventCommands = [
00102 "/vis/open GAGTree",
00103 "/vis/scene/create",
00104 "/vis/scene/add/volume "+self.detelem,
00105 "/vis/sceneHandler/attach",
00106 "/vis/drawTree",
00107 "/vis/viewer/flush",
00108 ]
00109 elif self.which == "xml":
00110 viscmd.BeginOfEventCommands = [
00111 "/vis/open XMLTree",
00112 "/vis/scene/create",
00113 "/vis/scene/add/volume "+self.detelem,
00114 "/vis/sceneHandler/attach",
00115 "/vis/drawTree",
00116 "/vis/viewer/flush",
00117 ]
00118 else:
00119 viscmd.BeginOfEventCommands = []
00120
00121
00122
00123
00124
00125
00126 app.TopAlg += [ "GaudiSequencer/Simulation" ]
00127 seq = app.algorithm("Simulation")
00128 seq.Members = [ "GiGaInputStream/GIO" ]
00129
00130 gio = app.algorithm("GIO")
00131 gio.ExecuteOnce = True
00132 gio.ConversionSvcName = "GiGaGeo"
00133 gio.DataProviderSvcName = "DetectorDataSvc"
00134 gio.StreamItems = [ self.logvol, self.detelem ]
00135
00136 import units
00137 ggg = app.service("GiGaGeo")
00138 ggg.XsizeOfWorldVolume = 2400*units.meter
00139 ggg.YsizeOfWorldVolume = 2400*units.meter
00140 ggg.ZsizeOfWorldVolume = 2400*units.meter
00141
00142
00143
00144 seq.Members += [ "DsPushKine/PushKine", "DsPullEvent/PullEvent" ]
00145 push = app.algorithm("PushKine")
00146 push.Converter = "HepMCtoG4"
00147
00148 giga = app.service("GiGa")
00149 giga.PhysicsList = "GiGaPhysListModular"
00150 giga.EventAction = "GiGaEventActionCommand"
00151 giga.VisManager = "GiGaVisManager/GiGaVis"
00152 if self.which[0:3] == 'Ray':
00153 giga.UIsession = "GiGaUIsession/GiGaUI"
00154
00155
00156
00157
00158 if '__main__' == __name__:
00159
00160 import sys, getopt, os
00161 det=os.getenv("XMLDETDESCROOT")
00162 if det == "":
00163 print "Warning: no XMLDETDESCROOT variable, no default detector description"
00164 else:
00165 det += "/DDDB/dayabay.xml"
00166
00167 optlist,args = getopt.getopt(sys.argv[1:],"-V:v:d:l:p:w:")
00168
00169 log = "/dd/Geometry/Pool/lvFarPoolOWS"
00170 phy = "/dd/Structure/daya-bay/far-rock/far-ows"
00171
00172 verbose = None
00173 which = "RayTracerX"
00174 for opt,arg in optlist:
00175 if opt == "-V":
00176 verbose = arg
00177 if opt == "-v":
00178 vol = arg
00179 if opt == "-d":
00180 det = arg
00181 if opt == "-l":
00182 log = arg
00183 if opt == "-p":
00184 phy = arg
00185 if opt == "-w":
00186 which = arg
00187 pass
00188 pass
00189
00190
00191 print "Detector file = ",det
00192 print "Logical volume = ",log
00193 print "Physical volume = ",phy
00194
00195 import gaudimodule as gm
00196 app = gm.AppMgr()
00197 if verbose:
00198 app.service('MessageSvc').OutputLevel = 1
00199 app.EvtMax = 2
00200 app.EvtSel = "NONE"
00201
00202
00203 import xmldetdesc,gentools
00204
00205 xddc = xmldetdesc.XmlDetDescConfig(loc=det)
00206
00207 tg = gentools.GenToolsConfig(volume=log)
00208 dsc = VisDetConfig(detelem=phy, logvol=log, which=which)
00209
00210 app.run(1)
00211