3#include <nlohmann/json.hpp>
7#include "Framework/Exception/Exception.h"
8#include "Tracking/Reco/SiStripChannelMap.h"
9#include "Tracking/Reco/TrackerPedestals.h"
11namespace tracking::reco {
31 EXCEPTION_RAISE(
"BadConfig",
32 "The name provided to TrackerPedestalProvider '" + name +
33 "' is not the expected '" +
36 pedestal_file_ = parameters.
get<std::string>(
"pedestal_file");
38 parameters.
get<std::string>(
"pedestal_format", pedestal_format_);
41 std::pair<const framework::ConditionsObject*, framework::ConditionsIOV>
47 if (pedestal_format_ ==
"json") {
50 EXCEPTION_RAISE(
"BadConfiguration",
51 "TrackerPedestalProvider unknown pedestal_format '" +
52 pedestal_format_ +
"' (supported: 'json').");
55 std::cout <<
"[TrackerPedestalProvider] Loaded " << peds->size()
56 <<
" channel pedestals from '" << pedestal_file_ <<
"'"
65 std::ifstream in(pedestal_file_);
67 EXCEPTION_RAISE(
"FileNotFound",
68 "TrackerPedestalProvider could not open pedestal file '" +
69 pedestal_file_ +
"'.");
75 }
catch (
const nlohmann::json::parse_error& e) {
78 "TrackerPedestalProvider failed to parse pedestal file '" +
79 pedestal_file_ +
"': " + e.what());
83 for (
const auto& [key, ch] : doc.at(
"channels").items()) {
84 uint8_t feb, hybrid, apv, channel;
87 TrackerPedestals::Channel ped;
88 ped.mean_ = ch.at(
"mean").get<
decltype(ped.mean_)>();
89 ped.noise_ = ch.at(
"noise").get<
decltype(ped.noise_)>();
90 peds.
add(feb, hybrid, apv, channel, ped);
94 std::string pedestal_file_;
95 std::string pedestal_format_{
"json"};
Base class for provider of conditions information like pedestals, gains, electronics maps,...
#define DECLARE_CONDITIONS_PROVIDER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class which defines the run/event/type range for which a given condition is valid,...
Base class for all providers of conditions objects.
const Process & process() const
Get the process handle.
Class which represents the process under execution.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Conditions provider for the per-channel tracker pedestals/noise.
std::pair< const framework::ConditionsObject *, framework::ConditionsIOV > getCondition(const ldmx::EventHeader &) override
Pure virtual getCondition function.
Per-channel tracker pedestal conditions: the per-sample pedestal mean and RMS noise for every silicon...
void add(uint8_t feb, uint8_t hybrid, uint8_t apv, uint8_t channel, const Channel &ped)
Insert the pedestal for one electronics channel.
static const std::string CONDITIONS_NAME
Name of the conditions object (must match the python registration).
bool parseChannelKey(const std::string &key, uint8_t &feb, uint8_t &hybrid, uint8_t &apv, uint8_t &channel)
Parse a "feb:hybrid:apv:channel" key (as produced by channelKey()) back into its electronics fields.