ATLAS Offline Software
Loading...
Searching...
No Matches
EGammaCommonConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 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
11from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12from AthenaConfiguration.ComponentFactory import CompFactory
13from AthenaConfiguration.Enums import LHCPeriod
14
15
16def EGammaCommonCfg(flags):
17 """Main config method for e-gamma decorations"""
18
19 acc = ComponentAccumulator()
20
21 includeFwdElectrons = "ForwardElectrons" in flags.Input.Collections
22
23 # ====================================================================
24 # PHOTON ETA (=ETA2), ET (=E/COSH(ETA2))
25 # ====================================================================
26 from DerivationFrameworkEGamma.EGammaToolsConfig import PhotonsDirectionToolCfg
27
28 DFCommonPhotonsDirection = acc.addPublicTool(acc.popToolsAndMerge(
29 PhotonsDirectionToolCfg(
30 flags,
31 name="DFCommonPhotonsDirection",
32 EtaSGEntry="DFCommonPhotons_eta",
33 PhiSGEntry="DFCommonPhotons_phi",
34 EtSGEntry="DFCommonPhotons_et",
35 )
36 ))
37
38 # ====================================================================
39 # SHOWER SHAPE CORRECTIONS IN MC
40 # The default tunes are set in
41 # PhysicsAnalysis/ElectronPhotonID/EGammaVariableCorrection/python/EGammaVariableCorrectionConfig.py
42 # AF3 is tuned to FullSim, so same FFs can be used for AF3 and FS
43 # ====================================================================
44 isMC = flags.Input.isMC
45 isFullSim = False
46 if isMC:
47 isFullSim = flags.Sim.ISF.Simulator.isFullSim()
48 isRun2orRun3 = flags.GeoModel.Run in (LHCPeriod.Run2, LHCPeriod.Run3)
49
50 print("EGammaCommon: isMC = ", isMC)
51 if isMC:
52 print("EGammaCommon: isFullSim = ", isFullSim)
53
54 if isMC:
55 from EGammaVariableCorrection.EGammaVariableCorrectionConfig import (
56 ElectronVariableCorrectionToolCfg,
57 PhotonVariableCorrectionToolCfg,
58 ElectronPhotonVariableNFCorrectionToolCfg,
59 )
60
61 ElectronVariableCorrectionTool = acc.popToolsAndMerge(
62 ElectronVariableCorrectionToolCfg(flags)
63 )
64 acc.addPublicTool(ElectronVariableCorrectionTool)
65
66 PhotonVariableCorrectionTool = acc.popToolsAndMerge(
67 PhotonVariableCorrectionToolCfg(flags)
68 )
69 acc.addPublicTool(PhotonVariableCorrectionTool)
70
71 if isRun2orRun3:
72 nFoldsNF = flags.Egamma.NFoldsNF if flags.hasFlag('Egamma.NFoldsNF') else None
73 PhotonVariableNFCorrectionTool = acc.popToolsAndMerge(
74 ElectronPhotonVariableNFCorrectionToolCfg(flags, nFolds=nFoldsNF)
75 )
76 acc.addPublicTool(PhotonVariableNFCorrectionTool)
77
78 # ====================================================================
79 # ELECTRON LH SELECTORS
80 # see Reconstruction/egamma/egammaTools/python/EMPIDBuilderBase.py
81 # on how to configure the selectors
82 # ====================================================================
83 from ROOT import LikeEnum
84
85 from ElectronPhotonSelectorTools.AsgElectronLikelihoodToolsConfig import (
86 AsgElectronLikelihoodToolCfg,
87 )
88 from ElectronPhotonSelectorTools.ElectronLikelihoodToolMapping import electronLHmenu
89
90 lhMenu = electronLHmenu.offlineMC21
91 if flags.GeoModel.Run is LHCPeriod.Run2:
92 lhMenu = electronLHmenu.offlineMC20
93
94 # Very Loose
95 ElectronLHSelectorVeryLoose = acc.popToolsAndMerge(
96 AsgElectronLikelihoodToolCfg(
97 flags,
98 name="ElectronLHSelectorVeryLoose",
99 quality=LikeEnum.VeryLoose,
100 menu=lhMenu,
101 )
102 )
103 ElectronLHSelectorVeryLoose.primaryVertexContainer = "PrimaryVertices"
104 acc.addPublicTool(ElectronLHSelectorVeryLoose)
105
106 # Loose
107 ElectronLHSelectorLoose = acc.popToolsAndMerge(
108 AsgElectronLikelihoodToolCfg(
109 flags,
110 name="ElectronLHSelectorLoose",
111 quality=LikeEnum.Loose,
112 menu=lhMenu,
113 )
114 )
115 ElectronLHSelectorLoose.primaryVertexContainer = "PrimaryVertices"
116 acc.addPublicTool(ElectronLHSelectorLoose)
117
118 # LooseBL
119 ElectronLHSelectorLooseBL = acc.popToolsAndMerge(
120 AsgElectronLikelihoodToolCfg(
121 flags,
122 name="ElectronLHSelectorLooseBL",
123 quality=LikeEnum.LooseBL,
124 menu=lhMenu,
125 )
126 )
127 ElectronLHSelectorLooseBL.primaryVertexContainer = "PrimaryVertices"
128 acc.addPublicTool(ElectronLHSelectorLooseBL)
129
130 # Medium
131 ElectronLHSelectorMedium = acc.popToolsAndMerge(
132 AsgElectronLikelihoodToolCfg(
133 flags,
134 name="ElectronLHSelectorMedium",
135 quality=LikeEnum.Medium,
136 menu=lhMenu,
137 )
138 )
139 ElectronLHSelectorMedium.primaryVertexContainer = "PrimaryVertices"
140 acc.addPublicTool(ElectronLHSelectorMedium)
141
142 # Tight
143 ElectronLHSelectorTight = acc.popToolsAndMerge(
144 AsgElectronLikelihoodToolCfg(
145 flags,
146 name="ElectronLHSelectorTight",
147 quality=LikeEnum.Tight,
148 menu=lhMenu,
149 )
150 )
151 ElectronLHSelectorTight.primaryVertexContainer = "PrimaryVertices"
152 acc.addPublicTool(ElectronLHSelectorTight)
153
154 # ====================================================================
155 # ELECTRON DNN SELECTORS
156 # ====================================================================
157 from ElectronPhotonSelectorTools.AsgElectronSelectorToolConfig import (
158 AsgElectronSelectorToolCfg,
159 )
160
161 # Loose
162 ElectronDNNSelectorLoose = acc.popToolsAndMerge(
163 AsgElectronSelectorToolCfg(
164 flags,
165 name="ElectronDNNSelectorLoose",
166 WorkingPoint="LooseDNNElectron",
167 )
168 )
169 acc.addPublicTool(ElectronDNNSelectorLoose)
170
171 # Medium
172 ElectronDNNSelectorMedium = acc.popToolsAndMerge(
173 AsgElectronSelectorToolCfg(
174 flags,
175 name="ElectronDNNSelectorMedium",
176 WorkingPoint="MediumDNNElectron",
177 )
178 )
179 acc.addPublicTool(ElectronDNNSelectorMedium)
180
181 # Tight
182 ElectronDNNSelectorTight = acc.popToolsAndMerge(
183 AsgElectronSelectorToolCfg(
184 flags,
185 name="ElectronDNNSelectorTight",
186 WorkingPoint="TightDNNElectron",
187 )
188 )
189 acc.addPublicTool(ElectronDNNSelectorTight)
190
191 # ====================================================================
192 # ELECTRON DNN SELECTORS WITHOUT CF REJECTION
193 # ====================================================================
194 # Very-Loose 97%
195 ElectronDNNSelectorVeryLooseNoCF97 = acc.popToolsAndMerge(
196 AsgElectronSelectorToolCfg(
197 flags,
198 name="ElectronDNNSelectorVeryLooseNoCF97",
199 WorkingPoint="VeryLooseNoCF97DNNElectron",
200 )
201 )
202 acc.addPublicTool(ElectronDNNSelectorVeryLooseNoCF97)
203
204 # Loose
205 ElectronDNNSelectorLooseNoCF = acc.popToolsAndMerge(
206 AsgElectronSelectorToolCfg(
207 flags,
208 name="ElectronDNNSelectorLooseNoCF",
209 WorkingPoint="LooseNoCFDNNElectron",
210 )
211 )
212 acc.addPublicTool(ElectronDNNSelectorLooseNoCF)
213
214 # Medium
215 ElectronDNNSelectorMediumNoCF = acc.popToolsAndMerge(
216 AsgElectronSelectorToolCfg(
217 flags,
218 name="ElectronDNNSelectorMediumNoCF",
219 WorkingPoint="MediumNoCFDNNElectron",
220 )
221 )
222 acc.addPublicTool(ElectronDNNSelectorMediumNoCF)
223
224 # Tight
225 ElectronDNNSelectorTightNoCF = acc.popToolsAndMerge(
226 AsgElectronSelectorToolCfg(
227 flags,
228 name="ElectronDNNSelectorTightNoCF",
229 WorkingPoint="TightNoCFDNNElectron",
230 )
231 )
232 acc.addPublicTool(ElectronDNNSelectorTightNoCF)
233
234 # ====================================================================
235 # ELECTRON CHARGE SELECTION
236 # ====================================================================
237 if flags.Derivation.Egamma.addECIDS:
238 from ElectronPhotonSelectorTools.AsgElectronChargeIDSelectorToolConfig import (
239 AsgElectronChargeIDSelectorToolCfg,
240 )
241
242 ElectronChargeIDSelector = acc.popToolsAndMerge(
243 AsgElectronChargeIDSelectorToolCfg(
244 flags, name="ElectronChargeIDSelectorLoose"
245 )
246 )
247 ElectronChargeIDSelector.primaryVertexContainer = "PrimaryVertices"
248 ElectronChargeIDSelector.TrainingFile = (
249 "ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root"
250 )
251 acc.addPublicTool(ElectronChargeIDSelector)
252
253 # ====================================================================
254 # FWD ELECTRON LH SELECTORS
255 # ====================================================================
256 if includeFwdElectrons:
257 from ElectronPhotonSelectorTools.AsgForwardElectronLikelihoodToolConfig import (
258 AsgForwardElectronLikelihoodToolCfg,
259 )
260
261 ForwardElectronLHSelectorLoose = acc.popToolsAndMerge(
262 AsgForwardElectronLikelihoodToolCfg(
263 flags,
264 name="ForwardElectronLHSelectorLoose",
265 WorkingPoint="LooseLHForwardElectron",
266 )
267 )
268 acc.addPublicTool(ForwardElectronLHSelectorLoose)
269
270 ForwardElectronLHSelectorMedium = acc.popToolsAndMerge(
271 AsgForwardElectronLikelihoodToolCfg(
272 flags,
273 name="ForwardElectronLHSelectorMedium",
274 WorkingPoint="MediumLHForwardElectron",
275 )
276 )
277 acc.addPublicTool(ForwardElectronLHSelectorMedium)
278
279 ForwardElectronLHSelectorTight = acc.popToolsAndMerge(
280 AsgForwardElectronLikelihoodToolCfg(
281 flags,
282 name="ForwardElectronLHSelectorTight",
283 WorkingPoint="TightLHForwardElectron",
284 )
285 )
286 acc.addPublicTool(ForwardElectronLHSelectorTight)
287
288 # ====================================================================
289 # PHOTON SELECTION (loose and tight cut-based)
290 # ====================================================================
291 from ROOT import egammaPID
292
293 from ElectronPhotonSelectorTools.AsgPhotonIsEMSelectorsConfig import (
294 AsgPhotonIsEMSelectorCfg,
295 )
296 from ElectronPhotonSelectorTools.PhotonIsEMSelectorMapping import photonPIDmenu
297 pidMenu = photonPIDmenu.offlineMC21
298 if flags.GeoModel.Run is LHCPeriod.Run2:
299 pidMenu = photonPIDmenu.offlineMC20
300
301 # Loose
302 PhotonIsEMSelectorLoose = acc.popToolsAndMerge(
303 AsgPhotonIsEMSelectorCfg(
304 flags,
305 name="PhotonIsEMSelectorLoose",
306 quality=egammaPID.PhotonIDLoose,
307 menu=pidMenu
308 )
309 )
310 acc.addPublicTool(PhotonIsEMSelectorLoose)
311
312 # Medium
313 PhotonIsEMSelectorMedium = acc.popToolsAndMerge(
314 AsgPhotonIsEMSelectorCfg(
315 flags,
316 name="PhotonIsEMSelectorMedium",
317 quality=egammaPID.PhotonIDMedium,
318 menu=pidMenu
319 )
320 )
321 acc.addPublicTool(PhotonIsEMSelectorMedium)
322
323 # Tight
324 PhotonIsEMSelectorTight = acc.popToolsAndMerge(
325 AsgPhotonIsEMSelectorCfg(
326 flags,
327 name="PhotonIsEMSelectorTight",
328 quality=egammaPID.PhotonIDTight,
329 menu=pidMenu
330 )
331 )
332 acc.addPublicTool(PhotonIsEMSelectorTight)
333
334 # ====================================================================
335 # PHOTON BDT SELECTION
336 # ====================================================================
337 photonIDBDTWP = "TightBDTPhoton_Run3"
338 if flags.GeoModel.Run is LHCPeriod.Run2:
339 photonIDBDTWP = "TightBDTPhoton_Run2"
340 from ElectronPhotonSelectorTools.AsgPhotonBDTSelectorConfig import (
341 PhotonBDTCalculatorCfg,
342 AsgPhotonBDTSelectorCfg,
343 )
344 PhotonBDTCalculator = acc.popToolsAndMerge(
345 PhotonBDTCalculatorCfg(
346 flags,
347 name="PhotonBDTCalculator",
348 useNFs=False,
349 )
350 )
351 PhotonBDTSelectorTight = acc.popToolsAndMerge(
352 AsgPhotonBDTSelectorCfg(
353 flags,
354 name="PhotonBDTSelectorTight",
355 ScoreDecoration="DFCommonPhotonsBDTScore",
356 WorkingPoint=photonIDBDTWP,
357 useNFs=False,
358 SuppressInputDependence=True
359 )
360 )
361 PhotonBDTCalculatorNF = acc.popToolsAndMerge(
362 PhotonBDTCalculatorCfg(
363 flags,
364 name="PhotonBDTCalculatorNF",
365 useNFs=True,
366 )
367 )
368 PhotonBDTSelectorTightNF = acc.popToolsAndMerge(
369 AsgPhotonBDTSelectorCfg(
370 flags,
371 name="PhotonBDTSelectorTightNF",
372 ScoreDecoration="DFCommonPhotonsNFBDTScore",
373 WorkingPoint=photonIDBDTWP+"_NFs",
374 useNFs=True,
375 SuppressInputDependence=True
376 )
377 )
378 # ====================================================================
379 # RECTANGULAR CLUSTER TOOLS
380 # ====================================================================
381
382 from egammaCaloTools.egammaCaloToolsConfig import CaloFillRectangularClusterCfg
383
384 EGAMCOM_caloFillRect55 = acc.popToolsAndMerge(
385 CaloFillRectangularClusterCfg(
386 flags,
387 name="EGAMCOMCaloFillRectangularCluster55",
388 cells_name="AllCalo",
389 eta_size=5,
390 phi_size=5,
391 fill_cluster=True,
392 )
393 )
394 acc.addPublicTool(EGAMCOM_caloFillRect55)
395
396 EGAMCOM_caloFillRect35 = acc.popToolsAndMerge(
397 CaloFillRectangularClusterCfg(
398 flags,
399 name="EGAMCOMCaloFillRectangularCluster35",
400 cells_name="AllCalo",
401 eta_size=3,
402 phi_size=5,
403 fill_cluster=True,
404 )
405 )
406 acc.addPublicTool(EGAMCOM_caloFillRect35)
407
408 EGAMCOM_caloFillRect37 = acc.popToolsAndMerge(
409 CaloFillRectangularClusterCfg(
410 flags,
411 name="EGAMCOMCaloFillRectangularCluster37",
412 cells_name="AllCalo",
413 eta_size=3,
414 phi_size=7,
415 fill_cluster=True,
416 )
417 )
418 acc.addPublicTool(EGAMCOM_caloFillRect37)
419
420 EGAMCOM_caloFillRect711 = acc.popToolsAndMerge(
421 CaloFillRectangularClusterCfg(
422 flags,
423 name="EGAMCOMCaloFillRectangularCluster711",
424 cells_name="AllCalo",
425 eta_size=7,
426 phi_size=11,
427 fill_cluster=True,
428 )
429 )
430 acc.addPublicTool(EGAMCOM_caloFillRect711)
431
432 # ====================================================================
433 # AUGMENTATION TOOLS
434 # ====================================================================
435 from DerivationFrameworkEGamma.EGammaToolsConfig import EGSelectionToolWrapperCfg
436 from DerivationFrameworkEGamma.EGammaToolsConfig import (
437 EGElectronLikelihoodToolWrapperCfg,
438 EGPhotonBDTToolWrapperCfg,
439 EGPhotonBDTToolDecoratorCfg
440 )
441
442 # Note: LH selectors don't need fudging since the LH is tuned to data
443
444 # decorate electrons with the output of LH very loose
445 ElectronPassLHVeryLoose = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
446 flags,
447 name="ElectronPassLHVeryLoose",
448 EGammaElectronLikelihoodTool=ElectronLHSelectorVeryLoose,
449 EGammaFudgeMCTool=None,
450 CutType="",
451 StoreGateEntryName="DFCommonElectronsLHVeryLoose",
452 ContainerName="Electrons",
453 StoreTResult=False,
454 )
455 ))
456
457 # decorate electrons with the output of LH loose
458 ElectronPassLHLoose = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
459 flags,
460 name="ElectronPassLHLoose",
461 EGammaElectronLikelihoodTool=ElectronLHSelectorLoose,
462 EGammaFudgeMCTool=None,
463 CutType="",
464 StoreGateEntryName="DFCommonElectronsLHLoose",
465 ContainerName="Electrons",
466 StoreTResult=False,
467 )
468 ))
469
470 # decorate electrons with the output of LH loose+BL
471 ElectronPassLHLooseBL = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
472 flags,
473 name="ElectronPassLHLooseBL",
474 EGammaElectronLikelihoodTool=ElectronLHSelectorLooseBL,
475 EGammaFudgeMCTool=None,
476 CutType="",
477 StoreGateEntryName="DFCommonElectronsLHLooseBL",
478 ContainerName="Electrons",
479 StoreTResult=False,
480 )
481 ))
482
483 # decorate electrons with the output of LH medium
484 ElectronPassLHMedium = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
485 flags,
486 name="ElectronPassLHMedium",
487 EGammaElectronLikelihoodTool=ElectronLHSelectorMedium,
488 EGammaFudgeMCTool=None,
489 CutType="",
490 StoreGateEntryName="DFCommonElectronsLHMedium",
491 ContainerName="Electrons",
492 StoreTResult=False,
493 )
494 ))
495
496 # decorate electrons with the output of LH tight
497 ElectronPassLHTight = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
498 flags,
499 name="ElectronPassLHTight",
500 EGammaElectronLikelihoodTool=ElectronLHSelectorTight,
501 EGammaFudgeMCTool=None,
502 CutType="",
503 StoreGateEntryName="DFCommonElectronsLHTight",
504 ContainerName="Electrons",
505 StoreTResult=False,
506 )
507 ))
508
509 # decorate electrons with the output of DNN Loose
510 ElectronPassDNNLoose = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
511 flags,
512 name="ElectronPassDNNLoose",
513 EGammaElectronLikelihoodTool=ElectronDNNSelectorLoose,
514 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
515 CutType="",
516 StoreGateEntryName="DFCommonElectronsDNNLoose",
517 ContainerName="Electrons",
518 StoreTResult=False,
519 StoreGateEntryMultipleNames=[
520 "DFCommonElectronsDNN_pel",
521 "DFCommonElectronsDNN_pcf",
522 "DFCommonElectronsDNN_ppc",
523 "DFCommonElectronsDNN_phf",
524 "DFCommonElectronsDNN_ple",
525 "DFCommonElectronsDNN_plh",
526 ],
527 StoreMultipleOutputs=True,
528 )
529 ))
530
531 # decorate electrons with the output of DNN Medium
532 ElectronPassDNNMedium = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
533 flags,
534 name="ElectronPassDNNMedium",
535 EGammaElectronLikelihoodTool=ElectronDNNSelectorMedium,
536 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
537 CutType="",
538 StoreGateEntryName="DFCommonElectronsDNNMedium",
539 ContainerName="Electrons",
540 StoreTResult=False,
541 )
542 ))
543
544 # decorate electrons with the output of DNN Tight
545 ElectronPassDNNTight = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
546 flags,
547 name="ElectronPassDNNTight",
548 EGammaElectronLikelihoodTool=ElectronDNNSelectorTight,
549 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
550 CutType="",
551 StoreGateEntryName="DFCommonElectronsDNNTight",
552 ContainerName="Electrons",
553 StoreTResult=False,
554 )
555 ))
556
557 # decorate electrons with the output of DNN VeryLoose97 without CF
558 ElectronPassDNNVeryLooseNoCF97 = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
559 flags,
560 name="ElectronPassDNNVeryLooseNoCF97",
561 EGammaElectronLikelihoodTool=ElectronDNNSelectorVeryLooseNoCF97,
562 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
563 CutType="",
564 StoreGateEntryName="DFCommonElectronsDNNVeryLooseNoCF97",
565 ContainerName="Electrons",
566 StoreTResult=False,
567 )
568 ))
569 # decorate electrons with the output of DNN Loose without CF
570 ElectronPassDNNLooseNoCF = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
571 flags,
572 name="ElectronPassDNNLooseNoCF",
573 EGammaElectronLikelihoodTool=ElectronDNNSelectorLooseNoCF,
574 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
575 CutType="",
576 StoreGateEntryName="DFCommonElectronsDNNLooseNoCF",
577 ContainerName="Electrons",
578 StoreTResult=False,
579 )
580 ))
581
582 # decorate electrons with the output of DNN Medium without CF
583 ElectronPassDNNMediumNoCF = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
584 flags,
585 name="ElectronPassDNNMediumNoCF",
586 EGammaElectronLikelihoodTool=ElectronDNNSelectorMediumNoCF,
587 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
588 CutType="",
589 StoreGateEntryName="DFCommonElectronsDNNMediumNoCF",
590 ContainerName="Electrons",
591 StoreTResult=False,
592 )
593 ))
594
595 # decorate electrons with the output of DNN Tight without CF
596 ElectronPassDNNTightNoCF = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
597 flags,
598 name="ElectronPassDNNTightNoCF",
599 EGammaElectronLikelihoodTool=ElectronDNNSelectorTightNoCF,
600 EGammaFudgeMCTool=(ElectronVariableCorrectionTool if isMC else None),
601 CutType="",
602 StoreGateEntryName="DFCommonElectronsDNNTightNoCF",
603 ContainerName="Electrons",
604 StoreTResult=False,
605 )
606 ))
607
608 # decorate electrons with the output of ECIDS
609 if flags.Derivation.Egamma.addECIDS:
610 ElectronPassECIDS = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
611 flags,
612 name="ElectronPassECIDS",
613 EGammaElectronLikelihoodTool=ElectronChargeIDSelector,
614 EGammaFudgeMCTool=None,
615 CutType="",
616 StoreGateEntryName="DFCommonElectronsECIDS",
617 ContainerName="Electrons",
618 StoreTResult=True,
619 )
620 ))
621
622 if includeFwdElectrons:
623 # decorate forward electrons with the output of LH loose
624 ForwardElectronPassLHLoose = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
625 flags,
626 name="ForwardElectronPassLHLoose",
627 EGammaElectronLikelihoodTool=ForwardElectronLHSelectorLoose,
628 EGammaFudgeMCTool=None,
629 CutType="",
630 StoreGateEntryName="DFCommonForwardElectronsLHLoose",
631 ContainerName="ForwardElectrons",
632 )
633 ))
634
635 # decorate forward electrons with the output of LH medium
636 ForwardElectronPassLHMedium = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
637 flags,
638 name="ForwardElectronPassLHMedium",
639 EGammaElectronLikelihoodTool=ForwardElectronLHSelectorMedium,
640 EGammaFudgeMCTool=None,
641 CutType="",
642 StoreGateEntryName="DFCommonForwardElectronsLHMedium",
643 ContainerName="ForwardElectrons",
644 )
645 ))
646
647 # decorate forward electrons with the output of LH tight
648 ForwardElectronPassLHTight = acc.addPublicTool(acc.popToolsAndMerge(EGElectronLikelihoodToolWrapperCfg(
649 flags,
650 name="ForwardElectronPassLHTight",
651 EGammaElectronLikelihoodTool=ForwardElectronLHSelectorTight,
652 EGammaFudgeMCTool=None,
653 CutType="",
654 StoreGateEntryName="DFCommonForwardElectronsLHTight",
655 ContainerName="ForwardElectrons",
656 )
657 ))
658
659 # decorate photons with the output of IsEM loose
660 # on MC, fudge the shower shapes before computing the ID (but the
661 # original shower shapes are not overridden)
662 PhotonPassIsEMLoose = acc.addPublicTool(acc.popToolsAndMerge(
663 EGSelectionToolWrapperCfg(
664 flags,
665 name="PhotonPassIsEMLoose",
666 EGammaSelectionTool=PhotonIsEMSelectorLoose,
667 EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
668 CutType="",
669 StoreGateEntryName="DFCommonPhotonsIsEMLoose",
670 ContainerName="Photons",
671 )
672 ))
673
674 # decorate photons with the output of IsEM medium
675 # on MC, fudge the shower shapes before computing the ID (but the
676 # original shower shapes are not overridden)
677 PhotonPassIsEMMedium = acc.addPublicTool(acc.popToolsAndMerge(
678 EGSelectionToolWrapperCfg(
679 flags,
680 name="PhotonPassIsEMMedium",
681 EGammaSelectionTool=PhotonIsEMSelectorMedium,
682 EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
683 CutType="",
684 StoreGateEntryName="DFCommonPhotonsIsEMMedium",
685 ContainerName="Photons",
686 )
687 ))
688
689 # decorate photons with the output of IsEM tight
690 # on full-sim MC, fudge the shower shapes before computing the ID
691 # (but the original shower shapes are not overridden)
692 PhotonPassIsEMTight = acc.addPublicTool(acc.popToolsAndMerge(
693 EGSelectionToolWrapperCfg(
694 flags,
695 name="PhotonPassIsEMTight",
696 EGammaSelectionTool=PhotonIsEMSelectorTight,
697 EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
698 CutType="",
699 StoreGateEntryName="DFCommonPhotonsIsEMTight",
700 ContainerName="Photons",
701 )
702 ))
703
704 # decorate photons with the output of BDT tight
705 # on full-sim MC, fudge the shower shapes before computing the ID
706 # (but the original shower shapes are not overridden)
707 PhotonBDTDecorator = acc.addPublicTool(acc.popToolsAndMerge(
708 EGPhotonBDTToolDecoratorCfg(
709 flags,
710 name="PhotonBDTDecorator",
711 PhotonObservableTool=PhotonBDTCalculator,
712 EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
713 StoreGateEntryName="DFCommonPhotonsBDT",
714 ContainerName="Photons",
715 )
716 ))
717
718
719 PhotonPassBDTTight = acc.addPublicTool(acc.popToolsAndMerge(
720 EGPhotonBDTToolWrapperCfg(
721 flags,
722 name="PhotonPassBDTTight",
723 PhotonBDTSelectionTool=PhotonBDTSelectorTight,
724 EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
725 CutType="",
726 StoreGateEntryName="DFCommonPhotonsBDT",
727 WorkingPointName="Tight",
728 ContainerName="Photons",
729 )
730 ))
731
732 # decorate photons with the output of IsEM tight
733 # on full-sim or fast-sim MC, normalizing flows-based correction before computing the ID
734 # (but the original shower shapes are not overridden)
735 PhotonPassIsEMTightNF = acc.addPublicTool(acc.popToolsAndMerge(
736 EGSelectionToolWrapperCfg(
737 flags,
738 name="PhotonPassIsEMTightNF",
739 EGammaSelectionTool=PhotonIsEMSelectorTight,
740 EGammaFudgeMCTool=(PhotonVariableNFCorrectionTool if (isMC and isRun2orRun3) else None),
741 CutType="",
742 StoreGateEntryName="DFCommonPhotonsIsEMTightNF",
743 ContainerName="Photons",
744 )
745 ))
746
747 # decorate photons with the output of BDT tight
748 # on full-sim MC, normalizing flows-based correction before computing the ID
749 # (but the original shower shapes are not overridden)
750 PhotonBDTDecoratorNF = acc.addPublicTool(acc.popToolsAndMerge(
751 EGPhotonBDTToolDecoratorCfg(
752 flags,
753 name="PhotonBDTDecoratorNF",
754 PhotonObservableTool=PhotonBDTCalculatorNF,
755 EGammaFudgeMCTool=(PhotonVariableNFCorrectionTool if (isMC and isRun2orRun3) else None),
756 StoreGateEntryName="DFCommonPhotonsNFBDT",
757 ContainerName="Photons",
758 )
759 ))
760
761 PhotonPassBDTTightNF = acc.addPublicTool(acc.popToolsAndMerge(
762 EGPhotonBDTToolWrapperCfg(
763 flags,
764 name="PhotonPassBDTTightNF",
765 PhotonBDTSelectionTool=PhotonBDTSelectorTightNF,
766 EGammaFudgeMCTool=(PhotonVariableNFCorrectionTool if (isMC and isRun2orRun3) else None),
767 CutType="",
768 StoreGateEntryName="DFCommonPhotonsNFBDT",
769 WorkingPointName="Tight",
770 ContainerName="Photons",
771 )
772 ))
773
774
775 # decorate photons with the photon cleaning flags
776 # on MC, fudge the shower shapes before computing the flags
777 from DerivationFrameworkEGamma.EGammaToolsConfig import EGPhotonCleaningWrapperCfg
778
779 PhotonPassCleaning = acc.addPublicTool(acc.popToolsAndMerge(
780 EGPhotonCleaningWrapperCfg(
781 flags,
782 name="PhotonPassCleaning",
783 EGammaFudgeMCTool=(PhotonVariableCorrectionTool if isFullSim else None),
784 StoreGateEntryName="DFCommonPhotonsCleaning",
785 ContainerName="Photons",
786 )
787 ))
788
789 # decorate some electrons with an additional ambiguity flag
790 # against internal and early material conversion
791 from DerivationFrameworkEGamma.EGammaToolsConfig import EGElectronAmbiguityToolCfg
792
793 ElectronAmbiguity = acc.addPublicTool(acc.popToolsAndMerge(
794 EGElectronAmbiguityToolCfg(
795 flags,
796 name="ElectronAdditionnalAmbiguity",
797 isMC=flags.Input.isMC,
798 )
799 ))
800
801 # list of all the decorators so far
802 EGAugmentationTools = [
803 DFCommonPhotonsDirection,
804 ElectronPassLHVeryLoose,
805 ElectronPassLHLoose,
806 ElectronPassLHLooseBL,
807 ElectronPassLHMedium,
808 ElectronPassLHTight,
809 ElectronPassDNNLoose,
810 ElectronPassDNNMedium,
811 ElectronPassDNNTight,
812 ElectronPassDNNVeryLooseNoCF97,
813 ElectronPassDNNLooseNoCF,
814 ElectronPassDNNMediumNoCF,
815 ElectronPassDNNTightNoCF,
816 PhotonPassIsEMLoose,
817 PhotonPassIsEMMedium,
818 PhotonPassIsEMTight,
819 PhotonPassIsEMTightNF,
820 PhotonBDTDecorator,
821 PhotonPassBDTTight,
822 PhotonBDTDecoratorNF,
823 PhotonPassBDTTightNF,
824 PhotonPassCleaning,
825 ElectronAmbiguity,
826 ]
827
828 if flags.Derivation.Egamma.addECIDS:
829 EGAugmentationTools.extend([ElectronPassECIDS])
830
831 if includeFwdElectrons:
832 EGAugmentationTools.extend(
833 [
834 ForwardElectronPassLHLoose,
835 ForwardElectronPassLHMedium,
836 ForwardElectronPassLHTight,
837 ]
838 )
839
840 from egammaAlgs.egammaAODFixesConfig import runAODFix
841 _, fixes = runAODFix(flags)
842 # the topoIso fix already provides the decorations that this tool creates
843 if not('egammatopoIsoFix' in fixes):
844 if flags.Derivation.Egamma.addMissingCellInfo:
845 from DerivationFrameworkCalo.DerivationFrameworkCaloConfig import (
846 EgammaCoreCellRecoveryCfg,
847 )
848
849 CoreCellRecoveryTool = acc.popToolsAndMerge(
850 EgammaCoreCellRecoveryCfg(flags)
851 )
852 acc.addPublicTool(CoreCellRecoveryTool)
853 EGAugmentationTools.append(CoreCellRecoveryTool)
854
855 from DerivationFrameworkEGamma.EGammaToolsConfig import EGammaEnergyCalibrationWrapperCfg
856 TransformerEnergyCalibration = acc.addPublicTool(acc.popToolsAndMerge(
857 EGammaEnergyCalibrationWrapperCfg(
858 flags,
859 name="TransformerEnergyCalibration",
860 )
861 ))
862 EGAugmentationTools.append(TransformerEnergyCalibration)
863
864 # ==================================================
865 # Truth Related tools
866 if flags.Input.isMC:
867 # Decorate Electron with bkg electron type/origin
868 from DerivationFrameworkEGamma.EGammaToolsConfig import (
869 BkgElectronClassificationCfg,
870 )
871
872 BkgElectronClassificationTool = acc.addPublicTool(acc.popToolsAndMerge(
873 BkgElectronClassificationCfg(
874 flags,
875 name="BkgElectronClassificationTool"
876 )
877 ))
878 EGAugmentationTools.append(BkgElectronClassificationTool)
879
880 # Decorate egammaTruthParticles with truth-particle-level etcone20,30,40
881 from DerivationFrameworkMCTruth.TruthDerivationToolsConfig import (
882 TruthIsolationToolCfg,
883 )
884
885 TruthEgetIsolationTool = acc.getPrimaryAndMerge(
886 TruthIsolationToolCfg(
887 flags,
888 name="TruthEgetIsolationTool",
889 isoParticlesKey="egammaTruthParticles",
890 allParticlesKey="TruthParticles",
891 particleIDsToCalculate=[-11, 11, 22],
892 IsolationConeSizes=[0.2, 0.3, 0.4],
893 excludeIDsFromCone=[-16, -14, -13, -12, 12, 13, 14, 16],
894 IsolationVarNamePrefix="etcone",
895 ChargedParticlesOnly=False,
896 )
897 )
898 EGAugmentationTools.append(TruthEgetIsolationTool)
899
900 # Decorate egammaTruthParticles with truth-particle-level ptcone20,30,40
901 TruthEgptIsolationTool = acc.getPrimaryAndMerge(
902 TruthIsolationToolCfg(
903 flags,
904 name="TruthEgptIsolationTool",
905 isoParticlesKey="egammaTruthParticles",
906 allParticlesKey="TruthParticles",
907 particleIDsToCalculate=[-11, 11, 22],
908 IsolationConeSizes=[0.2, 0.3, 0.4],
909 IsolationVarNamePrefix="ptcone",
910 ChargedParticlesOnly=True,
911 )
912 )
913 EGAugmentationTools.append(TruthEgptIsolationTool)
914
915 # Compute the truth-particle-level energy density in the central eta region
916 from EventShapeTools.EventDensityConfig import configEventDensityTool
917 from JetRecConfig.JetRecConfig import (
918 getInputAlgs,
919 getConstitPJGAlg,
920 reOrderAlgs,
921 )
922 from JetRecConfig.StandardJetConstits import stdConstitDic as cst
923
924 # Schedule PseudoJetTruth
925 constit_algs = getInputAlgs(cst.Truth, flags=flags)
926 constit_algs, ca = reOrderAlgs([a for a in constit_algs if a is not None])
927 acc.merge(ca)
928 for a in constit_algs:
929 acc.addEventAlgo(a)
930 constitPJAlg = getConstitPJGAlg(cst.Truth, suffix=None)
931 acc.addEventAlgo(constitPJAlg)
932
933 tc = configEventDensityTool(
934 "EDTruthCentralTool",
935 cst.Truth,
936 0.5,
937 AbsRapidityMin=0.0,
938 AbsRapidityMax=1.5,
939 OutputContainer="TruthIsoCentralEventShape",
940 OutputLevel=3,
941 )
942 acc.addPublicTool(tc)
943
944 # Compute the truth-particle-level energy density in the forward eta region
945 tf = configEventDensityTool(
946 "EDTruthForwardTool",
947 cst.Truth,
948 0.5,
949 AbsRapidityMin=1.5,
950 AbsRapidityMax=3.0,
951 OutputContainer="TruthIsoForwardEventShape",
952 OutputLevel=3,
953 )
954 acc.addPublicTool(tf)
955
956 acc.addEventAlgo(
957 CompFactory.EventDensityAthAlg("EDTruthCentralAlg", EventDensityTool=tc)
958 )
959 acc.addEventAlgo(
960 CompFactory.EventDensityAthAlg("EDTruthForwardAlg", EventDensityTool=tf)
961 )
962
963 # =======================================
964 # CREATE THE DERIVATION KERNEL ALGORITHM
965 # =======================================
966
967 acc.addEventAlgo(
968 CompFactory.DerivationFramework.CommonAugmentation(
969 "EGammaCommonKernel", AugmentationTools=EGAugmentationTools
970 )
971 )
972
973 # =======================================
974 # ADD TOOLS : custom electron, photon and muon track isolation
975 # =======================================
976 from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
977
978 acc.merge(DerivationTrackIsoCfg(flags, object_types=("Electrons", "Muons")))
979
980 hasFlowObject = (
981 "JetETMissChargedParticleFlowObjects" in flags.Input.Collections
982 and "JetETMissNeutralParticleFlowObjects" in flags.Input.Collections
983 )
984 if hasFlowObject:
985 from IsolationAlgs.IsolationSteeringDerivConfig import IsolationSteeringDerivCfg
986
987 acc.merge(IsolationSteeringDerivCfg(flags))
988
989 return acc
void print(char *figname, TCanvas *c1)