LDMX Software
PedestalCalculator.h
1#ifndef TRACKING_RECO_PEDESTALCALCULATOR_H_
2#define TRACKING_RECO_PEDESTALCALCULATOR_H_
3
4#include <array>
5#include <string>
6#include <unordered_map>
7
9#include "Tracking/Reco/SiStripChannelMap.h"
10
11namespace tracking::reco {
12
22 public:
23 PedestalCalculator(const std::string& name, framework::Process& process)
25
27 void analyze(const framework::Event& event) override;
28 void onProcessEnd() override;
29
30 private:
32 void writePedestalsJson();
33
34 // Welford's online algorithm for numerically stable mean+variance.
35 struct Accumulator {
37 std::array<double, channelmap::K_SAMPLES_PER_APV_TRIGGER> mean_{};
39 std::array<double, channelmap::K_SAMPLES_PER_APV_TRIGGER> m2_{};
40 long n_{0}; // hit count for this channel
41 };
42
43 std::string input_collection_{"TrackerRawData"};
44 std::string input_pass_name_{""};
45 std::string output_file_{"pedestals.json"};
47 std::string output_format_{"json"};
48
49 std::unordered_map<std::string, Accumulator> accumulators_;
50 long n_events_{0};
51};
52
53} // namespace tracking::reco
54
55#endif // TRACKING_RECO_PEDESTALCALCULATOR_H_
Base classes for all user event processing components to extend.
Base class for a module which does not produce a data product.
virtual void process(Event &event) final
Processing an event for an Analyzer is calling analyze.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:37
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Compute per-channel, per-sample pedestal mean and noise from a baseline run.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
std::string output_format_
Storage backend for the pedestals ("json"; future: "sqlite", ...).
void writePedestalsJson()
Write the accumulated pedestals to a JSON file (output_file_).
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
void analyze(const framework::Event &event) override
Process the event and make histograms or summaries.
std::array< double, channelmap::K_SAMPLES_PER_APV_TRIGGER > mean_
running mean
std::array< double, channelmap::K_SAMPLES_PER_APV_TRIGGER > m2_
running sum of squared deviations from mean