Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions | Variables
python.EGAM9 Namespace Reference

Functions

def EGAM9SkimmingToolCfg (flags)
 
def EGAM9KernelCfg (flags, name="EGAM9Kernel", **kwargs)
 
def EGAM9Cfg (flags)
 

Variables

bool thinCells = False
 
bool keepCells = False
 
bool applyTriggerSelection = True
 
bool saveJets = False
 

Function Documentation

◆ EGAM9Cfg()

def python.EGAM9.EGAM9Cfg (   flags)

Definition at line 267 of file EGAM9.py.

267 def EGAM9Cfg(flags):
268  acc = ComponentAccumulator()
269 
270  # Get the lists of triggers needed for trigger matching.
271  # This is needed at this scope (for the slimming) and further down
272  # in the config chain for actually configuring the matching, so we create
273  # it here and pass it down
274  # TODO: this should ideally be called higher up to avoid it being run
275  # multiple times in a train.
276  # TODO: restrict it to relevant triggers
277  from DerivationFrameworkPhys.TriggerListsHelper import TriggerListsHelper
278 
279  EGAM9TriggerListsHelper = TriggerListsHelper(flags)
280 
281  # configure skimming/thinning/augmentation tools
282  acc.merge(
284  flags,
285  name="EGAM9Kernel",
286  StreamName="StreamDAOD_EGAM9",
287  TriggerListsHelper=EGAM9TriggerListsHelper,
288  )
289  )
290 
291  # configure slimming
292  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
293  from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg
294  from DerivationFrameworkCore.SlimmingHelper import SlimmingHelper
295 
296  EGAM9SlimmingHelper = SlimmingHelper(
297  "EGAM9SlimmingHelper",
298  NamesAndTypes=flags.Input.TypedCollections,
299  flags=flags,
300  )
301 
302  # ------------------------------------------
303  # containers for which we save all variables
304  # -------------------------------------------
305 
306  # baseline
307  EGAM9SlimmingHelper.AllVariables = [
308  "Electrons",
309  "Photons",
310  "GSFTrackParticles",
311  "egammaClusters",
312  ]
313 
314  # for trigger studies we also add:
315  MenuType = None
316  if flags.Trigger.EDMVersion == 2:
317  MenuType = "Run2"
318  elif flags.Trigger.EDMVersion == 3:
319  MenuType = "Run3"
320  else:
321  MenuType = ""
322  EGAM9SlimmingHelper.AllVariables += ExtraContainersTrigger[MenuType]
323  EGAM9SlimmingHelper.AllVariables += ExtraContainersPhotonTrigger[MenuType]
324  if not flags.Input.isMC:
325  EGAM9SlimmingHelper.AllVariables += ExtraContainersTriggerDataOnly[MenuType]
326 
327  # and on MC we also add:
328  if flags.Input.isMC:
329  EGAM9SlimmingHelper.AllVariables += [
330  "TruthEvents",
331  "TruthParticles",
332  "TruthVertices",
333  "egammaTruthParticles",
334  ]
335 
336  # -------------------------------------------
337  # containers that we slim
338  # -------------------------------------------
339 
340  # first add variables from smart-slimming
341  # adding only also those for which we add all variables since
342  # the XXXCPContent.py files also bring in some extra variables
343  # for other collections
344  EGAM9SlimmingHelper.SmartCollections = [
345  "Electrons",
346  "Photons",
347  "InDetTrackParticles",
348  "PrimaryVertices",
349  ]
350  if saveJets:
351  EGAM9SlimmingHelper.SmartCollections += ["AntiKt4EMPFlowJets"]
352  if flags.Input.isMC:
353  EGAM9SlimmingHelper.SmartCollections += [
354  "AntiKt4TruthJets",
355  "AntiKt4TruthDressedWZJets",
356  ]
357 
358  # then add extra variables:
359 
360  # photons
361  EGAM9SlimmingHelper.ExtraVariables += ["Photons.DFCommonLoosePrime5"]
362 
363  # conversion vertices
364  EGAM9SlimmingHelper.ExtraVariables += [
365  "GSFConversionVertices.x.y.z.px.py.pz.pt1.pt2.etaAtCalo.phiAtCalo",
366  "GSFConversionVertices.trackParticleLinks",
367  ]
368 
369  # primary vertices
370  EGAM9SlimmingHelper.ExtraVariables += ["PrimaryVertices.x.y.sumPt2"]
371 
372  # track jets
373  if saveJets:
374  EGAM9SlimmingHelper.ExtraVariables += [
375  "AntiKt4PV0TrackJets.pt.eta.phi.e.m.btaggingLink.constituentLinks"
376  ]
377 
378  # photons and electrons: detailed shower shape variables and track variables
379  EGAM9SlimmingHelper.ExtraVariables += PhotonsCPDetailedContent
380  EGAM9SlimmingHelper.ExtraVariables += ElectronsCPDetailedContent
381  EGAM9SlimmingHelper.ExtraVariables += GSFTracksCPDetailedContent
382 
383  # photons: gain and cluster energy per layer
384  from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
385  getGainDecorations,
386  getClusterEnergyPerLayerDecorations,
387  )
388 
389  gainDecorations = getGainDecorations(acc, flags, "EGAM9Kernel")
390  print("EGAM9 gain decorations: ", gainDecorations)
391  EGAM9SlimmingHelper.ExtraVariables.extend(gainDecorations)
392  clusterEnergyDecorations = getClusterEnergyPerLayerDecorations(acc, "EGAM9Kernel")
393  print("EGAM9 cluster energy decorations: ", clusterEnergyDecorations)
394  EGAM9SlimmingHelper.ExtraVariables.extend(clusterEnergyDecorations)
395 
396  # energy density
397  EGAM9SlimmingHelper.ExtraVariables += [
398  "TopoClusterIsoCentralEventShape.Density",
399  "TopoClusterIsoForwardEventShape.Density",
400  "NeutralParticleFlowIsoCentralEventShape.Density",
401  "NeutralParticleFlowIsoForwardEventShape.Density",
402  ]
403 
404  # truth
405  if flags.Input.isMC:
406  EGAM9SlimmingHelper.ExtraVariables += [
407  "Photons.truthOrigin.truthType.truthParticleLink"
408  ]
409 
410  # Add event info
411  if flags.Derivation.Egamma.doEventInfoSlimming:
412  EGAM9SlimmingHelper.SmartCollections.append("EventInfo")
413  else:
414  EGAM9SlimmingHelper.AllVariables += ["EventInfo"]
415 
416  # Add egamma trigger objects
417  EGAM9SlimmingHelper.IncludeEGammaTriggerContent = True
418 
419  # Trigger matching
420  # Run 2
421  if flags.Trigger.EDMVersion == 2:
422  from DerivationFrameworkPhys.TriggerMatchingCommonConfig import AddRun2TriggerMatchingToSlimmingHelper
423  AddRun2TriggerMatchingToSlimmingHelper(SlimmingHelper = EGAM9SlimmingHelper,
424  OutputContainerPrefix = "TrigMatch_",
425  TriggerList = EGAM9TriggerListsHelper.Run2TriggerNamesNoTau)
426  # Run 3, or Run 2 with navigation conversion
427  if flags.Trigger.EDMVersion == 3 or (flags.Trigger.EDMVersion == 2 and flags.Trigger.doEDMVersionConversion):
428  from TrigNavSlimmingMT.TrigNavSlimmingMTConfig import AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
430 
431  # Add CellContainer and cluster->cell links
432  if keepCells:
433  if thinCells:
434  EGAM9SlimmingHelper.StaticContent = [
435  "CaloCellContainer#DFEGAMCellContainer",
436  "CaloClusterCellLinkContainer#egammaClusters_links",
437  ]
438  else:
439  EGAM9SlimmingHelper.StaticContent = [
440  "CaloCellContainer#AllCalo",
441  "CaloClusterCellLinkContainer#egammaClusters_links",
442  ]
443 
444  EGAM9ItemList = EGAM9SlimmingHelper.GetItemList()
445  acc.merge(
447  flags,
448  "DAOD_EGAM9",
449  ItemList=EGAM9ItemList,
450  AcceptAlgs=["EGAM9Kernel"],
451  )
452  )
453  acc.merge(
455  flags,
456  "DAOD_EGAM9",
457  AcceptAlgs=["EGAM9Kernel"],
458  createMetadata=[
459  MetadataCategory.CutFlowMetaData,
460  MetadataCategory.TruthMetaData,
461  ],
462  )
463  )
464 
465  return acc

