Skip to content

Commit

Permalink
Update tracking to use Acts v36.0 (#1454)
Browse files Browse the repository at this point in the history
* move acts to v36 and required ldmx::tracking code changes, ldmx-sw builds but does not link yet

* remove now non-existent acts component from linking

The ActsPluginIdentification does not exist within ACTS v36 and so
asking for it to be built just gets ignored since its not an option ACTS
looks for; however, asking to link to it errors since this component is
not a valid library that can be linked to (it is never built).

We can remove reference to this plugin and point out that the
default-build of acts appears to satisfy our needs.

* v36 is building, linking, running and give resonable results.  Still need to update GSF track fitting and restore a few features.

* forgot a couple of changes to MeasurementCalibrator

* fix up CKF so that it makes everything for ldmx::track; GSF builds but not sure if working yet

* Once in a while CKFProcessor crashes when it cant extrapolate to target state.  Put in a catch and some info statements

* Add back a block I accidently deleted

* adapted GSF for v36 and added tagger/recoil flexibility

* move acts to v36 and required ldmx::tracking code changes, ldmx-sw builds but does not link yet

* remove now non-existent acts component from linking

The ActsPluginIdentification does not exist within ACTS v36 and so
asking for it to be built just gets ignored since its not an option ACTS
looks for; however, asking to link to it errors since this component is
not a valid library that can be linked to (it is never built).

We can remove reference to this plugin and point out that the
default-build of acts appears to satisfy our needs.

* v36 is building, linking, running and give resonable results.  Still need to update GSF track fitting and restore a few features.

* forgot a couple of changes to MeasurementCalibrator

* fix up CKF so that it makes everything for ldmx::track; GSF builds but not sure if working yet

* Once in a while CKFProcessor crashes when it cant extrapolate to target state.  Put in a catch and some info statements

* Add back a block I accidently deleted

* adapted GSF for v36 and added tagger/recoil flexibility

* add new plots and ranges to dqm

* update the example reco so that it actually works right

* clang_format and some other cleanup

* clang-format checker didnt like my comment for some reason

* damn formatting

* Update Tracking/include/Tracking/Reco/DigitizationProcessor.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/GSFProcessor.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Sim/MeasurementCalibrator.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/python/tracking.py

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/TruthSeedProcessor.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/CKFProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Sim/MeasurementCalibrator.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Sim/MeasurementCalibrator.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Sim/MeasurementCalibrator.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Sim/MeasurementCalibrator.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/CKFProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/SeedFinderProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/TrackExtrapolatorTool.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/TrackExtrapolatorTool.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/TrackExtrapolatorTool.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/TrackExtrapolatorTool.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/include/Tracking/Reco/TrackExtrapolatorTool.h

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/Vertexer.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/VertexProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/Vertexer.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/CKFProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/CKFProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* Update Tracking/src/Tracking/Reco/CKFProcessor.cxx

Co-authored-by: Tamas Vami <[email protected]>

* add typename to make it clearer

* clean up some comments from tvami.  Probably some more clang-format issues though

* a few more changes for clang-format

* add specific measurement_collection to pn validation config

---------

Co-authored-by: tomeichlersmith <[email protected]>
Co-authored-by: EBerzin <[email protected]>
Co-authored-by: Tamas Vami <[email protected]>
  • Loading branch information
4 people authored Sep 16, 2024
1 parent 5cfe49e commit 77fffe1
Show file tree
Hide file tree
Showing 35 changed files with 756 additions and 967 deletions.
1 change: 1 addition & 0 deletions .github/validation_samples/ecal_pn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
seed_recoil_dqm.title = ""

recoil_dqm = tkdqm.TrackingRecoDQM("RecoilTrackerDQM")
recoil_dqm.measurement_collection=digi_recoil.out_collection
recoil_dqm.buildHistograms()
recoil_dqm.track_collection = tracking_recoil.out_trk_collection
recoil_dqm.truth_collection = "RecoilTruthTracks"
Expand Down
13 changes: 4 additions & 9 deletions Tracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,11 @@ if(BUILD_EVENT_ONLY)
endif()

# since ACTS changes frequently enough, we build it as a submodule of Tracking
# here we 'set' some CMake variables that we would have passed to 'cmake' on
# here we could 'set' some CMake variables that we would have passed to 'cmake' on
# the command line with '-D' if we were building ACTS directly.
#set(ACTS_BUILD_PLUGIN_DD4HEP ON) # representing geometry with DD4hep right now
#set(ACTS_BUILD_PLUGIN_TGEO ON) # representing geometry with DD4hep right now
set(ACTS_BUILD_PLUGIN_IDENTIFICATION ON) #This turns on the identiers
set(ACTS_BUILD_EXAMPLES OFF) # don't waste time building examples
set(CMAKE_CXX_STANDARD 17) # set C++ standard we use within ldmx-sw
add_subdirectory(acts) # now build acts
#add_subdirectory(acts-dd4hep)
# for example, disable the building of examples (which is already disabled by default)
#set(ACTS_BUILD_EXAMPLES OFF) # don't waste time building examples
add_subdirectory(acts) # now build acts
# luckily for us, adding ACTS as a subdirectory produces the same CMake targets
# as find_package, so we don't need to do anything else from here on out

Expand All @@ -79,7 +75,6 @@ setup_library(module Tracking
dependencies Framework::Configure
Framework::Framework
ActsCore
ActsPluginIdentification
Geant4::Interface
ROOT::Physics
Tracking::Event
Expand Down
2 changes: 1 addition & 1 deletion Tracking/acts
Submodule acts updated 2789 files
162 changes: 89 additions & 73 deletions Tracking/exampleConfigs/reco.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import os,math
from LDMX.Framework import ldmxcfg
from LDMX.SimCore import generators
from LDMX.SimCore import simulator

p = ldmxcfg.Process("TrackerReco")

Expand All @@ -14,21 +16,33 @@
# From the conditions
from LDMX.Tracking import geo

n_evts=1000 #number of events to gen/reco

# set up a simple particle gun for this example #
# just 8gev electrons started upstream of tagger and first ts #
partGunString='single_8gev_e_upstream_tagger'
detector = 'ldmx-det-v14-8gev-no-cals'
#### set up beam simulation
sim = simulator.simulator('inclusive_single_8gev')
sim.setDetector(detector,include_scoring_planes = True)
sim.description = 'A single 8gev electron shot from upstream of the 8gev tagger.'
sim.beamSpotSmear = [20., 80., 0]
particle_gun = generators.single_8gev_e_upstream_tagger()
sim.generators.append(particle_gun)
#### end beam simulation

# Truth seeder
# Runs truth tracking producing tracks from target scoring plane hits for Recoil
# and generated electros for Tagger.
# Truth tracks can be used for assessing tracking performance or using as seeds
truth_tracking = tracking.TruthSeedProcessor()
truth_tracking.debug = True
truth_tracking.trk_coll_name = "RecoilTruthSeeds"
truth_tracking.pdgIDs = [11]
truth_tracking.scoring_hits = "TargetScoringPlaneHits"
truth_tracking.z_min = 0.
truth_tracking.track_id = -1
truth_tracking.p_cut = 0.05 # In MeV
truth_tracking.pz_cut = 0.03
truth_tracking.p_cutEcal = 0. # In MeV
truth_tracking = tracking.TruthSeedProcessor("TruthSeeds")
truth_tracking.debug = False
#truth_tracking.trk_coll_name = "RecoilTruthSeeds"
#truth_tracking.pdgIDs = [11]
#truth_tracking.scoring_hits = "TargetScoringPlaneHits"
#truth_tracking.z_min = 0.
#truth_tracking.track_id = -1
#truth_tracking.p_cut = 0.05 # In MeV


# These smearing quantities are default. We expect around 6um hit resolution in bending plane
Expand All @@ -41,20 +55,20 @@
# Smearing Processor - Tagger
# Runs G4 hit smearing producing measurements in the Tagger tracker.
# Hits that belong to the same sensor with the same trackID are merged together to reduce combinatorics
digiTagger = tracking.DigitizationProcessor("DigitizationProcessor")
digiTagger.hit_collection = "TaggerSimHits"
digiTagger.out_collection = "DigiTaggerSimHits"
digiTagger.merge_hits = True
digiTagger.sigma_u = uSmearing
digiTagger.sigma_v = vSmearing
digi_tagger = tracking.DigitizationProcessor("DigitizationProcessor")
digi_tagger.hit_collection = "TaggerSimHits"
digi_tagger.out_collection = "DigiTaggerSimHits"
digi_tagger.merge_hits = True
digi_tagger.sigma_u = uSmearing
digi_tagger.sigma_v = vSmearing

# Smearing Processor - Recoil
digiRecoil = tracking.DigitizationProcessor("DigitizationProcessorRecoil")
digiRecoil.hit_collection = "RecoilSimHits"
digiRecoil.out_collection = "DigiRecoilSimHits"
digiRecoil.merge_hits = True
digiRecoil.sigma_u = uSmearing
digiRecoil.sigma_v = vSmearing
digi_recoil = tracking.DigitizationProcessor("DigitizationProcessorRecoil")
digi_recoil.hit_collection = "RecoilSimHits"
digi_recoil.out_collection = "DigiRecoilSimHits"
digi_recoil.merge_hits = True
digi_recoil.sigma_u = uSmearing
digi_recoil.sigma_v = vSmearing


# Seed Finder Tagger
Expand All @@ -63,25 +77,26 @@
# parameters and the impact parameters at the target or generation point. For the tagger one should look
# for compatibility with the beam orbit / beam spot

seederTagger = tracking.SeedFinderProcessor()
seederTagger.input_hits_collection = digiTagger.out_collection
seederTagger.out_seed_collection = "TaggerRecoSeeds"
seederTagger.pmin = 2.
seederTagger.pmax = 8.
seederTagger.d0min = -60.
seederTagger.d0max = 0.
seeder_tagger = tracking.SeedFinderProcessor("SeedTagger")
seeder_tagger.input_hits_collection = digi_tagger.out_collection
seeder_tagger.out_seed_collection = "TaggerRecoSeeds"
seeder_tagger.pmin = 0.1
seeder_tagger.pmax = 10.0
seeder_tagger.d0min = -45.
seeder_tagger.d0max = 45.
seeder_tagger.z0max = 60.

#Seed finder processor - Recoil
seederRecoil = tracking.SeedFinderProcessor("SeedRecoil")
seederRecoil.perigee_location = [0.,0.,0.]
seederRecoil.input_hits_collection = digiRecoil.out_collection
seederRecoil.out_seed_collection = "RecoilRecoSeeds"
seederRecoil.bfield = 1.5
seederRecoil.pmin = 0.1
seederRecoil.pmax = 4.
seederRecoil.d0min = -0.5
seederRecoil.d0max = 0.5
seederRecoil.z0max = 10.
seeder_recoil = tracking.SeedFinderProcessor("SeedRecoil")
seeder_recoil.perigee_location = [0.,0.,0.]
seeder_recoil.input_hits_collection = digi_recoil.out_collection
seeder_recoil.out_seed_collection = "RecoilRecoSeeds"
seeder_recoil.bfield = 1.5
seeder_recoil.pmin = 0.1
seeder_recoil.pmax = 10.0
seeder_recoil.d0min = -40.0
seeder_recoil.d0max = 40.0
seeder_recoil.z0max = 50.


# Producer for running the CKF track finding starting from the found seeds.
Expand All @@ -93,14 +108,14 @@
tracking_tagger.const_b_field = False

#Target location for the CKF extrapolation
tracking_tagger.seed_coll_name = seederTagger.out_seed_collection
tracking_tagger.seed_coll_name = seeder_tagger.out_seed_collection
tracking_tagger.out_trk_collection = "TaggerTracks"

#smear the hits used for finding/fitting
tracking_tagger.trackID = -1 #1
tracking_tagger.pdgID = -9999 #11
tracking_tagger.measurement_collection = digiTagger.out_collection
tracking_tagger.min_hits = 5
tracking_tagger.measurement_collection = digi_tagger.out_collection
tracking_tagger.min_hits = 6


#CKF Options
Expand All @@ -110,73 +125,74 @@
tracking_recoil.propagator_step_size = 1000. #mm
tracking_recoil.bfield = -1.5 #in T #From looking at the BField map
tracking_recoil.const_b_field = False

tracking_recoil.taggerTracking=False
#Target location for the CKF extrapolation
#tracking_recoil.seed_coll_name = seederRecoil.out_seed_collection
#tracking_recoil.seed_coll_name = seeder_recoil.out_seed_collection
tracking_recoil.seed_coll_name = "RecoilTruthSeeds"
tracking_recoil.out_trk_collection = "RecoilTracks"

#smear the hits used for finding/fitting
tracking_recoil.trackID = -1 #1
tracking_recoil.pdgID = -9999 #11
tracking_recoil.measurement_collection = digiRecoil.out_collection
tracking_recoil.min_hits = 5
tracking_recoil.measurement_collection = digi_recoil.out_collection
tracking_recoil.min_hits = 6


from LDMX.Tracking import dqm
digi_dqm = dqm.TrackerDigiDQM()
tracking_dqm = dqm.TrackingRecoDQM()

seed_tagger_dqm = dqm.TrackingRecoDQM("SeedTaggerDQM")
seed_tagger_dqm.track_collection = seeder_tagger.out_seed_collection
seed_tagger_dqm.truth_collection = "TaggerTruthTracks"
seed_tagger_dqm.title = ""
seed_tagger_dqm.buildHistograms()

tagger_dqm = dqm.TrackingRecoDQM("TaggerDQM")
tagger_dqm.track_collection = tracking_tagger.out_trk_collection
tagger_dqm.truth_collection = "TaggerTruthTracks"
tagger_dqm.trackStates = ["target"]
tagger_dqm.title = ""
tagger_dqm.measurement_collection=digi_tagger.out_collection
tagger_dqm.truth_hit_collection="TaggerSimHits"
tagger_dqm.buildHistograms()


seed_recoil_dqm = dqm.TrackingRecoDQM("SeedRecoilDQM")
seed_recoil_dqm.track_collection = seederRecoil.out_seed_collection
seed_recoil_dqm.track_collection = seeder_recoil.out_seed_collection
seed_recoil_dqm.truth_collection = "RecoilTruthTracks"
seed_recoil_dqm.title = ""
seed_recoil_dqm.buildHistograms()

recoil_dqm = dqm.TrackingRecoDQM("RecoilDQM")
recoil_dqm.track_collection = tracking_recoil.out_trk_collection
recoil_dqm.truth_collection = "RecoilTruthTracks"
recoil_dqm.trackStates = ["ecal","target"]
recoil_dqm.title = ""
recoil_dqm.measurement_collection=digi_recoil.out_collection
recoil_dqm.truth_hit_collection="RecoilSimHits"
recoil_dqm.buildHistograms()

# This sequence runs the digitization in the tagger and recoil
# Then the truth tracking to have TruthTracks in the final state
# the nominal seeding is ran on the tagger and recoil
# Track finding is then raun in the tagger and in the recoil
# Finally two dqm examples are run in the recoil tracks and using the seed tracks

p.sequence = [digiTagger, digiRecoil,
truth_tracking,
seederTagger, seederRecoil,
p.sequence = [sim,truth_tracking,digi_tagger, digi_recoil,
seeder_tagger, seeder_recoil,
tracking_tagger, tracking_recoil,
recoil_dqm, seed_recoil_dqm]

# The input file to be added.
# for now, we just take the first argument on the command line
import sys
p.inputFiles = [sys.argv[1]]

# Example about how to drop some of the collections in the output file.
p.keep = [
# "drop .*SimHits.*", #drop all sim hits
"drop .*Ecal.*", #drop all ecal (Digis are not removed)
# "drop .*Magnet*",
"drop .*Hcal.*",
"drop .*Scoring.*",
"drop .*SimParticles.*",
"drop .*TriggerPad.*",
"drop .*trig.*"
]
recoil_dqm, seed_recoil_dqm,
tagger_dqm, seed_tagger_dqm]

# Output name
# just append '_withTracking' to the name of the input file
from pathlib import Path
input_filepath = Path(p.inputFiles[0])
p.outputFiles = [str(input_filepath.with_suffix(''))+'_withTracking.root']
p.outputFiles = ['test_8gev_electrons_withTracking.root']

# lower log level so 'info' and above messages can be printed
p.termLogLevel=1

# Number of events
p.maxEvents = 10000
p.maxEvents = n_evts

# Where to store DQM plots
p.histogramFile = "test_dqmMonitoringFile.root"
Expand Down
24 changes: 10 additions & 14 deletions Tracking/include/Tracking/Reco/CKFProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/Definitions/Units.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/EventData/detail/TransformationFreeToBound.hpp"
#include "Acts/Utilities/Logger.hpp"

// geometry
Expand Down Expand Up @@ -76,22 +75,17 @@

//--- Interpolated magnetic field ---//
#include "Tracking/Sim/BFieldXYZUtils.h"
// mg Aug 2024 not sure if these are needed...
using Updater = Acts::GainMatrixUpdater;
using Smoother = Acts::GainMatrixSmoother;

using ActionList =
Acts::ActionList<Acts::detail::SteppingLogger, Acts::MaterialInteractor>;
using AbortList = Acts::AbortList<Acts::EndOfWorldReached>;

using CkfPropagator = Acts::Propagator<Acts::EigenStepper<>, Acts::Navigator>;
using GsfPropagator = Acts::Propagator<
Acts::MultiEigenStepperLoop<
Acts::StepperExtensionList<
Acts::detail::GenericDefaultExtension<double>>,
Acts::WeightedComponentReducerLoop, Acts::detail::VoidAuctioneer>,
Acts::Navigator>;

//?!
// using PropagatorOptions =
// Acts::DenseStepperPropagatorOptions<ActionList, AbortList>;
using TrackContainer = Acts::TrackContainer<Acts::VectorTrackContainer,
Acts::VectorMultiTrajectory>;

namespace tracking {
namespace reco {
Expand Down Expand Up @@ -161,8 +155,10 @@ class CKFProcessor final : public TrackingGeometryUser {
// time profiling
std::map<std::string, double> profiling_map_;

bool debug_{false};
bool debug_acts_{false};

std::shared_ptr<Acts::PlaneSurface> target_surface;
Acts::RotationMatrix3 surf_rotation;
// Constant BField
double bfield_{0};
// Use constant bfield
Expand Down Expand Up @@ -209,8 +205,8 @@ class CKFProcessor final : public TrackingGeometryUser {
std::unique_ptr<const CkfPropagator> propagator_;

// The CKF
std::unique_ptr<const Acts::CombinatorialKalmanFilter<
CkfPropagator, Acts::VectorMultiTrajectory>>
std::unique_ptr<
const Acts::CombinatorialKalmanFilter<CkfPropagator, TrackContainer>>
ckf_;

// Track Extrapolator Tool
Expand Down
Loading

0 comments on commit 77fffe1

Please sign in to comment.