63 def makeAlgs (self, config) :
65 log = logging.getLogger(
'OutputAnalysisConfig')
67 self.vars =
set(self.vars)
68 self.varsOnlyForMC =
set(self.varsOnlyForMC)
70 if config.dataType()
is not DataType.Data:
71 self.vars |= self.varsOnlyForMC
78 keys_message = [
repr(key)
for key
in overlapping_keys]
79 raise KeyError(f
"containersOnlyForMC would overwrite the following container keys: {', '.join(keys_message)}")
82 self.containers.
update(self.containersOnlyForMC)
84 self.containersOnlyForMC.
clear()
87 for container,dsid_filters
in self.containersOnlyForDSIDs.
items():
88 if container
not in self.containers:
89 log.warning(f
"Skipping unrecognised container {container} for DSID-filtering in OutputAnalysisConfig...")
91 if not filter_dsids (dsid_filters, config):
93 self.containers.pop (container)
95 if self.storeSelectionFlags:
96 self.createSelectionFlagBranches(config)
99 for prefix
in self.containers.
keys() :
100 containerName = self.containers[prefix]
101 outputDict = config.getOutputVars (containerName)
102 for outputName
in outputDict :
103 outputConfig = copy.deepcopy (outputDict[outputName])
104 if containerName ==
'EventInfo' :
105 outputConfig.outputContainerName = outputConfig.origContainerName
106 elif outputConfig.outputContainerName != outputConfig.origContainerName :
107 outputConfig.outputContainerName = containerName +
'_%SYS%'
109 outputConfig.outputContainerName = config.readName (containerName)
110 outputConfigs[prefix + outputName] = outputConfig
112 for command
in self.commands :
113 words = command.split (
' ')
114 if len (words) == 0 :
115 raise ValueError (
'received empty command for "commands" option')
116 if words[0] ==
'enable' :
117 if len (words) != 2 :
118 raise ValueError (
'enable takes exactly one argument: ' + command)
120 for name
in outputConfigs :
121 if re.match (words[1], name) :
122 outputConfigs[name].enabled =
True
124 if not used
and config.dataType()
is not DataType.Data:
125 raise KeyError (
'unknown branch pattern for enable: ' + words[1])
126 elif words[0] ==
'disable' :
127 if len (words) != 2 :
128 raise ValueError (
'disable takes exactly one argument: ' + command)
130 for name
in outputConfigs :
131 if re.match (words[1], name) :
132 outputConfigs[name].enabled =
False
134 if not used
and config.dataType()
is not DataType.Data:
135 raise KeyError (
'unknown branch pattern for disable: ' + words[1])
137 raise KeyError (
'unknown command for "commands" option: ' + words[0])
141 for outputName
in outputConfigs :
142 outputConfig = outputConfigs[outputName]
143 if outputConfig.enabled :
144 if config.isMetContainer (outputConfig.origContainerName) :
148 if outputConfig.noSys :
149 outputConfig.outputContainerName = outputConfig.outputContainerName.replace (
'%SYS%',
'NOSYS')
150 outputConfig.variableName = outputConfig.variableName.replace (
'%SYS%',
'NOSYS')
151 if self.alwaysAddNosys :
152 outputName +=
"_NOSYS"
154 outputName +=
'_%SYS%'
155 myVars += [outputConfig.outputContainerName +
'.' + outputConfig.variableName +
' -> ' + outputName]
157 postfix = self.postfix
160 treeMaker = config.createAlgorithm(
'CP::TreeMakerAlg',
'TreeMaker' + postfix )
161 treeMaker.TreeName = self.treeName
162 treeMaker.RootStreamName = self.streamName
166 if len (self.vars) + len (autoVars) :
167 ntupleMaker = config.createAlgorithm(
'CP::AsgxAODNTupleMakerAlg',
'NTupleMaker' + postfix )
168 ntupleMaker.TreeName = self.treeName
169 ntupleMaker.RootStreamName = self.streamName
170 branchList =
list(self.vars |
set(autoVars))
172 branchList_nosys = [branch
for branch
in branchList
if "%SYS%" not in branch]
173 branchList_sys = [branch
for branch
in branchList
if "%SYS%" in branch]
174 ntupleMaker.Branches = branchList_nosys + branchList_sys
177 if len (self.metVars) + len (autoMetVars) > 0:
178 ntupleMaker = config.createAlgorithm(
'CP::AsgxAODMetNTupleMakerAlg',
'MetNTupleMaker' + postfix )
179 ntupleMaker.TreeName = self.treeName
180 ntupleMaker.RootStreamName = self.streamName
181 branchList = self.metVars + autoMetVars
183 branchList_nosys = [branch
for branch
in branchList
if "%SYS%" not in branch]
184 branchList_sys = [branch
for branch
in branchList
if "%SYS%" in branch]
185 ntupleMaker.Branches = branchList_nosys + branchList_sys
186 ntupleMaker.termName = self.metTermName
189 treeFiller = config.createAlgorithm(
'CP::TreeFillerAlg',
'TreeFiller' + postfix )
190 treeFiller.TreeName = self.treeName
191 treeFiller.RootStreamName = self.streamName