ATLAS Offline Software
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
python.HLT.MET.ConfigHelpers.AlgConfig Class Reference

Inherits ABC.

Inherited by python.HLT.MET.AlgConfigs.CellConfig, python.HLT.MET.AlgConfigs.CVFPufitConfig, python.HLT.MET.AlgConfigs.MHTConfig, python.HLT.MET.AlgConfigs.MHTPufitConfig, python.HLT.MET.AlgConfigs.NNHLTConfig, python.HLT.MET.AlgConfigs.PFOPufitConfig, python.HLT.MET.AlgConfigs.PFSumConfig, python.HLT.MET.AlgConfigs.TCConfig, python.HLT.MET.AlgConfigs.TCPufitConfig, and python.HLT.MET.AlgConfigs.TrkMHTConfig.

Collaboration diagram for python.HLT.MET.ConfigHelpers.AlgConfig:

Public Member Functions

str algType (cls)
 
def __init__ (self, **str recoDict)
 
str outputKey (self)
 
str fexName (self)
 
dict[str, Any] interpret_reco_dict (self)
 
def getMonTool (self, flags)
 
str name_step (self, idx)
 
StepOutput make_reco_algs (self, flags, **recoDict)
 
def make_reco_ca (self, flags)
 
def make_accumulator_steps (self, flags, chainDict)
 
def make_hypo_alg (self)
 
def make_passthrough_hypo_alg (self, step)
 
def inputMakerCA (self, idx)
 
AlgConfig fromRecoDict (cls, EFrecoAlg, **recoDict)
 

Public Attributes

 recoDict
 

Private Member Functions

None _append_fex (self, flags, fex, Optional[StepOutput] inputs=None)
 
def _get_subclasses (cls)
 

Private Attributes

 _suffix
 

Detailed Description

Base class to describe algorithm configurations

Each individual 'EFrecoAlg' should be described by *one* AlgConfig subclass.
It must provide its list of required inputs to the constructor and override
the make_fex method

The name of fexAlg *must* be self.fexName and the METContainerKey property
*must* be set to self.outputKey (but this class usually should take care of
this).

The subclass must also implement the @classmethod 'algType' which returns
the EFrecoAlg string that it describes.

Definition at line 94 of file ConfigHelpers.py.

Constructor & Destructor Documentation

◆ __init__()

def python.HLT.MET.ConfigHelpers.AlgConfig.__init__ (   self,
**str  recoDict 
)
Initialise the base class

=========
Arguments
=========
recoDict: Pass *all* the keys required for the recoDict

Definition at line 119 of file ConfigHelpers.py.

119  def __init__(self, **recoDict: str):
120  """Initialise the base class
121 
122  =========
123  Arguments
124  =========
125  recoDict: Pass *all* the keys required for the recoDict
126  """
127 
128  # Make sure that we got *all* the keys (i.e. the subclass didn't
129  # inadvertently steal one of them from us)
130  alg_type = self.algType()
131  assert all(k in recoDict for k in recoKeys), (
132  f"AlgConfig.__init__ for {alg_type} did not receive all the recoKeys"
133  " - this suggests a problem in the subclass __init__ method!"
134  )
135  self.recoDict = copy(recoDict)
136  self._suffix = metRecoDictToString(recoDict)
137 

Member Function Documentation

◆ _append_fex()

None python.HLT.MET.ConfigHelpers.AlgConfig._append_fex (   self,
  flags,
  fex,
Optional[StepOutput]   inputs = None 
)
private
Append the FEX to the output object

Finalizes the FEX by setting the monitoring tool and output name.

Definition at line 168 of file ConfigHelpers.py.

168  def _append_fex(self, flags, fex, inputs: Optional[StepOutput] = None) -> None:
169  """Append the FEX to the output object
170 
171  Finalizes the FEX by setting the monitoring tool and output name.
172  """
173  fex.MonTool = self.getMonTool(flags)
174  fex.METContainerKey = self.outputKey
175  acc = ComponentAccumulator()
176  acc.addEventAlgo(fex, primary=True)
177  return StepOutput.create(acc, inputs, MET=self.outputKey)
178 

◆ _get_subclasses()

