Skip to content

Commit

Permalink
Fix building with ACTS 34 (#374)
Browse files Browse the repository at this point in the history
Co-authored-by: jmcarcell <[email protected]>
  • Loading branch information
jmcarcell and jmcarcell authored Jul 18, 2024
1 parent 0905420 commit 1f03903
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 23 deletions.
39 changes: 24 additions & 15 deletions analyzers/dataframe/src/VertexFinderActs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <iostream>

// ACTS

#include "Acts/MagneticField/ConstantBField.hpp"
#include "Acts/Propagator/EigenStepper.hpp"
#include "Acts/Propagator/Propagator.hpp"
Expand Down Expand Up @@ -61,12 +62,12 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){
auto propagator = std::make_shared<Propagator>(stepper);

// Set up ImpactPointEstimator
using IPEstimator = Acts::ImpactPointEstimator<Acts::BoundTrackParameters, Propagator>;
using IPEstimator = Acts::ImpactPointEstimator;
IPEstimator::Config ipEstimatorCfg(bField, propagator);
IPEstimator ipEstimator(ipEstimatorCfg);

// Set up the helical track linearizer
using Linearizer = Acts::HelicalTrackLinearizer<Propagator>;
using Linearizer = Acts::HelicalTrackLinearizer;
Linearizer::Config ltConfig(bField, propagator);
Linearizer linearizer(ltConfig);

Expand All @@ -78,14 +79,18 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){


// Set up the vertex fitter with user-defined annealing
using Fitter = Acts::AdaptiveMultiVertexFitter<Acts::BoundTrackParameters, Linearizer>;
using Fitter = Acts::AdaptiveMultiVertexFitter;
Fitter::Config fitterCfg(ipEstimator);
fitterCfg.annealingTool = annealingUtility;
Fitter fitter(fitterCfg);//, Acts::getDefaultLogger("Fitter", Acts::Logging::VERBOSE));

// Set up the vertex seed finder
using SeedFinder = Acts::TrackDensityVertexFinder<Fitter, Acts::GaussianTrackDensity<Acts::BoundTrackParameters>>;
SeedFinder seedFinder;
using SeedFinder = Acts::TrackDensityVertexFinder;
Acts::GaussianTrackDensity::Config trkDensityCfg;
trkDensityCfg.extractParameters.connect<&Acts::InputTrack::extractParameters>();

auto seedFinder = std::make_shared<SeedFinder>(SeedFinder::Config{trkDensityCfg});



/*
Expand All @@ -103,11 +108,10 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){
*/

// The vertex finder type
using Finder = Acts::AdaptiveMultiVertexFinder<Fitter, SeedFinder>;
using Finder = Acts::AdaptiveMultiVertexFinder;
//using Finder = Acts::AdaptiveMultiVertexFinder<Fitter, VertexSeedFinder>;
//Finder::Config finderConfig(std::move(fitter), seedFinder, ipEstimator, linearizer);
Finder::Config finderConfig = {std::move(fitter), std::move(seedFinder), ipEstimator,
std::move(linearizer), bField};
Finder::Config finderConfig(std::move(fitter), std::move(seedFinder), ipEstimator, bField);

#if ACTS_VERSION_MAJOR < 29
// We do not want to use a beamspot constraint here
Expand All @@ -126,10 +130,11 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){
Finder finder(finderConfig);//, Acts::getDefaultLogger("Finder", Acts::Logging::VERBOSE));
#endif
// The vertex finder state
Finder::State state;
// TODO:
// Finder::State state;

// Default vertexing options, this is where e.g. a constraint could be set
using VertexingOptions = Acts::VertexingOptions<Acts::BoundTrackParameters>;
using VertexingOptions = Acts::VertexingOptions;
//VertexingOptions finderOpts(myContext, myContext);
VertexingOptions finderOpts(geoContext, magFieldContext);
#if ACTS_VERSION_MAJOR >= 29
Expand Down Expand Up @@ -210,6 +215,7 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){
for (const auto& trk : allTracks) {
tracksPtr.push_back(&trk);
}
std::vector<Acts::InputTrack> newTracks;


ROOT::VecOps::RVec<VertexingUtils::FCCAnalysesVertex> TheVertexColl;
Expand All @@ -218,7 +224,9 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){
return TheVertexColl; // can not reconstruct a vertex with only one track...return an empty collection

// find vertices
auto result = finder.find(tracksPtr, finderOpts, state);
// TODO:
auto state = finder.makeState(Acts::MagneticFieldContext());
auto result = finder.find(newTracks, finderOpts, state);

//std::cout << "result " << result.ok() << std::endl;
if (not result.ok()) {
Expand Down Expand Up @@ -268,16 +276,17 @@ VertexFinderAMVF(ROOT::VecOps::RVec<edm4hep::TrackState> tracks ){
edm4hep_vertex.algorithmType = 2;
edm4hep_vertex.covMatrix = edm4hep_vtxcov;

std::vector<Acts::TrackAtVertex<Acts::BoundTrackParameters>> tracksAtVertex = vtx.tracks();
std::vector<Acts::TrackAtVertex> tracksAtVertex = vtx.tracks();

for (const auto& trk : tracksAtVertex) {

reco_chi2.push_back(trk.chi2Track);
double ndf = trk.ndf;

const Acts::BoundTrackParameters* originalParams = trk.originalParams;
for (size_t trkind=0;trkind<tracksPtr.size();trkind++)
if (originalParams == tracksPtr.at(trkind))reco_ind.push_back(trkind);
// TODO:
//const Acts::BoundTrackParameters* originalParams = trk.originalParams;
//for (size_t trkind=0;trkind<tracksPtr.size();trkind++)
// if (originalParams == tracksPtr.at(trkind))reco_ind.push_back(trkind);
}
TheVertex.vertex = edm4hep_vertex;
TheVertex.reco_ind = reco_ind;
Expand Down
24 changes: 16 additions & 8 deletions analyzers/dataframe/src/VertexFitterActs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,25 @@ VertexingUtils::FCCAnalysesVertex VertexFitterFullBilloir(ROOT::VecOps::RVec<edm
auto propagator = std::make_shared<Propagator>(stepper);


using Linearizer = Acts::HelicalTrackLinearizer<Propagator>;
using Linearizer = Acts::HelicalTrackLinearizer;
Linearizer::Config ltConfig(bField, propagator);
Linearizer linearizer(ltConfig);

// Set up Billoir Vertex Fitter
using VertexFitter = Acts::FullBilloirVertexFitter<Acts::BoundTrackParameters, Linearizer>;
using VertexFitter = Acts::FullBilloirVertexFitter;
VertexFitter::Config vertexFitterCfg;
VertexFitter billoirFitter(vertexFitterCfg);
//VertexFitter::State state(magFieldContext);
VertexFitter::State state(bField->makeCache(magFieldContext));
// TODO:
//VertexFitter::State state(bField->makeCache(magFieldContext));

#if ACTS_VERSION_MAJOR < 29
using CovMatrix4D = Acts::SymMatrix4;
#else
using CovMatrix4D = Acts::SquareMatrix4;
#endif
// Constraint for vertex fit
Acts::Vertex<Acts::BoundTrackParameters> myConstraint;
Acts::Vertex myConstraint;
// Some abitrary values
CovMatrix4D myCovMat = CovMatrix4D::Zero();
myCovMat(0, 0) = 30.;
Expand All @@ -81,8 +82,8 @@ VertexingUtils::FCCAnalysesVertex VertexFitterFullBilloir(ROOT::VecOps::RVec<edm
myConstraint.setFullPosition(Acts::Vector4(0, 0, 0, 0));


Acts::VertexingOptions<Acts::BoundTrackParameters> vfOptions(geoContext, magFieldContext);
Acts::VertexingOptions<Acts::BoundTrackParameters> vfOptionsConstr(geoContext, magFieldContext, myConstraint);
Acts::VertexingOptions vfOptions(geoContext, magFieldContext);
Acts::VertexingOptions vfOptionsConstr(geoContext, magFieldContext, myConstraint);


int Ntr = tracks.size();
Expand Down Expand Up @@ -176,8 +177,15 @@ VertexingUtils::FCCAnalysesVertex VertexFitterFullBilloir(ROOT::VecOps::RVec<edm
return TheVertex; // can not reconstruct a vertex with only one track...
}

Acts::Vertex<Acts::BoundTrackParameters> fittedVertex =
billoirFitter.fit(tracksPtr, linearizer, vfOptions, state).value();
// TODO:
std::vector<Acts::InputTrack> newTracks;

// TODO:
auto ctx = Acts::MagneticFieldContext();
auto cache = Acts::MagneticFieldProvider::Cache();

Acts::Vertex fittedVertex =
billoirFitter.fit(newTracks, vfOptions, cache).value();
//Acts::Vertex<Acts::BoundTrackParameters> fittedVertexConstraint =
// billoirFitter.fit(tracksPtr, linearizer, vfOptionsConstr, state).value();

Expand Down

0 comments on commit 1f03903

Please sign in to comment.