◆ EGAM9KernelCfg()

def python.EGAM9.EGAM9KernelCfg (   flags,
  name = "EGAM9Kernel",
**  kwargs 
)
Configure the derivation framework driving algorithm (kernel)
for EGAM9

Definition at line 96 of file EGAM9.py.

96 def EGAM9KernelCfg(flags, name="EGAM9Kernel", **kwargs):
97  """Configure the derivation framework driving algorithm (kernel)
98  for EGAM9"""
99  acc = ComponentAccumulator()
100 
101  # Common augmentations
102  from DerivationFrameworkPhys.PhysCommonConfig import PhysCommonAugmentationsCfg
103 
104  acc.merge(
106  flags, TriggerListsHelper=kwargs["TriggerListsHelper"]
107  )
108  )
109 
110  # EGAM9 augmentations
111  augmentationTools = []
112 
113  # ====================================================================
114  # Common calo decoration tools
115  # ====================================================================
116  from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
117  CaloDecoratorKernelCfg)
118  acc.merge(CaloDecoratorKernelCfg(flags))
119 
120  # thinning tools
121  thinningTools = []
122  streamName = kwargs["StreamName"]
123 
124  # Track thinning
125  if flags.Derivation.Egamma.doTrackThinning:
126  TrackThinningKeepElectronTracks = False
127  TrackThinningKeepPhotonTracks = True
128  TrackThinningKeepPVTracks = False
129 
130  # Tracks associated with Electrons
131  if TrackThinningKeepElectronTracks:
132  EGAM9ElectronTPThinningTool = (
133  CompFactory.DerivationFramework.EgammaTrackParticleThinning(
134  name="EGAM9ElectronTPThinningTool",
135  StreamName=streamName,
136  SGKey="Electrons",
137  GSFTrackParticlesKey="GSFTrackParticles",
138  InDetTrackParticlesKey="InDetTrackParticles",
139  SelectionString="Electrons.pt > 0*GeV",
140  BestMatchOnly=True,
141  ConeSize=0.3,
142  )
143  )
144  acc.addPublicTool(EGAM9ElectronTPThinningTool)
145  thinningTools.append(EGAM9ElectronTPThinningTool)
146 
147  # Tracks associated with Photons
148  if TrackThinningKeepPhotonTracks:
149  EGAM9PhotonTPThinningTool = (
150  CompFactory.DerivationFramework.EgammaTrackParticleThinning(
151  name="EGAM9PhotonTPThinningTool",
152  StreamName=streamName,
153  SGKey="Photons",
154  GSFTrackParticlesKey="GSFTrackParticles",
155  InDetTrackParticlesKey="InDetTrackParticles",
156  GSFConversionVerticesKey="GSFConversionVertices",
157  SelectionString="Photons.pt > 0*GeV",
158  BestMatchOnly=True,
159  ConeSize=0.3,
160  )
161  )
162  acc.addPublicTool(EGAM9PhotonTPThinningTool)
163  thinningTools.append(EGAM9PhotonTPThinningTool)
164 
165  # Tracks from primary vertex
166  thinning_expression = " && ".join(
167  [
168  "(InDetTrackParticles.DFCommonTightPrimary)",
169  "(abs(DFCommonInDetTrackZ0AtPV)*sin(InDetTrackParticles.theta)<3*mm)",
170  "(InDetTrackParticles.pt > 10*GeV)",
171  ]
172  )
173  if TrackThinningKeepPVTracks:
174  from DerivationFrameworkInDet.InDetToolsConfig import (
175  TrackParticleThinningCfg,
176  )
177 
178  EGAM9TPThinningTool = acc.getPrimaryAndMerge(
180  flags,
181  name="EGAM9TPThinningTool",
182  StreamName=streamName,
183  SelectionString=thinning_expression,
184  InDetTrackParticlesKey="InDetTrackParticles",
185  )
186  )
187  thinningTools.append(EGAM9TPThinningTool)
188 
189  # truth thinning
190  if flags.Input.isMC:
191  # W, Z and Higgs
192  truth_cond_WZH = " && ".join(
193  ["(abs(TruthParticles.pdgId) >= 23)", "(abs(TruthParticles.pdgId) <= 25)"]
194  )
195  # Leptons
196  truth_cond_lep = " && ".join(
197  ["(abs(TruthParticles.pdgId) >= 11)", "(abs(TruthParticles.pdgId) <= 16)"]
198  )
199  # Top quark
200  truth_cond_top = "(abs(TruthParticles.pdgId) == 6)"
201  # Photon
202  truth_cond_gam = " && ".join(
203  ["(abs(TruthParticles.pdgId) == 22)", "(TruthParticles.pt > 1*GeV)"]
204  )
205  # stable particles
206  truth_cond_finalState = "(TruthParticles.isGenStable)"
207  truth_expression = (
208  "( "
209  + truth_cond_WZH
210  + " ) || "
211  + "( "
212  + truth_cond_lep
213  + " ) || "
214  + "( "
215  + truth_cond_top
216  + " ) || "
217  + "( "
218  + truth_cond_gam
219  + " ) || "
220  + "( "
221  + truth_cond_finalState
222  + " )"
223  )
224  print("EGAM9 truth thinning expression: ", truth_expression)
225 
226  EGAM9TruthThinningTool = CompFactory.DerivationFramework.GenericTruthThinning(
227  name="EGAM9TruthThinningTool",
228  StreamName=streamName,
229  ParticleSelectionString=truth_expression,
230  PreserveDescendants=False,
231  PreserveGeneratorDescendants=True,
232  PreserveAncestors=True,
233  )
234  acc.addPublicTool(EGAM9TruthThinningTool)
235  thinningTools.append(EGAM9TruthThinningTool)
236 
237  # Keep only calo cells associated with the egammaClusters collection
238  if thinCells:
239  from DerivationFrameworkCalo.CaloCellDFGetterConfig import thinCaloCellsForDFCfg
240 
241  acc.merge(
243  flags,
244  inputClusterKeys=["egammaClusters"],
245  streamName="StreamDAOD_EGAM9",
246  inputCellKey="AllCalo",
247  outputCellKey="DFEGAMCellContainer",
248  )
249  )
250 
251  # skimming
252  skimmingTool = acc.getPrimaryAndMerge(EGAM9SkimmingToolCfg(flags))
253 
254  # setup the kernel
255  acc.addEventAlgo(
256  CompFactory.DerivationFramework.DerivationKernel(
257  name,
258  SkimmingTools=[skimmingTool],
259  AugmentationTools=augmentationTools,
260  ThinningTools=thinningTools,
261  )
262  )
263 
264  return acc
265 
266 

