LDMX Software
tracking::reco::PedestalSubtractor Class Reference

Subtract per-channel, per-sample pedestals from a RawSiStripHit collection. More...

#include <PedestalSubtractor.h>

Public Member Functions

 PedestalSubtractor (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_ {"RawSiStripHits"}
 
std::string input_pass_name_ {""}
 
std::string output_collection_ {"TrackerHits"}
 
std::set< std::string > warned_channels_
 

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

Subtract per-channel, per-sample pedestals from a RawSiStripHit collection.

The pedestal means are obtained from the TrackerPedestals conditions object (a service, provided by TrackerPedestalProvider) rather than read from a file here. On every event the per-sample mean is subtracted from each RawSiStripHit and a new (pedestal-subtracted) RawSiStripHit collection is written out; the raw and subtracted collections are distinguished only by name. No noise or other calibration constant is stored on the hits — downstream consumers query the same conditions object when they need it.

Definition at line 22 of file PedestalSubtractor.h.

Constructor & Destructor Documentation

◆ PedestalSubtractor()

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

Definition at line 24 of file PedestalSubtractor.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::PedestalSubtractor::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 PedestalSubtractor.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}

References framework::config::Parameters::get().

◆ produce()

void tracking::reco::PedestalSubtractor::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 20 of file PedestalSubtractor.cxx.

20 {
21 const auto& peds =
23
24 const auto& raw = event.getCollection<ldmx::RawSiStripHit>(input_collection_,
25 input_pass_name_);
26
27 std::vector<ldmx::RawSiStripHit> hits;
28 hits.reserve(raw.size());
29
30 for (const auto& raw_hit : raw) {
31 const auto* ped = peds.find(raw_hit.getFebId(), raw_hit.getHybridId(),
32 raw_hit.getApvId(), raw_hit.getChannel());
33
34 const auto& s = raw_hit.getSamples();
35 std::vector<short> sub(s.begin(), s.end());
36
37 if (!ped) {
38 // Warn once per unknown channel, pass hit through un-subtracted.
39 const auto key =
40 channelmap::channelKey(raw_hit.getFebId(), raw_hit.getHybridId(),
41 raw_hit.getApvId(), raw_hit.getChannel());
42 if (warned_channels_.insert(key).second) {
43 std::cout << "[PedestalSubtractor] WARN: no pedestal for channel "
44 << key << " — passing through un-subtracted" << std::endl;
45 }
46 } else {
47 for (int i = 0; i < channelmap::K_SAMPLES_PER_APV_TRIGGER &&
48 i < static_cast<int>(sub.size());
49 ++i)
50 sub[i] = static_cast<short>(s[i] - ped->mean_[i]);
51 }
52
53 // Emit a pedestal-subtracted RawSiStripHit that keeps the same electronics
54 // identity as the input; only the ADC samples differ.
55 ldmx::RawSiStripHit out(raw_hit.getChannel(), sub, raw_hit.getTime());
56 out.setApvId(raw_hit.getApvId());
57 out.setHybridId(raw_hit.getHybridId());
58 out.setFebId(raw_hit.getFebId());
59 out.setApvTrigger(raw_hit.getApvTrigger());
60 hits.push_back(std::move(out));
61 }
62
63 event.add(output_collection_, hits);
64}
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).
std::string channelKey(uint8_t feb, uint8_t hybrid, uint8_t apv, uint8_t channel)
Build the per-channel pedestal-map key "feb:hybrid:apv:channel".
constexpr int K_SAMPLES_PER_APV_TRIGGER
Number of ADC samples the APV25 reads out per channel per trigger.

References tracking::reco::channelmap::channelKey(), tracking::reco::TrackerPedestals::CONDITIONS_NAME, framework::EventProcessor::getCondition(), and tracking::reco::channelmap::K_SAMPLES_PER_APV_TRIGGER.

Member Data Documentation

◆ input_collection_

std::string tracking::reco::PedestalSubtractor::input_collection_ {"RawSiStripHits"}
private

Definition at line 31 of file PedestalSubtractor.h.

31{"RawSiStripHits"};

◆ input_pass_name_

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

Definition at line 32 of file PedestalSubtractor.h.

32{""};

◆ output_collection_

std::string tracking::reco::PedestalSubtractor::output_collection_ {"TrackerHits"}
private

Definition at line 33 of file PedestalSubtractor.h.

33{"TrackerHits"};

◆ warned_channels_

std::set<std::string> tracking::reco::PedestalSubtractor::warned_channels_
private

Definition at line 35 of file PedestalSubtractor.h.


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