Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • andesai/calypso
  • sazhang/calypso
  • yuxu/calypso
  • wfilali/calypso
  • bewilson/calypso
  • ovaldesm/calypso
  • xai/calypso
  • ymaruya/calypso
  • anburger/calypso
  • seley/calypso
  • sudatta/calypso
  • notarann/calypso
  • hhjelm/calypso
  • tarai/calypso
  • lmccoy/calypso
  • agarabag/calypso
  • fneuhaus/calypso
  • vlian/calypso
  • yechou/calypso
  • vlian/calypso-official
  • fasermc/calypso
  • schsu/calypso
  • maprim/calypso
  • cantel/calypso
  • jwspence/calypso
  • diwang/calypso
  • ccavanag/calypso
  • gwilliam/calypso
  • asalman/calypso
  • toinada/calypso
  • jboyd/calypso
  • abarkley/calypso
  • yafik/calypso
  • cpandini/calypso
  • tboeckh/calypso
  • sshively/calypso
  • keli/calypso
  • dfellers/calypso
  • torrence/calypso
  • coccaro/calypso
  • dcasper/calypso
  • faser/calypso
42 results
Show changes
Showing
with 1038 additions and 531 deletions
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
from PyUtils.MetaReader import read_metadata
from AthenaCommon.Logging import logging
from functools import lru_cache
......
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
from AthenaConfiguration.AthConfigFlags import AthConfigFlags
from CalypsoConfiguration.AutoConfigFlags import DetDescrInfo, getDefaultDetectors
from CalypsoConfiguration.AutoConfigFlags import getDefaultDetectors
# This module is based upon Control/AthenaCommon/python/DetFlags.py
# Only some flags have been migrated.
......@@ -124,7 +124,7 @@ def _parseDetectorsList(flags, detectors):
return detectors
def setupDetectorsFromList(flags, detectors, toggle_geometry=False, validate_only=False):
def setupDetectorsFromList(flags, detectors = allDetectors, toggle_geometry=False, validate_only=False):
"""Setup (toggle) detectors from a pre-defined list"""
changed = False
# setup logging
......@@ -144,7 +144,7 @@ def setupDetectorsFromList(flags, detectors, toggle_geometry=False, validate_onl
status = d in detectors
name = f'Detector.Enable{d}'
if flags.hasFlag(name):
if flags(name) != status:
if flags[name] != status:
changed = True
if validate_only:
log.warning("Flag '%s' should be %s but is set to %s", name, status, not status)
......@@ -154,7 +154,7 @@ def setupDetectorsFromList(flags, detectors, toggle_geometry=False, validate_onl
if toggle_geometry:
name = f'Detector.Geometry{d}'
if flags.hasFlag(name):
if flags(name) != status:
if flags[name] != status:
changed = True
if validate_only:
log.warning("Flag '%s' should be %s but is set to %s", name, status, not status)
......@@ -180,14 +180,14 @@ def enableDetectors(flags, detectors, toggle_geometry=False):
for d in detectors:
name = f'Detector.Enable{d}'
if flags.hasFlag(name):
if flags(name) is not True:
if flags[name] is not True:
changed = True
log.info("Enabling '%s'", name)
flags._set(name, True)
if toggle_geometry:
name = f'Detector.Geometry{d}'
if flags.hasFlag(name):
if flags(name) is not True:
if flags[name] is not True:
changed = True
log.info("Enabling '%s'", name)
flags._set(name, True)
......@@ -211,14 +211,14 @@ def disableDetectors(flags, detectors, toggle_geometry=False):
for d in detectors:
name = f'Detector.Enable{d}'
if flags.hasFlag(name):
if flags(name) is not False:
if flags[name] is not False:
changed = True
log.info("Disabling '%s'", name)
flags._set(name, False)
if toggle_geometry:
name = f'Detector.Geometry{d}'
if flags.hasFlag(name):
if flags(name) is not False:
if flags[name] is not False:
changed = True
log.info("Disabling '%s'", name)
flags._set(name, False)
......
......@@ -18,6 +18,7 @@ def createGeoModelConfigFlags():
def modifyGeoModelConfigFlags(flags):
# print("modifyGeoModelConfigFlags called for FaserVersion: ", flags.GeoModel.FaserVersion)
flags.GeoModel.Run = lambda prevFlags : DetDescrInfo(prevFlags.GeoModel.FaserVersion)['Common']['Run']
flags.GeoModel.Align.Dynamic = False
# print(DetDescrInfo(flags.GeoModel.FaserVersion)['Common']['Run'])
return flags
\ No newline at end of file
#!/usr/bin/env python
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
from CalypsoConfiguration.DetectorConfigFlags import setupDetectorsFromList, enableDetectors, disableDetectors
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
from CalypsoConfiguration.DetectorConfigFlags import setupDetectorsFromList #, enableDetectors, disableDetectors
ConfigFlags._loadDynaFlags('GeoModel')
ConfigFlags._loadDynaFlags('Detector')
configFlags = initConfigFlags()
configFlags._loadDynaFlags('GeoModel')
configFlags._loadDynaFlags('Detector')
test_tags = [
'FASER-00',
'FASER-01' # example
]
flags_runs = {t: ConfigFlags.clone() for t in test_tags}
flags_runs = {t: configFlags.clone() for t in test_tags}
for tag in test_tags:
flags = flags_runs[tag]
......
......@@ -9,7 +9,8 @@ atlas_subdir( Digitization )
atlas_install_scripts( scripts/*.sh scripts/*.py )
atlas_add_test( ProdDigi
SCRIPT scripts/faser_digi.py ${CMAKE_CURRENT_SOURCE_DIR}/../rawdata/FaserMC-MC22_PG_muon_fasernu_100GeV-100012-00000-HITS.root
PROPERTIES TIMEOUT 300 )
SCRIPT scripts/faser_digi.py ${CMAKE_CURRENT_SOURCE_DIR}/../rawdata/FaserMC-MC24_PG_muon_fasernu_100GeV-100012-00000-HITS.root
POST_EXEC_SCRIPT nopost.sh
PROPERTIES TIMEOUT 300 )
......@@ -55,33 +55,34 @@ from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = True # Needed to bypass autoconfig
ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
configFlags = initConfigFlags()
configFlags.Input.isMC = True # Needed to bypass autoconfig
configFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
ConfigFlags.Input.ProjectName = "mc20"
ConfigFlags.GeoModel.Align.Dynamic = False
ConfigFlags.Beam.NumberOfCollisions = 0.
ConfigFlags.Digitization.TruthOutput = True
configFlags.Input.ProjectName = "mc20"
#configFlags.GeoModel.Align.Dynamic = False
configFlags.Beam.NumberOfCollisions = 0.
configFlags.Digitization.TruthOutput = True
# TI12 old geometry
if runtype == "TI12OldMC":
ConfigFlags.GeoModel.FaserVersion = "FASER-01"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
configFlags.GeoModel.FaserVersion = "FASER-01"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
# Testbeam setup
elif runtype == "TestBeamMC" :
ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00"
configFlags.GeoModel.FaserVersion = "FASER-TB00"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00"
# New TI12 geometry (ugh)
elif runtype == "TI12MC":
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
configFlags.GeoModel.FaserVersion = "FASERNU-03"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
else:
print("Invalid run type found:", runtype)
......@@ -89,7 +90,7 @@ else:
sys.exit(-1)
# Must use original input string here, as pathlib mangles double // in path names
ConfigFlags.Input.Files = [ args.file_path ]
configFlags.Input.Files = [ args.file_path ]
filestem = filepath.stem
# Remove any filetype modifier
......@@ -103,12 +104,12 @@ if len(args.tag) > 0:
else:
filestem += f"-{args.tag}"
ConfigFlags.Output.RDOFileName = f"{filestem}-RDO.root"
configFlags.Output.RDOFileName = f"{filestem}-RDO.root"
#
# Play around with this?
# ConfigFlags.Concurrency.NumThreads = 2
# ConfigFlags.Concurrency.NumConcurrentEvents = 2
ConfigFlags.lock()
# configFlags.Concurrency.NumThreads = 2
# configFlags.Concurrency.NumConcurrentEvents = 2
configFlags.lock()
#
# Configure components
......@@ -116,33 +117,33 @@ from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
acc.merge(PoolWriteCfg(ConfigFlags))
acc = MainServicesCfg(configFlags)
acc.merge(PoolReadCfg(configFlags))
acc.merge(PoolWriteCfg(configFlags))
#
# Needed, or move to MainServicesCfg?
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
acc.merge(FaserGeometryCfg(ConfigFlags))
acc.merge(FaserGeometryCfg(configFlags))
# Set up algorithms
from FaserSCT_Digitization.FaserSCT_DigitizationConfigNew import FaserSCT_DigitizationCfg
acc.merge(FaserSCT_DigitizationCfg(ConfigFlags))
acc.merge(FaserSCT_DigitizationCfg(configFlags))
from CaloDigiAlgs.CaloDigiAlgsConfig import CaloWaveformDigitizationCfg
if args.highCaloGain:
calo_norm = 25.
else:
calo_norm = 5.
acc.merge(CaloWaveformDigitizationCfg(ConfigFlags, CB_norm=calo_norm))
acc.merge(CaloWaveformDigitizationCfg(configFlags, CB_norm=calo_norm))
from ScintDigiAlgs.ScintDigiAlgsConfig import ScintWaveformDigitizationCfg
acc.merge(ScintWaveformDigitizationCfg(ConfigFlags))
acc.merge(ScintWaveformDigitizationCfg(configFlags))
# Configure verbosity
if args.verbose:
acc.foreach_component("*").OutputLevel = VERBOSE
ConfigFlags.dump()
configFlags.dump()
else:
acc.foreach_component("*").OutputLevel = INFO
......
......@@ -128,33 +128,34 @@ from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = True # Needed to bypass autoconfig
ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
configFlags = initConfigFlags()
configFlags.Input.isMC = True # Needed to bypass autoconfig
configFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
ConfigFlags.Input.ProjectName = "mc20"
ConfigFlags.GeoModel.Align.Dynamic = False
ConfigFlags.Beam.NumberOfCollisions = 0.
ConfigFlags.Digitization.TruthOutput = True
configFlags.Input.ProjectName = "mc20"
#configFlags.GeoModel.Align.Dynamic = False
configFlags.Beam.NumberOfCollisions = 0.
configFlags.Digitization.TruthOutput = True
# TI12 old geometry
if runtype == "TI12OldMC":
ConfigFlags.GeoModel.FaserVersion = "FASER-01"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
configFlags.GeoModel.FaserVersion = "FASER-01"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
# Testbeam setup
elif runtype == "TestBeamMC" :
ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00"
configFlags.GeoModel.FaserVersion = "FASER-TB00"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00"
# New TI12 geometry (ugh)
elif runtype == "TI12MC":
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
configFlags.GeoModel.FaserVersion = "FASERNU-03"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
else:
print("Invalid run type found:", runtype)
......@@ -163,14 +164,14 @@ else:
# Try just passing the filelist
ConfigFlags.Input.Files = [str(file) for file in filelist]
ConfigFlags.Output.RDOFileName = outfile
configFlags.Input.Files = [str(file) for file in filelist]
configFlags.Output.RDOFileName = outfile
#
# Play around with this?
# ConfigFlags.Concurrency.NumThreads = 2
# ConfigFlags.Concurrency.NumConcurrentEvents = 2
ConfigFlags.lock()
# configFlags.Concurrency.NumThreads = 2
# configFlags.Concurrency.NumConcurrentEvents = 2
configFlags.lock()
#
# Configure components
......@@ -178,33 +179,33 @@ from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
acc.merge(PoolWriteCfg(ConfigFlags))
acc = MainServicesCfg(configFlags)
acc.merge(PoolReadCfg(configFlags))
acc.merge(PoolWriteCfg(configFlags))
#
# Needed, or move to MainServicesCfg?
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
acc.merge(FaserGeometryCfg(ConfigFlags))
acc.merge(FaserGeometryCfg(configFlags))
# Set up algorithms
from FaserSCT_Digitization.FaserSCT_DigitizationConfigNew import FaserSCT_DigitizationCfg
acc.merge(FaserSCT_DigitizationCfg(ConfigFlags))
acc.merge(FaserSCT_DigitizationCfg(configFlags))
from CaloDigiAlgs.CaloDigiAlgsConfig import CaloWaveformDigitizationCfg
if args.highCaloGain:
calo_norm = 25.
else:
calo_norm = 5.
acc.merge(CaloWaveformDigitizationCfg(ConfigFlags, CB_norm=calo_norm))
acc.merge(CaloWaveformDigitizationCfg(configFlags, CB_norm=calo_norm))
from ScintDigiAlgs.ScintDigiAlgsConfig import ScintWaveformDigitizationCfg
acc.merge(ScintWaveformDigitizationCfg(ConfigFlags))
acc.merge(ScintWaveformDigitizationCfg(configFlags))
# Configure verbosity
if args.verbose:
acc.foreach_component("*").OutputLevel = VERBOSE
ConfigFlags.dump()
configFlags.dump()
else:
acc.foreach_component("*").OutputLevel = INFO
......
......@@ -27,6 +27,8 @@ parser.add_argument("-t", "--tag", default="",
help="Specify digi tag (to append to output filename)")
parser.add_argument("--subtractTime", type=float, default=-999.,
help="Subtract time parameter for SCT RDOs")
parser.add_argument("--simpleTiming", action="store_true",
help="Use simple waveform time digitization")
parser.add_argument("--digiTag", default="",
help="Specify tag for waveform digi folder")
parser.add_argument("--short", default="",
......@@ -56,33 +58,38 @@ from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = True # Needed to bypass autoconfig
ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
configFlags = initConfigFlags()
configFlags.Input.isMC = True # Needed to bypass autoconfig
configFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
ConfigFlags.Input.ProjectName = "mc20"
ConfigFlags.GeoModel.Align.Dynamic = False
ConfigFlags.Beam.NumberOfCollisions = 0.
ConfigFlags.Digitization.TruthOutput = True
configFlags.Input.ProjectName = "mc20"
#configFlags.GeoModel.Align.Dynamic = False
configFlags.Beam.NumberOfCollisions = 0.
configFlags.Digitization.EnableTruth = True
# TI12 old geometry
if runtype == "TI12OldMC":
ConfigFlags.GeoModel.FaserVersion = "FASER-01"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
configFlags.GeoModel.FaserVersion = "FASER-01"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
# Testbeam setup
elif runtype == "TestBeamMC" :
ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00"
configFlags.GeoModel.FaserVersion = "FASER-TB01" # New geometry
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB01"
# New TI12 geometry (ugh)
elif runtype == "TI12MC":
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
elif runtype == "TI12MC" or runtype == "TI12MC04":
configFlags.GeoModel.FaserVersion = "FASERNU-04" # New geometry
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04"
elif runtype == "TI12MC03":
configFlags.GeoModel.FaserVersion = "FASERNU-03" # New geometry
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
else:
print("Invalid geometry type found:", runtype)
......@@ -90,7 +97,7 @@ else:
sys.exit(-1)
# Must use original input string here, as pathlib mangles double // in path names
ConfigFlags.Input.Files = [ args.file_path ]
configFlags.Input.Files = [ args.file_path ]
filestem = filepath.stem
# Remove any filetype modifier
......@@ -137,12 +144,12 @@ if len(args.tag) > 0:
else:
filestem += f"-{args.tag}"
ConfigFlags.Output.RDOFileName = f"{filestem}-RDO.root"
configFlags.Output.RDOFileName = f"{filestem}-RDO.root"
#
# Play around with this?
# ConfigFlags.Concurrency.NumThreads = 2
# ConfigFlags.Concurrency.NumConcurrentEvents = 2
ConfigFlags.lock()
# configFlags.Concurrency.NumThreads = 2
# configFlags.Concurrency.NumConcurrentEvents = 2
configFlags.lock()
#
# Configure components
......@@ -150,18 +157,18 @@ from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
acc.merge(PoolWriteCfg(ConfigFlags))
acc = MainServicesCfg(configFlags)
acc.merge(PoolReadCfg(configFlags))
acc.merge(PoolWriteCfg(configFlags))
#
# Needed, or move to MainServicesCfg?
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
acc.merge(FaserGeometryCfg(ConfigFlags))
acc.merge(FaserGeometryCfg(configFlags))
# Set up algorithms
from FaserSCT_Digitization.FaserSCT_DigitizationConfigNew import FaserSCT_DigitizationCfg
acc.merge(FaserSCT_DigitizationCfg(ConfigFlags))
acc.merge(FaserSCT_DigitizationCfg(configFlags))
# Set the time offset for SCT RDOs
pualg = acc.getEventAlgo("StandardPileUpToolsAlg")
......@@ -169,15 +176,23 @@ pualg.PileUpTools['FaserSCT_DigitizationTool'].SurfaceChargesGenerator.SubtractT
# Pass something to set folder tag
from CaloDigiAlgs.CaloDigiAlgsConfig import CaloWaveformDigitizationCfg
acc.merge(CaloWaveformDigitizationCfg(ConfigFlags, digiTag=args.digiTag))
acc.merge(CaloWaveformDigitizationCfg(configFlags, digiTag=args.digiTag, AdvancedTiming=(not args.simpleTiming)))
from ScintDigiAlgs.ScintDigiAlgsConfig import ScintWaveformDigitizationCfg
acc.merge(ScintWaveformDigitizationCfg(ConfigFlags, digiTag=args.digiTag))
acc.merge(ScintWaveformDigitizationCfg(configFlags, digiTag=args.digiTag, AdvancedTiming=(not args.simpleTiming)))
#add beam truth event
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
# acc = ComponentAccumulator()
ItemList = ["McEventCollection#BeamTruthEvent"]
acc.merge(OutputStreamCfg(configFlags, "RDO", ItemList))
# Configure verbosity
if args.verbose:
acc.foreach_component("*").OutputLevel = VERBOSE
ConfigFlags.dump()
configFlags.dump()
else:
acc.foreach_component("*").OutputLevel = INFO
......
......@@ -35,6 +35,8 @@ parser.add_argument("-t", "--tag", default="",
help="Specify digi tag (to append to output filename)")
parser.add_argument("--subtractTime", type=float, default=-999.,
help="Subtract time parameter for SCT RDOs")
parser.add_argument("--simpleTiming", action="store_true",
help="Use simple waveform time digitization")
parser.add_argument("--digiTag", default="",
help="Specify tag for waveform digi folder")
parser.add_argument("--short", default="",
......@@ -166,53 +168,57 @@ from AthenaConfiguration.ComponentFactory import CompFactory
from AthenaCommon.Constants import VERBOSE, INFO
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = True # Needed to bypass autoconfig
ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
ConfigFlags.Input.ProjectName = "mc20"
ConfigFlags.GeoModel.Align.Dynamic = False
ConfigFlags.Beam.NumberOfCollisions = 0.
ConfigFlags.Digitization.TruthOutput = True
configFlags = initConfigFlags()
configFlags.Input.isMC = True # Needed to bypass autoconfig
configFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions for now
configFlags.Input.ProjectName = "mc20"
#configFlags.GeoModel.Align.Dynamic = False
configFlags.Beam.NumberOfCollisions = 0.
configFlags.Digitization.EnableTruth = True
# TI12 old geometry
if runtype == "TI12OldMC":
ConfigFlags.GeoModel.FaserVersion = "FASER-01"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
configFlags.GeoModel.FaserVersion = "FASER-01"
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01"
# Testbeam setup
elif runtype == "TestBeamMC" :
ConfigFlags.GeoModel.FaserVersion = "FASER-TB00"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00"
configFlags.GeoModel.FaserVersion = "FASER-TB01" # New geometry
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB01"
# New TI12 geometry (ugh)
elif runtype == "TI12MC":
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03"
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
elif runtype == "TI12MC" or runtype == "TI12MC04":
configFlags.GeoModel.FaserVersion = "FASERNU-04" # New geometry
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04"
elif runtype == "TI12MC03":
configFlags.GeoModel.FaserVersion = "FASERNU-03" # New geometry
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03"
else:
print("Invalid run type found:", runtype)
print("Specify correct type or update list")
print("Invalid geometry type found:", runtype)
print("Specify correct geometry or update list")
sys.exit(-1)
# Try just passing the filelist
if args.dir_path[:22] == '/eos/experiment/faser/':
ConfigFlags.Input.Files = [f"root://eospublic.cern.ch/{str(file)}" for file in filelist]
configFlags.Input.Files = [f"root://eospublic.cern.ch/{str(file)}" for file in filelist]
else:
ConfigFlags.Input.Files = [str(file) for file in filelist]
configFlags.Input.Files = [str(file) for file in filelist]
ConfigFlags.Output.RDOFileName = outfile
configFlags.Output.RDOFileName = outfile
#
# Play around with this?
# ConfigFlags.Concurrency.NumThreads = 2
# ConfigFlags.Concurrency.NumConcurrentEvents = 2
ConfigFlags.lock()
# configFlags.Concurrency.NumThreads = 2
# configFlags.Concurrency.NumConcurrentEvents = 2
configFlags.lock()
#
# Configure components
......@@ -220,18 +226,18 @@ from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
acc.merge(PoolWriteCfg(ConfigFlags))
acc = MainServicesCfg(configFlags)
acc.merge(PoolReadCfg(configFlags))
acc.merge(PoolWriteCfg(configFlags))
#
# Needed, or move to MainServicesCfg?
from FaserGeoModel.FaserGeoModelConfig import FaserGeometryCfg
acc.merge(FaserGeometryCfg(ConfigFlags))
acc.merge(FaserGeometryCfg(configFlags))
# Set up algorithms
from FaserSCT_Digitization.FaserSCT_DigitizationConfigNew import FaserSCT_DigitizationCfg
acc.merge(FaserSCT_DigitizationCfg(ConfigFlags))
acc.merge(FaserSCT_DigitizationCfg(configFlags))
# Set the time offset for SCT RDOs
pualg = acc.getEventAlgo("StandardPileUpToolsAlg")
......@@ -239,15 +245,15 @@ pualg.PileUpTools['FaserSCT_DigitizationTool'].SurfaceChargesGenerator.SubtractT
# Pass something to set folder tag
from CaloDigiAlgs.CaloDigiAlgsConfig import CaloWaveformDigitizationCfg
acc.merge(CaloWaveformDigitizationCfg(ConfigFlags, digiTag=args.digiTag))
acc.merge(CaloWaveformDigitizationCfg(configFlags, digiTag=args.digiTag, AdvancedTiming=(not args.simpleTiming)))
from ScintDigiAlgs.ScintDigiAlgsConfig import ScintWaveformDigitizationCfg
acc.merge(ScintWaveformDigitizationCfg(ConfigFlags, digiTag=args.digiTag))
acc.merge(ScintWaveformDigitizationCfg(configFlags, digiTag=args.digiTag, AdvancedTiming=(not args.simpleTiming)))
# Configure verbosity
if args.verbose:
acc.foreach_component("*").OutputLevel = VERBOSE
ConfigFlags.dump()
configFlags.dump()
else:
acc.foreach_component("*").OutputLevel = INFO
......
......@@ -2,11 +2,9 @@
# Used with a condor file to submit to vanilla universe
#
# Usage:
# submit_faser_digi.sh filepath [release_directory] [working_directory]
# submit_faser_digi.sh [--script_options --] filepath [release_directory] [working_directory] [--other_options]
#
# Options:
# --digiTag <tag> - override digitization tag for calo gain
# --geom - geometry setting
# Script Options:
# --out - specify output location (in EOS) to copy output HITS file
# --log - specify output location (in EOS) for log file
#
......@@ -14,6 +12,8 @@
# release_directory - optional path to release install directory (default pwd)
# working_directory - optional path to output directory location (default pwd)
#
# Other Options will be passed to digi script
#
# The release directory must already be set up
# (so an unqualified asetup can set up the release properly)
#
......@@ -27,23 +27,30 @@ SECONDS=0
# Parse command-line options
while [ -n "$1" ]
do
case "$1" in
--digiTag)
echo "Override calo digi tag with $2"
gainstr="--digiTag $2"
shift;
shift;;
case "$1" in
# Remove depricated options
--digiTag)
echo "--digiTag is no longer supported at the script level!"
exit 1;;
#echo "Override calo digi tag with $2"
#gainstr="--digiTag $2"
#shift;
#shift;;
--subtractTime)
echo "Subtract $2 ns from SCT RDOs"
timestr="--subtractTime $2"
shift;
shift;;
--subtractTime)
echo "--subtractTime is no longer supported at the script level!"
exit 1;;
#echo "Subtract $2 ns from SCT RDOs"
#timestr="--subtractTime $2"
#shift;
#shift;;
-g | --geom)
geomstr="--geom $2";
shift;
shift;;
-g | --geom)
echo "--geom is no longer supported at the script level"
exit 1;;
#geomstr="--geom $2";
#shift;
#shift;;
-l | --log)
logdest="$2";
......@@ -68,15 +75,42 @@ do
done
#
# Parse command-line options
file_path=${1}
release_directory=${2}
working_directory=${3}
while [ -n "$1" ]
do
case "$1" in
--) # Stop parsing
shift; # Eat this
break;; # and stop parsing
-*) # Some option
break;; # Stop parsing
*) # Not an option, fill next parameter value
if [ -z "$file_path" ]
then
file_path=${1}
shift
elif [ -z "$release_directory" ]
then
release_directory=${1}
shift
elif [ -z "$working_directory" ]
then
working_directory=${1}
shift
else
break # Already filled everything
fi
;;
esac
done
#
# Set defaults if arguments aren't provided
if [ -z "$file_path" ]
then
echo "No file specified!"
echo "Usage: submit_faser_digi.sh [--highGain] file [release dir] [output dir]"
echo "Usage: submit_faser_digi.sh file [release dir] [output dir]"
exit 1
fi
#
......@@ -119,23 +153,22 @@ logfile="${file_stem}.rdo.log"
exec >& "${output_directory}/${logfile}"
echo `date` - $HOSTNAME
echo "File: $file_name"
echo "Geom: $geomstr"
echo "Gain: $gainstr"
echo "Time: $timestr"
#echo "Geom: $geomstr"
#echo "Gain: $gainstr"
#echo "Time: $timestr"
echo "Release: $release_directory"
echo "Output: $output_directory"
echo "Starting: $starting_directory"
echo "Remaining: $@"
#
# Set up the release (do this automatically)?
# Must follow with -- to avoid command-line arguments being passed
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh --
#
# Try automatic
# Always go back to the starting directory in case paths are relative
cd "$starting_directory"
cd "$release_directory"
# asetup
# source build/x8*/setup.sh
#
# Do this by hand
asetup --input=calypso/asetup.faser Athena,22.0.49
......@@ -185,10 +218,15 @@ cd "$file_stem"
#
# Run job
#
faser_digi.py $geomstr $gainstr $timestr $tagstr "$file_path"
echo
echo "Submit job:"
echo faser_digi.py "$file_path" $tagstr "$@"
echo
#
faser_digi.py "$file_path" $tagstr "$@"
digi_code=$?
#
echo "Return code: $digi_code"
#
# Print out ending time
date
......@@ -204,11 +242,11 @@ then
thefile=`ls *-RDO.root`
if [ $? -eq 0 ]; then
echo "copy $thefile to $outdest"
eos mkdir -p $outdest
eos cp $thefile ${outdest}/${thefile} || true
mkdir -p $outdest
cp $thefile ${outdest}/${thefile} || true
# Check that this worked
eos ls ${outdest}/${thefile} > /dev/null
ls ${outdest}/${thefile} > /dev/null
if [ $? -eq 0 ]; then
echo "file $thefile copied to $outdest"
copy_code=0
......@@ -229,19 +267,19 @@ then
echo "Working directory:"
ls -l
echo "copy $logfile to $logdest"
eos mkdir -p $logdest
eos cp $logfile $logdest/$logfile
mkdir -p $logdest
cp $logfile $logdest/$logfile
elif ! [ -z "$outdest" ]
then
cd ..
echo "Working directory:"
ls -l
echo "copy $logfile to $outdest"
eos mkdir -p $outdest
eos cp $logfile $outdest/$logfile
mkdir -p $outdest
cp $logfile $outdest/$logfile
fi
# Make sure to return an error is calypso failed
# Make sure to return an error is calypso failed
if [ $digi_code -ne 0 ] || [ $copy_code -ne 0 ]; then
exit 1
else
......
......@@ -2,14 +2,12 @@
# Used with a condor file to submit to vanilla universe
#
# Usage:
# submit_faser_digi_merge.sh dirpath slice nfiles [release_directory] [working_directory]
# submit_faser_digi_merge.sh [--script_options --] dirpath slice nfiles [release_directory] [working_directory] [--other_options]
#
# Options:
# --digiTag <tag> - override digitization tag for calo gain
# --partial - allow missing files in merge
# --geom - geometry setting
# Script Options:
# --out - specify output location (in EOS) to copy output HITS file
# --log - specify output location (in EOS) for log file
# --no_clobber - don't overwrite EOS output file
#
# dirpath - full directory path to HITS files
# slice - ordinal output file number
......@@ -17,6 +15,8 @@
# release_directory - optional path to release install directory (default pwd)
# working_directory - optional path to output directory location (default pwd)
#
# Other Options will be passed to job script
#
# The release directory must already be set up
# (so an unqualified asetup can set up the release properly)
#
......@@ -27,37 +27,39 @@
# Keep track of time
SECONDS=0
#
# Job options strings
gainstr=""
timestr=""
partialstr=""
geomstr=""
#
# Parse command-line options
while [ -n "$1" ]
do
case "$1" in
--digiTag)
echo "Override calo digi tag with $2"
gainstr="--digiTag $2"
shift;
shift;;
echo "--digiTag no longer allowed in script!"
exit 1;;
#echo "Override calo digi tag with $2"
#gainstr="--digiTag $2"
#shift;
#shift;;
--subtractTime)
echo "Subtract $2 ns from SCT RDOs"
timestr="--subtractTime $2"
shift;
shift;;
echo "--subtractTime no longer allowed in script!"
exit 1;;
#echo "Subtract $2 ns from SCT RDOs"
#timestr="--subtractTime $2"
#shift;
#shift;;
--partial)
echo "Allowing partial merge"
partialstr="--partial"
shift;;
echo "--partial no longer allowed in script!"
exit 1;;
#echo "Allowing partial merge"
#partialstr="--partial"
#shift;;
-g | --geom)
geomstr="--geom $2";
shift;
shift;;
echo "--geom no longer allowed in script!"
exit 1;;
#geomstr="--geom $2";
#shift;
#shift;;
-l | --log)
logdest="$2";
......@@ -69,6 +71,10 @@ do
shift;
shift;;
-n | --no_clobber)
no_clobber=1;
shift;;
--) # End of options
shift; # Eat this
break;; # And stop parsing
......@@ -82,11 +88,44 @@ do
done
#
# Parse command-line options
dir_path=${1}
slice=${2}
nfiles=${3}
release_directory=${4}
working_directory=${5}
while [ -n "$1" ]
do
case "$1" in
--) # Stop parsing
shift; # Eat this
break;; # and stop parsing
-*) # Some option
break;; # Stop parsing
*) # Not an option, fill next parameter value
if [ -z "$dir_path" ]
then
dir_path=${1}
shift
elif [ -z "$slice" ]
then
slice=${1}
shift
elif [ -z "$nfiles" ]
then
nfiles=${1}
shift
elif [ -z "$release_directory" ]
then
release_directory=${1}
shift
elif [ -z "$working_directory" ]
then
working_directory=${1}
shift
else
break # Already filled everything
fi
;;
esac
done
#
# Set defaults if arguments aren't provided
if [ -z "$dir_path" ]
......@@ -152,26 +191,22 @@ logfile="${file_stem}.rdo.log"
exec >& "$output_directory/$logfile"
echo `date` - $HOSTNAME
echo "Directory: $dir_path"
echo "Geom: $geomstr"
echo "Gain: $gainstr"
echo "Time: $timestr"
echo "Slice: $slice"
echo "NFiles: $nfiles"
echo "Release: $release_directory"
echo "Output: $output_directory"
echo "Starting: $starting_directory"
echo "job: $file_stem"
echo "Remaining: $@"
#
# Set up the release (do this automatically)?
# Must follow with -- to avoid command-line arguments being passed
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh --
#
# Try automatic
# Always go back to the starting directory in case paths are relative
cd "$starting_directory"
cd "$release_directory"
# asetup
# source build/x8*/setup.sh
#
# Do this by hand
asetup --input=calypso/asetup.faser Athena,22.0.49
......@@ -221,7 +256,12 @@ cd "$file_stem"
#
# Run job
#
faser_digi_merge.py $partialstr $geomstr $gainstr $timestr $tagstr --slice $slice --files $nfiles $dir_path
echo
echo "Submit job:"
echo faser_digi_merge.py $dir_path $tagstr --slice $slice --files $nfiles "$@"
echo
#
faser_digi_merge.py $dir_path $tagstr --slice $slice --files $nfiles "$@"
digi_code=$?
echo "Return code: $digi_code"
#
......@@ -236,19 +276,37 @@ if ! [ -z "$outdest" ]
then
echo "Output directory:"
ls -l
thefile=`ls *-RDO.root`
srcfile=`ls *-RDO.root`
dstfile=$srcfile
if [ $? -eq 0 ]; then
echo "copy $thefile to $outdest"
eos mkdir -p $outdest
eos cp $thefile ${outdest}/${thefile} || true
echo "copy $srcfile to $outdest"
mkdir -p $outdest
# Check if we can overwrite
if ! [ -z "$no_clobber" ]; then
echo "--no_clobber set, checking destination"
ls -l ${outdest}
# Need to check if file already exists
if [ -f ${outdest}/${dstfile} ]; then
echo "File exists, appending date!"
dstfile=${dstfile}.`date "+%y%m%d%H%m"`
else
echo "File doesn't exist!"
fi
# all good, now copy with --no_clobber
cp -n $srcfile ${outdest}/${dstfile} || true
else
# just copy
cp $srcfile ${outdest}/${dstfile} || true
fi
#
# Check that this worked
eos ls ${outdest}/${thefile} > /dev/null
ls ${outdest}/${dstfile} > /dev/null
if [ $? -eq 0 ]; then
echo "file $thefile copied to $outdest"
echo "file $srcfile copied to $outdest"
copy_code=0
else
echo "didnt find $thefile in $outdest !"
echo "didnt find $dstfile in $outdest!"
copy_code=1
fi
else
......@@ -264,19 +322,19 @@ then
echo "Working directory:"
ls -l
echo "copy $logfile to $logdest"
eos mkdir -p $logdest
eos cp $logfile $logdest/$logfile
mkdir -p $logdest
cp $logfile $logdest/$logfile
elif ! [ -z "$outdest" ]
then
cd ..
echo "Working directory:"
ls -l
echo "copy $logfile to $outdest"
eos mkdir -p $outdest
eos cp $logfile $outdest/$logfile
mkdir -p $outdest
cp $logfile $outdest/$logfile
fi
# Make sure to return an error is calypso failed
#
# Make sure to return an error is calypso failed
if [ $digi_code -ne 0 ] || [ $copy_code -ne 0 ]; then
exit 1
else
......
......@@ -20,29 +20,30 @@ def GenEventReadExampleCfg(flags, name="GenEventReadExampleAlg", **kwargs):
if __name__ == "__main__":
from AthenaCommon.Configurable import Configurable
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
Configurable.configurableRun3Behavior = True
# Flags for this job
ConfigFlags.Input.isMC = True # Needed to bypass autoconfig
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-01" # Always needed; must match FaserVersion
ConfigFlags.GeoModel.FaserVersion = "FASER-01" # Default FASER geometry
ConfigFlags.Detector.EnableFaserSCT = True
ConfigFlags.Input.Files = ["my.cosmics.pool.root"]
ConfigFlags.lock()
configFlags = initConfigFlags()
configFlags.Input.isMC = True # Needed to bypass autoconfig
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Always needed; must match FaserVersion
configFlags.GeoModel.FaserVersion = "FASERNU-04" # Default FASER geometry
# configFlags.Detector.EnableFaserSCT = True
configFlags.Input.Files = ["my.cosmics.pool.root"]
configFlags.lock()
# Configure components
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
acc = MainServicesCfg(ConfigFlags)
acc.merge(PoolReadCfg(ConfigFlags))
acc = MainServicesCfg(configFlags)
acc.merge(PoolReadCfg(configFlags))
# Set things up to create a conditions DB with neutral Tracker alignment transforms
acc.merge(GenEventReadExampleCfg(ConfigFlags))
acc.merge(GenEventReadExampleCfg(configFlags))
# Configure verbosity
# ConfigFlags.dump()
# configFlags.dump()
# logging.getLogger('forcomps').setLevel(VERBOSE)
# acc.foreach_component("*").OutputLevel = VERBOSE
# acc.foreach_component("*ClassID*").OutputLevel = INFO
......
#include "GenEventReadAlg.h"
#ifdef HEPMC3
#include "HepMC3/PrintStreams.h"
#endif
GenEventReadAlg::GenEventReadAlg(const std::string& name, ISvcLocator* pSvcLocator)
: AthHistogramAlgorithm(name, pSvcLocator) { m_cosThetaHist = nullptr; m_rVertexHist = nullptr; }
......@@ -33,11 +35,28 @@ StatusCode GenEventReadAlg::execute()
ATH_MSG_INFO("Read McEventContainer with " << h_mcEvents->size() << " events");
if (h_mcEvents->size() == 0) return StatusCode::FAILURE;
const HepMC::GenEvent* theEvent = h_mcEvents->at(0);
if (theEvent->particles_size() != 1 && theEvent->vertices_size() != 1) return StatusCode::FAILURE;
// h_mcEvents->at(0)->print( msg().stream() );
// if (theEvent->particles_size() != 1 && theEvent->vertices_size() != 1) return StatusCode::FAILURE;
#ifdef HEPMC3
msg(MSG::INFO) << *theEvent << endmsg;
const HepMC::ConstGenParticlePtr& pHat {theEvent->particles().front()};
for (auto p : theEvent->particles())
{
m_cosThetaHist->Fill(-p->momentum().y()/p->momentum().rho());
m_phiHist->Fill(atan2(p->momentum().x(), p->momentum().z()));
}
for (auto v : theEvent->vertices())
{
HepMC::FourVector vOffset { v->position().x() , v->position().y(), v->position().z() - m_zOffset, v->position().t() };
m_rVertexHist->Fill(vOffset.rho());
m_rPerpHist->Fill(pow(vOffset.rho(), 2) - pow((vOffset.x() * pHat->momentum().x() +
vOffset.y() * pHat->momentum().y() +
vOffset.z() * pHat->momentum().z())/pHat->momentum().rho(), 2));
}
#else
const HepMC::GenParticle* pHat { nullptr };
auto pParticles = theEvent->particles_begin();
auto pParticlesEnd = theEvent->particles_end();
const HepMC::GenParticle* pHat { nullptr };
for (; pParticles != pParticlesEnd ; ++pParticles)
{
const HepMC::GenParticle* p = *pParticles;
......@@ -45,7 +64,6 @@ StatusCode GenEventReadAlg::execute()
m_cosThetaHist->Fill(-p->momentum().y()/p->momentum().rho());
m_phiHist->Fill(atan2(p->momentum().x(), p->momentum().z()));
}
auto pVertices = theEvent->vertices_begin();
auto pVerticesEnd = theEvent->vertices_end();
for (; pVertices != pVerticesEnd; ++pVertices)
......@@ -57,6 +75,7 @@ StatusCode GenEventReadAlg::execute()
vOffset.y() * pHat->momentum().y() +
vOffset.z() * pHat->momentum().z())/pHat->momentum().rho(), 2));
}
#endif
return StatusCode::SUCCESS;
}
......
......@@ -19,10 +19,12 @@ def faser_pgparser():
parser = argparse.ArgumentParser(description="Run FASER ParticleGun Simulation")
parser.add_argument("--verbose", action="store_true", help="Debug output")
parser.add_argument("--conf", action='append',
help="Specify configuration file with default values")
parser.add_argument("--geom", default="TI12MC",
help="Specify geomtery to simulation (default: TI12MC, alt: TestBeamMC)")
help="Specify geometry to simulation (default: TI12MC, alt: TestBeamMC)")
parser.add_argument("--run", default=123456, type=int,
help="Run number to generate")
......@@ -73,6 +75,8 @@ def faser_pgparser():
help="Write out full configuration")
parser.add_argument("--noexec", action='store_true',
help="Exit after parsing configuration (no execution)")
parser.add_argument('--filter',default="",type=str,
help='Specify "type" of filter, e.g. "muon_conversion" ,etc')
pg_args = parser.parse_args()
......
#!/usr/bin/env python
"""
Produce particle gun samples
Derived from G4FaserAlgConfigNew
Derived from G4FaserAlgConfig
Usage:
faserMDC_particlegun.py --conf=<config_file>
......@@ -42,44 +42,45 @@ if __name__ == '__main__':
#
# Import and set config flags
#
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
ConfigFlags.Exec.MaxEvents = nevents
ConfigFlags.Exec.SkipEvents = nskipped
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
configFlags = initConfigFlags()
configFlags.Exec.MaxEvents = nevents
configFlags.Exec.SkipEvents = nskipped
from AthenaConfiguration.Enums import ProductionStep
ConfigFlags.Common.ProductionStep = ProductionStep.Simulation
configFlags.Common.ProductionStep = ProductionStep.Simulation
#
# All these must be specified to avoid auto-configuration
#
ConfigFlags.Input.RunNumber = [args.run] #Isn't updating - todo: investigate
ConfigFlags.Input.OverrideRunNumber = True
ConfigFlags.Input.LumiBlockNumber = [(args.segment+1)]
ConfigFlags.Input.isMC = True
configFlags.Input.RunNumber = [args.run] #Isn't updating - todo: investigate
configFlags.Input.OverrideRunNumber = True
configFlags.Input.LumiBlockNumber = [(args.segment+1)]
configFlags.Input.isMC = True
#
# Output file name
#
ConfigFlags.Output.HITSFileName = args.outfile
configFlags.Output.HITSFileName = args.outfile
#
# Sim ConfigFlags
# Sim configFlags
#
ConfigFlags.Sim.Layout = "FASER"
ConfigFlags.Sim.PhysicsList = "FTFP_BERT"
ConfigFlags.Sim.ReleaseGeoModel = False
ConfigFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
configFlags.GeoModel.Layout = "FASER"
configFlags.Sim.PhysicsList = "FTFP_BERT"
configFlags.Sim.ReleaseGeoModel = False
configFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
# Property bag for particle gun keyword:argument pairs
# Apply +12mm vertical shift (to get to FASER CL)
# And 150 uRad crossing angle (Jamie claims this is half-angle)
ConfigFlags.addFlag("Sim.Gun",{"Generator" : "Foresee"})
ConfigFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles
ConfigFlags.addFlag("Sim.Beam.yangle", -0.000150)
ConfigFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift
ConfigFlags.addFlag("Sim.Beam.yshift", 12.)
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" # Geometry set-up
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Conditions set-up
ConfigFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig
ConfigFlags.GeoModel.Align.Dynamic = False
configFlags.addFlag("Sim.Gun",{"Generator" : "Foresee"})
configFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles
configFlags.addFlag("Sim.Beam.yangle", -0.000150)
configFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift
configFlags.addFlag("Sim.Beam.yshift", 12.)
configFlags.GeoModel.FaserVersion = "FASERNU-03" # Geometry set-up
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Conditions set-up
configFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig
#configFlags.GeoModel.Align.Dynamic = False
#
# Preset particle gun parameters
#
......@@ -97,7 +98,7 @@ if __name__ == '__main__':
# Note the mother mass here is in GeV for some reason
import ParticleGun as PG
ConfigFlags.Sim.Gun = {
configFlags.Sim.Gun = {
"Generator" : "Foresee",
"model_path" : args.model_path,
"model_name" : args.model,
......@@ -111,15 +112,15 @@ if __name__ == '__main__':
# To get all the material currently defined in front, specify -5m.
# Note zpos is in mm!
#if args.zpos:
# ConfigFlags.Sim.Gun["z"] = args.zpos
# configFlags.Sim.Gun["z"] = args.zpos
doShiftLOS = (ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle or
ConfigFlags.Sim.Beam.xshift or ConfigFlags.Sim.Beam.yshift)
doShiftLOS = (configFlags.Sim.Beam.xangle or configFlags.Sim.Beam.yangle or
configFlags.Sim.Beam.xshift or configFlags.Sim.Beam.yshift)
if doShiftLOS:
pgConfig = ConfigFlags.Sim.Gun
pgConfig = configFlags.Sim.Gun
pgConfig["McEventKey"] = "BeamTruthEvent_ATLASCoord"
ConfigFlags.Sim.Gun = pgConfig
configFlags.Sim.Gun = pgConfig
#
# MDC geometry configuration
......@@ -129,16 +130,16 @@ if __name__ == '__main__':
# Setup detector flags
#
from CalypsoConfiguration.DetectorConfigFlags import setupDetectorsFromList
setupDetectorsFromList(ConfigFlags, detectors, toggle_geometry=True)
setupDetectorsFromList(configFlags, detectors, toggle_geometry=True)
#
# Finalize flags
#
ConfigFlags.lock()
configFlags.lock()
#
# Initialize a new component accumulator
#
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
cfg = MainServicesCfg(ConfigFlags)
cfg = MainServicesCfg(configFlags)
#
# Configure the particle gun as requested, or using defaults
#
......@@ -147,15 +148,15 @@ if __name__ == '__main__':
# Particle gun generators - the generator, energy, angle, particle type, position, etc can be modified by passing keyword arguments
#
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg
cfg.merge(FaserParticleGunCfg(ConfigFlags))
cfg.merge(FaserParticleGunCfg(configFlags))
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags))
cfg.merge(McEventSelectorCfg(configFlags))
#
# Output file
#
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
cfg.merge(PoolWriteCfg(ConfigFlags))
cfg.merge(PoolWriteCfg(configFlags))
#
# Shift LOS
......@@ -165,18 +166,18 @@ if __name__ == '__main__':
import McParticleEvent.Pythonizations
from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg
cfg.merge(ShiftLOSCfg(ConfigFlags,
xcross = ConfigFlags.Sim.Beam.xangle,
ycross = ConfigFlags.Sim.Beam.yangle,
xshift = ConfigFlags.Sim.Beam.xshift,
yshift = ConfigFlags.Sim.Beam.yshift))
cfg.merge(ShiftLOSCfg(configFlags,
xcross = configFlags.Sim.Beam.xangle,
ycross = configFlags.Sim.Beam.yangle,
xshift = configFlags.Sim.Beam.xshift,
yshift = configFlags.Sim.Beam.yshift))
#
# Add the G4FaserAlg
#
from G4FaserAlg.G4FaserAlgConfigNew import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(ConfigFlags))
from G4FaserAlg.G4FaserAlgConfig import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(configFlags))
#
# Dump config
#
......@@ -186,7 +187,7 @@ if __name__ == '__main__':
cfg.getService("ConditionStore").Dump = True
cfg.printConfig(withDetails=True, summariseProps = False) # gags on ParticleGun if summariseProps = True?
ConfigFlags.dump()
configFlags.dump()
#f = open("test.pkl","wb")
#cfg.store(f)
#f.close()
......
#!/usr/bin/env python
"""
Produce particle gun samples
Derived from G4FaserAlgConfigNew
Derived from G4FaserAlgConfig
Usage:
faserMDC_particlegun.py --conf=<config_file>
......@@ -42,40 +42,41 @@ if __name__ == '__main__':
#
# Import and set config flags
#
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
ConfigFlags.Exec.MaxEvents = nevents
ConfigFlags.Exec.SkipEvents = nskipped
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
configFlags = initConfigFlags()
configFlags.Exec.MaxEvents = nevents
configFlags.Exec.SkipEvents = nskipped
from AthenaConfiguration.Enums import ProductionStep
ConfigFlags.Common.ProductionStep = ProductionStep.Simulation
configFlags.Common.ProductionStep = ProductionStep.Simulation
#
# All these must be specified to avoid auto-configuration
#
ConfigFlags.Input.RunNumber = [args.run]
ConfigFlags.Input.OverrideRunNumber = True
ConfigFlags.Input.LumiBlockNumber = [(args.segment+1)]
ConfigFlags.Input.isMC = True
configFlags.Input.RunNumber = [args.run]
configFlags.Input.OverrideRunNumber = True
configFlags.Input.LumiBlockNumber = [(args.segment+1)]
configFlags.Input.isMC = True
#
# Output file name
#
ConfigFlags.Output.HITSFileName = args.outfile
configFlags.Output.HITSFileName = args.outfile
#
# Sim ConfigFlags
# Sim configFlags
#
ConfigFlags.Sim.Layout = "FASER"
ConfigFlags.Sim.PhysicsList = "FTFP_BERT"
ConfigFlags.Sim.ReleaseGeoModel = False
ConfigFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
ConfigFlags.addFlag("Sim.Gun",{"Generator" : "SingleParticle"}) # Property bag for particle gun keyword:argument pairs
ConfigFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles
ConfigFlags.addFlag("Sim.Beam.yangle", 0)
ConfigFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift
ConfigFlags.addFlag("Sim.Beam.yshift", 0)
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" # Geometry set-up
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Conditions set-up
ConfigFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig
ConfigFlags.GeoModel.Align.Dynamic = False
configFlags.GeoModel.Layout = "FASER"
configFlags.Sim.PhysicsList = "FTFP_BERT"
configFlags.Sim.ReleaseGeoModel = False
configFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
configFlags.addFlag("Sim.Gun",{"Generator" : "SingleParticle"}) # Property bag for particle gun keyword:argument pairs
configFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles
configFlags.addFlag("Sim.Beam.yangle", 0)
configFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift
configFlags.addFlag("Sim.Beam.yshift", 0)
configFlags.GeoModel.FaserVersion = "FASERNU-03" # Geometry set-up
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Conditions set-up
configFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig
#configFlags.GeoModel.Align.Dynamic = False
#
# Preset particle gun parameters
#
......@@ -121,16 +122,16 @@ if __name__ == '__main__':
print(f"Sampler {args.sampler} not known!")
sys.exit(1)
# Pass this in one go to ConfigFlags
ConfigFlags.Sim.Gun = sg_dict
# Pass this in one go to configFlags
configFlags.Sim.Gun = sg_dict
doShiftLOS = (ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle or
ConfigFlags.Sim.Beam.xshift or ConfigFlags.Sim.Beam.yshift)
doShiftLOS = (configFlags.Sim.Beam.xangle or configFlags.Sim.Beam.yangle or
configFlags.Sim.Beam.xshift or configFlags.Sim.Beam.yshift)
if doShiftLOS:
pgConfig = ConfigFlags.Sim.Gun
pgConfig = configFlags.Sim.Gun
pgConfig["McEventKey"] = "BeamTruthEvent_ATLASCoord"
ConfigFlags.Sim.Gun = pgConfig
configFlags.Sim.Gun = pgConfig
#
# MDC geometry configuration
......@@ -140,16 +141,16 @@ if __name__ == '__main__':
# Setup detector flags
#
from CalypsoConfiguration.DetectorConfigFlags import setupDetectorsFromList
setupDetectorsFromList(ConfigFlags, detectors, toggle_geometry=True)
setupDetectorsFromList(configFlags, detectors, toggle_geometry=True)
#
# Finalize flags
#
ConfigFlags.lock()
configFlags.lock()
#
# Initialize a new component accumulator
#
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
cfg = MainServicesCfg(ConfigFlags)
cfg = MainServicesCfg(configFlags)
#
# Configure the particle gun as requested, or using defaults
#
......@@ -158,15 +159,15 @@ if __name__ == '__main__':
# Particle gun generators - the generator, energy, angle, particle type, position, etc can be modified by passing keyword arguments
#
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg
cfg.merge(FaserParticleGunCfg(ConfigFlags))
cfg.merge(FaserParticleGunCfg(configFlags))
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags))
cfg.merge(McEventSelectorCfg(configFlags))
#
# Output file
#
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
cfg.merge(PoolWriteCfg(ConfigFlags))
cfg.merge(PoolWriteCfg(configFlags))
#
# Shift LOS
......@@ -176,18 +177,18 @@ if __name__ == '__main__':
import McParticleEvent.Pythonizations
from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg
cfg.merge(ShiftLOSCfg(ConfigFlags,
xcross = ConfigFlags.Sim.Beam.xangle,
ycross = ConfigFlags.Sim.Beam.yangle,
xshift = ConfigFlags.Sim.Beam.xshift,
yshift = ConfigFlags.Sim.Beam.yshift))
cfg.merge(ShiftLOSCfg(configFlags,
xcross = configFlags.Sim.Beam.xangle,
ycross = configFlags.Sim.Beam.yangle,
xshift = configFlags.Sim.Beam.xshift,
yshift = configFlags.Sim.Beam.yshift))
#
# Add the G4FaserAlg
#
from G4FaserAlg.G4FaserAlgConfigNew import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(ConfigFlags))
from G4FaserAlg.G4FaserAlgConfig import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(configFlags))
#
# Dump config
#
......@@ -197,7 +198,7 @@ if __name__ == '__main__':
cfg.getService("ConditionStore").Dump = True
cfg.printConfig(withDetails=True, summariseProps = False) # gags on ParticleGun if summariseProps = True?
ConfigFlags.dump()
configFlags.dump()
#f = open("test.pkl","wb")
#cfg.store(f)
#f.close()
......
#!/usr/bin/env python
"""
Produce particle gun samples
Derived from G4FaserAlgConfigNew
Derived from G4FaserAlgConfig
Usage:
faser_particlegun.py --conf=<config_file>
......@@ -37,53 +37,75 @@ if __name__ == '__main__':
from AthenaCommon.Logging import log
from AthenaCommon.Constants import DEBUG, VERBOSE
from AthenaCommon.Configurable import Configurable
log.setLevel(DEBUG)
Configurable.configurableRun3Behavior = 1
if args.verbose:
log.setLevel(DEBUG)
#
# Import and set config flags
#
from CalypsoConfiguration.AllConfigFlags import ConfigFlags
ConfigFlags.Exec.MaxEvents = nevents
ConfigFlags.Exec.SkipEvents = nskipped
from CalypsoConfiguration.AllConfigFlags import initConfigFlags
configFlags = initConfigFlags()
configFlags.Exec.MaxEvents = nevents
configFlags.Exec.SkipEvents = nskipped
from AthenaConfiguration.Enums import ProductionStep
ConfigFlags.Common.ProductionStep = ProductionStep.Simulation
configFlags.Common.ProductionStep = ProductionStep.Simulation
#
# All these must be specified to avoid auto-configuration
#
ConfigFlags.Input.RunNumber = [args.run]
ConfigFlags.Input.OverrideRunNumber = True
ConfigFlags.Input.LumiBlockNumber = [(args.segment+1)]
ConfigFlags.Input.isMC = True
ConfigFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions
configFlags.Input.RunNumbers = [args.run]
configFlags.Input.OverrideRunNumber = True
configFlags.Input.LumiBlockNumbers = [(args.segment+1)]
configFlags.Input.isMC = True
configFlags.IOVDb.DatabaseInstance = "OFLP200" # Use MC conditions
#
# Output file name
#
ConfigFlags.Output.HITSFileName = args.outfile
#
# Sim ConfigFlags
#
ConfigFlags.Sim.Layout = "FASER"
ConfigFlags.Sim.PhysicsList = "FTFP_BERT"
ConfigFlags.Sim.ReleaseGeoModel = False
ConfigFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
ConfigFlags.addFlag("Sim.Gun",{"Generator" : "SingleParticle"}) # Property bag for particle gun keyword:argument pairs
ConfigFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles
ConfigFlags.addFlag("Sim.Beam.yangle", 0)
ConfigFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift
ConfigFlags.addFlag("Sim.Beam.yshift", 0)
configFlags.Output.HITSFileName = args.outfile
#
# More config flags (R24)
#
from Campaigns.Utils import Campaign
from AthenaConfiguration.Enums import BeamType
configFlags.Common.MsgSourceLength = 30
configFlags.Input.MCCampaign = Campaign.Unknown
configFlags.Input.TypedCollections = []
configFlags.Input.MetadataItems = []
configFlags.Beam.Type = BeamType.Collisions
#
# Sim configFlags
#
configFlags.GeoModel.Layout = "FASER"
configFlags.Sim.PhysicsList = "FTFP_BERT"
configFlags.Sim.ReleaseGeoModel = False
configFlags.Sim.IncludeParentsInG4Event = True # Controls whether BeamTruthEvent is written to output HITS file
configFlags.addFlag("Sim.Gun",{"Generator" : "SingleParticle"}) # Property bag for particle gun keyword:argument pairs
configFlags.addFlag("Sim.Beam.xangle", 0) # Potential beam crossing angles
configFlags.addFlag("Sim.Beam.yangle", 0)
configFlags.addFlag("Sim.Beam.xshift", 0) # Potential beam shift
configFlags.addFlag("Sim.Beam.yshift", 0)
if args.geom == "TI12MC" or args.geom == "TI12MC04":
# New TI12 geometry
configFlags.GeoModel.FaserVersion = "FASERNU-04" # Geometry set-up
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-04" # Conditions set-up
# TI12 detectors
detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger',
'Dipole', 'Emulsion', 'Trench']
if args.geom == "TI12MC":
elif args.geom == "TI12MC03":
# 2022 TI12 geometry
ConfigFlags.GeoModel.FaserVersion = "FASERNU-03" # Geometry set-up
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Conditions set-up
configFlags.GeoModel.FaserVersion = "FASERNU-03" # Geometry set-up
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-03" # Conditions set-up
# TI12 detectors
detectors = ['Veto', 'VetoNu', 'Preshower', 'FaserSCT', 'Ecal', 'Trigger',
'Dipole', 'Emulsion', 'Trench']
elif args.geom == "TestBeamMC":
# Define 2021 test beam geometry
ConfigFlags.GeoModel.FaserVersion = "FASER-TB00" # Geometry set-up
ConfigFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB00" # Conditions set-up
configFlags.GeoModel.FaserVersion = "FASER-TB01" # Geometry set-up
configFlags.IOVDb.GlobalTag = "OFLCOND-FASER-TB01" # Conditions set-up
# Testbeam detectors (trigger layers are actually veto counters)
detectors = ['Veto', 'Preshower', 'FaserSCT', 'Ecal']
......@@ -91,8 +113,8 @@ if __name__ == '__main__':
print(f"Unknown geometry {args.geom}!")
sys.exit(1)
ConfigFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig
ConfigFlags.GeoModel.Align.Dynamic = False
configFlags.addFlag("Input.InitialTimeStamp", 0) # To avoid autoconfig
#configFlags.GeoModel.Align.Dynamic = False
#
# Preset particle gun parameters
#
......@@ -191,32 +213,32 @@ if __name__ == '__main__':
print(f"Sampler {args.sampler} not known!")
sys.exit(1)
# Pass this in one go to ConfigFlags
ConfigFlags.Sim.Gun = sg_dict
# Pass this in one go to configFlags
configFlags.Sim.Gun = sg_dict
doShiftLOS = (ConfigFlags.Sim.Beam.xangle or ConfigFlags.Sim.Beam.yangle or
ConfigFlags.Sim.Beam.xshift or ConfigFlags.Sim.Beam.yshift)
doShiftLOS = (configFlags.Sim.Beam.xangle or configFlags.Sim.Beam.yangle or
configFlags.Sim.Beam.xshift or configFlags.Sim.Beam.yshift)
if doShiftLOS:
pgConfig = ConfigFlags.Sim.Gun
pgConfig = configFlags.Sim.Gun
pgConfig["McEventKey"] = "BeamTruthEvent_ATLASCoord"
ConfigFlags.Sim.Gun = pgConfig
configFlags.Sim.Gun = pgConfig
#
# By being a little clever, we can steer the geometry setup from the command line using GeoModel.FaserVersion
#
# Setup detector flags
#
from CalypsoConfiguration.DetectorConfigFlags import setupDetectorsFromList
setupDetectorsFromList(ConfigFlags, detectors, toggle_geometry=True)
setupDetectorsFromList(configFlags, detectors, toggle_geometry=True)
#
# Finalize flags
#
ConfigFlags.lock()
configFlags.lock()
#
# Initialize a new component accumulator
#
from CalypsoConfiguration.MainServicesConfig import MainServicesCfg
cfg = MainServicesCfg(ConfigFlags)
cfg = MainServicesCfg(configFlags)
#
# Configure the particle gun as requested, or using defaults
#
......@@ -225,36 +247,76 @@ if __name__ == '__main__':
# Particle gun generators - the generator, energy, angle, particle type, position, etc can be modified by passing keyword arguments
#
from FaserParticleGun.FaserParticleGunConfig import FaserParticleGunCfg
cfg.merge(FaserParticleGunCfg(ConfigFlags))
cfg.merge(FaserParticleGunCfg(configFlags))
from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
cfg.merge(McEventSelectorCfg(ConfigFlags))
cfg.merge(McEventSelectorCfg(configFlags))
#
# Output file
# Shift LOS for particle gun (into AthBeginSeq)
#
from AthenaPoolCnvSvc.PoolWriteConfig import PoolWriteCfg
cfg.merge(PoolWriteCfg(ConfigFlags))
if doShiftLOS:
import McParticleEvent.Pythonizations
from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg
cfg.merge(ShiftLOSCfg(configFlags,
xcross = configFlags.Sim.Beam.xangle, ycross = configFlags.Sim.Beam.yangle,
xshift = configFlags.Sim.Beam.xshift, yshift = configFlags.Sim.Beam.yshift),
sequenceName = "AthBeginSeq")
# #
# # Shift LOS
# #
# if doShiftLOS:
# import McParticleEvent.Pythonizations
# from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg
# cfg.merge(ShiftLOSCfg(configFlags,
# xcross = configFlags.Sim.Beam.xangle,
# ycross = configFlags.Sim.Beam.yangle,
# xshift = configFlags.Sim.Beam.xshift,
# yshift = configFlags.Sim.Beam.yshift))
#
# Header conversion seems necessary to write events
#
from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
cfg.merge(EventInfoCnvAlgCfg(configFlags, disableBeamSpot=True))
#
# Shift LOS
# Add the G4FaserAlg
#
from G4FaserAlg.G4FaserAlgConfig import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(configFlags))
if doShiftLOS:
import McParticleEvent.Pythonizations
from GeneratorUtils.ShiftLOSConfig import ShiftLOSCfg
#
# Output file
#
AcceptAlgNames = ['G4FaserAlg']
from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
from G4FaserAlg.G4FaserAlgConfig import getG4FaserAlgItemList
cfg.merge(OutputStreamCfg(configFlags, "HITS", ItemList=getG4FaserAlgItemList(configFlags), disableEventTag=True, AcceptAlgs=AcceptAlgNames))
# Add in-file MetaData
from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
cfg.merge(SetupMetaDataForStreamCfg(configFlags, "HITS", AcceptAlgs=AcceptAlgNames))
cfg.merge(ShiftLOSCfg(ConfigFlags,
xcross = ConfigFlags.Sim.Beam.xangle,
ycross = ConfigFlags.Sim.Beam.yangle,
xshift = ConfigFlags.Sim.Beam.xshift,
yshift = ConfigFlags.Sim.Beam.yshift))
#
# Add the G4FaserAlg
#Event Filtering?
#
if args.filter == 'muon_conversion':
from GeneratorUtils.MuonFilters import ConversionFilter
import AthenaCommon.AppMgr as acam
import AthenaCommon.AlgSequence as acas
from OutputStreamAthenaPool.OutputStreamConfig import outputStreamName
filt = ConversionFilter("MuonFilter") # , muonEnergyLoss = 5000, minConversionEnergy = 2000) # , muonEnergyLoss = 5000, maxRadius = 100)
cfg.addEventAlgo(filt)
cfg.getEventAlgo(outputStreamName("HITS")).WritingTool.ProcessingTag = "StreamHITS"
OutputStreamHITS = cfg.getEventAlgo(outputStreamName("HITS"))
OutputStreamHITS.RequireAlgs = ["MuonFilter"]
#
from G4FaserAlg.G4FaserAlgConfigNew import G4FaserAlgCfg
cfg.merge(G4FaserAlgCfg(ConfigFlags))
#
# Dump config
#
......@@ -264,7 +326,7 @@ if __name__ == '__main__':
cfg.getService("ConditionStore").Dump = True
cfg.printConfig(withDetails=True, summariseProps = False) # gags on ParticleGun if summariseProps = True?
ConfigFlags.dump()
configFlags.dump()
#f = open("test.pkl","wb")
#cfg.store(f)
#f.close()
......
......@@ -2,17 +2,20 @@
# Used with a condor file to submit to vanilla universe
#
# Usage:
# submit_faser_particlegun.sh config_file segment [release_directory] [working_directory]
# submit_faser_particlegun.sh [script_options --] config_file segment [release_directory] [working_directory] [--other_options]
#
# Options:
# Script Options:
# --out - specify output location (in EOS) to copy output HITS file
# --log - specify output location (in EOS) for log file
# --no_clobber - don't overwrite EOS output file
#
# config_file - full file name (with path)
# segment - segment number (file segment)
# release_directory - optional path to release install directory (default pwd)
# working_directory - optional path to output directory location (default pwd)
#
# Other Options will be passed directly to job script
#
# Afterwards, the output file will be copied to the directory specified in working_directory
#
# The release directory must already be set up
......@@ -39,6 +42,10 @@ do
shift;
shift;;
-n | --no_clobber)
no_clobber=1;
shift;;
--) # End of options
shift; # Eat this
break;; # And stop parsing
......@@ -52,10 +59,40 @@ do
done
#
# Parse command-line options
config_path=${1}
segment=${2}
release_directory=${3}
working_directory=${4}
while [ -n "$1" ]
do
case "$1" in
--) # Stop parsing
shift; # Eat this
break;; # and stop parsing
-*) # Some option
break;; # Stop parsing
*) # Not an option, fill next parameter value
if [ -z "$config_path" ]
then
config_path=${1}
shift
elif [ -z "$segment" ]
then
segment=${1}
shift
elif [ -z "$release_directory" ]
then
release_directory=${1}
shift
elif [ -z "$working_directory" ]
then
working_directory=${1}
shift
else
break # Already filled everything
fi
;;
esac
done
#
# Set defaults if arguments aren't provided
if [ -z "$config_path" ]; then
......@@ -125,22 +162,21 @@ echo "Segment: $seg_str"
echo "Release: $release_directory"
echo "Output: $output_directory"
echo "Starting: $starting_directory"
echo "Remaining: $@"
#
# Set up the release (do this automatically)?
# Must follow with -- to avoid command-line arguments being passed
export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh
source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh --
#
# Try automatic
# Always go back to the starting directory in case paths are relative
cd "$starting_directory"
cd "$release_directory"
# This doesn't seem to work, as we need the --input argument
#asetup
#source build/x8*/setup.sh
#
# Do this by hand
asetup --input=calypso/asetup.faser Athena,22.0.49
source run/setup.sh
#
echo "ATLAS_POOLCOND_PATH = $ATLAS_POOLCOND_PATH"
#
#
......@@ -184,12 +220,18 @@ cd "${config_file_stem}-${seg_str}"
#
# Run job
if [[ -z "$tag" ]]; then
faser_particlegun.py "--conf=$config_path" "--segment=$seg_str"
gen_code=$?
tagstr=""
else
faser_particlegun.py "--conf=$config_path" "--segment=$seg_str" "--tag=$tag"
gen_code=$?
tagstr="--tag=$tag"
fi
#
echo
echo "Submit job:"
echo faser_particlegun.py "--conf=$config_path" "--segment=$seg_str" $tagstr "$@"
echo
faser_particlegun.py "--conf=$config_path" "--segment=$seg_str" $tagstr "$@"
gen_code=$?
#
echo "Return code: $gen_code"
#
# Print out ending time
......@@ -203,19 +245,37 @@ if ! [ -z "$outdest" ]
then
echo "Output directory:"
ls -l
thefile=`ls *-HITS.root`
srcfile=`ls *-HITS.root`
dstfile=$srcfile
if [ $? -eq 0 ]; then
echo "copy $thefile to $outdest"
eos mkdir -p $outdest
eos cp $thefile ${outdest}/${thefile} || true
echo "copy $srcfile to $outdest"
mkdir -p $outdest
# Check if we can overwrite
if ! [ -z "$no_clobber" ]; then
echo "--no_clobber set, checking destination"
ls -l ${outdest}
# Need to check if file already exists
if [ -f ${outdest}/${dstfile} ]; then
echo "File exists, appending date!"
dstfile=${dstfile}.`date "+%y%m%d%H%m"`
else
echo "File doesn't exist!"
fi
# all good, now copy with --no_clobber
cp -n $srcfile ${outdest}/${dstfile} || true
else
# just copy
cp $srcfile ${outdest}/${dstfile} || true
fi
#
# Check that it worked
eos ls ${outdest}/${thefile} > /dev/null
ls ${outdest}/${dstfile} > /dev/null
if [ $? -eq 0 ]; then
echo "file $thefile copied to $outdest"
echo "file $srcfile copied to $outdest"
copy_code=0
else
echo "didnt find $thefile in $outdest !"
echo "didnt find $dstfile in $outdest!"
copy_code=1
fi
else
......@@ -232,15 +292,15 @@ then
echo "Working directory:"
ls -l
echo "copy $logfile to $logdest"
eos mkdir -p $logdest
eos cp $logfile $logdest/$logfile
mkdir -p $logdest
cp $logfile $logdest/$logfile
elif ! [ -z "$outdest" ]
then
cd ..
ls -l
echo "copy $logfile to $outdest"
eos mkdir -p $outdest
eos cp $logfile $outdest/$logfile
mkdir -p $outdest
cp $logfile $outdest/$logfile
fi
# Make sure to return an error is calypso failed
......
......@@ -18,24 +18,46 @@ atlas_add_component( GeoModelTest
atlas_add_test( Faser01GeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser01TestConfig.py
PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
PROPERTIES TIMEOUT 300 )
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT noerror.sh
)
atlas_add_test( Faser02GeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser02TestConfig.py
PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
PROPERTIES TIMEOUT 300 )
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT noerror.sh
)
atlas_add_test( Faser03GeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser03TestConfig.py
PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
PROPERTIES TIMEOUT 300 )
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT noerror.sh
)
atlas_add_test( Faser04GeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/Faser04TestConfig.py
PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT noerror.sh
)
atlas_add_test( TestBeamGeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/TestBeamTestConfig.py
atlas_add_test( TestBeam00GeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/TestBeam00TestConfig.py
PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
PROPERTIES TIMEOUT 300 )
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT noerror.sh
)
atlas_add_test( TestBeam01GeoCheck
SCRIPT python ${CMAKE_CURRENT_SOURCE_DIR}/python/TestBeam01TestConfig.py
PROPERTIES WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
PROPERTIES TIMEOUT 300
POST_EXEC_SCRIPT noerror.sh
)
# Install files from the package:
#atlas_install_headers( GeoModelTest )
#atlas_install_joboptions( share/*.py )
......