◆ EGAM9SkimmingToolCfg()

def python.EGAM9.EGAM9SkimmingToolCfg (   flags)
Configure the EGAM9 skimming tool

Definition at line 38 of file EGAM9.py.

38 def EGAM9SkimmingToolCfg(flags):
39  """Configure the EGAM9 skimming tool"""
40  acc = ComponentAccumulator()
41 
42  # criteria for off-line based selection
43  photon_selection = (
44  "(count(Photons.pt > 9.5*GeV && " + "Photons.DFCommonPhotonsIsEMLoose) > 0)"
45  )
46  electron_selection = (
47  "(count(Electrons.pt > 9.5*GeV && "
48  + "Electrons.DFCommonElectronsLHMedium) > 0)"
49  )
50  expression = photon_selection + " || " + electron_selection
51 
52  if applyTriggerSelection:
53  # trigger-based selection
54  MenuType = None
55  if flags.Trigger.EDMVersion == 2:
56  MenuType = "Run2"
57  elif flags.Trigger.EDMVersion == 3:
58  MenuType = "Run3"
59  else:
60  MenuType = ""
61  triggers = BootstrapPhotonTriggers[MenuType]
62  triggers += noalgTriggers[MenuType]
63  print("EGAM9 trigger skimming list (OR): ", triggers)
64  EGAM9_TriggerSkimmingTool = CompFactory.DerivationFramework.TriggerSkimmingTool(
65  name="EGAM9_TriggerSkimmingTool", TriggerListOR=triggers
66  )
67 
68  # off-line based selection
69  print("EGAM9 offline skimming expression: ", expression)
70  EGAM9_OfflineSkimmingTool = (
71  CompFactory.DerivationFramework.xAODStringSkimmingTool(
72  name="EGAM9_OfflineSkimmingTool", expression=expression
73  )
74  )
75 
76  # do the AND of trigger-based and offline-based selection
77  print("EGAM9 skimming is logical AND of previous selections")
78  EGAM9_SkimmingTool = CompFactory.DerivationFramework.FilterCombinationAND(
79  name="EGAM9_SkimmingTool",
80  FilterList=[EGAM9_OfflineSkimmingTool, EGAM9_TriggerSkimmingTool],
81  )
82  acc.addPublicTool(EGAM9_OfflineSkimmingTool)
83  acc.addPublicTool(EGAM9_TriggerSkimmingTool)
84  acc.addPublicTool(EGAM9_SkimmingTool, primary=True)
85  else:
86  # off-line based selection
87  print("EGAM9 skimming expression: ", expression)
88  EGAM9_SkimmingTool = CompFactory.DerivationFramework.xAODStringSkimmingTool(
89  name="EGAM9_SkimmingTool", expression=expression
90  )
91  acc.addPublicTool(EGAM9_SkimmingTool, primary=True)
92 
93  return acc
94 
95 

