Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EGammaCommonConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 # ********************************************************************
4 # EGammaCommonConfig.py
5 # Configures all tools needed for e-gamma object selection and sets
6 # up the kernel algorithms so the results can be accessed/written to
7 # the DAODs.
8 # Component accumulator version.
9 # ********************************************************************
10 
11 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12 from AthenaConfiguration.ComponentFactory import CompFactory
13 
14 
15 def EGammaCommonCfg(ConfigFlags):
16  """Main config method for e-gamma decorations"""
17 
18  acc = ComponentAccumulator()
19 
20  includeFwdElectrons = "ForwardElectrons" in ConfigFlags.Input.Collections
21 
22  # ====================================================================
23  # PHOTON ETA (=ETA2), ET (=E/COSH(ETA2))
24  # ====================================================================
25  from DerivationFrameworkEGamma.EGammaToolsConfig import PhotonsDirectionToolCfg
26 
27  DFCommonPhotonsDirection = acc.getPrimaryAndMerge(
29  ConfigFlags,
30  name="DFCommonPhotonsDirection",
31  EtaSGEntry="DFCommonPhotons_eta",
32  PhiSGEntry="DFCommonPhotons_phi",
33  EtSGEntry="DFCommonPhotons_et",
34  )
35  )
36 
37  # ====================================================================
38  # SHOWER SHAPE CORRECTIONS IN MC
39  # TUNE26: e/gamma FUDGE FACTORS RUN2 FULL DATA, derived with
40  # rel 22 (e) or 21.2 (gamma)
41  # ====================================================================
42  isMC = ConfigFlags.Input.isMC
43  isFullSim = False
44  if isMC:
45  isFullSim = ConfigFlags.Sim.ISF.Simulator.isFullSim()
46 
47  print("EGammaCommon: isMC = ", isMC)
48  if isMC:
49  print("EGammaCommon: isFullSim = ", isFullSim)
50 
51  if isFullSim:
52  from EGammaVariableCorrection.EGammaVariableCorrectionConfig import (
53  ElectronVariableCorrectionToolCfg,
54  PhotonVariableCorrectionToolCfg,
55  )
56 
57  ElectronVariableCorrectionTool = acc.popToolsAndMerge(
59  )
60  acc.addPublicTool(ElectronVariableCorrectionTool)
61 
62  PhotonVariableCorrectionTool = acc.popToolsAndMerge(
64  )
65  acc.addPublicTool(PhotonVariableCorrectionTool)
66 
67  # ====================================================================
68  # ELECTRON LH SELECTORS
69  # see Reconstruction/egamma/egammaTools/python/EMPIDBuilderBase.py
70  # on how to configure the selectors
71  # ====================================================================
72  from ROOT import LikeEnum
73 
74  from ElectronPhotonSelectorTools.AsgElectronLikelihoodToolsConfig import (
75  AsgElectronLikelihoodToolCfg,
76  )
77  from ElectronPhotonSelectorTools.ElectronLikelihoodToolMapping import electronLHmenu
78 
79  lhMenu = electronLHmenu.offlineMC21
80  from AthenaConfiguration.Enums import LHCPeriod
81 
82  if ConfigFlags.GeoModel.Run is LHCPeriod.Run2:
83  lhMenu = electronLHmenu.offlineMC20
84 
85  # Very Loose
86  ElectronLHSelectorVeryLoose = acc.popToolsAndMerge(
88  ConfigFlags,
89  name="ElectronLHSelectorVeryLoose",
90  quality=LikeEnum.VeryLoose,
91  menu=lhMenu,
92  )
93  )
94  ElectronLHSelectorVeryLoose.primaryVertexContainer = "PrimaryVertices"
95  acc.addPublicTool(ElectronLHSelectorVeryLoose)
96 
97  # Loose
98  ElectronLHSelectorLoose = acc.popToolsAndMerge(
100  ConfigFlags,
101  name="ElectronLHSelectorLoose",
102  quality=LikeEnum.Loose,
103  menu=lhMenu,
104  )
105  )
106  ElectronLHSelectorLoose.primaryVertexContainer = "PrimaryVertices"
107  acc.addPublicTool(ElectronLHSelectorLoose)
108 
109  # LooseBL
110  ElectronLHSelectorLooseBL = acc.popToolsAndMerge(
112  ConfigFlags,
113  name="ElectronLHSelectorLooseBL",
114  quality=LikeEnum.LooseBL,
115  menu=lhMenu,
116  )
117  )
118  ElectronLHSelectorLooseBL.primaryVertexContainer = "PrimaryVertices"
119  acc.addPublicTool(ElectronLHSelectorLooseBL)
120 
121  # Medium
122  ElectronLHSelectorMedium = acc.popToolsAndMerge(
124  ConfigFlags,
125  name="ElectronLHSelectorMedium",
126  quality=LikeEnum.Medium,
127  menu=lhMenu,
128  )
129  )
130  ElectronLHSelectorMedium.primaryVertexContainer = "PrimaryVertices"
131  acc.addPublicTool(ElectronLHSelectorMedium)
132 
133  # Tight
134  ElectronLHSelectorTight = acc.popToolsAndMerge(
136  ConfigFlags,
137  name="ElectronLHSelectorTight",
138  quality=LikeEnum.Tight,
139  menu=lhMenu,
140  )
141  )
142  ElectronLHSelectorTight.primaryVertexContainer = "PrimaryVertices"
143  acc.addPublicTool(ElectronLHSelectorTight)
144 
145  # ====================================================================
146  # ELECTRON DNN SELECTORS
147  # ====================================================================
148  from ElectronPhotonSelectorTools.AsgElectronSelectorToolConfig import (
149  AsgElectronSelectorToolCfg,
150  )
151 
152  # Loose
153  ElectronDNNSelectorLoose = acc.popToolsAndMerge(
155  ConfigFlags,
156  name="ElectronDNNSelectorLoose",
157  WorkingPoint="LooseDNNElectron",
158  )
159  )
160  acc.addPublicTool(ElectronDNNSelectorLoose)
161 
162  # Medium
163  ElectronDNNSelectorMedium = acc.popToolsAndMerge(
165  ConfigFlags,
166  name="ElectronDNNSelectorMedium",
167  WorkingPoint="MediumDNNElectron",
168  )
169  )
170  acc.addPublicTool(ElectronDNNSelectorMedium)
171 
172  # Tight
173  ElectronDNNSelectorTight = acc.popToolsAndMerge(
175  ConfigFlags,
176  name="ElectronDNNSelectorTight",
177  WorkingPoint="TightDNNElectron",
178  )
179  )
180  acc.addPublicTool(ElectronDNNSelectorTight)
181 
182  # ====================================================================
183  # ELECTRON DNN SELECTORS WITHOUT CF REJECTION
184  # ====================================================================
185  # Very-Loose 97%
186  ElectronDNNSelectorVeryLooseNoCF97 = acc.popToolsAndMerge(
188  ConfigFlags,
189  name="ElectronDNNSelectorVeryLooseNoCF97",
190  WorkingPoint="VeryLooseNoCF97DNNElectron",
191  )
192  )
193  acc.addPublicTool(ElectronDNNSelectorVeryLooseNoCF97)
194 
195  # Loose
196  ElectronDNNSelectorLooseNoCF = acc.popToolsAndMerge(
198  ConfigFlags,
199  name="ElectronDNNSelectorLooseNoCF",
200  WorkingPoint="LooseNoCFDNNElectron",
201  )
202  )
203  acc.addPublicTool(ElectronDNNSelectorLooseNoCF)
204 
205  # Medium
206  ElectronDNNSelectorMediumNoCF = acc.popToolsAndMerge(
208  ConfigFlags,
209  name="ElectronDNNSelectorMediumNoCF",
210  WorkingPoint="MediumNoCFDNNElectron",
211  )
212  )
213  acc.addPublicTool(ElectronDNNSelectorMediumNoCF)
214 
215  # Tight
216  ElectronDNNSelectorTightNoCF = acc.popToolsAndMerge(
218  ConfigFlags,
219  name="ElectronDNNSelectorTightNoCF",
220  WorkingPoint="TightNoCFDNNElectron",
221  )
222  )
223  acc.addPublicTool(ElectronDNNSelectorTightNoCF)
224 
225  # ====================================================================
226  # ELECTRON CHARGE SELECTION
227  # ====================================================================
228  if ConfigFlags.Derivation.Egamma.addECIDS:
229  from ElectronPhotonSelectorTools.AsgElectronChargeIDSelectorToolConfig import (
230  AsgElectronChargeIDSelectorToolCfg,
231  )
232 
233  ElectronChargeIDSelector = acc.popToolsAndMerge(
235  ConfigFlags, name="ElectronChargeIDSelectorLoose"
236  )
237  )
238  ElectronChargeIDSelector.primaryVertexContainer = "PrimaryVertices"
239  ElectronChargeIDSelector.TrainingFile = (
240  "ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root"
241  )
242  acc.addPublicTool(ElectronChargeIDSelector)
243 
244  # ====================================================================
245  # FWD ELECTRON LH SELECTORS
246  # ====================================================================
247  if includeFwdElectrons:
248  from ElectronPhotonSelectorTools.AsgForwardElectronLikelihoodToolConfig import (
249  AsgForwardElectronLikelihoodToolCfg,
250  )
251 
252  ForwardElectronLHSelectorLoose = acc.popToolsAndMerge(
254  ConfigFlags,
255  name="ForwardElectronLHSelectorLoose",
256  WorkingPoint="LooseLHForwardElectron",
257  )
258  )
259  acc.addPublicTool(ForwardElectronLHSelectorLoose)
260 
261  ForwardElectronLHSelectorMedium = acc.popToolsAndMerge(
263  ConfigFlags,
264  name="ForwardElectronLHSelectorMedium",
265  WorkingPoint="MediumLHForwardElectron",
266  )
267  )
268  acc.addPublicTool(ForwardElectronLHSelectorMedium)
269 
270  ForwardElectronLHSelectorTight = acc.popToolsAndMerge(
272  ConfigFlags,
273  name="ForwardElectronLHSelectorTight",
274  WorkingPoint="TightLHForwardElectron",
275  )
276  )
277  acc.addPublicTool(ForwardElectronLHSelectorTight)
278 
279  # ====================================================================
280  # PHOTON SELECTION (loose and tight cut-based)
281  # ====================================================================
282  from ROOT import egammaPID
283 
284  from ElectronPhotonSelectorTools.AsgPhotonIsEMSelectorsConfig import (
285  AsgPhotonIsEMSelectorCfg,
286  )
287  from ElectronPhotonSelectorTools.PhotonIsEMSelectorMapping import photonPIDmenu
288 
289  # Loose
290  PhotonIsEMSelectorLoose = acc.popToolsAndMerge(
292  ConfigFlags, name="PhotonIsEMSelectorLoose", quality=egammaPID.PhotonIDLoose
293  )
294  )
295  acc.addPublicTool(PhotonIsEMSelectorLoose)
296 
297  # Medium
298  PhotonIsEMSelectorMedium = acc.popToolsAndMerge(
300  ConfigFlags, name="PhotonIsEMSelectorMedium", quality=egammaPID.PhotonIDMedium
301  )
302  )
303  acc.addPublicTool(PhotonIsEMSelectorMedium)
304 
305  # Tight (default == pt-dependent)
306  PhotonIsEMSelectorTight = acc.popToolsAndMerge(
308  ConfigFlags, name="PhotonIsEMSelectorTight", quality=egammaPID.PhotonIDTight
309  )
310  )
311  acc.addPublicTool(PhotonIsEMSelectorTight)
312 
313  # Tight (pt-inclusive)
314  # To be removed when pt-dependent menu above is supported with scale factors
315  PhotonIsEMSelectorTightPtIncl = acc.popToolsAndMerge(
317  ConfigFlags,
318  name="PhotonIsEMSelectorTightPtIncl",
319  quality=egammaPID.PhotonIDTight,
320  menu=photonPIDmenu.menuPtInclJan2018,
321  )
322  )
323  acc.addPublicTool(PhotonIsEMSelectorTightPtIncl)
324 
325  # ====================================================================
326  # RECTANGULAR CLUSTER TOOLS
327  # ====================================================================
328 
329  from egammaCaloTools.egammaCaloToolsConfig import CaloFillRectangularClusterCfg
330 
331  EGAMCOM_caloFillRect55 = acc.popToolsAndMerge(
333  ConfigFlags,
334  name="EGAMCOMCaloFillRectangularCluster55",
335  cells_name="AllCalo",
336  eta_size=5,
337  phi_size=5,
338  fill_cluster=True,
339  )
340  )
341  acc.addPublicTool(EGAMCOM_caloFillRect55)
342 
343  EGAMCOM_caloFillRect35 = acc.popToolsAndMerge(
345  ConfigFlags,
346  name="EGAMCOMCaloFillRectangularCluster35",
347  cells_name="AllCalo",
348  eta_size=3,
349  phi_size=5,
350  fill_cluster=True,
351  )
352  )
353  acc.addPublicTool(EGAMCOM_caloFillRect35)
354 
355  EGAMCOM_caloFillRect37 = acc.popToolsAndMerge(
357  ConfigFlags,
358  name="EGAMCOMCaloFillRectangularCluster37",
359  cells_name="AllCalo",
360  eta_size=3,
361  phi_size=7,
362  fill_cluster=True,
363  )
364  )
365  acc.addPublicTool(EGAMCOM_caloFillRect37)
366 
367  EGAMCOM_caloFillRect711 = acc.popToolsAndMerge(
369  ConfigFlags,
370  name="EGAMCOMCaloFillRectangularCluster711",
371  cells_name="AllCalo",
372  eta_size=7,
373  phi_size=11,
374  fill_cluster=True,
375  )
376  )
377  acc.addPublicTool(EGAMCOM_caloFillRect711)
378 
379  # ====================================================================
380  # AUGMENTATION TOOLS
381  # ====================================================================
382  from DerivationFrameworkEGamma.EGammaToolsConfig import EGSelectionToolWrapperCfg
383  from DerivationFrameworkEGamma.EGammaToolsConfig import (
384  EGElectronLikelihoodToolWrapperCfg,
385  )
386 
387  # decorate electrons with the output of LH very loose
388  ElectronPassLHVeryLoose = acc.getPrimaryAndMerge(
390  ConfigFlags,
391  name="ElectronPassLHVeryLoose",
392  EGammaElectronLikelihoodTool=ElectronLHSelectorVeryLoose,
393  EGammaFudgeMCTool=None,
394  CutType="",
395  StoreGateEntryName="DFCommonElectronsLHVeryLoose",
396  ContainerName="Electrons",
397  StoreTResult=False,
398  )
399  )
400 
401  # decorate electrons with the output of LH loose
402  ElectronPassLHLoose = acc.getPrimaryAndMerge(
404  ConfigFlags,
405  name="ElectronPassLHLoose",
406  EGammaElectronLikelihoodTool=ElectronLHSelectorLoose,
407  EGammaFudgeMCTool=None,
408  CutType="",
409  StoreGateEntryName="DFCommonElectronsLHLoose",
410  ContainerName="Electrons",
411  StoreTResult=False,
412  )
413  )
414 
415  # decorate electrons with the output of LH loose+BL
416  ElectronPassLHLooseBL = acc.getPrimaryAndMerge(
418  ConfigFlags,
419  name="ElectronPassLHLooseBL",
420  EGammaElectronLikelihoodTool=ElectronLHSelectorLooseBL,
421  EGammaFudgeMCTool=None,
422  CutType="",
423  StoreGateEntryName="DFCommonElectronsLHLooseBL",
424  ContainerName="Electrons",
425  StoreTResult=False,
426  )
427  )
428 
429  # decorate electrons with the output of LH medium
430  ElectronPassLHMedium = acc.getPrimaryAndMerge(
432  ConfigFlags,
433  name="ElectronPassLHMedium",
434  EGammaElectronLikelihoodTool=ElectronLHSelectorMedium,
435  EGammaFudgeMCTool=None,
436  CutType="",
437  StoreGateEntryName="DFCommonElectronsLHMedium",
438  ContainerName="Electrons",
439  StoreTResult=False,
440  )
441  )
442 
443  # decorate electrons with the output of LH tight
444  ElectronPassLHTight = acc.getPrimaryAndMerge(
446  ConfigFlags,
447  name="ElectronPassLHTight",
448  EGammaElectronLikelihoodTool=ElectronLHSelectorTight,
449  EGammaFudgeMCTool=None,
450  CutType="",
451  StoreGateEntryName="DFCommonElectronsLHTight",
452  ContainerName="Electrons",
453  StoreTResult=False,
454  )
455  )
456 
457  # decorate electrons with the output of DNN Loose
458  ElectronPassDNNLoose = acc.getPrimaryAndMerge(
460  ConfigFlags,
461  name="ElectronPassDNNLoose",
462  EGammaElectronLikelihoodTool=ElectronDNNSelectorLoose,
463  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
464  CutType="",
465  StoreGateEntryName="DFCommonElectronsDNNLoose",
466  ContainerName="Electrons",
467  StoreTResult=False,
468  StoreGateEntryMultipleNames=[
469  "DFCommonElectronsDNN_pel",
470  "DFCommonElectronsDNN_pcf",
471  "DFCommonElectronsDNN_ppc",
472  "DFCommonElectronsDNN_phf",
473  "DFCommonElectronsDNN_ple",
474  "DFCommonElectronsDNN_plh",
475  ],
476  StoreMultipleOutputs=True,
477  )
478  )
479 
480  # decorate electrons with the output of DNN Medium
481  ElectronPassDNNMedium = acc.getPrimaryAndMerge(
483  ConfigFlags,
484  name="ElectronPassDNNMedium",
485  EGammaElectronLikelihoodTool=ElectronDNNSelectorMedium,
486  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
487  CutType="",
488  StoreGateEntryName="DFCommonElectronsDNNMedium",
489  ContainerName="Electrons",
490  StoreTResult=False,
491  )
492  )
493 
494  # decorate electrons with the output of DNN Tight
495  ElectronPassDNNTight = acc.getPrimaryAndMerge(
497  ConfigFlags,
498  name="ElectronPassDNNTight",
499  EGammaElectronLikelihoodTool=ElectronDNNSelectorTight,
500  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
501  CutType="",
502  StoreGateEntryName="DFCommonElectronsDNNTight",
503  ContainerName="Electrons",
504  StoreTResult=False,
505  )
506  )
507 
508  # decorate electrons with the output of DNN VeryLoose97 without CF
509  ElectronPassDNNVeryLooseNoCF97 = acc.getPrimaryAndMerge(
511  ConfigFlags,
512  name="ElectronPassDNNVeryLooseNoCF97",
513  EGammaElectronLikelihoodTool=ElectronDNNSelectorVeryLooseNoCF97,
514  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
515  CutType="",
516  StoreGateEntryName="DFCommonElectronsDNNVeryLooseNoCF97",
517  ContainerName="Electrons",
518  StoreTResult=False,
519  )
520  )
521  # decorate electrons with the output of DNN Loose without CF
522  ElectronPassDNNLooseNoCF = acc.getPrimaryAndMerge(
524  ConfigFlags,
525  name="ElectronPassDNNLooseNoCF",
526  EGammaElectronLikelihoodTool=ElectronDNNSelectorLooseNoCF,
527  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
528  CutType="",
529  StoreGateEntryName="DFCommonElectronsDNNLooseNoCF",
530  ContainerName="Electrons",
531  StoreTResult=False,
532  )
533  )
534 
535  # decorate electrons with the output of DNN Medium without CF
536  ElectronPassDNNMediumNoCF = acc.getPrimaryAndMerge(
538  ConfigFlags,
539  name="ElectronPassDNNMediumNoCF",
540  EGammaElectronLikelihoodTool=ElectronDNNSelectorMediumNoCF,
541  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
542  CutType="",
543  StoreGateEntryName="DFCommonElectronsDNNMediumNoCF",
544  ContainerName="Electrons",
545  StoreTResult=False,
546  )
547  )
548 
549  # decorate electrons with the output of DNN Tight without CF
550  ElectronPassDNNTightNoCF = acc.getPrimaryAndMerge(
552  ConfigFlags,
553  name="ElectronPassDNNTightNoCF",
554  EGammaElectronLikelihoodTool=ElectronDNNSelectorTightNoCF,
555  EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isFullSim else None),
556  CutType="",
557  StoreGateEntryName="DFCommonElectronsDNNTightNoCF",
558  ContainerName="Electrons",
559  StoreTResult=False,
560  )
561  )
562 
563  # decorate electrons with the output of ECIDS
564  if ConfigFlags.Derivation.Egamma.addECIDS:
565  ElectronPassECIDS = acc.getPrimaryAndMerge(
567  ConfigFlags,
568  name="ElectronPassECIDS",
569  EGammaElectronLikelihoodTool=ElectronChargeIDSelector,
570  EGammaFudgeMCTool=None,
571  CutType="",
572  StoreGateEntryName="DFCommonElectronsECIDS",
573  ContainerName="Electrons",
574  StoreTResult=True,
575  )
576  )
577 
578  if includeFwdElectrons:
579  # decorate forward electrons with the output of LH loose
580  ForwardElectronPassLHLoose = acc.getPrimaryAndMerge(
582  ConfigFlags,
583  name="ForwardElectronPassLHLoose",
584  EGammaElectronLikelihoodTool=ForwardElectronLHSelectorLoose,
585  EGammaFudgeMCTool=None,
586  CutType="",
587  StoreGateEntryName="DFCommonForwardElectronsLHLoose",
588  ContainerName="ForwardElectrons",
589  )
590  )
591 
592  # decorate forward electrons with the output of LH medium
593  ForwardElectronPassLHMedium = acc.getPrimaryAndMerge(
595  ConfigFlags,
596  name="ForwardElectronPassLHMedium",
597  EGammaElectronLikelihoodTool=ForwardElectronLHSelectorMedium,
598  EGammaFudgeMCTool=None,
599  CutType="",
600  StoreGateEntryName="DFCommonForwardElectronsLHMedium",
601  ContainerName="ForwardElectrons",
602  )
603  )
604 
605  # decorate forward electrons with the output of LH tight
606  ForwardElectronPassLHTight = acc.getPrimaryAndMerge(
608  ConfigFlags,
609  name="ForwardElectronPassLHTight",
610  EGammaElectronLikelihoodTool=ForwardElectronLHSelectorTight,
611  EGammaFudgeMCTool=None,
612  CutType="",
613  StoreGateEntryName="DFCommonForwardElectronsLHTight",
614  ContainerName="ForwardElectrons",
615  )
616  )
617 
618  # decorate photons with the output of IsEM loose
619  # on MC, fudge the shower shapes before computing the ID (but the
620  # original shower shapes are not overridden)
621  PhotonPassIsEMLoose = acc.getPrimaryAndMerge(
623  ConfigFlags,
624  name="PhotonPassIsEMLoose",
625  EGammaSelectionTool=PhotonIsEMSelectorLoose,
626  EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
627  CutType="",
628  StoreGateEntryName="DFCommonPhotonsIsEMLoose",
629  ContainerName="Photons",
630  )
631  )
632 
633  # decorate photons with the output of IsEM medium
634  # on MC, fudge the shower shapes before computing the ID (but the
635  # original shower shapes are not overridden)
636  PhotonPassIsEMMedium = acc.getPrimaryAndMerge(
638  ConfigFlags,
639  name="PhotonPassIsEMMedium",
640  EGammaSelectionTool=PhotonIsEMSelectorMedium,
641  EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
642  CutType="",
643  StoreGateEntryName="DFCommonPhotonsIsEMMedium",
644  ContainerName="Photons",
645  )
646  )
647 
648  # decorate photons with the output of IsEM tight
649  # on full-sim MC, fudge the shower shapes before computing the ID
650  # (but the original shower shapes are not overridden)
651  PhotonPassIsEMTight = acc.getPrimaryAndMerge(
653  ConfigFlags,
654  name="PhotonPassIsEMTight",
655  EGammaSelectionTool=PhotonIsEMSelectorTight,
656  EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
657  CutType="",
658  StoreGateEntryName="DFCommonPhotonsIsEMTight",
659  ContainerName="Photons",
660  )
661  )
662 
663  # decorate photons with the output of IsEM tight pt-inclusive menu
664  # Can be removed once pt-dependent cuts are fully supported.
665  # On full-sim MC, fudge the shower shapes before computing the ID
666  # (but the original shower shapes are not overridden)
667  PhotonPassIsEMTightPtIncl = acc.getPrimaryAndMerge(
669  ConfigFlags,
670  name="PhotonPassIsEMTightPtIncl",
671  EGammaSelectionTool=PhotonIsEMSelectorTightPtIncl,
672  EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
673  CutType="",
674  StoreGateEntryName="DFCommonPhotonsIsEMTightPtIncl",
675  ContainerName="Photons",
676  )
677  )
678 
679  # decorate photons with the photon cleaning flags
680  # on MC, fudge the shower shapes before computing the flags
681  from DerivationFrameworkEGamma.EGammaToolsConfig import EGPhotonCleaningWrapperCfg
682 
683  PhotonPassCleaning = acc.getPrimaryAndMerge(
685  ConfigFlags,
686  name="PhotonPassCleaning",
687  EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
688  StoreGateEntryName="DFCommonPhotonsCleaning",
689  ContainerName="Photons",
690  )
691  )
692 
693  # decorate some electrons with an additional ambiguity flag
694  # against internal and early material conversion
695  from DerivationFrameworkEGamma.EGammaToolsConfig import EGElectronAmbiguityToolCfg
696 
697  ElectronAmbiguity = acc.getPrimaryAndMerge(
699  ConfigFlags,
700  name="ElectronAdditionnalAmbiguity",
701  isMC=ConfigFlags.Input.isMC,
702  )
703  )
704 
705  # list of all the decorators so far
706  EGAugmentationTools = [
707  DFCommonPhotonsDirection,
708  ElectronPassLHVeryLoose,
709  ElectronPassLHLoose,
710  ElectronPassLHLooseBL,
711  ElectronPassLHMedium,
712  ElectronPassLHTight,
713  ElectronPassDNNLoose,
714  ElectronPassDNNMedium,
715  ElectronPassDNNTight,
716  ElectronPassDNNVeryLooseNoCF97,
717  ElectronPassDNNLooseNoCF,
718  ElectronPassDNNMediumNoCF,
719  ElectronPassDNNTightNoCF,
720  PhotonPassIsEMLoose,
721  PhotonPassIsEMMedium,
722  PhotonPassIsEMTight,
723  PhotonPassIsEMTightPtIncl,
724  PhotonPassCleaning,
725  ElectronAmbiguity,
726  ]
727 
728  if ConfigFlags.Derivation.Egamma.addECIDS:
729  EGAugmentationTools.extend([ElectronPassECIDS])
730 
731  if includeFwdElectrons:
732  EGAugmentationTools.extend(
733  [
734  ForwardElectronPassLHLoose,
735  ForwardElectronPassLHMedium,
736  ForwardElectronPassLHTight,
737  ]
738  )
739 
740  if ConfigFlags.Derivation.Egamma.addMissingCellInfo:
741  from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
742  EgammaCoreCellRecoveryCfg,
743  )
744 
745  CoreCellRecoveryTool = acc.popToolsAndMerge(
746  EgammaCoreCellRecoveryCfg(ConfigFlags)
747  )
748  acc.addPublicTool(CoreCellRecoveryTool)
749  EGAugmentationTools.append(CoreCellRecoveryTool)
750 
751  # ==================================================
752  # Truth Related tools
753  if ConfigFlags.Input.isMC:
754  # Decorate Electron with bkg electron type/origin
755  from MCTruthClassifier.MCTruthClassifierConfig import MCTruthClassifierCfg
756 
757  BkgElectronMCTruthClassifier = acc.popToolsAndMerge(
759  ConfigFlags,
760  name="BkgElectronMCTruthClassifier",
761  ParticleCaloExtensionTool="",
762  )
763  )
764  acc.addPublicTool(BkgElectronMCTruthClassifier)
765 
766  from DerivationFrameworkEGamma.EGammaToolsConfig import (
767  BkgElectronClassificationCfg,
768  )
769 
770  BkgElectronClassificationTool = acc.getPrimaryAndMerge(
772  ConfigFlags,
773  name="BkgElectronClassificationTool",
774  MCTruthClassifierTool=BkgElectronMCTruthClassifier,
775  )
776  )
777  EGAugmentationTools.append(BkgElectronClassificationTool)
778 
779  # Decorate egammaTruthParticles with truth-particle-level etcone20,30,40
780  from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import (
781  TruthIsolationToolCfg,
782  )
783 
784  TruthEgetIsolationTool = acc.getPrimaryAndMerge(
786  ConfigFlags,
787  name="TruthEgetIsolationTool",
788  isoParticlesKey="egammaTruthParticles",
789  allParticlesKey="TruthParticles",
790  particleIDsToCalculate=[-11, 11, 22],
791  IsolationConeSizes=[0.2, 0.3, 0.4],
792  excludeIDsFromCone=[-16, -14, -13, -12, 12, 13, 14, 16],
793  IsolationVarNamePrefix="etcone",
794  ChargedParticlesOnly=False,
795  )
796  )
797  EGAugmentationTools.append(TruthEgetIsolationTool)
798 
799  # Decorate egammaTruthParticles with truth-particle-level ptcone20,30,40
800  TruthEgptIsolationTool = acc.getPrimaryAndMerge(
802  ConfigFlags,
803  name="TruthEgptIsolationTool",
804  isoParticlesKey="egammaTruthParticles",
805  allParticlesKey="TruthParticles",
806  particleIDsToCalculate=[-11, 11, 22],
807  IsolationConeSizes=[0.2, 0.3, 0.4],
808  IsolationVarNamePrefix="ptcone",
809  ChargedParticlesOnly=True,
810  )
811  )
812  EGAugmentationTools.append(TruthEgptIsolationTool)
813 
814  # Compute the truth-particle-level energy density in the central eta region
815  from EventShapeTools.EventDensityConfig import configEventDensityTool
816  from JetRecConfig.JetRecConfig import (
817  getInputAlgs,
818  getConstitPJGAlg,
819  reOrderAlgs,
820  )
821  from JetRecConfig.StandardJetConstits import stdConstitDic as cst
822 
823  # Schedule PseudoJetTruth
824  constit_algs = getInputAlgs(cst.Truth, flags=ConfigFlags)
825  constit_algs, ca = reOrderAlgs([a for a in constit_algs if a is not None])
826  acc.merge(ca)
827  for a in constit_algs:
828  acc.addEventAlgo(a)
829  constitPJAlg = getConstitPJGAlg(cst.Truth, suffix=None)
830  acc.addEventAlgo(constitPJAlg)
831 
833  "EDTruthCentralTool",
834  cst.Truth,
835  0.5,
836  AbsRapidityMin=0.0,
837  AbsRapidityMax=1.5,
838  OutputContainer="TruthIsoCentralEventShape",
839  OutputLevel=3,
840  )
841  acc.addPublicTool(tc)
842 
843  # Compute the truth-particle-level energy density in the forward eta region
845  "EDTruthForwardTool",
846  cst.Truth,
847  0.5,
848  AbsRapidityMin=1.5,
849  AbsRapidityMax=3.0,
850  OutputContainer="TruthIsoForwardEventShape",
851  OutputLevel=3,
852  )
853  acc.addPublicTool(tf)
854 
855  acc.addEventAlgo(
856  CompFactory.EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool=tc)
857  )
858  acc.addEventAlgo(
859  CompFactory.EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool=tf)
860  )
861 
862  # =======================================
863  # CREATE THE DERIVATION KERNEL ALGORITHM
864  # =======================================
865 
866  acc.addEventAlgo(
867  CompFactory.DerivationFramework.CommonAugmentation(
868  "EGammaCommonKernel", AugmentationTools=EGAugmentationTools
869  )
870  )
871 
872  # =======================================
873  # ADD TOOLS : custom electron, photon and muon track isolation
874  # =======================================
875  from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
876 
877  acc.merge(DerivationTrackIsoCfg(ConfigFlags, object_types=("Electrons", "Muons")))
878 
879  hasFlowObject = (
880  "JetETMissChargedParticleFlowObjects" in ConfigFlags.Input.Collections
881  and "JetETMissNeutralParticleFlowObjects" in ConfigFlags.Input.Collections
882  )
883  if hasFlowObject:
884  from IsolationAlgs.IsolationSteeringDerivConfig import IsolationSteeringDerivCfg
885 
886  acc.merge(IsolationSteeringDerivCfg(ConfigFlags))
887 
888  return acc
MCTruthClassifierConfig.MCTruthClassifierCfg
def MCTruthClassifierCfg(flags, **kwargs)
Definition: MCTruthClassifier/python/MCTruthClassifierConfig.py:8
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.JetRecConfig.getInputAlgs
def getInputAlgs(jetOrConstitdef, flags, context="default", monTool=None)
Definition: JetRecConfig.py:279
python.JetRecConfig.reOrderAlgs
def reOrderAlgs(algs)
Definition: JetRecConfig.py:796
IsolationSteeringDerivConfig.IsolationSteeringDerivCfg
def IsolationSteeringDerivCfg(flags, name='IsolationSteeringDeriv', inType='EMPFlow')
Definition: IsolationSteeringDerivConfig.py:11
python.EGammaToolsConfig.EGSelectionToolWrapperCfg
def EGSelectionToolWrapperCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:22
python.AsgElectronLikelihoodToolsConfig.AsgElectronLikelihoodToolCfg
def AsgElectronLikelihoodToolCfg(flag, name, quality, menu=electronLHmenu.offlineMC21)
Definition: AsgElectronLikelihoodToolsConfig.py:13
EventDensityConfig.configEventDensityTool
def configEventDensityTool(name, jetOrConstitdef, radius=0.4, **options)
Definition: EventDensityConfig.py:36
python.TruthDerivationToolsConfig.TruthIsolationToolCfg
def TruthIsolationToolCfg(flags, name, **kwargs)
Definition: TruthDerivationToolsConfig.py:166
python.AsgForwardElectronLikelihoodToolConfig.AsgForwardElectronLikelihoodToolCfg
def AsgForwardElectronLikelihoodToolCfg(ConfigFlags, name, **kwargs)
Definition: AsgForwardElectronLikelihoodToolConfig.py:6
python.EGammaCommonConfig.EGammaCommonCfg
def EGammaCommonCfg(ConfigFlags)
Definition: EGammaCommonConfig.py:15
python.EGammaToolsConfig.EGElectronAmbiguityToolCfg
def EGElectronAmbiguityToolCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:51
DerivationFrameworkCaloConfig.EgammaCoreCellRecoveryCfg
def EgammaCoreCellRecoveryCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:27
python.EGammaVariableCorrectionConfig.ElectronVariableCorrectionToolCfg
def ElectronVariableCorrectionToolCfg(flags, name="ElectronVariableCorrectionTool", **kwargs)
Definition: EGammaVariableCorrectionConfig.py:5
python.AsgElectronChargeIDSelectorToolConfig.AsgElectronChargeIDSelectorToolCfg
def AsgElectronChargeIDSelectorToolCfg(ConfigFlags, name, **kwargs)
Definition: AsgElectronChargeIDSelectorToolConfig.py:6
python.EGammaVariableCorrectionConfig.PhotonVariableCorrectionToolCfg
def PhotonVariableCorrectionToolCfg(flags, name="PhotonVariableCorrectionTool", **kwargs)
Definition: EGammaVariableCorrectionConfig.py:15
python.EGammaToolsConfig.EGPhotonCleaningWrapperCfg
def EGPhotonCleaningWrapperCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:42
python.AsgPhotonIsEMSelectorsConfig.AsgPhotonIsEMSelectorCfg
def AsgPhotonIsEMSelectorCfg(flags, name, quality, menu=photonPIDmenu.menuCurrentCuts, trigger=False)
Definition: AsgPhotonIsEMSelectorsConfig.py:15
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.EGammaToolsConfig.EGElectronLikelihoodToolWrapperCfg
def EGElectronLikelihoodToolWrapperCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:31
python.EGammaToolsConfig.BkgElectronClassificationCfg
def BkgElectronClassificationCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:60
python.JetRecConfig.getConstitPJGAlg
def getConstitPJGAlg(constitdef, suffix=None, flags=None, parent_jetdef=None)
Definition: JetRecConfig.py:350
python.AsgElectronSelectorToolConfig.AsgElectronSelectorToolCfg
def AsgElectronSelectorToolCfg(ConfigFlags, name, **kwargs)
Definition: AsgElectronSelectorToolConfig.py:7
python.EGammaToolsConfig.PhotonsDirectionToolCfg
def PhotonsDirectionToolCfg(flags, name, **kwargs)
Definition: EGammaToolsConfig.py:13
DerivationTrackIsoConfig.DerivationTrackIsoCfg
def DerivationTrackIsoCfg(flags, **jwarg)
Definition: DerivationTrackIsoConfig.py:11
DerivationFrameworkCaloConfig.CaloFillRectangularClusterCfg
def CaloFillRectangularClusterCfg(flags, **kwargs)
Definition: DerivationFrameworkCaloConfig.py:41