5 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from AthenaConfiguration.Enums
import ProductionStep
7 from DerivationFrameworkConfiguration
import DerivationConfigList
8 from PyJobTransforms.CommonRunArgsToFlags
import commonRunArgsToFlags
9 from PyJobTransforms.TransformUtils
import processPreExec, processPreInclude, processPostExec, processPostInclude
12 from AthenaCommon
import JobProperties
13 JobProperties.jobPropertiesDisallowed =
True
17 from AthenaCommon.Logging
import logging
18 logDerivation = logging.getLogger(
'Derivation')
19 logDerivation.info(
'****************** STARTING DERIVATION *****************')
21 logDerivation.info(
'**** Transformation run arguments')
22 logDerivation.info(
str(runArgs))
24 logDerivation.info(
'**** Setting-up configuration flags')
25 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
27 flags.Exec.EventPrintoutInterval = 100
30 flags.Common.ProductionStep = ProductionStep.Derivation
33 from PerfMonComps.PerfMonConfigHelpers
import setPerfmonFlagsFromRunArgs
37 allowedInputTypes = [
'AOD',
'DAOD_PHYS',
'EVNT' ]
38 availableInputTypes = [ hasattr(runArgs, f
'input{inputType}File')
for inputType
in allowedInputTypes ]
39 if sum(availableInputTypes) != 1:
40 raise ValueError(
'Input must be exactly one of the following types: inputAODFile, inputEVNTFile, inputDAOD_PHYSFile')
41 idx = availableInputTypes.index(
True)
42 flags.Input.Files = getattr(runArgs, f
'input{allowedInputTypes[idx]}File')
47 if hasattr(runArgs,
'augmentations'):
48 for val
in runArgs.augmentations:
49 if ':' not in val
or len(val.split(
':')) != 2:
50 logDerivation.error(
'Derivation job started, but with wrong augmentation syntax - aborting')
51 raise ValueError(
'Invalid augmentation argument: {0}'.
format(val))
53 child, parent = val.split(
':')
54 flags.addFlag(f
'Output.DAOD_{child}ParentStream',f
'DAOD_{parent}')
55 childStreamFlag = f
'Output.DAOD_{parent}ChildStream'
56 if not flags.hasFlag(childStreamFlag):
57 flags.addFlag(childStreamFlag, [f
'DAOD_{child}'])
59 flags._set(childStreamFlag, flags._get(childStreamFlag) + [f
'DAOD_{child}'])
60 logDerivation.info(
'Setting up event augmentation as {0} => {1}'.
format(child, parent))
64 if hasattr(runArgs,
'formats'):
65 formats = runArgs.formats
66 logDerivation.info(
'Will attempt to make the following derived formats: {0}'.
format(formats))
68 logDerivation.error(
'Derivation job started, but with no output formats specified - aborting')
69 raise ValueError(
'No derived formats specified')
72 for runArg
in dir(runArgs):
73 if 'output' in runArg
and 'File' in runArg
and 'Type' not in runArg
and 'NTUP_PHYSVAL' not in runArg:
74 outputFileName = getattr(runArgs, runArg)
75 flagString = f
'Output.{runArg.removeprefix("output")}Name'
76 flags.addFlag(flagString, outputFileName)
77 flags.addFlag(f
'Output.doWrite{runArg.removeprefix("output").removesuffix("File")}',
True)
78 flags.Output.doWriteDAOD =
True
81 from Campaigns.Utils
import Campaign, campaign_runs
82 if flags.Input.isMC
and flags.Input.MCCampaign
is Campaign.Unknown:
83 if flags.Input.RunNumbers:
84 mc_campaign = campaign_runs.get(flags.Input.RunNumbers[0], Campaign.Unknown)
86 if mc_campaign
is not Campaign.Unknown:
87 flags.Input.MCCampaign = mc_campaign
88 logDerivation.info(
'Will recover MC campaign to: %s', mc_campaign.value)
103 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
107 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
111 if (allowedInputTypes[idx]==
'EVNT'):
112 from AthenaServices.MetaDataSvcConfig
import MetaDataSvcCfg
115 for formatName
in formats:
116 derivationConfig = getattr(DerivationConfigList, f
'{formatName}Cfg')
117 cfg.merge(derivationConfig(flags))
120 if hasattr(runArgs,
'passThrough'):
121 logDerivation.info(
'Pass-through mode was requested. All events will be written to the output.')
122 for algo
in cfg.getEventAlgos():
123 if isinstance(algo, CompFactory.DerivationFramework.DerivationKernel):
124 algo.SkimmingTools = []
127 if flags.PerfMon.doFullMonMT
or flags.PerfMon.doFastMonMT:
128 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
132 from PyUtils.AMITagHelperConfig
import AMITagCfg
133 cfg.merge(
AMITagCfg(flags, runArgs, fixBroken=
True))
137 from GeneratorConfig.Versioning
import GeneratorVersioningFixCfg
141 if not flags.Input.isMC
and flags.Input.DataYear > 0:
142 from EventInfoMgt.TagInfoMgrConfig
import TagInfoMgrCfg
144 "data_year":
str(flags.Input.DataYear)
147 from EventInfoMgt.TagInfoMgrConfig
import TagInfoMgrCfg
157 from AthenaConfiguration.Utils
import setupLoggingLevels
162 sys.exit(
not sc.isSuccess())