Variable Documentation

◆ applyTriggerSelection

bool python.EGAM9.applyTriggerSelection = True

Definition at line 34 of file EGAM9.py.

◆ keepCells

bool python.EGAM9.keepCells = False

Definition at line 33 of file EGAM9.py.

◆ saveJets

bool python.EGAM9.saveJets = False

Definition at line 35 of file EGAM9.py.

◆ thinCells

bool python.EGAM9.thinCells = False

Definition at line 32 of file EGAM9.py.

TrigNavSlimmingMTConfig.AddRun3TrigNavSlimmingCollectionsToSlimmingHelper
def AddRun3TrigNavSlimmingCollectionsToSlimmingHelper(slimmingHelper)
Definition: TrigNavSlimmingMTConfig.py:98
python.EGAM9.EGAM9Cfg
def EGAM9Cfg(flags)
Definition: EGAM9.py:267
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, keepProvenanceTagsRegEx=None, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:16
python.EGAM9.EGAM9SkimmingToolCfg
def EGAM9SkimmingToolCfg(flags)
Definition: EGAM9.py:38
python.InDetToolsConfig.TrackParticleThinningCfg
def TrackParticleThinningCfg(flags, name, **kwargs)
Definition: InDetToolsConfig.py:458
python.TriggerMatchingCommonConfig.AddRun2TriggerMatchingToSlimmingHelper
def AddRun2TriggerMatchingToSlimmingHelper(**kwargs)
Definition: TriggerMatchingCommonConfig.py:49
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
DerivationFrameworkCaloConfig.CaloDecoratorKernelCfg
def CaloDecoratorKernelCfg(flags, name="CaloDecoratorKernel", **kwargs)
Definition: DerivationFrameworkCaloConfig.py:82
python.EGAM9.EGAM9KernelCfg
def EGAM9KernelCfg(flags, name="EGAM9Kernel", **kwargs)
Definition: EGAM9.py:96
CaloCellDFGetterConfig.thinCaloCellsForDFCfg
def thinCaloCellsForDFCfg(flags, inputClusterKeys, streamName, inputCellKey='AllCalo', outputCellKey=None)
Definition: CaloCellDFGetterConfig.py:6
DerivationFrameworkCaloConfig.getClusterEnergyPerLayerDecorations
def getClusterEnergyPerLayerDecorations(acc, kernel)
Definition: DerivationFrameworkCaloConfig.py:164
DerivationFrameworkCaloConfig.getGainDecorations
def getGainDecorations(acc, flags, kernel, collections=None, info=["E", "nCells"])
Definition: DerivationFrameworkCaloConfig.py:132
python.PhysCommonConfig.PhysCommonAugmentationsCfg
def PhysCommonAugmentationsCfg(flags, **kwargs)
Definition: PhysCommonConfig.py:14
InfileMetaDataConfig.SetupMetaDataForStreamCfg
def SetupMetaDataForStreamCfg(flags, streamName="", AcceptAlgs=None, createMetadata=None, propagateMetadataFromInput=True, *args, **kwargs)
Definition: InfileMetaDataConfig.py:222
SlimmingHelper
Definition: SlimmingHelper.py:1