| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

FullChainSimple.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 '''
00004 
00005 Configure the full chain of simulation from kinematics to readouts and
00006 with multiple kinematics types mixed together.
00007 
00008 usage:
00009     nuwa.py -n50 -o fifteen.root -m "FullChainSimple -T SingleLoader" > log
00010 
00011     -T: Optional stages are: Kinematic, Detector, Electronic, TrigRead or SingleLoader.
00012 
00013     More options are available like -w: wall clock starting time
00014                                     -F: time format
00015                                     -s: seed for IBD generator
00016 
00017     //////
00018     Aside: 
00019     This is a copy of MDC09b.runIBD15.FullChain, however with less options, 
00020     less generators configured and less truth info saved.
00021     //////
00022     
00023 '''
00024 import GaudiKernel.SystemOfUnits as units
00025 
00026 class ConfigureFullChain:
00027 
00028     '''
00029     Configure a Full Chain of pull simulations.
00030     '''
00031 
00032     def __init__(self,argv):
00033         self.parse_args(argv)
00034         return
00035 
00036     def parse_args(self,argv):
00037         from optparse import OptionParser
00038         import time
00039         parser = OptionParser(usage=self.__doc__)
00040         default_time_format = '%Y-%m-%dT%H:%M:%S'
00041         parser.add_option("-w","--start-time",
00042                           help="Date string to set simulation start, assumed UTC",
00043                           default=time.strftime(default_time_format,time.gmtime(0)))
00044         parser.add_option("-F","--time-format",
00045                           help="Format for parsing time (see man date), " \
00046                               + "default is '%s'"%default_time_format \
00047                               + " ('[YYYY]-[MM]-[DD]T[HH]:[MM]:[SS]')",
00048                           default=default_time_format)
00049         parser.add_option("-T","--top-stage",
00050                           help="Kinematic, Detector, Electronic, TrigRead or SingleLoader",
00051                           default="SingleLoader")
00052         parser.add_option("-s","--seed",
00053                           help="Random seed for generators",
00054                           default=1234567)
00055 
00056 
00057         (options,args) = parser.parse_args(args=argv)
00058         self.opts = options
00059         self.args = args
00060 
00061         timeformat = self.opts.time_format
00062         print "Using time format =",timeformat
00063 
00064         try:
00065             datestring = self.opts.start_time
00066         except AttributeError:
00067             self.start_time_seconds = 0
00068         else:
00069             # This may raise ValueError if string and format don't
00070             # match.  Just let it get thrown.
00071             t = time.strptime(datestring,timeformat)
00072             self.start_time_seconds = time.mktime(t) - time.timezone
00073         print 'Start time in human readable format',self.opts.start_time 
00074         print 'Start time in seconds UTC =',self.start_time_seconds
00075         print 'Top stage =',self.opts.top_stage
00076 
00077         return
00078 
00079     def configureKinematic(self):
00080         #IBD
00081         from Gnrtr.IBD import EvtGenerator
00082         # from IBD import EvtGenerator
00083         ibd_gds = EvtGenerator(name     = 'IBD_gds',
00084                                seed     = self.opts.seed,
00085                                volume   = '/dd/Structure/AD/db-oil1',
00086                                strategy = 'Material',
00087                                material = 'GdDopedLS',
00088                                mode     = 'Uniform',
00089                                lifetime = 78.4*units.second, #daya bay site
00090                                wallTime = self.start_time_seconds)
00091 
00092         ibd_gds.ThisStageName = "Kinematic"
00093         self.stage_cfg.KinematicSequence.Members.append( ibd_gds )
00094 
00095         from Gnrtr.Radioact import Radioact
00096         #K40
00097         k40_gds = Radioact(name       = 'K40_gds',
00098                            volume     = '/dd/Structure/AD/db-oil1',
00099                            nuclide    = 'K40',
00100                            abundance  = 3.01e17,
00101                            strategy   = 'Material',
00102                            material   = 'GdDopedLS',
00103                            start_time = self.start_time_seconds)
00104 
00105         k40_gds.ThisStageName = "Kinematic"
00106         self.stage_cfg.KinematicSequence.Members.append( k40_gds )
00107         
00108         return
00109 
00110     def configureDetector(self):
00111         '''Configure the Detector stage'''
00112         
00113         import DetSim
00114         ds = DetSim.Configure(physlist=DetSim.physics_list_basic+DetSim.physics_list_nuclear,site="dayabay",
00115                               use_push_algs = False)
00116 
00117         # QuantumEfficiency*CollectionEfficiency*QEScale = 0.24*1/0.9
00118         from DetSim.DetSimConf import DsPhysConsOptical
00119         optical = DsPhysConsOptical()
00120         #optical.UseScintillation = False
00121         #optical.CerenPhotonScaleWeight = 3.5
00122         #optical.UseCerenkov = False
00123         #optical.ScintPhotonScaleWeight = 3.5
00124 
00125         from DetSimProc.DetSimProcConf import DetSimProc
00126         dsp = DetSimProc()
00127         dsp.ThisStageName = "Detector"
00128         dsp.LowerStageName = "Kinematic"
00129         #dsp.OutputLevel = 2
00130         self.stage_cfg.DetectorSequence.Members.append(dsp)
00131 
00132         ds.historian(trackSelection="(pdg == 2112)",vertexSelection="(pdg == 2112)")
00133         return
00134 
00135     def configureElectronic(self):
00136         '''Configure the Electronics stage'''
00137 
00138         import ElecSim
00139         es = ElecSim.Configure(use_push_algs = False)
00140 
00141         from ElecSimProc.ElecSimProcConf import ElecSimProc
00142         esp = ElecSimProc()
00143         esp.ThisStageName = "Electronic"
00144         esp.LowerStageName = "Detector"
00145         #esp.OutputLevel = 2
00146         self.stage_cfg.ElectronicSequence.Members.append(esp)
00147         # wangzhe
00148         from ElecSim.ElecSimConf import EsIdealFeeTool
00149         feetool = EsIdealFeeTool()
00150         feetool.EnableNonlinearity=False
00151         #feetool.OutputLevel = 2
00152         # wz
00153         return
00154 
00155     def configureTrigRead(self):
00156         '''Configure the Trigger and Readout stage'''
00157         from TrigReadProc.TrigReadProcConf import TrigReadProc
00158         tsp = TrigReadProc()
00159         tsp.ThisStageName = "TrigRead"
00160         tsp.LowerStageName = "Electronic"
00161         #tsp.TrigTools = [...]
00162         #tsp.RoTools = [...]
00163         #tsp.OutputLevel = 2
00164         self.stage_cfg.TrigReadSequence.Members.append(tsp)
00165         return
00166 
00167     def configureSingleLoader(self):
00168         '''Configure the SingleLoader stage'''
00169         from SingleLoader.SingleLoaderConf import SingleLoader
00170         sll = SingleLoader()
00171         sll.ThisStageName = "SingleLoader"
00172         sll.LowerStageName = "TrigRead"
00173         #sll.OutputLevel = 2
00174         self.stage_cfg.SingleLoaderSequence.Members.append(sll)
00175 
00176     def configureSim15(self):
00177         from Stage.StageConf import Sim15
00178         sim15=Sim15()
00179         # Run for a long time by default You can use "nuwa.py -n XXX"
00180         # to limit.  This is actually the default now:
00181         sim15.TimeRange = 365*24*60*60*units.second 
00182         sim15.TopStage=self.opts.top_stage
00183 
00184         from Gaudi.Configuration import ApplicationMgr
00185         theApp = ApplicationMgr()
00186         theApp.TopAlg.append(sim15)
00187 
00188     def configure(self):
00189 
00190         from Stage import Configure as StageConfigure
00191         self.stage_cfg = StageConfigure()
00192 
00193         stagedic={'Kinematic':1,'Detector':2,'Electronic':3,'TrigRead':4,'SingleLoader':5}
00194 
00195         if not self.opts.top_stage in stagedic:
00196             print 'Error, wrong top stage parameter', self.opts.top_stage
00197             print 'Valid stage is Kinematic, Detector, Electronic, TrigRead or SingleLoader'
00198 
00199         for stg,idx in stagedic.iteritems():
00200             if idx <= stagedic[self.opts.top_stage]:
00201                 self.stage_cfg.addStages([stg])           ## stage tools are configured here.
00202                 
00203         for stg in self.stage_cfg.stages:
00204             #self.stage_cfg.__dict__[stg].OutputLevel = 2
00205             pass
00206 
00207         if stagedic[self.opts.top_stage]>=1:
00208             self.configureKinematic()
00209         if stagedic[self.opts.top_stage]>=2:
00210             self.configureDetector()
00211         if stagedic[self.opts.top_stage]>=3:
00212             self.configureElectronic()
00213         if stagedic[self.opts.top_stage]>=4:
00214             self.configureTrigRead()
00215         if stagedic[self.opts.top_stage]>=5:
00216             self.configureSingleLoader()
00217 
00218         self.configureSim15()
00219         
00220         return
00221         
00222 def configure(argv=[]):
00223     cfc = ConfigureFullChain(argv)
00224     cfc.configure()
00225     return
00226 
00227 if __name__ == "__main__":
00228     configure()
00229     pass
00230 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:36:44 2011 for Sim15 by doxygen 1.4.7