ATLAS Offline Software
Loading...
Searching...
No Matches
python.TruthCollectionsFixerConfig.TruthCollectionsFixerBlock Class Reference
Inheritance diagram for python.TruthCollectionsFixerConfig.TruthCollectionsFixerBlock:
Collaboration diagram for python.TruthCollectionsFixerConfig.TruthCollectionsFixerBlock:

Public Member Functions

 __init__ (self)
 makeAlgs (self, config)

Public Attributes

return fixDAODTruthRecord

Detailed Description

This Config Block is meant to help fix older DAOD samples that have the old HepMC barcode instead of uid.
   See also https://gitlab.cern.ch/atlas/athena/-/merge_requests/82613
   and https://gitlab.cern.ch/atlas/athena/-/merge_requests/82746

Definition at line 8 of file TruthCollectionsFixerConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.TruthCollectionsFixerConfig.TruthCollectionsFixerBlock.__init__ ( self)

Definition at line 14 of file TruthCollectionsFixerConfig.py.

14 def __init__(self):
15 super(TruthCollectionsFixerBlock, self).__init__()
16 self.addOption(
17 "truthParticleContainersToFix",
18 None,
19 type=list,
20 info="list of input DAOD truthParticle containers to fix",
21 )
22 self.addOption(
23 "truthVertexContainersToFix",
24 None,
25 type=list,
26 info="list of input DAOD truthVertex containers to fix",
27 )
28 self.addOption("fixDAODTruthRecord", True, type=bool,
29 info="older derivations have the old HepMC barcodes and need to be fixed, otherwise we get "
30 "a crash on 'missing ::uid'. Schedules an instance of TruthCollectionsFixerBlock. "
31 "Not needed for recent derivations.")
32

Member Function Documentation

◆ makeAlgs()

python.TruthCollectionsFixerConfig.TruthCollectionsFixerBlock.makeAlgs ( self,
config )

Definition at line 33 of file TruthCollectionsFixerConfig.py.

33 def makeAlgs(self, config):
34
35 # we need this boolean because the responsibility of scheduling the whole block is passed onto CommonServicesConfig
36 if not self.fixDAODTruthRecord: return
37
38 if config.dataType() is DataType.Data: return
39
40 partContainers = None
41 if self.truthParticleContainersToFix is not None:
42 partContainers = self.truthParticleContainersToFix
43 elif config.isPhyslite():
44 partContainers = [
45 "TruthBoson", "TruthBosonsWithDecayParticles",
46 "TruthElectrons", "TruthMuons", "TruthPhotons", "TruthNeutrinos",
47 "TruthTaus",
48 "TruthTop", "TruthBottom",
49 "TruthForwardProtons",
50 "TruthBSM", "TruthBSMWithDecayParticles",
51 "BornLeptons"
52 ]
53 else:
54 partContainers = [
55 "TruthBoson", "TruthBosonsWithDecayParticles",
56 "TruthElectrons", "TruthMuons", "TruthPhotons", "TruthNeutrinos",
57 "TruthTaus", "TruthTausWithDecayParticles",
58 "TruthTop", "TruthBottom", "TruthCharm", "TruthHFWithDecayParticles",
59 "TruthForwardProtons", "TruthPileupParticles",
60 "TruthBSM", "TruthBSMWithDecayParticles",
61 "BornLeptons"
62 ]
63
64 vertContainers = None
65 if self.truthVertexContainersToFix is not None:
66 vertContainers = self.truthVertexContainersToFix
67 elif config.isPhyslite():
68 vertContainers = [
69 "TruthBosonsWithDecayVertices",
70 "TruthBSMWithDecayVertices"
71 ]
72 else:
73 vertContainers = [
74 "TruthBosonsWithDecayVertices",
75 "TruthHFWithDecayVertices",
76 "TruthTausWithDecayVertices",
77 "TruthBSMWithDecayVertices"
78 ]
79
80 # in Athena, we have to rename the containers. In AnalysisBase, we can just overwrite in place
81 if DualUseConfig.isAthena:
82 # replicate the behaviour of AddressRemappingCfg
83 ars = config.createService("AddressRemappingSvc", "AddressRemappingSvc")
84 pps = config.createService("ProxyProviderSvc", "ProxyProviderSvc")
85 if "AddressRemappingSvc" not in pps.ProviderNames:
86 pps.ProviderNames += ["AddressRemappingSvc"]
87 for container in partContainers:
88 ars.TypeKeyRenameMaps += [
89 f"xAOD::TruthParticleContainer#{container}->InFile{container}",
90 f"xAOD::AuxContainerBase#{container}Aux.->InFile{container}Aux.",
91 ]
92 for container in vertContainers:
93 ars.TypeKeyRenameMaps += [
94 f"xAOD::TruthVertexContainer#{container}->InFile{container}",
95 f"xAOD::AuxContainerBase#{container}Aux.->InFile{container}Aux.",
96 ]
97
98 # the actual fix for old DAOD truth schema
99 for container in partContainers:
100 alg = config.createAlgorithm(
101 "xAODMaker::TruthParticleFixerAlg",
102 "TruthParticleFixerAlg_" + container,
103 reentrant=True,
104 )
105 alg.InputContainer = (
106 container if not DualUseConfig.isAthena else f"InFile{container}"
107 )
108 alg.OutputContainer = container
109
110 # in Athena, we further need to remap relevant ElementLinks for containers that have them
111 containers_without_parent_child_links = [
112 "TruthBosonsWithDecayParticles",
113 "TruthTausWithDecayParticles",
114 "BornLeptons", "TruthPileupParticles",
115 "TruthForwardProtons",
116 "TruthBSMWithDecayParticles"]
117 if DualUseConfig.isAthena and container not in containers_without_parent_child_links:
118 alg.LinkPrefixToRemove = "InFile"
119 alg.ParticleLinks = ["parentLinks", "childLinks"]
120
121 for container in vertContainers:
122 alg = config.createAlgorithm(
123 "xAODMaker::TruthVertexFixerAlg",
124 "TruthVertexFixerAlg_" + container,
125 reentrant=True,
126 )
127 alg.InputContainer = (
128 container if not DualUseConfig.isAthena else f"InFile{container}"
129 )
130 alg.OutputContainer = container
131
132 if DualUseConfig.isAthena :
133 alg.LinkPrefixToRemove = "InFile"

Member Data Documentation

◆ fixDAODTruthRecord

return python.TruthCollectionsFixerConfig.TruthCollectionsFixerBlock.fixDAODTruthRecord

Definition at line 36 of file TruthCollectionsFixerConfig.py.


The documentation for this class was generated from the following file: