LDMX Software
tracking::reco::SiStripWaveformBuilder Class Reference

Assemble per-trigger pedestal-subtracted hits into full per-channel waveforms. More...

#include <SiStripWaveformBuilder.h>

Public Member Functions

 SiStripWaveformBuilder (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &ps) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void produce (framework::Event &event) override
 Process the event and put new data products into it.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::string input_collection_ {"TrackerHits"}
 
std::string input_pass_name_ {""}
 
std::string output_collection_ {"TrackerWaveforms"}
 
double high_threshold_
 per-sample significance for high-threshold cut
 
int min_high_samples_ {4}
 min samples exceeding high_threshold
 
double low_threshold_
 per-sample significance for consecutive-streak cut
 
int min_consecutive_low_
 min consecutive samples exceeding low_threshold
 
int n_triggers_ {10}
 expected APV triggers per RoR
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Assemble per-trigger pedestal-subtracted hits into full per-channel waveforms.

Definition at line 15 of file SiStripWaveformBuilder.h.

Constructor & Destructor Documentation

◆ SiStripWaveformBuilder()

tracking::reco::SiStripWaveformBuilder::SiStripWaveformBuilder ( const std::string & name,
framework::Process & process )
inline

Definition at line 17 of file SiStripWaveformBuilder.h.

Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void tracking::reco::SiStripWaveformBuilder::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has class_name equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 12 of file SiStripWaveformBuilder.cxx.

12 {
13 input_collection_ =
14 ps.get<std::string>("input_collection", input_collection_);
15 input_pass_name_ = ps.get<std::string>("input_pass_name", input_pass_name_);
16 output_collection_ =
17 ps.get<std::string>("output_collection", output_collection_);
18 high_threshold_ = ps.get<double>("high_threshold", high_threshold_);
19 min_high_samples_ = ps.get<int>("min_high_samples", min_high_samples_);
20 low_threshold_ = ps.get<double>("low_threshold", low_threshold_);
22 ps.get<int>("min_consecutive_low", min_consecutive_low_);
23 n_triggers_ = ps.get<int>("n_triggers", n_triggers_);
24}
double high_threshold_
per-sample significance for high-threshold cut
int min_consecutive_low_
min consecutive samples exceeding low_threshold
int n_triggers_
expected APV triggers per RoR
int min_high_samples_
min samples exceeding high_threshold
double low_threshold_
per-sample significance for consecutive-streak cut

References framework::config::Parameters::get(), high_threshold_, low_threshold_, min_consecutive_low_, min_high_samples_, and n_triggers_.

◆ produce()

