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
 
NtupleManager & ntuple_ {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 37 of file TrigScintRecHitProducer.h.

Constructor & Destructor Documentation

◆ TrigScintRecHitProducer()

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

Definition at line 13 of file TrigScintRecHitProducer.cxx.

15 : 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 17 of file TrigScintRecHitProducer.cxx.

17{}

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 19 of file TrigScintRecHitProducer.cxx.

20 {
21 pedestal_ = parameters.get<double>("pedestal");
22 gain_ = parameters.get<double>("gain");
23 mev_per_mip_ = parameters.get<double>("mev_per_mip");
24 pe_per_mip_ = parameters.get<double>("pe_per_mip");
25 input_collection_ = parameters.get<std::string>("input_collection");
26 input_pass_name_ = parameters.get<std::string>("input_pass_name");
27 output_collection_ = parameters.get<std::string>("output_collection");
28 sample_of_interest_ = parameters.get<int>("sample_of_interest");
29
30 use_calib_file_ = parameters.get<bool>("use_calib_file", false);
31 calib_file_ = parameters.get<std::string>("calib_file", std::string{""});
32
33 // If > 0: integrate [sample_of_interest, sample_of_interest +
34 // integration_window) If <= 0: integrate all samples (default)
35 integration_window_ = parameters.get<int>("integration_window", 0);
36
37 if (use_calib_file_) {
38 if (calib_file_.empty()) {
39 throw std::runtime_error(
40 "TrigScintRecHitProducer: use_calib_file=true but calib_file is "
41 "empty.");
42 }
44 }
45}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
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 47 of file TrigScintRecHitProducer.cxx.

47 {
48 SimQIE qie;
49
50 const auto digis{event.getCollection<trigscint::TrigScintQIEDigis>(
52
53 std::vector<ldmx::TrigScintHit> trig_scint_hits;
54 trig_scint_hits.reserve(digis.size());
55
56 for (const auto& digi : digis) {
58 auto adc{digi.getADC()};
59 auto tdc{digi.getTDC()};
60
61 hit.setModuleID(0);
62 hit.setBarID(digi.getChanID());
63 // sim truth from the digi; -1 for data
64 hit.setBeamEfrac(digi.getBeamEfrac());
65
66 const int soi = sample_of_interest_;
67 if (soi < 0 || soi >= int(adc.size()) || soi >= int(tdc.size())) {
68 continue;
69 }
70 if (soi + 1 < int(adc.size())) {
71 hit.setAmplitude(qie.adc2Q(adc[soi]) + qie.adc2Q(adc[soi + 1]));
72 } else {
73 hit.setAmplitude(qie.adc2Q(adc[soi]));
74 }
75 if (tdc[soi] > 49)
76 hit.setTime(-999.);
77 else
78 hit.setTime(tdc[soi] * 0.5);
79
80 int start = soi;
81 int end = int(adc.size());
82 if (integration_window_ > 0) {
83 end = std::min(start + integration_window_, int(adc.size()));
84 }
85 const int n_samp = std::max(0, end - start);
86
87 float integrated_charge = 0.f;
88 for (int i = start; i < end; ++i) {
89 integrated_charge += qie.adc2Q(adc[i]);
90 }
91
92 double ped = pedestal_;
93 double gain = gain_;
94
95 if (use_calib_file_) {
96 const int ch = digi.getChanID();
97 if (ch >= 0 && ch < int(pedestals_.size())) ped = pedestals_[ch];
98 if (ch >= 0 && ch < int(gains_.size())) gain = gains_[ch];
99 }
100
101 const float ped_subtr_q = integrated_charge - float(n_samp) * float(ped);
102
103 hit.setEnergy(ped_subtr_q * 6250.f / float(gain) * float(mev_per_mip_) /
104 float(pe_per_mip_)); // MeV
105 hit.setPE(ped_subtr_q * 6250.f / float(gain));
106
107 trig_scint_hits.push_back(hit);
108 }
109 event.add(output_collection_, trig_scint_hits);
110}
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 112 of file TrigScintRecHitProducer.cxx.

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

Member Data Documentation

◆ calib_file_

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

Path to the per-channel calibration file.

Definition at line 88 of file TrigScintRecHitProducer.h.

88{""};

◆ gain_

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

SiPM gain.

Definition at line 70 of file TrigScintRecHitProducer.h.

70{1e6};

◆ gains_

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

Per-channel gains read from the calibration file.

Definition at line 95 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 59 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 63 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 92 of file TrigScintRecHitProducer.h.

92{0};

◆ mev_per_mip_

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

Total MeV per MIP.

Definition at line 76 of file TrigScintRecHitProducer.h.

76{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 67 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 79 of file TrigScintRecHitProducer.h.

79{13.5};

◆ pedestal_

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

QIE pedestal.

Definition at line 73 of file TrigScintRecHitProducer.h.

73{6.0};

◆ pedestals_

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

Per-channel pedestals read from the calibration file.

Definition at line 98 of file TrigScintRecHitProducer.h.

◆ sample_of_interest_

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

Total number of photoelectrons per MIP.

Definition at line 82 of file TrigScintRecHitProducer.h.

82{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 85 of file TrigScintRecHitProducer.h.

85{false};

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