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

In This Package:

gentools.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         self.init_generator()
00024         return
00025 
00026     def init_gen_tools(self):
00027         from GaudiKernel import SystemOfUnits as units
00028 
00029         #print " init_gen_tools"
00030 
00031         # Set up timerator
00032         tim = self.app.property("ToolSvc.GtTimeratorTool")
00033         #tim.OutputLevel=1
00034         tim.LifeTime = int(1*units.second)
00035 
00036 
00037         # Set up positioner
00038         #print " Creating poser"
00039         poser = self.app.property("ToolSvc.GtPositionerTool")
00040         poser.OutputLevel = 2
00041         poser.Volume = self.volume
00042         poser.Strategy = "FullVolume" # also "AvoidDaughters" and "Surface"
00043         poser.Mode = "Uniform"
00044         poser.Spread = 10*units.cm
00045         poser.Position = [0,0,0]
00046 
00047         # Deal with executable
00048         if self.hepevt_source[-1] == "|":
00049             exe = self.hepevt_source.split(' ')[0]
00050             if exe[0] != '/':   # Try to find full path
00051                 import os, os.path
00052                 path = os.getenv('PATH')
00053                 for p in path:
00054                     if (os.path.isfile(path+"/"+exe)):
00055                         exe = path+"/"+exe
00056                         break
00057                     continue
00058                 pass
00059             source = exe + ' ' + ' '.join(self.hepevt_source.split(' ')[1:])
00060             if "%" in source:   # Fill in any placemarks
00061                 source = source%{'nevents':str(self.nevents),
00062                                  'seed':str(self.seed)}
00063                 pass
00064             pass
00065         
00066 
00067         # HEPEvt -> HepMC generator
00068         #hepevt = self.app.property("ToolSvc.GtHepEvtGenTool")
00069         #hepevt.HepEvtDataSource = source
00070         #print " HepEvtGenTool with", source
00071 
00072         # Set up gun
00073         gun = self.app.property("ToolSvc.GtGunGenTool")
00074         gun.OutputLevel = 2
00075         gun.ParticleName = "opticalphoton"
00076         gun.MomentumMode = "Fixed"
00077         gun.Momentum = 2.5*units.eV
00078         gun.DirectionMode = "Fixed"
00079         gun.Direction = [ 0.0,0.0,-1.0 ]
00080 
00081 
00082         return
00083 
00084     def init_generator(self):
00085         #print " init_generator"
00086 #        self.app.TopAlg += [ "Gnrtr/Generator", "GtHepMCDumper/Dumper" ]
00087         self.app.TopAlg += [ "Gnrtr/Generator" ]
00088         #print " GtGenerator"
00089         gen = self.app.algorithm("Generator")
00090         #gen.OutputLevel = 2
00091         #gen.GenTools = [ "GtHepEvtGenTool", "GtPositionerTool", "GtTimeratorTool" ]
00092         gen.GenTools = [ "GtGunGenTool/GunGen", "GtPositionerTool/GunPos", "GtTimeratorTool/GunTim" ]
00093         gen.GenName = "Bang Bang"
00094         gen.Location = "/Event/Gen/HepMCEvents" # this is default anyways
00095 
00096         #print " GtDumper"
00097         dump = self.app.algorithm("Dumper")
00098         dump.Location = "/Event/Gen/HepMCEvents"  # this is default anyways.
00099         return
00100 
00101 if '__main__' == __name__:
00102     import os
00103     loc = os.getenv('XMLDETDESCROOT')
00104     if not loc:
00105         raise RuntimeError,"Location of DetDesc XML file not specified"
00106     loc += "/DDDB/pmtbox.xml"
00107 
00108     import xmldetdesc
00109     xddc = xmldetdesc.XmlDetDescConfig(loc=loc)
00110 
00111     tg = GenToolsConfig(volume="/dd/Structure/steel-2/water-2")
00112     from GaudiPython import AppMgr
00113     app = AppMgr()
00114     app.EvtSel = "NONE"
00115     app.run(tg.nevents)
00116 
00117     msv = app.service('MessageSvc')
00118     msv.OutputLevel = 2
| 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