if not deepCopy : fStack.SetEnergyCut(100.*u.MeV) if eventDisplay: # Set cuts for storing the trajectories, can only be done after initialization of run (?!) trajFilter = ROOT.FairTrajFilter.Instance() trajFilter.SetStepSizeCut(1*u.mm); trajFilter.SetVertexCut(-20*u.m, -20*u.m,ship_geo.target.z0-1*u.m, 20*u.m, 20*u.m, 200.*u.m) trajFilter.SetMomentumCutP(0.1*u.GeV) trajFilter.SetEnergyCut(0., 400.*u.GeV) trajFilter.SetStorePrimaries(ROOT.kTRUE) trajFilter.SetStoreSecondaries(ROOT.kTRUE) # manipulate G4 geometry to enable magnetic field in active shielding, VMC can't do it. if ship_geo.muShieldDesign != 1: import geomGeant4 geomGeant4.setMagnetField() # ('dump') for printout of mag fields if debug > 0: geomGeant4.printWeightsandFields() if inactivateMuonProcesses : mygMC = ROOT.TGeant4.GetMC() mygMC.ProcessGeantCommand("/process/inactivate muPairProd") mygMC.ProcessGeantCommand("/process/inactivate muBrems") mygMC.ProcessGeantCommand("/process/inactivate muIoni") mygMC.ProcessGeantCommand("/particle/select mu+") mygMC.ProcessGeantCommand("/particle/process/dump") import G4processes gProcessTable = G4processes.G4ProcessTable.GetProcessTable() procmu = gProcessTable.FindProcess('muIoni','mu+') procmu.SetVerboseLevel(2) # -----Start run---------------------------------------------------- run.Run(nEvents) # -----Runtime database--------------------------------------------- kParameterMerged = ROOT.kTRUE
# The VMC sets the fields using the "/mcDet/setIsLocalMagField true" option in "gconfig/g4config.in" import geomGeant4 # geomGeant4.setMagnetField() # replaced by VMC, only has effect if /mcDet/setIsLocalMagField false # Define extra VMC B fields not already set by the geometry definitions, e.g. a global field, # any field maps, or defining if any volumes feel only the local or local+global field. # For now, just keep the fields already defined by the C++ code, i.e comment out the fieldMaker if charm == 0: # charm and muflux testbeam not yet updated for using the new bfield interface if hasattr(ship_geo.Bfield, "fieldMap"): fieldMaker = geomGeant4.addVMCFields(ship_geo, '', True) # Print VMC fields and associated geometry objects if debug > 0: geomGeant4.printVMCFields() geomGeant4.printWeightsandFields(onlyWithField = True,\ exclude=['DecayVolume','Tr1','Tr2','Tr3','Tr4','Veto','Ecal','Hcal','MuonDetector','SplitCal']) # Plot the field example #fieldMaker.plotField(1, ROOT.TVector3(-9000.0, 6000.0, 50.0), ROOT.TVector3(-300.0, 300.0, 6.0), 'Bzx.png') #fieldMaker.plotField(2, ROOT.TVector3(-9000.0, 6000.0, 50.0), ROOT.TVector3(-400.0, 400.0, 6.0), 'Bzy.png') if inactivateMuonProcesses: ROOT.gROOT.ProcessLine('#include "Geant4/G4ProcessTable.hh"') mygMC = ROOT.TGeant4.GetMC() mygMC.ProcessGeantCommand("/process/inactivate muPairProd") mygMC.ProcessGeantCommand("/process/inactivate muBrems") mygMC.ProcessGeantCommand("/process/inactivate muIoni") mygMC.ProcessGeantCommand("/process/inactivate muonNuclear") mygMC.ProcessGeantCommand("/particle/select mu+") mygMC.ProcessGeantCommand("/particle/process/dump") gProcessTable = ROOT.G4ProcessTable.GetProcessTable() procmu = gProcessTable.FindProcess(ROOT.G4String('muIoni'),
fStack = ROOT.gMC.GetStack() if not deepCopy : fStack.SetEnergyCut(100.*u.MeV) if eventDisplay: # Set cuts for storing the trajectories, can only be done after initialization of run (?!) trajFilter = ROOT.FairTrajFilter.Instance() trajFilter.SetStepSizeCut(10*u.cm); trajFilter.SetVertexCut(-20*u.m, -20*u.m,ship_geo.target.z0-1*u.m, 20*u.m, 20*u.m, 200.*u.m) trajFilter.SetMomentumCutP(0.1*u.GeV) trajFilter.SetEnergyCut(0., 400.*u.GeV) trajFilter.SetStorePrimaries(ROOT.kTRUE) trajFilter.SetStoreSecondaries(ROOT.kTRUE) # manipulate G4 geometry to enable magnetic field in active shielding, VMC can't do it. if ship_geo.muShieldDesign != 1: import geomGeant4 geomGeant4.setMagnetField() # ('dump') for printout of mag fields geomGeant4.printWeightsandFields() if inactivateMuonProcesses : mygMC = ROOT.TGeant4.GetMC() mygMC.ProcessGeantCommand("/process/inactivate muPairProd") mygMC.ProcessGeantCommand("/process/inactivate muBrems") mygMC.ProcessGeantCommand("/process/inactivate muIoni") mygMC.ProcessGeantCommand("/particle/select mu+") mygMC.ProcessGeantCommand("/particle/process/dump") import G4processes gProcessTable = G4processes.G4ProcessTable.GetProcessTable() procmu = gProcessTable.FindProcess('muIoni','mu+') procmu.SetVerboseLevel(2) ## myTA = MyTrackingAction() # -----Start run----------------------------------------------------
trajFilter.SetEnergyCut(0., 400.*u.GeV) trajFilter.SetStorePrimaries(ROOT.kTRUE) trajFilter.SetStoreSecondaries(ROOT.kTRUE) # The VMC sets the fields using the "/mcDet/setIsLocalMagField true" option in "gconfig/g4config.in" import geomGeant4 # geomGeant4.setMagnetField() # replaced by VMC, only has effect if /mcDet/setIsLocalMagField false # Define extra VMC B fields not already set by the geometry definitions, e.g. a global field, # any field maps, or defining if any volumes feel only the local or local+global field. # For now, just keep the fields already defined by the C++ code, i.e comment out the fieldMaker #fieldMaker = geomGeant4.addVMCFields('field/ExampleBFieldSetup.txt', False) # Print VMC fields and associated geometry objects if debug > 0: geomGeant4.printVMCFields() geomGeant4.printWeightsandFields(onlyWithField = True,\ exclude=['DecayVolume','Tr1','Tr2','Tr3','Tr4','Veto','Ecal','Hcal','MuonDetector','SplitCal']) # Plot the field example #fieldMaker.plotField(1, ROOT.TVector3(-9000.0, 6000.0, 50.0), ROOT.TVector3(-300.0, 300.0, 6.0), 'Bzx.png') #fieldMaker.plotField(2, ROOT.TVector3(-9000.0, 6000.0, 50.0), ROOT.TVector3(-400.0, 400.0, 6.0), 'Bzy.png') if inactivateMuonProcesses : ROOT.gROOT.ProcessLine('#include "Geant4/G4ProcessTable.hh"') mygMC = ROOT.TGeant4.GetMC() mygMC.ProcessGeantCommand("/process/inactivate muPairProd") mygMC.ProcessGeantCommand("/process/inactivate muBrems") mygMC.ProcessGeantCommand("/process/inactivate muIoni") mygMC.ProcessGeantCommand("/particle/select mu+") mygMC.ProcessGeantCommand("/particle/process/dump") gProcessTable = ROOT.G4ProcessTable.GetProcessTable() procmu = gProcessTable.FindProcess(ROOT.G4String('muIoni'),ROOT.G4String('mu+')) procmu.SetVerboseLevel(2)
if eventDisplay: # Set cuts for storing the trajectories, can only be done after initialization of run (?!) trajFilter = ROOT.FairTrajFilter.Instance() trajFilter.SetStepSizeCut(1 * u.mm) trajFilter.SetVertexCut(-20 * u.m, -20 * u.m, ship_geo.target.z0 - 1 * u.m, 20 * u.m, 20 * u.m, 200. * u.m) trajFilter.SetMomentumCutP(0.1 * u.GeV) trajFilter.SetEnergyCut(0., 400. * u.GeV) trajFilter.SetStorePrimaries(ROOT.kTRUE) trajFilter.SetStoreSecondaries(ROOT.kTRUE) # manipulate G4 geometry to enable magnetic field in active shielding, VMC can't do it. if hasattr(ship_geo, "muShieldDesign"): if ship_geo.muShieldDesign != 1: import geomGeant4 geomGeant4.setMagnetField() # ('dump') for printout of mag fields if debug > 0: geomGeant4.printWeightsandFields() if inactivateMuonProcesses: mygMC = ROOT.TGeant4.GetMC() mygMC.ProcessGeantCommand("/process/inactivate muPairProd") mygMC.ProcessGeantCommand("/process/inactivate muBrems") mygMC.ProcessGeantCommand("/process/inactivate muIoni") mygMC.ProcessGeantCommand("/particle/select mu+") mygMC.ProcessGeantCommand("/particle/process/dump") import G4processes gProcessTable = G4processes.G4ProcessTable.GetProcessTable() procmu = gProcessTable.FindProcess('muIoni', 'mu+') procmu.SetVerboseLevel(2) # -----Start run---------------------------------------------------- run.Run(nEvents) # -----Runtime database--------------------------------------------- kParameterMerged = ROOT.kTRUE
if not deepCopy: fStack.SetEnergyCut(100. * u.MeV) if eventDisplay: # Set cuts for storing the trajectories, can only be done after initialization of run (?!) trajFilter = ROOT.FairTrajFilter.Instance() trajFilter.SetStepSizeCut(10 * u.cm) trajFilter.SetVertexCut(-20 * u.m, -20 * u.m, ship_geo.target.z0 - 1 * u.m, 20 * u.m, 20 * u.m, 200. * u.m) trajFilter.SetMomentumCutP(0.1 * u.GeV) trajFilter.SetEnergyCut(0., 400. * u.GeV) trajFilter.SetStorePrimaries(ROOT.kTRUE) trajFilter.SetStoreSecondaries(ROOT.kTRUE) # manipulate G4 geometry to enable magnetic field in active shielding, VMC can't do it. if ship_geo.muShieldDesign != 1: import geomGeant4 geomGeant4.setMagnetField() # ('dump') for printout of mag fields geomGeant4.printWeightsandFields() if inactivateMuonProcesses: mygMC = ROOT.TGeant4.GetMC() mygMC.ProcessGeantCommand("/process/inactivate muPairProd") mygMC.ProcessGeantCommand("/process/inactivate muBrems") mygMC.ProcessGeantCommand("/process/inactivate muIoni") mygMC.ProcessGeantCommand("/particle/select mu+") mygMC.ProcessGeantCommand("/particle/process/dump") import G4processes gProcessTable = G4processes.G4ProcessTable.GetProcessTable() procmu = gProcessTable.FindProcess('muIoni', 'mu+') procmu.SetVerboseLevel(2) ## myTA = MyTrackingAction() # -----Start run----------------------------------------------------