LDMX Software
trigscint::TrigScintRecHitProducer Class Reference

Organizes digis into TrigScintHits, linearizes TDC and ADC info, and converts amplitudes to PEs. More...

#include <TrigScintRecHitProducer.h>

Public Member Functions

 TrigScintRecHitProducer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the processor 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 Member Functions

void readCalib (const std::string &filename, std::vector< double > *gains, std::vector< double > *pedestals)
 Read per-channel gains and pedestals from a calibration file.
 

Private Attributes

std::string input_collection_
 Name of the input collection containing the sim hits.
 
std::string input_pass_name_
 Name of the pass that the input collection is on (empty string means take any pass)
 
std::string output_collection_
 Name of the output collection that will be used to stored the digitized trigger scintillator hits.
 
double gain_ {1e6}
 SiPM gain.
 
double pedestal_ {6.0}
 QIE pedestal.
 
double mev_per_mip_ {1.40}
 Total MeV per MIP.
 
double pe_per_mip_ {13.5}
 Total number of photoelectrons per MIP.
 
int sample_of_interest_ {2}
 Total number of photoelectrons per MIP.
 
bool use_calib_file_ {false}
 If true, read per-channel gains/pedestals from calib_file_.
 
std::string calib_file_ {""}
 Path to the per-channel calibration file.
 
int integration_window_ {0}
 If > 0: integrate a fixed window starting at sample_of_interest_ If <= 0: integrate all samples.
 
std::vector< double > gains_
 Per-channel gains read from the calibration file.
 
std::vector< double > pedestals_
 Per-channel pedestals read from the calibration file.
 

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

Organizes digis into TrigScintHits, linearizes TDC and ADC info, and converts amplitudes to PEs.

Definition at line 44 of file TrigScintRecHitProducer.h.

Constructor & Destructor Documentation

◆ TrigScintRecHitProducer()

trigscint::TrigScintRecHitProducer::TrigScintRecHitProducer ( const std::string & name,
framework::Process & process )

Definition at line 12 of file TrigScintRecHitProducer.cxx.

14 : Producer(name, process) {}
Producer(const std::string &name, Process &process)
Class constructor.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

◆ ~TrigScintRecHitProducer()

trigscint::TrigScintRecHitProducer::~TrigScintRecHitProducer ( )

Definition at line 16 of file TrigScintRecHitProducer.cxx.

16{}

Member Function Documentation

◆ configure()

void trigscint::TrigScintRecHitProducer::configure ( framework::config::Parameters & parameters)
overridevirtual

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

Parameters
parametersParameterSet for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 18 of file TrigScintRecHitProducer.cxx.

18 {
19 pedestal_ = parameters.get<double>("pedestal");
20 gain_ = parameters.get<double>("gain");
21 mev_per_mip_ = parameters.get<double>("mev_per_mip");
22 pe_per_mip_ = parameters.get<double>("pe_per_mip");
23 input_collection_ = parameters.get<std::string>("input_collection");
24 input_pass_name_ = parameters.get<std::string>("input_pass_name");
25 output_collection_ = parameters.get<std::string>("output_collection");
26 sample_of_interest_ = parameters.get<int>("sample_of_interest");
27
28 use_calib_file_ = parameters.get<bool>("use_calib_file", false);
29 calib_file_ = parameters.get<std::string>("calib_file", std::string{""});
30
31 // If > 0: integrate [sample_of_interest, sample_of_interest + integration_window)
32 // If <= 0: integrate all samples (default)
33 integration_window_ = parameters.get<int>("integration_window", 0);
34
35 if (use_calib_file_) {
36 if (calib_file_.empty()) {
37 throw std::runtime_error(
38 "TrigScintRecHitProducer: use_calib_file=true but calib_file is empty.");
39 }
41 }
42}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
std::string calib_file_
Path to the per-channel calibration file.
double pe_per_mip_
Total number of photoelectrons per MIP.
std::string output_collection_
Name of the output collection that will be used to stored the digitized trigger scintillator hits.
int integration_window_
If > 0: integrate a fixed window starting at sample_of_interest_ If <= 0: integrate all samples.
void readCalib(const std::string &filename, std::vector< double > *gains, std::vector< double > *pedestals)
Read per-channel gains and pedestals from a calibration file.
std::vector< double > pedestals_
Per-channel pedestals read from the calibration file.
std::string input_pass_name_
Name of the pass that the input collection is on (empty string means take any pass)
std::string input_collection_
Name of the input collection containing the sim hits.
int sample_of_interest_
Total number of photoelectrons per MIP.
bool use_calib_file_
If true, read per-channel gains/pedestals from calib_file_.
std::vector< double > gains_
Per-channel gains read from the calibration file.

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

