/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

my.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 class GenToolsConfig:
00004     def __init__(self,
00005                  volume="/dd/Geometry/AD/lvAD",
00006                  nevents=10,
00007                  seed=1234567,
00008                  # Use Co60.exe because it is fast, easy testing
00009                  hepevt_source="Co60.exe -seed %(seed)s -n %(nevents)s|"):
00010         import GaudiPython as gm
00011         self.app = gm.AppMgr()
00012         #msg = self.app.service("MessageSvc")
00013         #msg.OutputLevel = 1
00014         self.nevents = nevents
00015         self.seed = seed
00016         self.volume = volume
00017         self.hepevt_source=hepevt_source
00018         self.init()
00019         return
00020 
00021     def init(self):
00022         self.init_gen_tools()
00023         return
00024 
00025     def init_gen_tools(self):
00026         from GaudiKernel import SystemOfUnits as units
00027 
00028         #print " init_gen_tools"
00029 
00030         # Set up timerator
00031         tim = self.app.property("ToolSvc.GtTimeratorTool")
00032         #tim.OutputLevel=1
00033         tim.LifeTime = int(1*units.second)
00034 
00035 
00036         # Set up positioner
00037         #print " Creating poser"
00038         poser = self.app.property("ToolSvc.GtPositionerTool")
00039         poser.OutputLevel = 2
00040         poser.Volume = self.volume
00041         poser.Strategy = "FullVolume" # also "AvoidDaughters" and "Surface"
00042         poser.Mode = "Uniform"
00043         poser.Spread = 10*units.cm
00044         poser.Position = [0,0,0]
00045 
00046         # Deal with executable
00047         if self.hepevt_source[-1] == "|":
00048             exe = self.hepevt_source.split(' ')[0]
00049             if exe[0] != '/':   # Try to find full path
00050                 import os, os.path
00051                 path = os.getenv('PATH')
00052                 for p in path:
00053                     if (os.path.isfile(path+"/"+exe)):
00054                         exe = path+"/"+exe
00055                         break
00056                     continue
00057                 pass
00058             source = exe + ' ' + ' '.join(self.hepevt_source.split(' ')[1:])
00059             if "%" in source:   # Fill in any placemarks
00060                 source = source%{'nevents':str(self.nevents),
00061                                  'seed':str(self.seed)}
00062                 pass
00063             pass
00064         
00065 
00066         # HEPEvt -> HepMC generator
00067         #hepevt = self.app.property("ToolSvc.GtHepEvtGenTool")
00068         #hepevt.HepEvtDataSource = source
00069         #print " HepEvtGenTool with", source
00070 
00071         # Set up gun
00072         gun = self.app.property("ToolSvc.GtGunGenTool")
00073         gun.OutputLevel = 2
00074         gun.ParticleName = "opticalphoton"
00075         gun.MomentumMode = "Fixed"
00076         gun.Momentum = 2.5*units.eV
00077         gun.DirectionMode = "Fixed"
00078         gun.Direction = [ 0.0,0.0,-1.0 ]
00079 
00080         return
00081 
00082 
00083 if '__main__' == __name__:
00084     import os
00085     loc = os.getenv('XMLDETDESCROOT')
00086     if not loc:
00087         raise RuntimeError,"Location of DetDesc XML file not specified"
00088     loc += "/DDDB/pmtbox.xml"
00089 
00090     import xmldetdesc
00091     xddc = xmldetdesc.XmlDetDescConfig(loc=loc)
00092 
00093     tg = GenToolsConfig(volume="/dd/Structure/steel-2/water-2")
00094     from GaudiPython import AppMgr
00095     app = AppMgr()
00096     app.EvtSel = "NONE"
00097 #    app.run(tg.nevents)
00098 
00099     msv = app.service('MessageSvc')
00100     msv.OutputLevel = 2
00101 
00102     #########
00103     app.TopAlg += [ "Gnrtr/Generator" ]
00104     #print " GtGenerator"
00105     gen = app.algorithm("Generator")
00106     #gen.OutputLevel = 2
00107     #gen.GenTools = [ "GtHepEvtGenTool", "GtPositionerTool", "GtTimeratorTool" ]
00108     gen.GenTools = [ "GtGunGenTool", "GtPositionerTool", "GtTimeratorTool" ]
00109     gen.GenName = "Bang Bang"
00110     gen.Location = "/Event/Gen/HepMCEvents" # this is default anyways
00111     
00112     app.run(tg.nevents)
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:20:44 for Gnrtr by doxygen 1.7.4