Skip to content
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

refactor: FPE masking updates & improvements #2349

Merged
merged 20 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
3 changes: 2 additions & 1 deletion CI/check_fpe_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ async def check(token: str, repo: str):
first = False
exp = m.group(1)
for m in re.findall(
r"fpeMask\((\w+), ?(\d+) ?, ?issue: ?(\d+)\)", exp
r"fpeMask(?:Begin)?\( ?(\w+), ?(\d+) ?, ?#(\d+) ?\)",
exp,
):
fpeType, count, number = m

Expand Down
2 changes: 0 additions & 2 deletions CI/physmon/fpe_masks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
FLTUND: 1
"Core/include/Acts/TrackFitting/detail/GsfUtils.hpp:197":
FLTUND: 1
"Acts/Utilities/GaussianMixtureReduction.hpp:198":
FLTUND: 1
"Core/src/Utilities/AnnealingUtility.cpp:43":
FLTUND: 1
"Core/src/Utilities/AnnealingUtility.cpp:40":
Expand Down
18 changes: 12 additions & 6 deletions CI/physmon/workflows/physmon_track_finding_ttbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,38 @@
Path(__file__).parent.parent / "fpe_masks.yml"
) + [
acts.examples.Sequencer.FpeMask(
"Examples/Algorithms/Fatras/src/FatrasSimulation.cpp:172",
"Examples/Algorithms/Fatras/src/FatrasSimulation.cpp",
(172, 173),
acts.FpeType.FLTINV,
1,
andiwand marked this conversation as resolved.
Show resolved Hide resolved
),
acts.examples.Sequencer.FpeMask(
"Examples/Algorithms/Fatras/src/FatrasSimulation.cpp:172",
"Examples/Algorithms/Fatras/src/FatrasSimulation.cpp",
(172, 173),
acts.FpeType.FLTOVF,
1,
),
acts.examples.Sequencer.FpeMask(
"Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp:371",
"Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp",
(371, 372),
acts.FpeType.FLTINV,
1,
),
acts.examples.Sequencer.FpeMask(
"Core/src/Utilities/AnnealingUtility.cpp:38",
"Core/src/Utilities/AnnealingUtility.cpp",
(38, 39),
acts.FpeType.FLTUND,
1,
),
acts.examples.Sequencer.FpeMask(
"Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp:110",
"Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp",
(110, 111),
acts.FpeType.FLTINV,
1,
),
acts.examples.Sequencer.FpeMask(
"Fatras/include/ActsFatras/Kernel/Simulation.hpp:98",
"Fatras/include/ActsFatras/Kernel/Simulation.hpp",
(98, 99),
acts.FpeType.FLTOVF,
1,
),
Expand Down
4 changes: 3 additions & 1 deletion Core/include/Acts/Utilities/GaussianMixtureReduction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ auto gaussianMixtureCov(const components_t components,
for (const auto &cmp : components) {
const auto &[weight_l, pars_l, cov_l] = projector(cmp);

cov += weight_l * cov_l;
cov += weight_l * cov_l; // MARK: fpeMask(FLTUND, 1, #2347)

ActsVector<D> diff = pars_l - mean;

Expand Down Expand Up @@ -195,8 +195,10 @@ auto gaussianMixtureMeanCov(const components_t components,

std::apply([&](auto... dsc) { (wrap(dsc), ...); }, angleDesc);

// MARK: fpeMaskBegin(FLTUND, 1, #2347)
const auto cov =
gaussianMixtureCov(components, mean, sumOfWeights, projector, angleDesc);
// MARK: fpeMaskEnd(FLTUND)

return RetType{mean, cov};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class SequenceConfigurationException : public std::runtime_error {
class Sequencer {
public:
struct FpeMask {
std::string loc;
std::string file;
std::pair<unsigned int, unsigned int> lines;
paulgessinger marked this conversation as resolved.
Show resolved Hide resolved
Acts::FpeType type;
std::size_t count;
};
Expand Down Expand Up @@ -186,9 +187,7 @@ class Sequencer {
const Acts::Logger &logger() const { return *m_logger; }
};

inline std::ostream &operator<<(std::ostream &os, const Sequencer::FpeMask &m) {
os << "FpeMask(" << m.loc << ", " << m.type << " <= " << m.count << ")";
return os;
}
std::ostream &operator<<(std::ostream &os,
const ActsExamples::Sequencer::FpeMask &m);

} // namespace ActsExamples
28 changes: 25 additions & 3 deletions Examples/Framework/src/Framework/Sequencer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <ratio>
#include <regex>
#include <stdexcept>
#include <string>
#include <string_view>
#include <typeinfo>

Expand Down Expand Up @@ -655,9 +656,17 @@ std::pair<std::string, std::size_t> Sequencer::fpeMaskCount(
const boost::stacktrace::stacktrace& st, Acts::FpeType type) const {
for (const auto& frame : st) {
std::string loc = Acts::FpeMonitor::getSourceLocation(frame);
for (const auto& [filt, fType, count] : m_cfg.fpeMasks) {
if (boost::algorithm::ends_with(loc, filt) && fType == type) {
return {filt, count};
auto it = loc.find_last_of(':');
std::string locFile = loc.substr(0, it);
unsigned int locLine = std::stoi(loc.substr(it + 1));
for (const auto& [file, lines, fType, count] : m_cfg.fpeMasks) {
const auto [start, end] = lines;
if (boost::algorithm::ends_with(locFile, file) &&
(start <= locLine && locLine < end) && fType == type) {
std::string ls = start + 1 == end ? std::to_string(start)
: "(" + std::to_string(start) + ", " +
std::to_string(end) + "]";
return {file + ":" + ls, count};
}
}
andiwand marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -674,4 +683,17 @@ Acts::FpeMonitor::Result Sequencer::fpeResult() const {
return merged;
}

std::ostream& operator<<(std::ostream& os,
const ActsExamples::Sequencer::FpeMask& m) {
os << "FpeMask(" << m.file << ":";

if (m.lines.first + 1 == m.lines.second) {
os << m.lines.first;
} else {
os << "(" << m.lines.first << ", " << m.lines.second << "]";
}
os << ", " << m.type << " <= " << m.count << ")";
return os;
}

} // namespace ActsExamples
3 changes: 1 addition & 2 deletions Examples/Io/Root/src/RootTrajectorySummaryWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectorySummaryWriter::writeT(

if (hasFittedCov) {
for (unsigned int i = 0; i < Acts::eBoundSize; ++i) {
pull[i] =
res[i] / error[i]; // MARK: fpeMask(FLTINV, 1, issue: 2284)
pull[i] = res[i] / error[i]; // MARK: fpeMask(FLTINV, 1, #2284)
}
}
}
Expand Down
Loading
Loading