1#include <catch2/catch_approx.hpp>
2#include <catch2/catch_test_macros.hpp>
3#include <catch2/matchers/catch_matchers.hpp>
8#include "Framework/ConfigurePython.h"
24static const double PE_ENERGY = 4.66 / 68;
45static const double MAX_PE_ERROR_DAQ = 40;
47static const double MAX_PE_PERCENT_ERROR_DAQ = 0.4;
59static const int NUM_TEST_SIM_HITS = 1000;
84 double const &rel_diff)
96 bool match(
const double &daq)
const override {
105 std::ostringstream ss;
150 header.setDetectorName(
"ldmx-det-v12");
155 std::vector<ldmx::SimCalorimeterHit> pretendSimHits(1);
161 pretendSimHits[0].setPosition(-6.70265, 3.70265, 879);
162 pretendSimHits[0].setID(
id.raw());
163 pretendSimHits[0].addContrib(
173 REQUIRE_NOTHROW(event.add(
"HcalFakeSimHits", pretendSimHits));
195 const bool save_ =
false;
227 REQUIRE(simHits.size() == 1);
229 float truth_energy = simHits.at(0).getEdep();
233 ntuple_.
setVar<
float>(
"SimX", simHits.at(0).getPosition()[0]);
234 ntuple_.
setVar<
float>(
"SimY", simHits.at(0).getPosition()[1]);
235 ntuple_.
setVar<
float>(
"SimZ", simHits.at(0).getPosition()[2]);
236 ntuple_.
setVar<
float>(
"SimTime", simHits.at(0).getContrib(0).time);
241 auto daqDigi = daqDigis.
getDigi(0);
242 bool is_in_adc_mode = daqDigi.
isADC();
251 const auto recHits =
event.getCollection<
ldmx::HcalHit>(
"HcalRecHits");
252 CHECK(recHits.size() == 1);
254 auto hit = recHits.at(0);
256 CHECK_FALSE(hit.isNoise());
257 CHECK(
id.raw() == simHits.at(0).getID());
269 double daq_pe{hit.getPE()};
270 CHECK_THAT(daq_pe,
isCloseEnough(truth_energy / PE_ENERGY, MAX_PE_ERROR_DAQ,
271 MAX_PE_PERCENT_ERROR_DAQ));
321TEST_CASE(
"Hcal Digi Pipeline test",
"[Hcal][functionality]") {
322 const std::string config_file{
"hcal_digi_pipeline_test_config.py"};
324 char **args{
nullptr};
328 REQUIRE_NOTHROW(p = cfg.makeProcess());
Base classes for all user event processing components to extend.
#define DECLARE_ANALYZER_NS(NS, CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that stores Stores reconstructed hit information from the HCAL.
Class that defines an HCal sensitive detector.
Class that represents a digitized hit in a calorimeter cell readout by an HGCROC.
Class which represents the process under execution.
Class which stores simulated calorimeter hit information.
Base class for a module which does not produce a data product.
NtupleManager & ntuple_
Manager for any ntuples.
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
Implements an event buffer system for storing event data.
void addVar(const std::string &tname, const std::string &vname)
Add a variable of type VarType to the ROOT tree with name 'tname'.
void create(const std::string &tname)
Create a ROOT tree to hold the ntuple variables (ROOT leaves).
void setVar(const std::string &vname, const T &value)
Set the value of the variable named 'vname'.
Class which represents the process under execution.
Base class for a module which produces a data product.
Producer(const std::string &name, Process &process)
Class constructor.
void analyze(const framework::Event &event) final override
Process the event and make histograms or summaries.
void onProcessStart() final override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
const double maxEnergy_
Maximum energy to make a simulated hit for [MeV].
void beforeNewRun(ldmx::RunHeader &header) final override
Handle allowing producers to modify run headers before the run begins.
void produce(framework::Event &event) final override
Process the event and put new data products into it.
double currEnergy_
current energy of the sim hit we are on
const double minEnergy_
Minimum energy to make a sim hit for [MeV] Needs to be above readout threshold (after internal HcalDi...
const double energyStep_
The step between energies is calculated depending on the min, max energy and the total number of sim ...
Our custom checker which makes sure that the input energy/position is "close enough" to the truth ene...
const double max_absolute_diff_
maximum absolute difference
bool match(const double &daq) const override
Performs the test for this matcher.
isCloseEnough(double const &truth, double const &abs_diff, double const &rel_diff)
Constructor.
double truth_
correct (sim-level)
virtual std::string describe() const override
Describes matcher for printing to terminal.
const double max_relative_diff_
maximum relative difference
Stores reconstructed hit information from the HCAL.
Implements detector ids for HCal subdetector.
bool isADC() const
Check if this DIGI is an ADC measurement.
Represents a collection of the digi hits readout by an HGCROC.
const HgcrocDigi getDigi(unsigned int digiIndex) const
Get samples for the input digi index.
Stores simulated calorimeter hit information.
All classes in the ldmx-sw project use this namespace.
std::unique_ptr< Process > ProcessHandle
A handle to the current process Used to pass a process from ConfigurePython to fire....