void tracking::reco::SiStripWaveformBuilder::produce ( framework::Event & event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 26 of file SiStripWaveformBuilder.cxx.

26 {
27 const auto& peds =
29
30 const auto& hits = event.getCollection<ldmx::RawSiStripHit>(input_collection_,
31 input_pass_name_);
32
33 // Key: encodes (feb, hybrid, pchannel) uniquely.
34 // Value: vector of (apv_trigger, samples) pairs.
35 struct TriggerSamples {
36 uint16_t apv_trigger_;
37 std::vector<short> samples_;
38 };
39 struct ChannelInfo {
40 float noise_{0};
41 uint8_t hybrid_id_{0};
42 uint8_t feb_id_{0};
43 std::vector<TriggerSamples> triggers_;
44 };
45
46 // Use a map keyed by (feb, hybrid, pchannel) for grouping.
47 std::map<uint32_t, ChannelInfo> channel_map;
48
49 for (const auto& hit : hits) {
50 const float noise = peds.noise(hit.getFebId(), hit.getHybridId(),
51 hit.getApvId(), hit.getChannel());
52 if (noise <= 0) continue;
53
54 const int16_t pchannel =
55 channelmap::pchannel(hit.getApvId(), hit.getChannel());
56 uint32_t key =
57 channelmap::groupKey(hit.getFebId(), hit.getHybridId(), pchannel);
58
59 auto& ch = channel_map[key];
60 ch.noise_ = noise;
61 ch.hybrid_id_ = hit.getHybridId();
62 ch.feb_id_ = hit.getFebId();
63 ch.triggers_.push_back({hit.getApvTrigger(), hit.getSamples()});
64 }
65
66 std::vector<ldmx::SiStripWaveform> waveforms;
67
68 for (auto& [key, ch] : channel_map) {
69 // Sort triggers by apv_trigger index.
70 std::sort(ch.triggers_.begin(), ch.triggers_.end(),
71 [](const TriggerSamples& a, const TriggerSamples& b) {
72 return a.apv_trigger_ < b.apv_trigger_;
73 });
74
75 // Assemble full waveform: [s0_t0, s1_t0, s2_t0, s0_t1, ...].
76 std::vector<short> samples;
77 samples.reserve(ch.triggers_.size() *
79 for (const auto& trig : ch.triggers_) {
80 for (short s : trig.samples_) samples.push_back(s);
81 }
82
83 if (samples.empty()) continue;
84
85 // Condition 1: at least min_high_samples_ samples exceed high_threshold_.
86 int n_high = 0;
87 for (short s : samples)
88 if (static_cast<float>(s) / ch.noise_ > high_threshold_) ++n_high;
89 if (n_high < min_high_samples_) continue;
90
91 // Condition 2: at least min_consecutive_low_ consecutive samples exceed
92 // low_threshold_.
93 int max_streak = 0, cur_streak = 0;
94 for (short s : samples) {
95 if (static_cast<float>(s) / ch.noise_ > low_threshold_) {
96 max_streak = std::max(max_streak, ++cur_streak);
97 } else {
98 cur_streak = 0;
99 }
100 }
101 if (max_streak < min_consecutive_low_) continue;
102
104 uint8_t n_trig = static_cast<uint8_t>(
105 std::min(static_cast<int>(ch.triggers_.size()), 255));
106
107 waveforms.emplace_back(std::move(samples), pchannel, ch.hybrid_id_,
108 ch.feb_id_, n_trig);
109 }
110
111 ldmx_log(debug) << "Built " << waveforms.size()
112 << " waveforms (>=" << min_high_samples_ << " samples @"
113 << high_threshold_ << "s, streak>=" << min_consecutive_low_
114 << " @" << low_threshold_ << "s) from " << hits.size()
115 << " hits";
116
117 for (const auto& wf : waveforms) {
118 ldmx_log(trace) << wf;
119 }
120
121 event.add(output_collection_, waveforms);
122}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
Implementation of a raw digitized hit from a silicon strip detector.
static const std::string CONDITIONS_NAME
Name of the conditions object (must match the python registration).
constexpr int K_SAMPLES_PER_APV_TRIGGER
Number of ADC samples the APV25 reads out per channel per trigger.
constexpr int16_t pchannelFromGroupKey(uint32_t key)
Extract the pchannel back out of a key produced by groupKey().
constexpr uint32_t groupKey(uint8_t feb, uint8_t hybrid, int16_t pchannel)
Pack (feb, hybrid, pchannel) into a single 32-bit waveform-grouping key.
constexpr int16_t pchannel(uint8_t apv_id, uint8_t channel)
Convert an (APV id, APV channel) pair into the physical strip number (pchannel) within a hybrid,...

References tracking::reco::TrackerPedestals::CONDITIONS_NAME, framework::EventProcessor::getCondition(), tracking::reco::channelmap::groupKey(), high_threshold_, tracking::reco::channelmap::K_SAMPLES_PER_APV_TRIGGER, low_threshold_, min_consecutive_low_, min_high_samples_, tracking::reco::channelmap::pchannel(), and tracking::reco::channelmap::pchannelFromGroupKey().

Member Data Documentation

◆ high_threshold_

double tracking::reco::SiStripWaveformBuilder::high_threshold_
private
Initial value:
{
5.0}

per-sample significance for high-threshold cut

Definition at line 27 of file SiStripWaveformBuilder.h.

27 {
28 5.0};

Referenced by configure(), and produce().

◆ input_collection_

std::string tracking::reco::SiStripWaveformBuilder::input_collection_ {"TrackerHits"}
private

Definition at line 24 of file SiStripWaveformBuilder.h.

24{"TrackerHits"};

◆ input_pass_name_

std::string tracking::reco::SiStripWaveformBuilder::input_pass_name_ {""}
private

Definition at line 25 of file SiStripWaveformBuilder.h.

25{""};

◆ low_threshold_

double tracking::reco::SiStripWaveformBuilder::low_threshold_
private
Initial value:
{
3.0}

per-sample significance for consecutive-streak cut

Definition at line 30 of file SiStripWaveformBuilder.h.

30 {
31 3.0};

Referenced by configure(), and produce().

◆ min_consecutive_low_

int tracking::reco::SiStripWaveformBuilder::min_consecutive_low_
private
Initial value:
{
5}

min consecutive samples exceeding low_threshold

Definition at line 32 of file SiStripWaveformBuilder.h.

32 {
33 5};

Referenced by configure(), and produce().

◆ min_high_samples_

int tracking::reco::SiStripWaveformBuilder::min_high_samples_ {4}
private

min samples exceeding high_threshold

Definition at line 29 of file SiStripWaveformBuilder.h.

29{4};

Referenced by configure(), and produce().

◆ n_triggers_

int tracking::reco::SiStripWaveformBuilder::n_triggers_ {10}
private

expected APV triggers per RoR

Definition at line 34 of file SiStripWaveformBuilder.h.

34{10};

Referenced by configure().

◆ output_collection_

std::string tracking::reco::SiStripWaveformBuilder::output_collection_ {"TrackerWaveforms"}
private

Definition at line 26 of file SiStripWaveformBuilder.h.

26{"TrackerWaveforms"};

The documentation for this class was generated from the following files: