timer = ROOT.TStopwatch() timer.Start() # ------------------------------------------------------------------------ # -----Create simulation run---------------------------------------- run = ROOT.FairRunSim() run.SetName(mcEngine) # Transport engine run.SetOutputFile(outFile) # Output file run.SetUserConfig("g4Config.C") # user configuration file default g4Config.C rtdb = run.GetRuntimeDb() # -----Create geometry---------------------------------------------- # import shipMuShield_only as shipDet_conf # special use case for an attempt to convert active shielding geometry for use with FLUKA # import shipTarget_only as shipDet_conf if charm != 0: import charmDet_conf as shipDet_conf else: import shipDet_conf modules = shipDet_conf.configure(run, ship_geo) # -----Create PrimaryGenerator-------------------------------------- primGen = ROOT.FairPrimaryGenerator() if simEngine == "Pythia8": primGen.SetTarget(ship_geo.target.z0, 0.) # -----Pythia8-------------------------------------- if HNL or RPVSUSY: P8gen = ROOT.HNLPythia8Generator() import pythia8_conf if HNL: print 'Generating HNL events of mass %.3f GeV' % theMass if theProductionCouplings is None and theDecayCouplings is None: print 'and with couplings=', theCouplings theProductionCouplings = theDecayCouplings = theCouplings elif theProductionCouplings is not None and theDecayCouplings is not None: print 'and with couplings', theProductionCouplings, 'at production'
for f in fnames: print "add ",f if options.onEOS: sTree.Add(os.environ['EOSSHIP']+f) else: sTree.Add(f) #-------------------------------geometry initialization from ShipGeoConfig import ConfigRegistry ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py", Setup = 1, cTarget = 3) builtin.ShipGeo = ShipGeo import charmDet_conf run = ROOT.FairRunSim() run.SetName("TGeant4") # Transport engine run.SetOutputFile(ROOT.TMemFile('output', 'recreate')) # Output file run.SetUserConfig("g4Config_basic.C") # geant4 transport not used, only needed for creating VMC field rtdb = run.GetRuntimeDb() modules = charmDet_conf.configure(run,ShipGeo) # -----Create geometry and draw display---------------------------------------------- run.Init() sGeo = ROOT.gGeoManager nav = sGeo.GetCurrentNavigator() top = sGeo.GetTopVolume() top.SetVisibility(0) if options.withDisplay: try: #building the EVE display instead of the simple root one allows to add new objects there (instead of a separate canvas) ROOT.TEveManager.Create() gEve = ROOT.gEve #TEve material for track drawing tracklist = ROOT.TEveTrackList() prop = tracklist.GetPropagator() prop.SetMaxZ(20000)
fgeo = ROOT.TFile.Open(options.geoFile) from ShipGeoConfig import ConfigRegistry from rootpyPickler import Unpickler #load Shipgeo dictionary upkl = Unpickler(fgeo) ShipGeo = upkl.load('ShipGeo') # -----Create geometry---------------------------------------------- import charmDet_conf run = ROOT.FairRunSim() run.SetName("TGeant4") # Transport engine run.SetOutputFile(ROOT.TMemFile('output', 'recreate')) # Output file run.SetUserConfig("g4Config_basic.C") # geant4 transport not used, only needed for the mag field rtdb = run.GetRuntimeDb() modules = charmDet_conf.configure(run,ShipGeo) fgeo.FAIRGeom # make global variables global_variables.debug = options.debug global_variables.ShipGeo = ShipGeo global_variables.iEvent = 0 # import reco tasks import MufluxDigi SHiP = MufluxDigi.MufluxDigi(outFile) nEvents = min(SHiP.sTree.GetEntries(),int(options.nEvents)) # main loop for global_variables.iEvent in range(firstEvent, nEvents):
# -----Timer-------------------------------------------------------- timer = ROOT.TStopwatch() timer.Start() # -----Create simulation run---------------------------------------- run = ROOT.FairRunSim() run.SetName(mcEngine) # Transport engine run.SetOutputFile(outFile) # Output file run.SetUserConfig("g4Config.C") # user configuration file default g4Config.C rtdb = run.GetRuntimeDb() # -----Materials---------------------------------------------- run.SetMaterials("media.geo") # -----Create geometry---------------------------------------------- import charmDet_conf as shipDet_conf modules = shipDet_conf.configure(run,ship_geo) # -----Create PrimaryGenerator-------------------------------------- primGen = ROOT.FairPrimaryGenerator() P8gen = ROOT.FixedTargetGenerator() if (ship_geo.MufluxSpectrometer.muflux==True): P8gen.SetTarget("/TargetArea_1",0.,0.) # will distribute PV inside target, beam offset x=y=0. else: P8gen.SetCharmTarget() #looks for charm target instead of SHiP standard target P8gen.SetTarget("volTarget_1",0.,0.) # will distribute PV inside target, beam offset x=y=0. if ship_geo.Box.gausbeam: primGen.SetBeam(0.,0., 0.5, 0.5) #more central beam, for hits in downstream detectors primGen.SmearGausVertexXY(True) #sigma = x else: primGen.SetBeam(0.,0., ship_geo.Box.TX-1., ship_geo.Box.TY-1.) #Uniform distribution in x/y on the target (0.5 cm of margin at both sides) primGen.SmearVertexXY(True)