Skip to content

Commit

Permalink
full_chain_itk.py uses eta-dependent cuts and maxHoles, maxSharedHits
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Adye authored and Tim Adye committed Feb 6, 2024
1 parent 9b2fd7d commit 03a867e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 28 deletions.
1 change: 1 addition & 0 deletions Examples/Python/python/acts/examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def NamedTypeArgsWrapper(*args, **kwargs):
cls is not None
and v is not None
and type(v).__module__ == int.__module__ # is v a 'builtins'?
and not (issubclass(type(v), Iterable) and all(type(e) is cls for e in v)) # not [cls]
):
if issubclass(cls, Iterable):
kwargs[k] = cls(*v)
Expand Down
77 changes: 53 additions & 24 deletions Examples/Python/python/acts/examples/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@
"pt",
"phi",
"nMeasurementsMin",
"maxHoles",
"maxOutliers",
"maxSharedHits",
"maxChi2",
"nMeasurementsGroupMin",
],
defaults=[(None, None)] * 7 + [None] * 2,
defaults=[(None, None)] * 7 + [None] * 6,
)

CkfConfig = namedtuple(
Expand Down Expand Up @@ -1125,7 +1129,7 @@ def addCKFTracks(
s: acts.examples.Sequencer,
trackingGeometry: acts.TrackingGeometry,
field: acts.MagneticFieldProvider,
trackSelectorConfig: Optional[TrackSelectorConfig] = None,
trackSelectorConfig: Optional[Union[TrackSelectorConfig, List[TrackSelectorConfig]]] = None,
ckfConfig: CkfConfig = CkfConfig(),
outputDirCsv: Optional[Union[Path, str]] = None,
outputDirRoot: Optional[Union[Path, str]] = None,
Expand Down Expand Up @@ -1154,6 +1158,52 @@ def addCKFTracks(

customLogLevel = acts.examples.defaultLogging(s, logLevel)

tslist = (
[]
if trackSelectorConfig is None
else (
[trackSelectorConfig]
if type(trackSelectorConfig) is TrackSelectorConfig
else trackSelectorConfig
)
)
cutSets = [
acts.TrackSelector.Config(
**acts.examples.defaultKWArgs(
loc0Min=c.loc0[0],
loc0Max=c.loc0[1],
loc1Min=c.loc1[0],
loc1Max=c.loc1[1],
timeMin=c.time[0],
timeMax=c.time[1],
phiMin=c.phi[0],
phiMax=c.phi[1],
etaMin=c.eta[0],
etaMax=c.eta[1],
absEtaMin=c.absEta[0],
absEtaMax=c.absEta[1] if len(tslist) == 1 else None,
ptMin=c.pt[0],
ptMax=c.pt[1],
minMeasurements=c.nMeasurementsMin,
maxHoles=c.maxHoles,
maxOutliers=c.maxOutliers,
maxSharedHits=c.maxSharedHits,
maxChi2=c.maxChi2,
measurementCounter=c.nMeasurementsGroupMin,
)
)
for c in tslist
]
if len(tslist) == 0:
trkSelCfg = None
elif len(tslist) == 1:
trkSelCfg = cutSets[0]
else:
trkSelCfg = acts.TrackSelector.EtaBinnedConfig(
cutSets=cutSets,
absEtaEdges=[cutSets[0].absEtaMin] + [c.absEta[1] for c in tslist],
)

# Setup the track finding algorithm with CKF
# It takes all the source links created from truth hit smearing, seeds from
# truth particle smearing and source link selection config
Expand All @@ -1171,28 +1221,7 @@ def addCKFTracks(
)
]
),
trackSelectorCfg=acts.TrackSelector.Config(
**acts.examples.defaultKWArgs(
loc0Min=trackSelectorConfig.loc0[0],
loc0Max=trackSelectorConfig.loc0[1],
loc1Min=trackSelectorConfig.loc1[0],
loc1Max=trackSelectorConfig.loc1[1],
timeMin=trackSelectorConfig.time[0],
timeMax=trackSelectorConfig.time[1],
phiMin=trackSelectorConfig.phi[0],
phiMax=trackSelectorConfig.phi[1],
etaMin=trackSelectorConfig.eta[0],
etaMax=trackSelectorConfig.eta[1],
absEtaMin=trackSelectorConfig.absEta[0],
absEtaMax=trackSelectorConfig.absEta[1],
ptMin=trackSelectorConfig.pt[0],
ptMax=trackSelectorConfig.pt[1],
minMeasurements=trackSelectorConfig.nMeasurementsMin,
measurementCounter=trackSelectorConfig.nMeasurementsGroupMin,
)
)
if trackSelectorConfig is not None
else None,
trackSelectorCfg=trkSelCfg,
inputMeasurements="measurements",
inputSourceLinks="sourcelinks",
inputInitialTrackParameters="estimatedparameters",
Expand Down
6 changes: 6 additions & 0 deletions Examples/Python/src/ExampleAlgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ void addExampleAlgorithms(Context& ctx) {
ACTS_PYTHON_MEMBER(ptMin);
ACTS_PYTHON_MEMBER(ptMax);
ACTS_PYTHON_MEMBER(minMeasurements);
ACTS_PYTHON_MEMBER(maxHoles);
ACTS_PYTHON_MEMBER(maxOutliers);
ACTS_PYTHON_MEMBER(maxSharedHits);
ACTS_PYTHON_MEMBER(maxChi2);
ACTS_PYTHON_MEMBER(measurementCounter);
ACTS_PYTHON_STRUCT_END();

Expand All @@ -126,6 +130,8 @@ void addExampleAlgorithms(Context& ctx) {
.def(py::init<>())
.def(py::init<const Config&>());

patchKwargsConstructor(c);

c.def_property_readonly("nEtaBins", &EtaBinnedConfig::nEtaBins);

ACTS_PYTHON_STRUCT_BEGIN(c, EtaBinnedConfig);
Expand Down
8 changes: 4 additions & 4 deletions Examples/Scripts/Python/full_chain_itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
s,
trackingGeometry,
field,
TrackSelectorConfig(
pt=(1.0 * u.GeV if ttbar_pu200 else 0.0, None),
absEta=(None, 4.0),
nMeasurementsMin=6,
trackSelectorConfig=(
TrackSelectorConfig(absEta=(None, 2.0), pt=(0.9 * u.GeV, None), nMeasurementsMin=9, maxHoles=2, maxSharedHits=2),
TrackSelectorConfig(absEta=(None, 2.6), pt=(0.4 * u.GeV, None), nMeasurementsMin=8, maxHoles=2, maxSharedHits=2),
TrackSelectorConfig(absEta=(None, 4.0), pt=(0.4 * u.GeV, None), nMeasurementsMin=7, maxHoles=2, maxSharedHits=2),
),
outputDirRoot=outputDir,
)
Expand Down

0 comments on commit 03a867e

Please sign in to comment.