Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/algorithms/reco/Beam.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#include <Math/Vector4D.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4eic/ReconstructedParticleCollection.h>
#include <algorithm>
#include <set>
#include <vector>
#include <cmath>

using ROOT::Math::PxPyPzEVector;

Expand All @@ -15,11 +18,10 @@ namespace eicrecon {
template <class T> auto find_first_with_pdg(const T* parts, const std::set<int32_t>& pdg) {
T c;
c.setSubsetCollection();
for (const auto& p : *parts) {
if (pdg.count(p.getPDG()) > 0) {
c.push_back(p);
break;
}
const auto it = std::find_if(parts->begin(), parts->end(),
[&pdg](const auto& p) { return pdg.count(p.getPDG()) > 0; });
if (it != parts->end()) {
c.push_back(*it);
}
return c;
}
Expand All @@ -29,11 +31,11 @@ auto find_first_with_status_pdg(const T* parts, const std::set<int32_t>& status,
const std::set<int32_t>& pdg) {
T c;
c.setSubsetCollection();
for (const auto& p : *parts) {
if (status.count(p.getGeneratorStatus()) > 0 && pdg.count(p.getPDG()) > 0) {
c.push_back(p);
break;
}
const auto it = std::find_if(parts->begin(), parts->end(), [&status, &pdg](const auto& p) {
return status.count(p.getGeneratorStatus()) > 0 && pdg.count(p.getPDG()) > 0;
});
if (it != parts->end()) {
c.push_back(*it);
}
return c;
}
Expand Down
19 changes: 7 additions & 12 deletions src/algorithms/reco/HadronicFinalState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <edm4hep/Vector3f.h>
#include <fmt/core.h>
#include <podio/ObjectID.h>
#include <algorithm>
#include <cmath>
#include <gsl/pointers>
#include <vector>
Expand Down Expand Up @@ -58,21 +59,15 @@ void HadronicFinalState::process(const HadronicFinalState::Input& input,
return;
}
// Associate first scattered electron with reconstructed electrons
//const auto ef_assoc = std::find_if(
// rcassoc->begin(),
// rcassoc->end(),
// [&ef_coll](const auto& a){ return a.getSim().getObjectID() == ef_coll[0].getObjectID(); });
auto ef_assoc = rcassoc->begin();
for (; ef_assoc != rcassoc->end(); ++ef_assoc) {
if (ef_assoc->getSim().getObjectID() == ef_coll[0].getObjectID()) {
break;
}
}
if (!(ef_assoc != rcassoc->end())) {
const auto ef_assoc = std::find_if(rcassoc->begin(), rcassoc->end(), [&ef_coll](const auto& a) {
return a.getSim().getObjectID() == ef_coll[0].getObjectID();
});

if (ef_assoc == rcassoc->end()) {
debug("Truth scattered electron not in reconstructed particles");
return;
}
const auto ef_rc{ef_assoc->getRec()};
const auto ef_rc{(*ef_assoc).getRec()};
const auto ef_rc_id{ef_rc.getObjectID().index};

// Sums in colinear frame
Expand Down
48 changes: 0 additions & 48 deletions src/algorithms/reco/InclusiveKinematicsElectron.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,6 @@ void InclusiveKinematicsElectron::process(const InclusiveKinematicsElectron::Inp
const auto [mcparts, escat, hfs] = input;
auto [kinematics] = output;

// 1. find_if
//const auto mc_first_electron = std::find_if(
// mcparts.begin(),
// mcparts.end(),
// [](const auto& p){ return p.getPDG() == 11; });

// 2a. simple loop over iterator (post-increment)
//auto mc_first_electron = mcparts.end();
//for (auto p = mcparts.begin(); p != mcparts.end(); p++) {
// if (p.getPDG() == 11) {
// mc_first_electron = p;
// break;
// }
//}
// 2b. simple loop over iterator (pre-increment)
//auto mc_first_electron = mcparts.end();
//for (auto p = mcparts.begin(); p != mcparts.end(); ++p) {
// if (p.getPDG() == 11) {
// mc_first_electron = p;
// break;
// }
//}

// 3. pre-initialized simple loop
//auto mc_first_electron = mcparts.begin();
//for (; mc_first_electron != mcparts.end(); ++mc_first_electron) {
// if (mc_first_electron.getPDG() == 11) {
// break;
// }
//}

// 4a. iterator equality
//if (mc_first_electron == mcparts.end()) {
// debug() << "No electron found" << endmsg;
// return StatusCode::FAILURE;
//}
// 4b. iterator inequality
//if (!(mc_first_electron != mcparts.end())) {
// debug() << "No electron found" << endmsg;
// return StatusCode::FAILURE;
//}

// 5. ranges and views
//auto is_electron = [](const auto& p){ return p.getPDG() == 11; };
//for (const auto& e: mcparts | std::views::filter(is_electron)) {
// break;
//}

// Get incoming electron beam
const auto ei_coll = find_first_beam_electron(mcparts);
if (ei_coll.empty()) {
Expand Down
20 changes: 8 additions & 12 deletions src/algorithms/reco/ScatteredElectronsTruth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <edm4hep/Vector3f.h>
#include <fmt/core.h>
#include <podio/ObjectID.h>
#include <algorithm>
#include <gsl/pointers>
#include <vector>

Expand Down Expand Up @@ -53,24 +54,19 @@ void ScatteredElectronsTruth::process(const ScatteredElectronsTruth::Input& inpu
return;
}

// Associate first scattered electron
// with reconstructed electron
auto ef_assoc = rcassoc->begin();
for (; ef_assoc != rcassoc->end(); ++ef_assoc) {
if (ef_assoc->getSim().getObjectID() == ef_coll[0].getObjectID()) {
break;
}
}
// Associate first scattered electron with reconstructed electron
const auto ef_assoc = std::find_if(rcassoc->begin(), rcassoc->end(), [&ef_coll](const auto& a) {
return a.getSim().getObjectID() == ef_coll[0].getObjectID();
});

// Check to see if the associated reconstructed
// particle is available
if (!(ef_assoc != rcassoc->end())) {
// Check to see if the associated reconstructed particle is available
if (ef_assoc == rcassoc->end()) {
trace("Truth scattered electron not in reconstructed particles");
return;
}

// Get the reconstructed electron object
const auto ef_rc{ef_assoc->getRec()};
const auto ef_rc{(*ef_assoc).getRec()};
const auto ef_rc_id{ef_rc.getObjectID()};

// Use these to compute the E-Pz
Expand Down
Loading