def getInput_GenericCosmicGenerator(name="GenericCosmicGenerator", **kwargs): ## Configuring the Athena application for a 'generator' job from G4AtlasApps.SimFlags import simFlags simFlags.load_cosmics_flags() ## Set up standard algorithms and random seeds from AthenaCommon.AppMgr import ServiceMgr from PartPropSvc.PartPropSvcConf import PartPropSvc ServiceMgr += PartPropSvc() if not simFlags.RandomSeedList.checkForExistingSeed("COSMICS"): simFlags.RandomSeedList.addSeed("COSMICS", 2040160768, 443921183) kwargs.setdefault('AtRndmGenSvc', simFlags.RandomSvc.get_Value()) from CosmicGenerator.CosmicGeneratorConfig import CavernPropertyCalculator theCavern = CavernPropertyCalculator() ##-------------------------------------------------------------- ## CosmicGenerator parameters ##-------------------------------------------------------------- ## ## Note that in this coordinate frame the y-axis points upward ## such that the cosmics arrive from upward to downward in y. ## The production vertex of cosmics is randomly distributed (flat) ## in the x-z plane with boundaries given below. ## The energy range is given as well. ## ## The following settings are tuned to scintillators of dimensions ## 140 x 0.5 x 100 cm^3 placed at +-115.0 cm kwargs.setdefault('emin', theCavern.CosmicEmin()) kwargs.setdefault('emax', theCavern.CosmicEmax()) #kwargs.setdefault('emin', 10000) # default =10000 #10 GeV #kwargs.setdefault('emax', 5000*1000) # 2 TeV - FIXME?! kwargs.setdefault('xvert_low', theCavern.CosmicLowVertex_X()) kwargs.setdefault('xvert_hig', theCavern.CosmicHighVertex_X()) kwargs.setdefault('zvert_low', theCavern.CosmicLowVertex_Z()) kwargs.setdefault('zvert_hig', theCavern.CosmicHighVertex_Z()) kwargs.setdefault('Radius', theCavern.CosmicRadius()) kwargs.setdefault('yvert_val', 57300. + 41000.) kwargs.setdefault('ctcut', 0.) kwargs.setdefault('OptimizeForCavern', True) kwargs.setdefault('IPx', 0.) kwargs.setdefault('IPy', 0.) kwargs.setdefault('IPz', 0.) if simFlags.CosmicFilterVolumeName.statusOn: print('Using %s Volume setup of Cosmic Generator...' % simFlags.CosmicFilterVolumeName.get_Value()) #special settings from Juerg Beringer if simFlags.CosmicFilterVolumeName == "Pixel" or simFlags.CosmicFilterVolumeName2 == "Pixel": kwargs.setdefault( 'doPathLengthCut', True) # Optimization based on box cut in pixel detector plane kwargs.setdefault( 'energyCutThreshold', 100.) # - margin of error for energy loss calculation (in MeV) kwargs.setdefault( 'doAimedAtPixelsCut', True) # Optimization based on box cut in pixel detector plane kwargs.setdefault('pixelplane_maxx', 1150.) # - require |x| < value in mm kwargs.setdefault('pixelplane_maxz', 1650.) # - require |y| < value in mm kwargs.setdefault( 'doReweighting', True) # Whether to use reweighting for cosmic ray generation kwargs.setdefault( 'rvert_max', 300000.) # - radius in mm for generating primary vertex if simFlags.CosmicPtSlice.statusOn and simFlags.CosmicPtSlice( ) is not 'NONE': print("Configuring cosmic pT slice: %s" % simFlags.CosmicPtSlice.get_Value()) theCavern.reconfigureCavernGeometry() from AthenaCommon import CfgMgr algorithm = CfgMgr.CosmicGenerator(**kwargs) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() if not hasattr(topSequence, 'CosmicGenerator'): topSequence += algorithm return algorithm
setInputEvgenFileJobProperties(runArgs.inputEVNTFile) elif hasattr(runArgs, "inputEVNT_TRFile"): setInputEvgenFileJobProperties(runArgs.inputEVNT_TRFile) elif jobproperties.Beam.beamType.get_Value() == 'cosmics': atlasG4log.debug( 'No inputEVNTFile provided. OK, as performing cosmics simulation.') athenaCommonFlags.PoolEvgenInput.set_Off() else: atlasG4log.info( 'No inputEVNTFile provided. Assuming that you are running a generator on the fly.' ) athenaCommonFlags.PoolEvgenInput.set_Off() ## Handle cosmics configs if jobproperties.Beam.beamType.get_Value() == 'cosmics': simFlags.load_cosmics_flags() if hasattr(runArgs, "inputEVNT_TRFile"): if simFlags.CosmicFilterVolumeName.statusOn and simFlags.CosmicFilterVolumeName.get_Value( ) != "Muon": atlasG4log.warning( "Filtering was already done. Using CosmicFilterVolumeName=Muon rather than " "provided value (%s)" % str(runArgs.CosmicFilterVolumeName)) simFlags.CosmicFilterVolumeName = "Muon" else: simFlags.CosmicFilterVolumeName = getattr(runArgs, "CosmicFilterVolume", "InnerDetector") simFlags.CosmicFilterVolumeName2 = getattr(runArgs, "CosmicFilterVolume2", "NONE") simFlags.CosmicPtSlice = getattr(runArgs, "CosmicPtSlice", "NONE")
def _do_jobproperties(self): """ Place to handle JobProperties. """ ## Import extra flags if it hasn't already been done from G4AtlasApps.SimFlags import simFlags if "atlas_flags" not in simFlags.extra_flags: simFlags.load_atlas_flags() if jobproperties.Beam.beamType( ) == "cosmics" and "cosmics_flags" not in simFlags.extra_flags: simFlags.load_cosmics_flags() AtlasG4Eng.G4Eng.log.verbose( 'AtlasSimSkeleton._do_jobproperties :: starting') ## Tidy up DBM DetFlags: temporary measure DetFlags.DBM_setOff() from AtlasGeoModel.MuonGMJobProperties import MuonGeometryFlags if not MuonGeometryFlags.hasCSC(): DetFlags.CSC_setOff() if not MuonGeometryFlags.hasSTGC(): DetFlags.sTGC_setOff() if not MuonGeometryFlags.hasMM(): DetFlags.Micromegas_setOff() ## Switch off tasks DetFlags.pileup.all_setOff() DetFlags.simulateLVL1.all_setOff() DetFlags.digitize.all_setOff() if not simFlags.IsEventOverlayInputSim(): DetFlags.overlay.all_setOff() DetFlags.readRDOPool.all_setOff() DetFlags.makeRIO.all_setOff() DetFlags.writeBS.all_setOff() DetFlags.readRDOBS.all_setOff() DetFlags.readRIOBS.all_setOff() DetFlags.readRIOPool.all_setOff() DetFlags.writeRIOPool.all_setOff() DetFlags.writeRDOPool.all_setOff() ## Global flags needed by externals from AthenaCommon.GlobalFlags import globalflags globalflags.DataSource = 'geant4' if jobproperties.Beam.beamType() == 'cosmics': globalflags.DetGeo = 'commis' else: globalflags.DetGeo = 'atlas' ## At this point we can set the global job properties flag globalflags.DetDescrVersion = simFlags.SimLayout.get_Value() # Switch off GeoModel Release in the case of parameterization if simFlags.LArParameterization.get_Value( ) > 0 and simFlags.ReleaseGeoModel(): AtlasG4Eng.G4Eng.log.info( 'AtlasSimSkeleton._do_jobproperties :: Running parameterization - switching off GeoModel release!' ) simFlags.ReleaseGeoModel = False ## Translate conditions tag into IOVDbSvc global tag: must be done before job properties are locked!!! from AthenaCommon.AppMgr import ServiceMgr from IOVDbSvc.IOVDbSvcConf import IOVDbSvc ServiceMgr += IOVDbSvc() if not hasattr( globalflags, "ConditionsTag") or not globalflags.ConditionsTag.get_Value(): msg = "AtlasSimSkeleton._do_jobproperties :: conditions tag has not been set and is no longer guessed by SimAtlasKernel. " msg += "You must set the globaltags.ConditionsTag flag in your job options." AtlasG4Eng.G4Eng.log.error(msg) raise SystemExit( "AtlasSimSkeleton._do_jobproperties :: Global ConditionsTag not set" ) if not hasattr(ServiceMgr.IOVDbSvc, 'GlobalTag') or not ServiceMgr.IOVDbSvc.GlobalTag: ServiceMgr.IOVDbSvc.GlobalTag = globalflags.ConditionsTag.get_Value( ) ## Enable floating point exception handling ## FIXME! This seems to cause the jobs to crash in the FpeControlSvc, so commenting this out for now... #from AthenaCommon.AthenaCommonFlags import athenaCommonFlags #athenaCommonFlags.RuntimeStrictness = 'abort' #AtlasG4Eng.G4Eng.log.debug('AtlasSimSkeleton._do_jobproperties :: Enabled floating point exceptions') if not simFlags.ISFRun: from G4AtlasApps.G4Atlas_Metadata import checkForSpecialConfigurationMetadata checkForSpecialConfigurationMetadata() ## Print flags if AtlasG4Eng.G4Eng.log.getEffectiveLevel() < 40: AtlasG4Eng.G4Eng.log.info( 'AtlasSimSkeleton._do_jobproperties :: printing detector flags DetFlags' ) DetFlags.Print() AtlasG4Eng.G4Eng.log.info( 'AtlasSimSkeleton._do_jobproperties :: printing simulation flags simFlags' ) jobproperties.print_JobProperties('tree&value') # Lock the job properties if not running ISF. if not simFlags.ISFRun: jobproperties.lock_JobProperties() AtlasG4Eng.G4Eng.log.verbose( 'AtlasSimSkeleton._do_jobproperties :: done')