Skip to content

Commit

Permalink
Reverted where the proton filter is selected from
Browse files Browse the repository at this point in the history
  • Loading branch information
simonge committed Aug 15, 2024
1 parent ce9e4e4 commit feaa087
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
26 changes: 20 additions & 6 deletions src/algorithms/fardetectors/MatrixTransferStatic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ void eicrecon::MatrixTransferStatic::process(
const MatrixTransferStatic::Input& input,
const MatrixTransferStatic::Output& output) {

const auto [beamP,scatP,rechits] = input;
const auto [mcparts,rechits] = input;
auto [outputParticles] = output;

//Set beam energy from first MCBeamElectron, using std::call_once
std::call_once(m_initBeamE,[&](){

m_initialized = initalizeMatrix(*beamP);
if(!m_initialized) m_initialized = initalizeMatrix(*scatP);
m_initialized = initalizeMatrix(*mcparts);

});

Expand Down Expand Up @@ -170,12 +169,27 @@ bool eicrecon::MatrixTransferStatic::initalizeMatrix(const edm4hep::MCParticleCo
return false;
}

double numBeamProtons = 0;
double runningMomentum = 0.0;

for (const auto p: mcparts) {
if(mcparts.size() == 1 && p.getPDG() == 2212){
runningMomentum = p.getMomentum().z;
numBeamProtons++;
}
if (p.getGeneratorStatus() == 4 && p.getPDG() == 2212) { //look for "beam" proton
runningMomentum += p.getMomentum().z;
numBeamProtons++;
}
}

if(numBeamProtons == 0) {error("No beam protons to choose matrix!"); return false;}

double nomMomentum = runningMomentum/numBeamProtons;

// Fractional error allowed in beam momentum
double nomMomentumError = 0.05;

// Set nominal momentum to MCParticle momentum
double nomMomentum = mcparts.at(0).getMomentum().z;

double aX[2][2] = {{0.0, 0.0},
{0.0, 0.0}};
double aY[2][2] = {{0.0, 0.0},
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/fardetectors/MatrixTransferStatic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <gsl/pointers>
#include <string>
#include <string_view>
#include <Eigen/Dense>

#include "MatrixTransferStaticConfig.h"
#include "algorithms/interfaces/WithPodConfig.h"
Expand All @@ -21,7 +22,6 @@ namespace eicrecon {

using MatrixTransferStaticAlgorithm = algorithms::Algorithm<
algorithms::Input<
edm4hep::MCParticleCollection,
edm4hep::MCParticleCollection,
edm4eic::TrackerHitCollection
>,
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/FOFFMTRK/FOFFMTRK.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void InitPlugin(JApplication *app) {

app->Add(new JOmniFactoryGeneratorT<MatrixTransferStatic_factory>(
"ForwardOffMRecParticles",
{"MCBeamProtons","MCScatteredProtons","ForwardOffMTrackerRecHits"},
{"MCParticles","ForwardOffMTrackerRecHits"},
{"ForwardOffMRecParticles"},
recon_cfg,
app
Expand Down
2 changes: 1 addition & 1 deletion src/detectors/RPOTS/RPOTS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void InitPlugin(JApplication *app) {

app->Add(new JOmniFactoryGeneratorT<MatrixTransferStatic_factory>(
"ForwardRomanPotRecParticles",
{"MCBeamProtons","MCScatteredProtons","ForwardRomanPotRecHits"},
{"MCParticles","ForwardRomanPotRecHits"},
{"ForwardRomanPotRecParticles"},
recon_cfg,
app
Expand Down
5 changes: 2 additions & 3 deletions src/factories/fardetectors/MatrixTransferStatic_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class MatrixTransferStatic_factory :
private:
std::unique_ptr<AlgoT> m_algo;

PodioInput<edm4hep::MCParticle> m_mcbeamp_input {this};
PodioInput<edm4hep::MCParticle> m_mcscatp_input {this};
PodioInput<edm4hep::MCParticle> m_mcparts_input {this};
PodioInput<edm4eic::TrackerHit> m_hits_input {this};
PodioOutput<edm4eic::ReconstructedParticle> m_tracks_output {this};

Expand Down Expand Up @@ -68,7 +67,7 @@ class MatrixTransferStatic_factory :
}

void Process(int64_t run_number, uint64_t event_number) {
m_algo->process({m_mcbeamp_input(), m_mcscatp_input(), m_hits_input()}, {m_tracks_output().get()});
m_algo->process({m_mcparts_input(), m_hits_input()}, {m_tracks_output().get()});
}

};
Expand Down

0 comments on commit feaa087

Please sign in to comment.