◆ produce()

void trigscint::TrigScintRecHitProducer::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 44 of file TrigScintRecHitProducer.cxx.

44 {
45 SimQIE qie;
46
47 const auto digis{event.getCollection<trigscint::TrigScintQIEDigis>(
49
50 std::vector<ldmx::TrigScintHit> trig_scint_hits;
51 trig_scint_hits.reserve(digis.size());
52
53 for (const auto &digi : digis) {
55 auto adc{digi.getADC()};
56 auto tdc{digi.getTDC()};
57
58 hit.setModuleID(0);
59 hit.setBarID(digi.getChanID());
60 // sim truth from the digi; -1 for data
61 hit.setBeamEfrac(digi.getBeamEfrac());
62
63 const int soi = sample_of_interest_;
64 if (soi < 0 || soi >= int(adc.size()) || soi >= int(tdc.size())) {
65 continue;
66 }
67 if (soi + 1 < int(adc.size())) {
68 hit.setAmplitude(qie.adc2Q(adc[soi]) + qie.adc2Q(adc[soi + 1]));
69 } else {
70 hit.setAmplitude(qie.adc2Q(adc[soi]));
71 }
72 if (tdc[soi] > 49)
73 hit.setTime(-999.);
74 else
75 hit.setTime(tdc[soi] * 0.5);
76
77 int start = soi;
78 int end = int(adc.size());
79 if (integration_window_ > 0) {
80 end = std::min(start + integration_window_, int(adc.size()));
81 }
82 const int n_samp = std::max(0, end - start);
83
84 float integrated_charge = 0.f;
85 for (int i = start; i < end; ++i) {
86 integrated_charge += qie.adc2Q(adc[i]);
87 }
88
89 double ped = pedestal_;
90 double gain = gain_;
91
92 if (use_calib_file_) {
93 const int ch = digi.getChanID();
94 if (ch >= 0 && ch < int(pedestals_.size())) ped = pedestals_[ch];
95 if (ch >= 0 && ch < int(gains_.size())) gain = gains_[ch];
96 }
97
98 const float ped_subtr_q = integrated_charge - float(n_samp) * float(ped);
99
100 hit.setEnergy(ped_subtr_q * 6250.f / float(gain) * float(mev_per_mip_) /
101 float(pe_per_mip_)); // MeV
102 hit.setPE(ped_subtr_q * 6250.f / float(gain));
103
104 trig_scint_hits.push_back(hit);
105 }
106 event.add(output_collection_, trig_scint_hits);
107}
void setTime(float time)
Set the time of the hit [ns].
void setAmplitude(float amplitude)
Set the amplitude of the hit, which is proportional to the signal in the calorimeter cell without sam...
void setEnergy(float energy)
Set the calorimetric energy of the hit, corrected for sampling factors [MeV].
void setPE(const float PE)
Set hit pe.
void setBarID(const int barID)
Set hit bar ID.
void setBeamEfrac(const float beamEfrac)
Set beam energy fraction of hit.
void setModuleID(const int moduleID)
Set hit module ID.
class for storing QIE output

References trigscint::SimQIE::adc2Q(), ldmx::CalorimeterHit::setAmplitude(), ldmx::TrigScintHit::setBarID(), ldmx::TrigScintHit::setBeamEfrac(), ldmx::CalorimeterHit::setEnergy(), ldmx::TrigScintHit::setModuleID(), ldmx::TrigScintHit::setPE(), and ldmx::CalorimeterHit::setTime().

◆ readCalib()

void trigscint::TrigScintRecHitProducer::readCalib ( const std::string & filename,
std::vector< double > * gains,
std::vector< double > * pedestals )
private

Read per-channel gains and pedestals from a calibration file.

Definition at line 109 of file TrigScintRecHitProducer.cxx.

111 {
112 std::ifstream infile(filename);
113 if (!infile) {
114 throw std::runtime_error(
115 "TrigScintRecHitProducer: Could not open calibration file: " + filename);
116 }
117
118 double ch = 0.;
119 double gain = 0.;
120 double ped = 0.;
121
122 while (infile >> ch >> gain >> ped) {
123 const int bar_id = int(ch);
124 if (bar_id < 0) continue;
125 if (bar_id >= int(gains->size())) {
126 gains->resize(bar_id + 1, 0.0);
127 pedestals->resize(bar_id + 1, 0.0);
128 }
129 (*gains)[bar_id] = gain;
130 (*pedestals)[bar_id] = ped;
131 }
132}

Member Data Documentation

◆ calib_file_

std::string trigscint::TrigScintRecHitProducer::calib_file_ {""}
private

Path to the per-channel calibration file.

Definition at line 96 of file TrigScintRecHitProducer.h.

96{""};

◆ gain_

double trigscint::TrigScintRecHitProducer::gain_ {1e6}
private

SiPM gain.

Definition at line 78 of file TrigScintRecHitProducer.h.

78{1e6};

◆ gains_

std::vector<double> trigscint::TrigScintRecHitProducer::gains_
private

Per-channel gains read from the calibration file.

Definition at line 103 of file TrigScintRecHitProducer.h.

◆ input_collection_

std::string trigscint::TrigScintRecHitProducer::input_collection_
private

Name of the input collection containing the sim hits.

Definition at line 67 of file TrigScintRecHitProducer.h.

◆ input_pass_name_

std::string trigscint::TrigScintRecHitProducer::input_pass_name_
private

Name of the pass that the input collection is on (empty string means take any pass)

Definition at line 71 of file TrigScintRecHitProducer.h.

◆ integration_window_

int trigscint::TrigScintRecHitProducer::integration_window_ {0}
private

If > 0: integrate a fixed window starting at sample_of_interest_ If <= 0: integrate all samples.

Definition at line 100 of file TrigScintRecHitProducer.h.

100{0};

◆ mev_per_mip_

double trigscint::TrigScintRecHitProducer::mev_per_mip_ {1.40}
private

Total MeV per MIP.

Definition at line 84 of file TrigScintRecHitProducer.h.

84{1.40};

◆ output_collection_

std::string trigscint::TrigScintRecHitProducer::output_collection_
private

Name of the output collection that will be used to stored the digitized trigger scintillator hits.

Definition at line 75 of file TrigScintRecHitProducer.h.

◆ pe_per_mip_

double trigscint::TrigScintRecHitProducer::pe_per_mip_ {13.5}
private

Total number of photoelectrons per MIP.

Definition at line 87 of file TrigScintRecHitProducer.h.

87{13.5};

◆ pedestal_

double trigscint::TrigScintRecHitProducer::pedestal_ {6.0}
private

QIE pedestal.

Definition at line 81 of file TrigScintRecHitProducer.h.

81{6.0};

◆ pedestals_

std::vector<double> trigscint::TrigScintRecHitProducer::pedestals_
private

Per-channel pedestals read from the calibration file.

Definition at line 106 of file TrigScintRecHitProducer.h.

◆ sample_of_interest_

int trigscint::TrigScintRecHitProducer::sample_of_interest_ {2}
private

Total number of photoelectrons per MIP.

Definition at line 90 of file TrigScintRecHitProducer.h.

90{2};

◆ use_calib_file_

bool trigscint::TrigScintRecHitProducer::use_calib_file_ {false}
private

If true, read per-channel gains/pedestals from calib_file_.

Definition at line 93 of file TrigScintRecHitProducer.h.

93{false};

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