85 def makeAlgs (self, config) :
87 log = logging.getLogger(
'OutputAnalysisConfig')
89 self.vars =
set(self.vars)
90 self.varsOnlyForMC =
set(self.varsOnlyForMC)
91 self.metVars =
set(self.metVars)
92 self.truthMetVars =
set(self.truthMetVars)
95 if config.dataType()
is not DataType.Data:
96 self.vars |= self.varsOnlyForMC
103 keys_message = [
repr(key)
for key
in overlapping_keys]
104 raise KeyError(f
"containersOnlyForMC would overwrite the following container keys: {', '.join(keys_message)}")
107 self.containers.
update(self.containersOnlyForMC)
109 self.containersOnlyForMC.
clear()
112 for container,dsid_filters
in self.containersOnlyForDSIDs.
items():
113 if container
not in self.containers:
114 log.warning(f
"Skipping unrecognised container {container} for DSID-filtering in OutputAnalysisConfig...")
116 if not filter_dsids (dsid_filters, config):
118 self.containers.pop (container)
120 if self.storeSelectionFlags:
121 self.createSelectionFlagBranches(config)
124 for prefix
in self.containers.
keys() :
125 containerName = self.containers[prefix]
126 outputDict = config.getOutputVars (containerName)
127 for outputName
in outputDict :
128 outputConfig = copy.deepcopy (outputDict[outputName])
129 if containerName ==
'EventInfo' :
130 outputConfig.outputContainerName = outputConfig.origContainerName
131 elif outputConfig.outputContainerName != outputConfig.origContainerName :
132 outputConfig.outputContainerName = containerName +
'_%SYS%'
134 outputConfig.outputContainerName = config.readName (containerName)
135 outputConfigs[prefix + outputName] = outputConfig
137 for command
in self.commands :
138 words = command.split (
' ')
139 if len (words) == 0 :
140 raise ValueError (
'received empty command for "commands" option')
141 if words[0] ==
'enable' :
142 if len (words) != 2 :
143 raise ValueError (
'enable takes exactly one argument: ' + command)
145 for name
in outputConfigs :
146 if re.match (words[1], name) :
147 outputConfigs[name].enabled =
True
149 if not used
and config.dataType()
is not DataType.Data:
150 raise KeyError (
'unknown branch pattern for enable: ' + words[1])
151 elif words[0] ==
'disable' :
152 if len (words) != 2 :
153 raise ValueError (
'disable takes exactly one argument: ' + command)
155 for name
in outputConfigs :
156 if re.match (words[1], name) :
157 outputConfigs[name].enabled =
False
159 if not used
and config.dataType()
is not DataType.Data:
160 raise KeyError (
'unknown branch pattern for disable: ' + words[1])
162 raise KeyError (
'unknown command for "commands" option: ' + words[0])
166 autoTruthMetVars =
set()
167 for outputName
in outputConfigs :
168 outputConfig = outputConfigs[outputName]
169 if outputConfig.enabled :
170 if config.isMetContainer (outputConfig.origContainerName):
171 if "Truth" in outputConfig.origContainerName:
172 myVars = autoTruthMetVars
177 if outputConfig.noSys :
178 outputConfig.outputContainerName = outputConfig.outputContainerName.replace (
'%SYS%',
'NOSYS')
179 outputConfig.variableName = outputConfig.variableName.replace (
'%SYS%',
'NOSYS')
180 if self.alwaysAddNosys :
181 outputName +=
"_NOSYS"
183 outputName +=
'_%SYS%'
184 myVars.add(f
"{outputConfig.outputContainerName}.{outputConfig.variableName} -> {outputName}")
187 postfix = self.postfix
189 postfix = self.treeName
192 treeMaker = config.createAlgorithm(
'CP::TreeMakerAlg', f
'TreeMaker{postfix}' )
193 treeMaker.TreeName = self.treeName
194 treeMaker.RootStreamName = self.streamName
198 if self.vars
or autoVars:
199 ntupleMaker = self.createOutputAlgs(config, f
'NTupleMaker{postfix}', self.vars | autoVars)
201 if self.metVars
or autoMetVars:
202 ntupleMaker = self.createOutputAlgs(config, f
'MetNTupleMaker{postfix}', self.metVars | autoMetVars, isMet=
True)
203 ntupleMaker.termName = self.metTermName
205 if config.dataType()
is not DataType.Data
and (self.truthMetVars
or autoTruthMetVars):
206 ntupleMaker = self.createOutputAlgs(config, f
'TruthMetNTupleMaker{postfix}', self.truthMetVars | autoTruthMetVars, isMet=
True)
207 ntupleMaker.termName = self.truthMetTermName
209 treeFiller = config.createAlgorithm(
'CP::TreeFillerAlg',
'TreeFiller' + postfix )
210 treeFiller.TreeName = self.treeName
211 treeFiller.RootStreamName = self.streamName