from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc", detectors=['file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', 'file:Detector/DetCommon/compact/TrackerAir.xml']) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4FastSimPhysicsList, SimG4FastSimActions, SimG4ParticleSmearRootFile from GaudiKernel.SystemOfUnits import GeV # create particle smearing tool, used for smearing in the tracker smeartool = SimG4ParticleSmearRootFile("Smear", detectorNames=["TrackerEnvelopeBarrel"], filename="/afs/cern.ch/exp/fcc/sw/0.7/testsamples/tkLayout_example_resolutions.root", minP = 5*GeV, maxP = 1000*GeV, maxEta=6) # create actions initialization tool actionstool = SimG4FastSimActions("Actions", smearing=smeartool) # create overlay on top of FTFP_BERT physics list, attaching fast sim/parametrization process physicslisttool = SimG4FastSimPhysicsList("Physics", fullphysics="SimG4FtfpBert") # attach those tools to the G4 service geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist=physicslisttool, actions=actionstool) # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveSmearedParticles, SimG4PrimariesFromEdmTool # first, create a tool that saves the smeared particles # Name of that tool in GAUDI is "XX/YY" where XX is the tool class name ("SimG4SaveSmearedParticles") # and YY is the given name ("saveSmearedParticles") saveparticlestool = SimG4SaveSmearedParticles("saveSmearedParticles") saveparticlestool.DataOutputs.particles.Path = "smearedParticles" saveparticlestool.DataOutputs.particlesMCparticles.Path = "particleMCparticleAssociation" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") particle_converter.DataInputs.genParticles.Path = "allGenParticles" geantsim = SimG4Alg("SimG4Alg", outputs = ["SimG4SaveSmearedParticles/saveSmearedParticles"],
OutputLevel=INFO) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4UserLimitPhysicsList, SimG4UserLimitRegion from GaudiKernel.SystemOfUnits import mm ## create region and a parametrisation model, pass smearing tool regiontool = SimG4UserLimitRegion("limits", volumeNames=["TrackerEnvelopeBarrel"], maxStep=1 * mm) # create overlay on top of FTFP_BERT physics list, attaching fast sim/parametrization process physicslisttool = SimG4UserLimitPhysicsList("Physics", fullphysics="SimG4FtfpBert") # attach those tools to the G4 service geantservice = SimG4Svc("SimG4Svc", physicslist=physicslisttool, regions=[regiontool]) # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") particle_converter.genParticles.Path = "allGenParticles" geantsim = SimG4Alg("SimG4Alg", eventProvider=particle_converter) # PODIO algorithm from Configurables import PodioOutput out = PodioOutput("out", filename="out_geant_userLimits.root") out.outputCommands = ["keep *"] out.OutputLevel = DEBUG
actions.enableHistory = True # Magnetic field from Configurables import SimG4ConstantMagneticFieldTool if magnetic_field: field = SimG4ConstantMagneticFieldTool("bField", FieldOn=True, FieldZMax=20 * units.m, IntegratorStepper="ClassicalRK4") else: field = SimG4ConstantMagneticFieldTool("bField", FieldOn=False) from Configurables import SimG4Svc geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions=actions, magneticField=field) # range cut geantservice.g4PostInitCommands += ["/run/setCut 0.1 mm"] from Configurables import SimG4Alg, SimG4SingleParticleGeneratorTool, SimG4SaveTrackerHits, SimG4SaveParticleHistory savehisttool = SimG4SaveParticleHistory("saveHistory") savehisttool.mcParticles.Path = "SimParticles" savehisttool.genVertices.Path = "SimVertices" savetrackertool = SimG4SaveTrackerHits( "saveTrackerHits", readoutNames=["TrackerBarrelReadout", "TrackerEndcapReadout"]) savetrackertool.positionedTrackHits.Path = "TrackerPositionedHits"
# Parses the given xml file from Configurables import GeoSvc, SimG4SingleParticleGeneratorTool geoservice = GeoSvc( "GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', 'file:Detector/DetFCChhTrackerTkLayout/compact/Tracker.xml' ], OutputLevel=INFO) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc # giving the names of tools will initialize the tools of that type geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4GeantinoDeposits", actions="SimG4FullSimActions") geantservice.g4PostInitCommands += ["/tracking/storeTrajectory 1"] # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveTrackerHits, SimG4SaveTrajectory # first, create a tool that saves the tracker hits # Name of that tool in GAUDI is "XX/YY" where XX is the tool class name ("SimG4SaveTrackerHits") # and YY is the given name ("saveTrackerHits") savetrajectorytool = SimG4SaveTrajectory("saveTrajectory") savetrajectorytool.trajectory.Path = "trajectory" savetrajectorytool.trajectoryPoints.Path = "trajectoryPoints" savetrackertool = SimG4SaveTrackerHits( "saveTrackerHits",
physicslist = SimG4UserLimitPhysicsList("Physics", fullphysics="SimG4GeantinoPhysicsList") regions = [regiontool] #physicslist = SimG4GeantinoPhysicsList() #regions = [] else: from Configurables import SimG4UserLimitRegion, SimG4UserLimitPhysicsList regiontool = SimG4UserLimitRegion("limits", volumeNames=["world"], maxStep = 0.1*units.mm) physicslist = SimG4UserLimitPhysicsList("Physics", fullphysics="SimG4FtfpBert") regions = [regiontool] geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist=physicslist, regions=regions, actions=actions, magneticField=field) # range cut geantservice.g4PostInitCommands += ["/run/setCut 0.1 mm"] if simargs.trajectories: geantservice.g4PostInitCommands += ["/tracking/storeTrajectory 1"] from Configurables import SimG4Alg, SimG4SingleParticleGeneratorTool, SimG4SaveTrackerHits, SimG4SaveParticleHistory outputHitsTools = [] if simargs.trajectories: from Configurables import SimG4SaveTrajectory savetrajectorytool = SimG4SaveTrajectory("saveTrajectory") savetrajectorytool.trajectory.Path = "trajectory" savetrajectorytool.trajectoryPoints.Path = "trajectoryPoints" outputHitsTools += [ "SimG4SaveTrajectory/saveTrajectory"]
from Configurables import HepMCDumper hepmc_dump = HepMCDumper("hepmc") hepmc_dump.hepmc.Path = "hepmc" from Configurables import GeoSvc geoservice = GeoSvc( "GeoSvc", detectors=['file:Test/TestGeometry/data/TestBoxCaloSD_volumes.xml']) from Configurables import SimG4Svc geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist='SimG4TestPhysicsList', actions='SimG4FullSimActions') from Configurables import SimG4Alg, SimG4SaveCalHits savecaltool = SimG4SaveCalHits("saveECalHits", readoutNames=["ECalHits"]) savecaltool.positionedCaloHits.Path = "positionedCaloHits" savecaltool.caloHits.Path = "caloHits" geantsim = SimG4Alg("SimG4Alg", outputs=["SimG4SaveCalHits/saveECalHits"]) from Configurables import FCCDataSvc, PodioOutput podiosvc = FCCDataSvc("EventDataSvc") out = PodioOutput("out", filename="testCellId_dd4hep_volumes.root") out.outputCommands = ["keep *"]
'file:../../../Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', 'file:../../../Detector/DetCommon/compact/TrackerAir.xml' ]) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4FastSimPhysicsList, SimG4FastSimTrackerRegion ## create region and a parametrisation model with a default smearing (sigma=const=0.01) regiontool = SimG4FastSimTrackerRegion("model", volumeNames=["TrackerEnvelopeBarrel"]) # create overlay on top of FTFP_BERT physics list, attaching fast sim/parametrization process physicslisttool = SimG4FastSimPhysicsList("Physics", fullphysics="SimG4FtfpBert") # attach those tools to the G4 service geantservice = SimG4Svc("SimG4Svc", physicslist=physicslisttool, regions=["SimG4FastSimTrackerRegion/model"]) # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveSmearedParticles, SimG4PrimariesFromEdmTool # first, create a tool that saves the smeared particles # Name of that tool in GAUDI is "XX/YY" where XX is the tool class name ("SimG4SaveSmearedParticles") # and YY is the given name ("saveSmearedParticles") saveparticlestool = SimG4SaveSmearedParticles("saveSmearedParticles") saveparticlestool.DataOutputs.particlesMCparticles.Path = "particleMCparticleAssociation" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") particle_converter.DataInputs.genParticles.Path = "allGenParticles" geantsim = SimG4Alg("SimG4Alg", outputs=["SimG4SaveSmearedParticles/saveSmearedParticles"],
reader.hepmc.Path = "hepmc" from Configurables import HepMCToEDMConverter hepmc_converter = HepMCToEDMConverter("Converter") hepmc_converter.hepmc.Path="hepmc" hepmc_converter.genparticles.Path="allGenParticles" hepmc_converter.genvertices.Path="allGenVertices" dumper = HepMCDumper("Dumper") dumper.hepmc.Path="hepmc" from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc", detectors=['file:Test/TestGeometry/data/TestBoxCaloSD_3readouts.xml'], OutputLevel = INFO) from Configurables import SimG4Svc geantservice = SimG4Svc("SimG4Svc", physicslist='SimG4TestPhysicsList') from Configurables import SimG4Alg, SimG4SaveCalHits, InspectHitsCollectionsTool inspecttool = InspectHitsCollectionsTool("inspect", readoutNames=["ECalHits"], OutputLevel = DEBUG) savecaltool = SimG4SaveCalHits("saveECalHits", readoutNames = ["ECalHits"], OutputLevel = DEBUG) savecaltool.positionedCaloHits.Path = "positionedCaloHits" savecaltool.caloHits.Path = "caloHits" geantsim = SimG4Alg("SimG4Alg", outputs= ["SimG4SaveCalHits/saveECalHits","InspectHitsCollectionsTool/inspect"]) from Configurables import RedoSegmentation resegment = RedoSegmentation("ReSegmentation", # old bitfield (readout) oldReadoutName = "ECalHits", # specify which fields are going to be deleted oldSegmentationIds = ["x","y","z"], # new bitfield (readout), with new segmentation
from Gaudi.Configuration import * from Configurables import GeoSvc, SimG4Svc, ApplicationMgr # initialize master geometry of FCC-hh geoservice = GeoSvc( "GeoSvc", detectors=['file:Detector/DetFCChhBaseline1/compact/FCChh_DectMaster.xml']) # giving the names of tools will initialize the tools of that type # adding G4 command that actually runs the overlap check geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions="SimG4FullSimActions", g4PostInitCommands=[ '/geometry/test/recursion_depth 2', '/geometry/test/run' ]) ApplicationMgr(TopAlg=[], EvtSel='NONE', EvtMax=1, ExtSvc=[geoservice, geantservice])
from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc", detectors=['file:share/compact/DRcalo.xml']) from Configurables import SimG4Svc, SimG4FastSimPhysicsList, SimG4FastSimOpFiberRegion, SimG4OpticalPhysicsList regionTool = SimG4FastSimOpFiberRegion("fastfiber") opticalPhysicsTool = SimG4OpticalPhysicsList("opticalPhysics", fullphysics="SimG4FtfpBert") physicslistTool = SimG4FastSimPhysicsList("Physics", fullphysics=opticalPhysicsTool) from Configurables import SimG4DRcaloActions actionTool = SimG4DRcaloActions("SimG4DRcaloActions") # Name of the tool in GAUDI is "XX/YY" where XX is the tool class name and YY is the given name geantservice = SimG4Svc("SimG4Svc", physicslist=physicslistTool, regions=["SimG4FastSimOpFiberRegion/fastfiber"], actions=actionTool) from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") edmConverter = SimG4PrimariesFromEdmTool("EdmConverter") from Configurables import SimG4SaveDRcaloHits, SimG4SaveDRcaloMCTruth saveDRcaloTool = SimG4SaveDRcaloHits("saveDRcaloTool", readoutNames=["DRcaloSiPMreadout"]) saveMCTruthTool = SimG4SaveDRcaloMCTruth( "saveMCTruthTool") # need SimG4DRcaloActions geantsim = SimG4Alg("SimG4Alg", outputs=[ "SimG4SaveDRcaloHits/saveDRcaloTool",
# DD4hep geometry service # Parses the given xml file from Configurables import GeoSvc geoservice = GeoSvc( "GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', 'file:Detector/DetFCChhTrackerTkLayout/compact/Tracker.xml' ], OutputLevel=INFO) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc # giving the names of tools will initialize the tools of that type geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions="SimG4FullSimActions", InteractiveMode="true") from Configurables import ApplicationMgr ApplicationMgr( TopAlg=[], EvtSel='NONE', EvtMax=1, # order is important, as GeoSvc is needed by SimG4Svc ExtSvc=[geoservice, geantservice], OutputLevel=DEBUG)
OutputLevel=INFO) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4UserLimitPhysicsList, SimG4UserLimitRegion from GaudiKernel.SystemOfUnits import mm ## create region and a parametrisation model, pass smearing tool regiontool = SimG4UserLimitRegion("limits", volumeNames=["TrackerEnvelopeBarrel"], maxStep=1 * mm) # create overlay on top of FTFP_BERT physics list, attaching fast sim/parametrization process physicslisttool = SimG4UserLimitPhysicsList("Physics", fullphysics="SimG4FtfpBert") # attach those tools to the G4 service geantservice = SimG4Svc("SimG4Svc", physicslist=physicslisttool, regions=["SimG4UserLimitRegion/limits"]) # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4PrimariesFromEdmTool # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") particle_converter.genParticles.Path = "allGenParticles" geantsim = SimG4Alg("SimG4Alg", eventProvider=particle_converter) # PODIO algorithm from Configurables import PodioOutput out = PodioOutput("out", filename="out_limits.root") out.outputCommands = ["keep *"]
from Configurables import SimG4Svc, SimG4FastSimPhysicsList, SimG4ParticleSmearFormula, SimG4FastSimTrackerRegion, SimG4GflashSamplingCalo, SimG4FastSimCalorimeterRegion ## create particle smearing tool, used for smearing in the tracker smeartool = SimG4ParticleSmearFormula("smear", resolutionMomentum = "0.013") ## create region and a parametrisation model, pass smearing tool regiontooltracker = SimG4FastSimTrackerRegion("modelTracker", volumeNames=["TrackerEnvelopeBarrel"], smearing=smeartool) ## create parametrisation of the calorimeter gflash = SimG4GflashSamplingCalo("gflash", materialActive = "G4_lAr", materialPassive = "G4_Pb", thicknessActive = 4, thicknessPassive = 2) regiontoolcalo = SimG4FastSimCalorimeterRegion("modelCalo", volumeNames=["ECalBarrel"], parametrisation = gflash) ## create overlay on top of FTFP_BERT physics list, attaching fast sim/parametrization process physicslisttool = SimG4FastSimPhysicsList("Physics", fullphysics="SimG4FtfpBert") ## attach those tools to the G4 service geantservice = SimG4Svc("SimG4Svc", physicslist=physicslisttool, regions=[regiontooltracker, regiontoolcalo]) # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveSmearedParticles, SimG4SaveCalHits, SimG4PrimariesFromEdmTool # first, create a tool that saves the smeared particles # Name of that tool in GAUDI is "XX/YY" where XX is the tool class name ("SimG4SaveSmearedParticles") # and YY is the given name ("saveSmearedParticles") saveparticlestool = SimG4SaveSmearedParticles("saveSmearedParticles") saveparticlestool.particles.Path = "smearedParticles" saveparticlestool.particlesMCparticles.Path = "particleMCparticleAssociation" savecaltool = SimG4SaveCalHits("saveCalHits", readoutNames = ["ECalHitsPhiEta"]) savecaltool.positionedCaloHits.Path = "positionedCaloHits" savecaltool.caloHits.Path = "caloHits" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter")
from Configurables import SimG4SaveCalHits saveHcalEndcaptool = SimG4SaveCalHits("saveHcalEndcapHits") saveHcalEndcaptool.readoutNames = ["HCalEndcapCollection"] saveHcalEndcaptool.CaloHits.Path = "hits_HcalEndcap" SimG4Alg("SimG4Alg").outputs += [saveHcalEndcaptool] from Gaudi.Configuration import * from GaudiKernel import SystemOfUnits as units from GaudiKernel import PhysicalConstants as constants # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc # giving the names of tools will initialize the tools of that type geantservice = SimG4Svc("SimG4Svc") geantservice.detector = "SimG4DD4hepDetector" geantservice.physicslist = "SimG4FtfpBert" geantservice.actions = "SimG4FullSimActions" ApplicationMgr().ExtSvc += [geantservice] # Geant4 algorithm # save tools are set up alongside the geoservice from Configurables import SimG4Alg geantsim = SimG4Alg("SimG4Alg") from Configurables import SimG4SaveTrackerHits from Configurables import SimG4PrimariesFromEdmTool geantsim.eventProvider = SimG4PrimariesFromEdmTool("EdmConverter") geantsim.eventProvider.GenParticles.Path = "GenParticles" ApplicationMgr().TopAlg += [geantsim]
actions = SimG4ExampleB4Actions() from Configurables import SimG4ConstantMagneticFieldTool field = SimG4ConstantMagneticFieldTool("bField") field.FieldOn = True field.FieldZMax = 20 * units.m field.IntegratorStepper = "ClassicalRK4" from Configurables import SimG4ExampleB4Detector geant_detector_tool = SimG4ExampleB4Detector() from Configurables import SimG4FtfpBert geant_physics_list = SimG4FtfpBert("PhysicsList") from Configurables import SimG4Svc geantservice = SimG4Svc() geantservice.detector = geant_detector_tool geantservice.physicslist = geant_physics_list geantservice.actions = actions geantservice.magneticField = field # range cut geantservice.g4PostInitCommands += ["/run/setCut 0.1 mm"] ApplicationMgr().ExtSvc += [geantservice] from Configurables import SimG4PrimariesFromEdmTool particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") particle_converter.genParticles.Path = "GenParticles" from Configurables import SimG4Alg geantsim = SimG4Alg("SimG4Alg") geantsim.outputs = []
detectors=['file:..//data/Barrel_testCaloSD_rphiz.xml']) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4FastSimPhysicsList, SimG4GflashHomoCalo, SimG4FastSimCalorimeterRegion ## create parametrisation of the calorimeter gflash = SimG4GflashHomoCalo("gflash", material="G4_PbWO4") regiontoolcalo = SimG4FastSimCalorimeterRegion("modelCalo", volumeNames=["BarrelECal"], parametrisation=gflash) ## create overlay on top of FTFP_BERT physics list, attaching fast sim/parametrization process physicslisttool = SimG4FastSimPhysicsList("Physics", fullphysics="SimG4FtfpBert") ## attach those tools to the G4 service geantservice = SimG4Svc("SimG4Svc", physicslist=physicslisttool, regions=["SimG4FastSimCalorimeterRegion/modelCalo"]) # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveCalHits, SimG4PrimariesFromEdmTool savecaltool = SimG4SaveCalHits("saveCalHits", readoutNames=["ECalHits"]) savecaltool.DataOutputs.positionedCaloHits.Path = "positionedCaloHits" savecaltool.DataOutputs.caloHits.Path = "caloHits" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") particle_converter.DataInputs.genParticles.Path = "allGenParticles" geantsim = SimG4Alg("SimG4Alg", outputs=["SimG4SaveCalHits/saveCalHits"], eventProvider=particle_converter)
# Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4FullSimActions, SimG4UserLimitPhysicsList, SimG4UserLimitRegion from GaudiKernel.SystemOfUnits import mm regiontool = SimG4UserLimitRegion("limits", volumeNames=["world"], maxStep = 2*mm) physicslisttool = SimG4UserLimitPhysicsList("Physics", fullphysics="SimG4FtfpBert") actions = SimG4FullSimActions() actions.enableHistory=True # giving the names of tools will initialize the tools of that type geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist=physicslisttool, actions=actions, regions=[regiontool], magneticField=field, g4PostInitCommands=['/random/setSeeds 1234500 3456700'] ) #geantservice.g4PostInitCommands += ["/run/setCut 0.7 mm"] #geantservice.g4PostInitCommands +=["/process/eLoss/minKinEnergy 1 MeV"] #geantservice.g4PostInitCommands +=["/score/quantity/energyDeposit edep1kev"] geantservice.g4PostInitCommands += ["/tracking/storeTrajectory 1"] # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveTrackerHits, SimG4SaveCalHits, SimG4PrimariesFromEdmTool, SimG4SaveParticleHistory, SimG4SaveTrajectory # first, create a tool that saves the tracker hits # Name of that tool in GAUDI is "XX/YY" where XX is the tool class name ("SimG4SaveTrackerHits") # and YY is the given name ("saveTrackerHits")
# DD4hep geometry service from Configurables import GeoSvc geoservice = GeoSvc( "GeoSvc", detectors=[ 'file:Detector/DetFCChhBaseline1/compact/FCChh_DectEmptyMaster.xml', 'file:Detector/DetFCChhHCalTile/compact/FCChh_HCalBarrel_TileCal.xml' ], OutputLevel=INFO) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist="SimG4FtfpBert", actions="SimG4FullSimActions") # Magnetic field from Configurables import SimG4ConstantMagneticFieldTool if magnetic_field == 1: field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool", FieldOn=True, IntegratorStepper="ClassicalRK4") else: field = SimG4ConstantMagneticFieldTool("SimG4ConstantMagneticFieldTool", FieldOn=False) #Setting random seeds for Geant4 simulations #geantservice.g4PreInitCommands += ["/random/setSeeds "+str(x)+" 0"] #where x is the number you want
IntegratorStepper="ClassicalRK4", FieldComponentZ=0.000, MaximumStep=10000.0) # Geant4 service # Configures the Geant simulation: geometry, physics list and user actions from Configurables import SimG4Svc, SimG4UserLimitPhysicsList, SimG4UserLimitRegion, SimG4FullSimActions from GaudiKernel.SystemOfUnits import mm regiontool = SimG4UserLimitRegion("limits", volumeNames=["CDCH"], maxStep = 2*mm) physicslisttool = SimG4UserLimitPhysicsList("Physics", fullphysics="SimG4FtfpBert") actions = SimG4FullSimActions() actions.enableHistory=True geantservice = SimG4Svc("SimG4Svc", detector='SimG4DD4hepDetector', physicslist=physicslisttool, actions=actions, regions=["SimG4UserLimitRegion/limits"], magneticField=field) geantservice.g4PostInitCommands +=["/process/eLoss/minKinEnergy 1 MeV"] geantservice.g4PostInitCommands += ["/tracking/storeTrajectory 1"] # Geant4 algorithm # Translates EDM to G4Event, passes the event to G4, writes out outputs via tools from Configurables import SimG4Alg, SimG4SaveTrackerHits, SimG4SaveTrajectory, SimG4SaveParticleHistory # first, create a tool that saves the tracker hits # Name of that tool in GAUDI is "XX/YY" where XX is the tool class name ("SimG4SaveTrackerHits") # and YY is the given name ("saveTrackerHits") savetrajectorytool = SimG4SaveTrajectory("saveTrajectory") savetrajectorytool.trajectory.Path = "trajectory" savetrajectorytool.trajectoryPoints.Path = "trajectoryPoints"