-
Notifications
You must be signed in to change notification settings - Fork 34
Secvertex amvf to be merged into main EICrecon repo #1915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 130 commits
097ec32
09636b8
7c9162b
f109512
b6579d5
8063442
888e5e5
4a699cb
ee917d1
2f12770
cbcf0c2
fff3b03
e2e19f4
1d0d8a7
4dd58e0
1231d7f
8f7852b
4ec0b87
65b261e
39fdc6e
4d918f5
4daa73b
8a5d527
3436fd5
532a4e9
7102fa9
1d562f2
17f8ab7
bfd67d5
7a032f0
bb450db
c875374
6fcbc89
8aef394
d6fb60a
0a4dd1e
34c77e3
907e208
995a9d8
92bde8f
de86c19
ccaf923
34efd49
12272d4
48efd0a
68e311d
f24b9c3
bcff707
b71d57d
0151dda
e9dd913
3bdfe4d
b9481db
86fbc50
5a8aa98
472cf51
44b0968
2c831d5
c92fb49
d02cda3
777478c
bb8086a
183f7a2
f11afde
428e586
eb7b341
ee123f7
155b346
0ecae3b
02c1c12
3da8bc0
8ea36e7
139ad4d
52f2f4a
2eae4f5
c9ce682
579251b
f66a6b4
9503602
be5dab4
9f24639
e37624d
5a235d4
a2fcd54
f851eaa
eda9580
76c701f
37db21d
3bd15c4
b9aae09
938c64c
ecc1bb4
7e980bc
91e1bcd
95d668b
def07f5
88eef22
109231f
554e3d5
9036a84
917abf5
b1b5d8a
a57ece3
07394e7
61dd02a
93b2e50
d049e29
1734966
6ebd198
bbbcdc8
c5f2c23
740f6ff
9119287
4a00881
ef1a410
f6f5f8d
3cc79b9
fb1e371
10cf069
3caae30
00efab5
9bd0922
b0f4fe4
640a499
f7c39d0
895ad5d
1571282
ef32d98
fb2793e
6355b67
35a1068
ba4db2c
2e3fff3
de73fd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| // Copyright (C) 2025 Dongwi H. Dongwi (Bishoy) | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <Acts/Geometry/GeometryContext.hpp> | ||
| #include <Acts/MagneticField/MagneticFieldContext.hpp> | ||
| #include <Acts/Propagator/EigenStepper.hpp> | ||
| #include <Acts/Vertexing/AdaptiveGridDensityVertexFinder.hpp> | ||
| #include <Acts/Vertexing/AdaptiveMultiVertexFinder.hpp> | ||
| #include <Acts/Vertexing/AdaptiveMultiVertexFitter.hpp> | ||
| #include <Acts/Vertexing/HelicalTrackLinearizer.hpp> | ||
| #include <Acts/Vertexing/ImpactPointEstimator.hpp> | ||
| #include <Acts/Vertexing/Vertex.hpp> | ||
| #include <Acts/Vertexing/VertexingOptions.hpp> | ||
| #include <ActsExamples/EventData/Trajectories.hpp> | ||
| #include <algorithms/algorithm.h> | ||
| #include <edm4eic/ReconstructedParticleCollection.h> | ||
| #include <edm4eic/VertexCollection.h> | ||
| #include <spdlog/logger.h> | ||
| #include <gsl/pointers> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <string_view> | ||
| #include <vector> | ||
|
|
||
| #include "ActsGeometryProvider.h" | ||
| #include "DD4hepBField.h" | ||
| #include "SecondaryVertexFinderConfig.h" | ||
| #include "algorithms/interfaces/WithPodConfig.h" | ||
|
|
||
| namespace eicrecon { | ||
|
|
||
| using SecondaryVertexFinderAlgorithm = | ||
| algorithms::Algorithm<algorithms::Input<edm4eic::ReconstructedParticleCollection, | ||
| std::vector<const ActsExamples::Trajectories>>, | ||
| algorithms::Output<edm4eic::VertexCollection, edm4eic::VertexCollection>>; | ||
|
|
||
| class SecondaryVertexFinder : public SecondaryVertexFinderAlgorithm, | ||
| public WithPodConfig<eicrecon::SecondaryVertexFinderConfig> { | ||
| public: | ||
| SecondaryVertexFinder(std::string_view name) | ||
| : SecondaryVertexFinderAlgorithm{name, | ||
| {"inputReconstructedParticles", "inputActsTrajectories"}, | ||
| {"outputPrimaryVertices", "outputSecondaryVertices"}, | ||
| ""} {} | ||
|
|
||
| void init() final; | ||
|
|
||
| void process(const Input&, const Output&) const final; | ||
|
|
||
| // FIXME this is not compliant with algorithms interface | ||
| void applyLogger(std::shared_ptr<spdlog::logger> log) { m_log = log; }; | ||
|
|
||
| private: | ||
| // Calculate an initial Primary Vertex | ||
| void calculatePrimaryVertex( | ||
| const edm4eic::ReconstructedParticleCollection&, | ||
| const std::vector<gsl::not_null<const ActsExamples::Trajectories*>>& trajectories, | ||
| Acts::EigenStepper<>, edm4eic::VertexCollection&) const; | ||
|
|
||
| //Calculate secondary vertex and store secVertex container | ||
| void calculateSecondaryVertex( | ||
| const edm4eic::ReconstructedParticleCollection&, | ||
| const std::vector<gsl::not_null<const ActsExamples::Trajectories*>>& trajectories, | ||
| Acts::EigenStepper<>, edm4eic::VertexCollection&) const; | ||
|
|
||
| // Functions to be used to check efficacy of sec. vertex | ||
| void setVertexContainer(std::vector<Acts::Vertex> inputcontainer) { | ||
| vtx_container = inputcontainer; | ||
| }; | ||
|
|
||
| //set up Impact estimator | ||
| using ImpactPointEstimator = Acts::ImpactPointEstimator; | ||
| using LinearizerSec = Acts::HelicalTrackLinearizer; | ||
| using VertexFitterSec = Acts::AdaptiveMultiVertexFitter; | ||
| using VertexFinderSec = Acts::AdaptiveMultiVertexFinder; | ||
| using VertexFinderOptionsSec = Acts::VertexingOptions; | ||
| using seedFinder = Acts::AdaptiveGridDensityVertexFinder; | ||
|
|
||
| std::shared_ptr<spdlog::logger> m_log; | ||
| std::shared_ptr<const ActsGeometryProvider> m_geoSvc; | ||
|
|
||
| std::shared_ptr<const eicrecon::BField::DD4hepBField> m_BField = nullptr; | ||
| Acts::GeometryContext m_geoctx; | ||
| Acts::MagneticFieldContext m_fieldctx; | ||
| SecondaryVertexFinderConfig m_cfg; | ||
| std::vector<Acts::Vertex> vtx_container; | ||
| }; | ||
|
|
||
| } // namespace eicrecon | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #pragma once | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing license header. |
||
|
|
||
| #include <Acts/Definitions/Units.hpp> | ||
|
|
||
| namespace eicrecon { | ||
|
|
||
| struct SecondaryVertexFinderConfig { | ||
| unsigned int maxVertices = 20; | ||
| unsigned int maxIterations = 500; | ||
| unsigned int maxSecIterations = 1000; | ||
| //Max z interval used for adding tracks to fit: when adding a new vertex to the multi vertex fit, | ||
| //only the tracks whose z at PCA is closer to the seeded vertex than tracksMaxZinterval | ||
| //are added to this new vertex | ||
| float tracksMaxZinterval = 3 * Acts::UnitConstants::mm; | ||
| float tracksMaxZintervalSec = 10 * Acts::UnitConstants::mm; | ||
|
|
||
| // Max chi2 value for which tracks are considered compatible with | ||
| // the fitted vertex. These tracks are removed from the seedTracks | ||
| // after the fit has been performed. | ||
| double maxVertexChi2 = 18.42; | ||
| bool doFullSplitting = false; | ||
| // 5 corresponds to a p-value of ~0.92 using `chi2(x=5,ndf=2)` | ||
| float tracksMaxSignificance = 6.7; | ||
| float maxMergeVertexSignificance = 3; | ||
| float minWeight = 1e-04; | ||
| float maxDistToLinPoint = 5.5 * Acts::UnitConstants::mm; | ||
| // Bin extent in z-direction | ||
| float spatialBinExtent = 25 * Acts::UnitConstants::um; | ||
| Acts::Vector4 initialVariances = Acts::Vector4{1e+2, 1e+2, 1e+2, 1e+8}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still needs units. |
||
| // Bin extent in t-direction | ||
| float temporalBinExtent = 19. * Acts::UnitConstants::mm; | ||
| bool doSmoothing = true; | ||
| bool reassignTracksAfterFirstFit = true; | ||
| bool useTime = false; | ||
| // Use seed vertex as a constraint for the fit | ||
| bool useSeedConstraint = true; | ||
| }; | ||
|
|
||
| } // namespace eicrecon | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| // Copyright (C) 2025 Dongwi H. Dongwi (Bishoy) | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <ActsExamples/EventData/Trajectories.hpp> | ||
| #include <JANA/JEvent.h> | ||
| #include <edm4eic/Vertex.h> | ||
| #include <edm4eic/TrackParameters.h> | ||
| #include <memory> | ||
| #include <string> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include "algorithms/tracking/SecondaryVertexFinderConfig.h" | ||
| #include "algorithms/tracking/SecondaryVertexFinder.h" | ||
| #include "extensions/jana/JOmniFactory.h" | ||
|
|
||
| namespace eicrecon { | ||
|
|
||
| class SecondaryVertexFinder_factory | ||
| : public JOmniFactory<SecondaryVertexFinder_factory, SecondaryVertexFinderConfig> { | ||
|
|
||
| private: | ||
| using AlgoT = eicrecon::SecondaryVertexFinder; | ||
| std::unique_ptr<AlgoT> m_algo; | ||
|
|
||
| PodioInput<edm4eic::ReconstructedParticle> m_reco_input{this}; | ||
| Input<ActsExamples::Trajectories> m_acts_trajectories_input{this}; | ||
| PodioOutput<edm4eic::Vertex> m_prm_vertices_output{this}; | ||
| PodioOutput<edm4eic::Vertex> m_sec_vertices_output{this}; | ||
|
|
||
| ParameterRef<unsigned int> m_maxVertices{this, "maxVertices", config().maxVertices, | ||
| "Maximum num vertices that can be found"}; | ||
| ParameterRef<bool> m_reassignTracksAfterFirstFit{ | ||
| this, "reassignTracksAfterFirstFit", config().reassignTracksAfterFirstFit, | ||
| "Whether or not to reassign tracks after first fit"}; | ||
| ParameterRef<float> m_tracksMaxZinterval{this, "tracksMaxZinterval", config().tracksMaxZinterval, | ||
| "Max z interval for Acts::AdaptiveMultiVertexFinder."}; | ||
| ParameterRef<unsigned int> m_maxIterations{this, "maxIterations", config().maxIterations, | ||
| "Max iterations for Acts::AdaptiveMultivertexFinder"}; | ||
| ParameterRef<float> m_maxDistToLinPoint{ | ||
| this, "maxDistToLinPoint", config().maxDistToLinPoint, | ||
| "Max disttance to line point (pca) for Acts::AdaptiveMultivertexFinder"}; | ||
|
|
||
| Service<ACTSGeo_service> m_ACTSGeoSvc{this}; | ||
|
|
||
| public: | ||
| void Configure() { | ||
| m_algo = std::make_unique<AlgoT>(this->GetPrefix()); | ||
| m_algo->applyConfig(config()); | ||
| m_algo->applyLogger(logger()); | ||
| m_algo->init(); | ||
| } | ||
|
|
||
| void Process(int32_t, uint64_t) { | ||
| std::vector<gsl::not_null<const ActsExamples::Trajectories*>> acts_trajectories_input; | ||
| for (auto acts_traj : m_acts_trajectories_input()) { | ||
| acts_trajectories_input.push_back(acts_traj); | ||
| } | ||
| m_algo->process( | ||
| { | ||
| m_reco_input(), | ||
| acts_trajectories_input, | ||
| }, | ||
| { | ||
| m_prm_vertices_output().get(), | ||
| m_sec_vertices_output().get(), | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace eicrecon |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |||||||||||||||||
| #include "factories/tracking/AmbiguitySolver_factory.h" | ||||||||||||||||||
| #include "factories/tracking/CKFTracking_factory.h" | ||||||||||||||||||
| #include "factories/tracking/IterativeVertexFinder_factory.h" | ||||||||||||||||||
| #include "factories/tracking/SecondaryVertexFinder_factory.h" | ||||||||||||||||||
| #include "factories/tracking/TrackParamTruthInit_factory.h" | ||||||||||||||||||
| #include "factories/tracking/TrackProjector_factory.h" | ||||||||||||||||||
| #include "factories/tracking/TrackPropagation_factory.h" | ||||||||||||||||||
|
|
@@ -392,6 +393,14 @@ void InitPlugin(JApplication* app) { | |||||||||||||||||
| app->Add(new JOmniFactoryGeneratorT<CollectionCollector_factory<edm4eic::Track, true>>( | ||||||||||||||||||
| "CombinedTracks", {"CentralCKFTracks", "B0TrackerCKFTracks"}, {"CombinedTracks"}, app)); | ||||||||||||||||||
|
|
||||||||||||||||||
| app->Add(new JOmniFactoryGeneratorT<SecondaryVertexFinder_factory>( | ||||||||||||||||||
| "SecondaryTrackVerticesAMVF", {"ReconstructedParticles", "CentralCKFActsTrajectories"}, | ||||||||||||||||||
| { | ||||||||||||||||||
| "PrimaryTrackVerticesAMVF", | ||||||||||||||||||
| "SecondaryTrackVerticesAMVF", | ||||||||||||||||||
|
Comment on lines
+399
to
+400
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, so our IVF collection is CentralTrackVertices, we can't just replace
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or if we are to be consistent with Xin's collections it would be
Suggested change
I wonder if primaries and secondaries produced by this factory can overlap? |
||||||||||||||||||
| }, | ||||||||||||||||||
| {}, app)); | ||||||||||||||||||
|
|
||||||||||||||||||
| app->Add(new JOmniFactoryGeneratorT< | ||||||||||||||||||
| CollectionCollector_factory<edm4eic::MCRecoTrackParticleAssociation, true>>( | ||||||||||||||||||
| "CombinedTrackAssociations", {"CentralCKFTrackAssociations", "B0TrackerCKFTrackAssociations"}, | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docstring.