Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ITkActsParticleCreationConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3 
5  *,
6  TrackContainers: list[str],
7  TrackParticleContainer: str,
8  persistifyCollection: bool = True,
9  PerigeeExpression: str = None) -> ComponentAccumulator:
10  # This function does the following:
11  # - Creates track particles from a collection of track containers
12  # - Attaches truth decoration to the track particles
13  # - Persistifies the track particles
14  # The function will be called within the loop on the tracking passes, if the uses asks
15  # for collections to be stored in different containers, as well as just before the primary
16  # vertex reconstruction, on the ensamble of track collections requested during reconstruction
17  # (but always on the primary pass tracks)
18 
19  assert isinstance(TrackContainers, list)
20  for container in TrackContainers:
21  assert isinstance(container, str)
22 
23  # Set the perigee expression to be used for track particle creation
24  # This is used by Heavy Ion configuration
25  if PerigeeExpression is None:
26  PerigeeExpression = flags.Tracking.perigeeExpression
27 
28  print("Storing track and track particle containers:")
29  print(f"- track collection(s): {TrackContainers}")
30  print(f"- track particle collection: {TrackParticleContainer}")
31 
32  acc = ComponentAccumulator()
33 
34  prefix = "ActsCombined" if "ActiveConfig" not in flags.Tracking else flags.Tracking.ActiveConfig.extension
35  prefix += f"To{TrackParticleContainer}"
36  from ActsConfig.ActsTrackFindingConfig import ActsTrackToTrackParticleCnvAlgCfg
37  acc.merge(ActsTrackToTrackParticleCnvAlgCfg(flags,
38  name = f"{prefix}TrackToTrackParticleCnvAlg",
39  ACTSTracksLocation = TrackContainers,
40  TrackParticlesOutKey = TrackParticleContainer,
41  PerigeeExpression = PerigeeExpression))
42 
43  if flags.Tracking.doTruth :
44  from AthenaCommon.Constants import WARNING, INFO
45  track_to_truth_maps = []
46  from ActsConfig.ActsTruthConfig import ActsTrackParticleTruthDecorationAlgCfg
47  for trackContainer in TrackContainers:
48  track_to_truth_maps.append(f"{trackContainer}ToTruthParticleAssociation")
50  name = f'{prefix}TruthDecorationAlg',
51  TrackToTruthAssociationMaps = track_to_truth_maps,
52  TrackParticleContainerName = TrackParticleContainer,
53  OutputLevel = WARNING if len(TrackContainers)==1 else INFO,
54  ComputeTrackRecoEfficiency = False if len(TrackContainers)==1 else True))
55 
56  # Persistification
57  # By default this is always happening, but in the case the perigee strategy is set
58  # to Vertex we need to create a temporary track particle collection wrt the BeamLine
59  # which does not need to be persistified
60  if persistifyCollection:
61  toAOD = []
62  trackparticles_shortlist = [] if flags.Acts.EDM.PersistifyTracks else ['-actsTrack']
63  trackparticles_variables = ".".join(trackparticles_shortlist)
64  toAOD += [f"xAOD::TrackParticleContainer#{TrackParticleContainer}",
65  f"xAOD::TrackParticleAuxContainer#{TrackParticleContainer}Aux." + trackparticles_variables]
66 
67  from OutputStreamAthenaPool.OutputStreamConfig import addToAOD
68  acc.merge(addToAOD(flags, toAOD))
69 
70  return acc
71 
72 
73 def ITkActsTrackParticlePersistificationCfg(flags) -> ComponentAccumulator:
74  acc = ComponentAccumulator()
75  # Particle creation and persistification
76  # Tracks from CKF and SiSPSeededTracks{extension}TrackParticles
77  if flags.Tracking.ActiveConfig.storeSiSPSeededTracks:
78  # Naming convention for track particles: SiSPSeededTracks{extension}TrackParticles
79  acc.merge(ITkActsTrackParticleCreationCfg(flags,
80  TrackContainers = [f"{flags.Tracking.ActiveConfig.extension}Tracks"],
81  TrackParticleContainer = f'SiSPSeededTracks{flags.Tracking.ActiveConfig.extension}TrackParticles'))
82 
83  # Track from CKF or ambiguity resolution if we want separate containers
84  # In case no ambiguity resolution is scheduled, the CKF tracks will be used instead of those from the ambiguity resolution
85  if flags.Tracking.ActiveConfig.storeSeparateContainer:
86  # If we do not want the track collection to be merged with another collection
87  # then we immediately create the track particles from it
88  # Naming convention for track particles: InDet{extension}TrackParticles
89  acts_tracks = f"{flags.Tracking.ActiveConfig.extension}Tracks" if not flags.Acts.doAmbiguityResolution else f"{flags.Tracking.ActiveConfig.extension}ResolvedTracks"
90  acc.merge(ITkActsTrackParticleCreationCfg(flags,
91  TrackContainers = [acts_tracks],
92  TrackParticleContainer = f'InDet{flags.Tracking.ActiveConfig.extension}TrackParticles'))
93 
94  return acc
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.ITkActsParticleCreationConfig.ITkActsTrackParticlePersistificationCfg
ComponentAccumulator ITkActsTrackParticlePersistificationCfg(flags)
Definition: ITkActsParticleCreationConfig.py:73
python.ITkActsParticleCreationConfig.ITkActsTrackParticleCreationCfg
ComponentAccumulator ITkActsTrackParticleCreationCfg(flags, *list[str] TrackContainers, str TrackParticleContainer, bool persistifyCollection=True, str PerigeeExpression=None)
Definition: ITkActsParticleCreationConfig.py:4
Constants
some useful constants -------------------------------------------------—
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
python.OutputStreamConfig.addToAOD
def addToAOD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:142
ActsTruthConfig.ActsTrackParticleTruthDecorationAlgCfg
ComponentAccumulator ActsTrackParticleTruthDecorationAlgCfg(flags, str name='ActsTrackParticleTruthDecorationAlg', **dict kwargs)
Definition: ActsTruthConfig.py:116
ActsTrackFindingConfig.ActsTrackToTrackParticleCnvAlgCfg
ComponentAccumulator ActsTrackToTrackParticleCnvAlgCfg(flags, str name="ActsTrackToTrackParticleCnvAlg", **kwargs)
Definition: ActsTrackFindingConfig.py:396