Skip to content

Commit

Permalink
Merge pull request #399 from eic/truth-seeding-momentum-offset
Browse files Browse the repository at this point in the history
feat: use modified true momentum as tracking seed parameter
  • Loading branch information
osbornjd authored Jan 14, 2023
2 parents 26f930d + bc6aa67 commit a5685ae
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/algorithms/tracking/TrackParamTruthInit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ eicrecon::TrackParameters *eicrecon::TrackParamTruthInit::produce(const edm4hep:
return nullptr;
}

// modify initial momentum to avoid bleeding truth to results when fit fails
// this picks uniformly between [1-eps,1,1+eps] times true momentum, then smeared
const auto pinit = pmag
* (1.0 + m_cfg.m_momentumSplit * m_uniformIntDist(generator))
* (1.0 + m_cfg.m_momentumSmear * m_normDist(generator));

// build some track cov matrix
Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero();
cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = 1000*um*1000*um;
Expand All @@ -86,7 +92,7 @@ eicrecon::TrackParameters *eicrecon::TrackParamTruthInit::produce(const edm4hep:
params(Acts::eBoundLoc1) = 0.0 * mm ; // cylinder length
params(Acts::eBoundPhi) = phi;
params(Acts::eBoundTheta) = theta;
params(Acts::eBoundQOverP) = charge / (pmag * GeV);
params(Acts::eBoundQOverP) = charge / (pinit * GeV);
params(Acts::eBoundTime) = part->getTime() * ns;

//// Construct a perigee surface as the target surface
Expand Down
12 changes: 10 additions & 2 deletions src/algorithms/tracking/TrackParamTruthInit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,31 @@
#include <algorithms/tracking/JugTrack/Track.hpp>
#include <edm4hep/MCParticle.h>
#include <spdlog/logger.h>

#include "TrackParamTruthInitConfig.h"
#include <algorithms/interfaces/WithPodConfig.h>

#include <random>
#include <TDatabasePDG.h>

namespace eicrecon {
class TrackParamTruthInit: eicrecon::IObjectProducer<edm4hep::MCParticle, eicrecon::TrackParameters> {
class TrackParamTruthInit: public WithPodConfig<TrackParamTruthInitConfig> {

public:

void init(const std::shared_ptr<spdlog::logger> &logger);

eicrecon::TrackParameters * produce(const edm4hep::MCParticle *) override;
eicrecon::TrackParameters * produce(const edm4hep::MCParticle *);

private:
std::shared_ptr<spdlog::logger> m_log;
TrackParamTruthInitConfig m_cfg;
std::shared_ptr<TDatabasePDG> m_pdg_db;

std::default_random_engine generator; // TODO: need something more appropriate here
std::uniform_int_distribution<int> m_uniformIntDist{-1, 1}; // defaults to min=-1, max=1
std::normal_distribution<double> m_normDist;

};
} // namespace eicrecon

Expand Down
2 changes: 2 additions & 0 deletions src/algorithms/tracking/TrackParamTruthInitConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct TrackParamTruthInitConfig {
double m_minMomentum = 100 * Acts::UnitConstants::MeV;
double m_maxEtaForward = 4.0;
double m_maxEtaBackward = 4.1;
double m_momentumSplit = 0.0;
double m_momentumSmear = 0.0;

};

Expand Down
24 changes: 21 additions & 3 deletions src/global/tracking/TrackParamTruthInit_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@
#include <algorithms/tracking/TrackParamTruthInitConfig.h>

void eicrecon::TrackParamTruthInit_factory::Init() {
auto app = GetApplication();

// This prefix will be used for parameters
std::string param_prefix = GetDefaultParameterPrefix();
std::string plugin_name = eicrecon::str::ReplaceAll(GetPluginName(), ".so", "");
std::string param_prefix = plugin_name+ ":" + GetTag();

InitLogger(param_prefix);
// Initialize input tags
InitDataTags(param_prefix);

// Initialize underlying algorithm
// Initialize logger
InitLogger(param_prefix, "info");

// Algorithm configuration
auto cfg = GetDefaultConfig();
app->SetDefaultParameter(param_prefix + ":MaxVertexX", cfg.m_maxVertexX , "Maximum abs(vertex x) for truth tracks turned into seed");
app->SetDefaultParameter(param_prefix + ":MaxVertexY", cfg.m_maxVertexY , "Maximum abs(vertex y) for truth tracks turned into seed");
app->SetDefaultParameter(param_prefix + ":MaxVertexZ", cfg.m_maxVertexZ , "Maximum abs(vertex z) for truth tracks turned into seed");
app->SetDefaultParameter(param_prefix + ":MinMomentum", cfg.m_minMomentum , "Minimum momentum for truth tracks turned into seed");
app->SetDefaultParameter(param_prefix + ":MaxEtaForward", cfg.m_maxEtaForward , "Maximum forward abs(eta) for truth tracks turned into seed");
app->SetDefaultParameter(param_prefix + ":MaxEtaBackward", cfg.m_maxEtaBackward , "Maximum backward abs(eta) for truth tracks turned into seed");
app->SetDefaultParameter(param_prefix + ":MomentumSplit", cfg.m_momentumSplit, "Momentum magnitude fraction to use as width for random trifurcation");
app->SetDefaultParameter(param_prefix + ":MomentumSmear", cfg.m_momentumSmear, "Momentum magnitude fraction to use as width of gaussian smearing");

// Initialize algorithm
m_truth_track_seeding_algo.applyConfig(cfg);
m_truth_track_seeding_algo.init(m_log);
}

Expand Down
7 changes: 4 additions & 3 deletions src/global/tracking/TrackParamTruthInit_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

namespace eicrecon {

class TrackParamTruthInit_factory : public JChainFactoryT<eicrecon::TrackParameters>,
class TrackParamTruthInit_factory :
public JChainFactoryT<eicrecon::TrackParameters, TrackParamTruthInitConfig>,
public SpdlogMixin<TrackParamTruthInit_factory> {

public:
TrackParamTruthInit_factory( std::vector<std::string> default_input_tags):
JChainFactoryT<eicrecon::TrackParameters>(std::move(default_input_tags) ) {
TrackParamTruthInit_factory( std::vector<std::string> default_input_tags, TrackParamTruthInitConfig cfg):
JChainFactoryT<eicrecon::TrackParameters, TrackParamTruthInitConfig>(std::move(default_input_tags), cfg ) {
}

/** One time initialization **/
Expand Down

0 comments on commit a5685ae

Please sign in to comment.