def python.HLT.MET.ConfigHelpers.AlgConfig._get_subclasses (   cls)
private
Provides a way to iterate over all subclasses of this class

Definition at line 288 of file ConfigHelpers.py.

288  def _get_subclasses(cls):
289  """Provides a way to iterate over all subclasses of this class"""
290  for subcls in cls.__subclasses__():
291  for subsubcls in subcls.__subclasses__():
292  yield subsubcls
293  yield subcls
294 

◆ algType()

str python.HLT.MET.ConfigHelpers.AlgConfig.algType (   cls)
The algorithm that this object configures - this corresponds to the
EFrecoAlg in the METChainParts dictionary

Note that no two subclasses of AlgConfig can describe the same algorithm
(as identified by this string).

Reimplemented in python.HLT.MET.AlgConfigs.NNHLTConfig, python.HLT.MET.AlgConfigs.MHTPufitConfig, python.HLT.MET.AlgConfigs.CVFPufitConfig, python.HLT.MET.AlgConfigs.PFOPufitConfig, python.HLT.MET.AlgConfigs.PFSumConfig, python.HLT.MET.AlgConfigs.TrkMHTConfig, python.HLT.MET.AlgConfigs.MHTConfig, python.HLT.MET.AlgConfigs.TCPufitConfig, python.HLT.MET.AlgConfigs.TCConfig, and python.HLT.MET.AlgConfigs.CellConfig.

Definition at line 110 of file ConfigHelpers.py.

110  def algType(cls) -> str:
111  """The algorithm that this object configures - this corresponds to the
112  EFrecoAlg in the METChainParts dictionary
113 
114  Note that no two subclasses of AlgConfig can describe the same algorithm
115  (as identified by this string).
116  """
117  raise NotImplementedError("algType not implemented by subclass!")
118 

◆ fexName()

str python.HLT.MET.ConfigHelpers.AlgConfig.fexName (   self)
The name of the algorithm made by this configuration

Definition at line 146 of file ConfigHelpers.py.

146  def fexName(self) -> str:
147  """The name of the algorithm made by this configuration"""
148  return "EFMET_{}".format(self._suffix)
149 

◆ fromRecoDict()

AlgConfig python.HLT.MET.ConfigHelpers.AlgConfig.fromRecoDict (   cls,
  EFrecoAlg,
**  recoDict 
)

Definition at line 296 of file ConfigHelpers.py.

296  def fromRecoDict(cls, EFrecoAlg, **recoDict) -> AlgConfig:
297  for subcls in cls._get_subclasses():
298  if subcls.algType() == EFrecoAlg:
299  return subcls(EFrecoAlg=EFrecoAlg, **recoDict)
300 
301  raise ValueError("Unknown EFrecoAlg '{}' requested".format(EFrecoAlg))
302 

◆ getMonTool()

def python.HLT.MET.ConfigHelpers.AlgConfig.getMonTool (   self,
  flags 
)
Create the monitoring tool

Definition at line 154 of file ConfigHelpers.py.

154  def getMonTool(self, flags):
155  """Create the monitoring tool"""
156  return getMETMonTool(flags)
157 

◆ inputMakerCA()

def python.HLT.MET.ConfigHelpers.AlgConfig.inputMakerCA (   self,
  idx 
)
Get the InEventRecoCA for the given step index

Definition at line 264 of file ConfigHelpers.py.

264  def inputMakerCA(self, idx):
265  """Get the InEventRecoCA for the given step index"""
266  from TrigT2CaloCommon.CaloDef import clusterFSInputMaker
267  from AthenaConfiguration.ComponentFactory import CompFactory
268  from ..CommonSequences.FullScanDefs import trkFSRoI
269 
270  name = self.name_step(idx) + "Reco"
271  if idx == 0:
272  return InEventRecoCA(name, inputMaker=clusterFSInputMaker())
273  elif idx == 1:
274  return None
275  elif idx == 2:
276  return InEventRecoCA(
277  name,
278  inputMaker=CompFactory.InputMakerForRoI(
279  "IM_Jet_TrackingStep",
280  RoITool=CompFactory.ViewCreatorInitialROITool(),
281  RoIs=trkFSRoI,
282  ),
283  )
284  else:
285  raise KeyError(f"No input maker for step {idx}")
286 

