1#include "DQM/ReSimVerifier.h"
5 simPassName_ = parameters.
getParameter<std::string>(
"sim_pass_name");
6 reSimPassName_ = parameters.
getParameter<std::string>(
"resim_pass_name");
7 stop_on_error = parameters.
getParameter<
bool>(
"stop_on_error");
9 parameters.
getParameter<std::vector<std::string>>(
"collections");
11bool ReSimVerifier::verifySimCalorimeterHits(
12 const std::vector<ldmx::SimCalorimeterHit>& simHits,
13 const std::vector<ldmx::SimCalorimeterHit>& reSimHits) {
14 for (
auto i{0}; i < simHits.size(); ++i) {
16 auto rehit{reSimHits[i]};
18 if (hit.getEdep() != rehit.getEdep()) {
21 if (hit.getID() != rehit.getID()) {
24 if (hit.getTime() != rehit.getTime()) {
27 if (hit.getNumberOfContribs() != rehit.getNumberOfContribs()) {
30 auto pos{hit.getPosition()};
31 auto repos{rehit.getPosition()};
32 if (pos[0] != repos[0] || pos[1] != repos[1] || pos[2] != repos[2]) {
40 const auto& simParticles{
42 const auto& reSimParticles{
44 for (
auto [
id, simParticle] : simParticles) {
45 if (!reSimParticles.count(
id)) {
48 auto reSimParticle{reSimParticles.at(
id)};
49 if (simParticle.getEnergy() != reSimParticle.getEnergy()) {
52 if (simParticle.getPdgID() != reSimParticle.getPdgID()) {
55 if (simParticle.getTime() != reSimParticle.getTime()) {
65 auto eventNumber{
event.getEventNumber()};
66 for (
auto collection : collections) {
70 collection, reSimPassName_);
71 if (ReSimHits.size() == 0) {
78 if (!verifySimCalorimeterHits(SimHits, ReSimHits)) {
80 ss <<
"Event " << eventNumber <<
" has different simhits for "
81 << collection << std::endl;
85 std::cout <<
"Skipping event " << eventNumber
86 <<
"since it was not resimulated" << std::endl;
88 if (!verifySimParticles(event)) {
90 ss <<
"Event " << eventNumber
91 <<
" has different SimParticles between the two passes" << std::endl;
95 EXCEPTION_RAISE(
"ReSimVerify", ss.str());
97 std::cout << ss.str();
#define DECLARE_ANALYZER_NS(NS, CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
void analyze(const framework::Event &event) override
Process the event and make histograms or summaries.
void configure(framework::config::Parameters ¶meters) override
Callback for the EventProcessor to configure itself from the given set of parameters.
Implements an event buffer system for storing event data.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Stores simulated calorimeter hit information.
Class representing a simulated particle.