LDMX Software
trigscint::TrigScintQIEDigiProducer Class Reference

Class that simulates QIE chip of the trigger scintillator. More...

#include <TrigScintQIEDigiProducer.h>

Public Member Functions

 TrigScintQIEDigiProducer (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
 Method to produce a collection of QIE digis.
 
- 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::unique_ptr< TRandom3 > random_ {nullptr}
 Random number generator.
 
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.
 
std::string sim_particles_coll_name_
 Name of the sim particle collection.
 
std::string sim_particles_passname_
 Pass name for the sim particle collection.
 
int strips_per_array_ {50}
 Number of strips per array.
 
double mean_noise_ {0}
 Mean readout noise.
 
double mev_per_mip_ {1.40}
 Total MeV per MIP.
 
double pe_per_mip_ {13.5}
 Total number of photoelectrons per MIP.
 
std::string input_pulse_shape_
 QIE Input pulse shape.
 
std::vector< float > pulse_params_
 QIE Input pulse parameters.
 
float toff_overall_
 Overall input pulse time offset.
 
int maxts_
 no. of time samples analysed by QIE
 
float tdc_thr_
 QIE TDC Current threshold.
 
float pedestal_
 QIE pedestal.
 
float elec_noise_
 QIE electronic noise.
 
float sipm_gain_
 SiPM Gain.
 
float s_freq_
 QIE sampling frequency [in MHz].
 
float zero_supp_cut_ {1.}
 Zero-suppression: discard any integrated pulses with PE < this number.
 
SimQIE * smq_ {nullptr}
 SimQIE pointer.
 

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

Class that simulates QIE chip of the trigger scintillator.

Definition at line 42 of file TrigScintQIEDigiProducer.h.

Constructor & Destructor Documentation

◆ TrigScintQIEDigiProducer()

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

Definition at line 14 of file TrigScintQIEDigiProducer.cxx.

16 : 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.

Member Function Documentation

◆ configure()

void trigscint::TrigScintQIEDigiProducer::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 TrigScintQIEDigiProducer.cxx.

19 {
20 // Configure this instance of the producer
21 strips_per_array_ = parameters.get<int>("number_of_strips");
22 // number_of_arrays_ = parameters.get<int>("number_of_arrays");
23 mean_noise_ = parameters.get<double>("mean_noise");
24 mev_per_mip_ = parameters.get<double>("mev_per_mip");
25 pe_per_mip_ = parameters.get<double>("pe_per_mip");
26 input_collection_ = parameters.get<std::string>("input_collection");
27 input_pass_name_ = parameters.get<std::string>("input_pass_name");
28 output_collection_ = parameters.get<std::string>("output_collection");
30 parameters.get<std::string>("sim_particles_coll_name");
32 parameters.get<std::string>("sim_particles_passname");
33
34 // QIE specific parameters initialization
35 maxts_ = parameters.get<int>("maxts");
36 toff_overall_ = parameters.get<double>("toff_overall");
37 input_pulse_shape_ = parameters.get<std::string>("input_pulse_shape");
38 tdc_thr_ = parameters.get<double>("tdc_thr");
39 pedestal_ = parameters.get<double>("pedestal");
40 elec_noise_ = parameters.get<double>("elec_noise");
41 sipm_gain_ = parameters.get<double>("sipm_gain");
42 s_freq_ = parameters.get<double>("qie_sf");
43 zero_supp_cut_ = parameters.get<double>("zero_supp_in_pe");
44
45 if (input_pulse_shape_ == "Expo") {
46 pulse_params_.clear();
47 pulse_params_.push_back(parameters.get<double>("expo_k"));
48 pulse_params_.push_back(parameters.get<double>("expo_tmax"));
49
50 ldmx_log(debug) << "expo_k =" << pulse_params_[0];
51 ldmx_log(debug) << "expo_tmax =" << pulse_params_[1];
52 }
53
54 // Debug mode: print parameter values.
55 ldmx_log(debug) << "maxts_ =" << maxts_;
56 ldmx_log(debug) << "toff_overall_ =" << toff_overall_;
57 ldmx_log(debug) << "input_pulse_shape_ =" << input_pulse_shape_;
58 ldmx_log(debug) << "tdc_thr =" << tdc_thr_;
59 ldmx_log(debug) << "pedestal =" << pedestal_;
60 ldmx_log(debug) << "elec_noise =" << elec_noise_;
61 ldmx_log(debug) << "sipm_gain =" << sipm_gain_;
62 ldmx_log(debug) << "qie_sf =" << s_freq_;
63 ldmx_log(debug) << "zero_supp_in_pe =" << zero_supp_cut_;
64 ldmx_log(debug) << "pe_per_mip =" << pe_per_mip_;
65 ldmx_log(debug) << "mev_per_mip =" << mev_per_mip_;
66}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
std::string input_collection_
Name of the input collection containing the sim hits.
float zero_supp_cut_
Zero-suppression: discard any integrated pulses with PE < this number.
std::vector< float > pulse_params_
QIE Input pulse parameters.
float toff_overall_
Overall input pulse time offset.
std::string sim_particles_passname_
Pass name for the sim particle collection.
std::string input_pass_name_
Name of the pass that the input collection is on (empty string means take any pass)
float tdc_thr_
QIE TDC Current threshold.
float s_freq_
QIE sampling frequency [in MHz].
double pe_per_mip_
Total number of photoelectrons per MIP.
int strips_per_array_
Number of strips per array.
int maxts_
no. of time samples analysed by QIE
std::string sim_particles_coll_name_
Name of the sim particle collection.
std::string output_collection_
Name of the output collection that will be used to stored the digitized trigger scintillator hits.
std::string input_pulse_shape_
QIE Input pulse shape.

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

◆ produce()

void trigscint::TrigScintQIEDigiProducer::produce ( framework::Event & event)
overridevirtual

Method to produce a collection of QIE digis.

For each event, the SimHit information is converted to an output format analogous to real QIE output.

Implements framework::Producer.

Definition at line 68 of file TrigScintQIEDigiProducer.cxx.

68 {
69 // no sim hits, e.g. real data
71 ldmx_log(warn) << "No input collection " << input_collection_ << "_"
72 << input_pass_name_ << " found; skipping";
73 return;
74 }
75
76 // Need to handle seeding on the first event
77 if (random_.get() == nullptr) {
82
83 random_ = std::make_unique<TRandom3>(rseed.getSeed(output_collection_));
84
85 // Initialize SimQIE instance with
86 // pedestal, electronic noise and the random seed
87 smq_ = new SimQIE(pedestal_, elec_noise_,
88 rseed2.getSeed(output_collection_ + "SimQIE"));
89
94 }
95
96 // To simulate multiple pulses coming at different times, SiPMS
97 // Initialize with strips_per_array_ zeros
98 std::vector<float> true_edep(strips_per_array_, 0.);
99
100 // The part of true_edep deposited by beam electrons
101 std::vector<float> beam_edep(strips_per_array_, 0.);
102
103 // Initialize with strips_per_array_ nullptrs
104 std::vector<Expo*> ex(strips_per_array_, nullptr);
105 for (int i = 0; i < strips_per_array_; i++) {
106 // Set the pulse shape with fixed parameters given by config. file
107 ex[i] = new Expo(pulse_params_[0], pulse_params_[1]);
108 true_edep[i] = 0;
109 }
110
111 // loop over sim hits and aggregate energy depositions for each detID
112 const auto sim_hits{event.getCollection<ldmx::SimCalorimeterHit>(
114 const bool has_sim_particles{
116 if (!has_sim_particles) {
117 ldmx_log(debug) << "No " << sim_particles_coll_name_
118 << " found; beamEfrac set to -1";
119 }
120 const auto particle_map{
121 has_sim_particles ? event.getMap<int, ldmx::SimParticle>(
123 : std::map<int, ldmx::SimParticle>{}};
124
125 for (const auto& sim_hit : sim_hits) {
126 ldmx::TrigScintID id(sim_hit.getID());
127
128 ldmx_log(debug) << "Processing sim hit with bar ID: " << id.bar();
129
130 // tag the edep coming from beam electrons
131 for (int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
132 const auto contrib{sim_hit.getContrib(i)};
133 const auto particle{particle_map.find(contrib.track_id_)};
134 if (particle == particle_map.end()) continue;
135
136 ldmx_log(trace) << "contrib " << i << " trackID: " << contrib.track_id_
137 << " pdgID: " << contrib.pdg_code_
138 << " edep: " << contrib.edep_;
139 ldmx_log(trace) << "\t particle id: " << particle->second.getPdgID()
140 << " particle status: "
141 << particle->second.getGenStatus();
142
143 if (particle->second.getPdgID() == 11 &&
144 particle->second.getGenStatus() == 1) {
145 beam_edep[id.bar()] += contrib.edep_;
146 }
147 }
148
149 // Simulating the noise corresponding to uncertainity in
150 // detecting scintillating photons.
151 // Poissonian distribution with mean = mean PEs generated
152 double pulse_amp =
153 random_->Poisson(sim_hit.getEdep() / mev_per_mip_ * pe_per_mip_);
154
155 // Adding a pulse for every sim hit recorded.
156 // time offset = global offset+simhit time
157 ex[id.bar()]->addPulse(toff_overall_ + sim_hit.getTime(), pulse_amp);
158
159 // incrementing true energy deposited in appropriate bar.
160 true_edep[id.bar()] += sim_hit.getEdep();
161 }
162
163 // A container to hold the digitized trigger scintillator hits.
164 std::vector<trigscint::TrigScintQIEDigis> q_digis;
165
166 double total_noise = mean_noise_ * maxts_;
167
168 // time period[ns] = 1000/sampling freq.[MHz]
169 double sampling_time = 1000 / s_freq_;
170
171 // Loop over all the bars available.
172 for (int bar_id = 0; bar_id < strips_per_array_; bar_id++) {
173 // Dark current simulation
174 // e-hole pairs may be generated at random times in SiPM
175 // due to thermal fluctuations.
176 // Every e- thus generated, mimicks a Photo Electron.
177 // Hence we will creat 1PE pulses for each electron generated.
178 int n_noise_pulses = random_->Poisson(total_noise);
179 for (int i = 0; i < n_noise_pulses; i++) {
180 ex[bar_id]->addPulse(random_->Uniform(0, maxts_ * sampling_time), 1);
181 }
182
183 // Storing the "good" digis
184 if (smq_->pulseCut(ex[bar_id], zero_supp_cut_)) {
186
187 qie_info.setChanID(bar_id);
188 qie_info.setADC(smq_->outAdc(ex[bar_id]));
189 qie_info.setTDC(smq_->outTdc(ex[bar_id]));
190 qie_info.setCID(smq_->capId(ex[bar_id]));
191
192 // sim truth; dark-current-only bars get 0, no SimParticles get -1
193 if (has_sim_particles) {
194 qie_info.setBeamEfrac(
195 true_edep[bar_id] > 0 ? beam_edep[bar_id] / true_edep[bar_id] : 0.);
196 }
197
198 q_digis.push_back(qie_info);
199 }
200 }
201 event.add(output_collection_, q_digis);
202}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:107
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:25
Class that defines the detector ID of the trigger scintillator.
Definition TrigScintID.h:14
void setGain(const float gg=1e+6)
Set gain of SiPM.
Definition SimQIE.h:43
void setNTimeSamples(const int maxts=5)
Set the number of time samples to analyze.
Definition SimQIE.h:57
void setFreq(const float sf=40)
Set sampling frequency of QIE.
Definition SimQIE.h:50
void setTDCThreshold(const float thr)
Set current threshold for TDC latch.
Definition SimQIE.h:35
std::unique_ptr< TRandom3 > random_
Random number generator.
class for storing QIE output
void setCID(const std::vector< int > cid)
Store cids of all time samples.
void setTDC(const std::vector< int > tdc)
Store tdcs of all time samples.
void setChanID(const int chanid)
Store the channel ID.
void setBeamEfrac(const float beamEfrac)
Store the beam energy fraction.
void setADC(const std::vector< int > adc)
Store adcs of all time samples.

References framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME, framework::Event::exists(), trigscint::TrigScintQIEDigis::setADC(), trigscint::TrigScintQIEDigis::setBeamEfrac(), trigscint::TrigScintQIEDigis::setChanID(), trigscint::TrigScintQIEDigis::setCID(), and trigscint::TrigScintQIEDigis::setTDC().

Member Data Documentation

◆ elec_noise_

float trigscint::TrigScintQIEDigiProducer::elec_noise_
private

QIE electronic noise.

Definition at line 118 of file TrigScintQIEDigiProducer.h.

◆ input_collection_

std::string trigscint::TrigScintQIEDigiProducer::input_collection_
private

Name of the input collection containing the sim hits.

Definition at line 68 of file TrigScintQIEDigiProducer.h.

◆ input_pass_name_

std::string trigscint::TrigScintQIEDigiProducer::input_pass_name_
private

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

Definition at line 72 of file TrigScintQIEDigiProducer.h.

◆ input_pulse_shape_

std::string trigscint::TrigScintQIEDigiProducer::input_pulse_shape_
private

QIE Input pulse shape.

Definition at line 100 of file TrigScintQIEDigiProducer.h.

◆ maxts_

int trigscint::TrigScintQIEDigiProducer::maxts_
private

no. of time samples analysed by QIE

Definition at line 109 of file TrigScintQIEDigiProducer.h.

◆ mean_noise_

double trigscint::TrigScintQIEDigiProducer::mean_noise_ {0}
private

Mean readout noise.

Definition at line 91 of file TrigScintQIEDigiProducer.h.

91{0};

◆ mev_per_mip_

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

Total MeV per MIP.

Definition at line 94 of file TrigScintQIEDigiProducer.h.

94{1.40};

◆ output_collection_

std::string trigscint::TrigScintQIEDigiProducer::output_collection_
private

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

Definition at line 76 of file TrigScintQIEDigiProducer.h.

◆ pe_per_mip_

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

Total number of photoelectrons per MIP.

Definition at line 97 of file TrigScintQIEDigiProducer.h.

97{13.5};

◆ pedestal_

float trigscint::TrigScintQIEDigiProducer::pedestal_
private

QIE pedestal.

Definition at line 115 of file TrigScintQIEDigiProducer.h.

◆ pulse_params_

std::vector<float> trigscint::TrigScintQIEDigiProducer::pulse_params_
private

QIE Input pulse parameters.

Definition at line 103 of file TrigScintQIEDigiProducer.h.

◆ random_

std::unique_ptr<TRandom3> trigscint::TrigScintQIEDigiProducer::random_ {nullptr}
private

Random number generator.

Definition at line 65 of file TrigScintQIEDigiProducer.h.

65{nullptr};

◆ s_freq_

float trigscint::TrigScintQIEDigiProducer::s_freq_
private

QIE sampling frequency [in MHz].

Definition at line 124 of file TrigScintQIEDigiProducer.h.

◆ sim_particles_coll_name_

std::string trigscint::TrigScintQIEDigiProducer::sim_particles_coll_name_
private

Name of the sim particle collection.

Definition at line 79 of file TrigScintQIEDigiProducer.h.

◆ sim_particles_passname_

std::string trigscint::TrigScintQIEDigiProducer::sim_particles_passname_
private

Pass name for the sim particle collection.

Definition at line 82 of file TrigScintQIEDigiProducer.h.

◆ sipm_gain_

float trigscint::TrigScintQIEDigiProducer::sipm_gain_
private

SiPM Gain.

Definition at line 121 of file TrigScintQIEDigiProducer.h.

◆ smq_

SimQIE* trigscint::TrigScintQIEDigiProducer::smq_ {nullptr}
private

SimQIE pointer.

Definition at line 130 of file TrigScintQIEDigiProducer.h.

130{nullptr};

◆ strips_per_array_

int trigscint::TrigScintQIEDigiProducer::strips_per_array_ {50}
private

Number of strips per array.

Definition at line 85 of file TrigScintQIEDigiProducer.h.

85{50};

◆ tdc_thr_

float trigscint::TrigScintQIEDigiProducer::tdc_thr_
private

QIE TDC Current threshold.

Definition at line 112 of file TrigScintQIEDigiProducer.h.

◆ toff_overall_

float trigscint::TrigScintQIEDigiProducer::toff_overall_
private

Overall input pulse time offset.

Definition at line 106 of file TrigScintQIEDigiProducer.h.

◆ zero_supp_cut_

float trigscint::TrigScintQIEDigiProducer::zero_supp_cut_ {1.}
private

Zero-suppression: discard any integrated pulses with PE < this number.

Definition at line 127 of file TrigScintQIEDigiProducer.h.

127{1.};

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