◆ interpret_reco_dict()

dict[str, Any] python.HLT.MET.ConfigHelpers.AlgConfig.interpret_reco_dict (   self)
Return a version of the reco dict with any necessary post-processing

Reimplemented in python.HLT.MET.AlgConfigs.MHTPufitConfig, and python.HLT.MET.AlgConfigs.MHTConfig.

Definition at line 150 of file ConfigHelpers.py.

150  def interpret_reco_dict(self) -> dict[str, Any]:
151  """Return a version of the reco dict with any necessary post-processing"""
152  return self.recoDict
153 

◆ make_accumulator_steps()

def python.HLT.MET.ConfigHelpers.AlgConfig.make_accumulator_steps (   self,
  flags,
  chainDict 
)
Make the full accumulator steps

Definition at line 193 of file ConfigHelpers.py.

193  def make_accumulator_steps(self, flags, chainDict):
194  """Make the full accumulator steps"""
195 
196  # Get the reco sequences
197  reco_sequences = self.make_reco_algs(flags, **self.interpret_reco_dict()).steps
198  output_steps = []
199  # build up the output steps
200  # We have to merge together the CAs containing the reconstruction sequences
201  # and the InEventRecoCAs that contain the input makers
202  for step_idx, reco_sequence in enumerate(reco_sequences):
203  reco_acc = self.inputMakerCA(step_idx)
204  sel_acc = None
205  step_name = f"Empty_METStep{step_idx}"
206  if (
207  reco_acc is not None
208  ): # Define reco and hypo algorithms only if reco_acc is not None
209  if step_idx == len(reco_sequences) - 1:
210  # If this is the last step we have to add the hypo alg
211  hypo_alg = self.make_hypo_alg()
212  hypo_tool = TrigMETHypoToolFromDict
213  else:
214  # Otherwise, we add a passthrough hypo
215  hypo_alg = self.make_passthrough_hypo_alg(step_idx)
216  hypo_tool = streamer_hypo_tool
217 
218  # Now merge the reco sequence into the InEventRecoCA
219  reco_acc.mergeReco(reco_sequence)
220 
221  # Create a selection CA
222  sel_acc = SelectionCA("METAthSeq_" + self.name_step(step_idx))
223  # Merge in the reconstruction sequence
224  sel_acc.mergeReco(reco_acc)
225  # Add its hypo alg
226  sel_acc.addHypoAlgo(hypo_alg)
227 
228  # FIXME: We need to mark the CA as merged because during the fast menu generation
229  # the merging is only done once for all chains, which is not compatible with the MET
230  # menu generation code. Remove this once ATR-29211 is fixed.
231  sel_acc.wasMerged()
232 
233  step_name = sel_acc.name
234 
235  # Build the menu sequence and create the actual chainStep
236  output_steps.append(
237  ChainStep(
238  name=step_name,
239  multiplicity=[] if sel_acc is None else [1],
240  chainDicts=[chainDict],
241  Sequences=[]
242  if sel_acc is None
243  else [
244  functools.partial(make_MET_menu_sequenceGenCfg, flags, sel_acc, hypo_tool)
245  ],
246  comboHypoCfg=ComboHypoCfg
247  )
248  )
249 
250  return output_steps
251 
252 

◆ make_hypo_alg()

def python.HLT.MET.ConfigHelpers.AlgConfig.make_hypo_alg (   self)
The hypo alg used for this configuration

Definition at line 253 of file ConfigHelpers.py.

253  def make_hypo_alg(self):
254  """The hypo alg used for this configuration"""
255  return CompFactory.TrigMissingETHypoAlg(
256  f"METHypoAlg_{self._suffix}", METContainerKey=self.outputKey
257  )
258 

◆ make_passthrough_hypo_alg()

def python.HLT.MET.ConfigHelpers.AlgConfig.make_passthrough_hypo_alg (   self,
  step 
)

Definition at line 259 of file ConfigHelpers.py.

259  def make_passthrough_hypo_alg(self, step):
260  return CompFactory.TrigStreamerHypoAlg(
261  "METPassThroughHypo_" + self.name_step(step)
262  )
263 

◆ make_reco_algs()

StepOutput python.HLT.MET.ConfigHelpers.AlgConfig.make_reco_algs (   self,
  flags,
**  recoDict 
)
Create the reconstruction sequences including the FEX

Returns a list of CAs split by step

Reimplemented in python.HLT.MET.AlgConfigs.NNHLTConfig, python.HLT.MET.AlgConfigs.MHTPufitConfig, python.HLT.MET.AlgConfigs.CVFPufitConfig, python.HLT.MET.AlgConfigs.PFOPufitConfig, python.HLT.MET.AlgConfigs.PFSumConfig, python.HLT.MET.AlgConfigs.TrkMHTConfig, python.HLT.MET.AlgConfigs.MHTConfig, python.HLT.MET.AlgConfigs.TCPufitConfig, python.HLT.MET.AlgConfigs.TCConfig, and python.HLT.MET.AlgConfigs.CellConfig.

Definition at line 162 of file ConfigHelpers.py.

162  def make_reco_algs(self, flags, **recoDict) -> StepOutput:
163  """Create the reconstruction sequences including the FEX
164 
165  Returns a list of CAs split by step
166  """
167 

◆ make_reco_ca()

def python.HLT.MET.ConfigHelpers.AlgConfig.make_reco_ca (   self,
  flags 
)
Make the reconstruction sequences for the new JO style

Definition at line 179 of file ConfigHelpers.py.

179  def make_reco_ca(self, flags):
180  """Make the reconstruction sequences for the new JO style"""
181  # Retrieve the inputs
182  log.verbose("Create inputs for %s", self._suffix)
183  steps, inputs = self.inputRegistry.build_steps(
184  flags, self._inputs, metFSRoIs, self.recoDict, return_ca=True
185  )
186  # Create the FEX and add it to the last input sequence
187  fex = self.make_fex_accumulator(flags, self.fexName, inputs)
188  fex.MonTool = self.getMonTool(flags)
189  fex.METContainerKey = self.outputKey
190  steps[-1].addEventAlgo(fex)
191  return steps
192 

◆ name_step()

str python.HLT.MET.ConfigHelpers.AlgConfig.name_step (   self,
  idx 
)

Definition at line 158 of file ConfigHelpers.py.

158  def name_step(self, idx) -> str:
159  return f"step{ascii_uppercase[idx]}_{self._suffix}"
160 

◆ outputKey()

str python.HLT.MET.ConfigHelpers.AlgConfig.outputKey (   self)
The MET container object produced by this algorithm

Definition at line 139 of file ConfigHelpers.py.

139  def outputKey(self) -> str:
140  """The MET container object produced by this algorithm"""
141  from TrigEDMConfig.TriggerEDM import recordable
142 
143  return recordable("HLT_MET_{}".format(self._suffix))
144 

Member Data Documentation

◆ _suffix

python.HLT.MET.ConfigHelpers.AlgConfig._suffix
private

Definition at line 136 of file ConfigHelpers.py.

◆ recoDict

python.HLT.MET.ConfigHelpers.AlgConfig.recoDict

Definition at line 135 of file ConfigHelpers.py.


The documentation for this class was generated from the following file:
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
python.HLT.MET.ConfigHelpers.metRecoDictToString
str metRecoDictToString(dict[str, str] recoDict, bool skipDefaults=True)
Definition: ConfigHelpers.py:49
CaloDef.clusterFSInputMaker
def clusterFSInputMaker()
cluster maker functions
Definition: CaloDef.py:51
TileDigitizationConfig.outputKey
outputKey
Definition: TileDigitizationConfig.py:104
MTCalibPebConfig.make_hypo_alg
def make_hypo_alg(name)
Definition: MTCalibPebConfig.py:154
TrigEFMissingETConfig.getMETMonTool
def getMETMonTool(flags, name="MonTool")
Definition: TrigEFMissingETConfig.py:5
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64
python.TriggerEDM.recordable
def recordable(arg, runVersion=3)
Definition: TriggerEDM.py:30
calibdata.copy
bool copy
Definition: calibdata.py:27