LDMX Software
trigscint::TrigScintDigiProducer Class Reference

Performs digitization of simulated Trigger Scintillator data. More...

#include <TrigScintDigiProducer.h>

Public Types

typedef int layer
 
typedef std::pair< double, double > zboundaries
 

Public Member Functions

 TrigScintDigiProducer (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.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader) override
 Random number generation.
 
ldmx::TrigScintID generateRandomID (int module)
 
- 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 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::mt19937 rng_
 Random number generator.
 
std::unique_ptr< ldmx::NoiseGeneratornoise_generator_ {nullptr}
 Generate noise hits given the number of channels and mean noise.
 
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 sim particles collection and pass name.
 
std::string sim_particles_passname_
 
int strips_per_array_ {50}
 Number of strips per array.
 
int number_of_arrays_ {3}
 Number of arrays.
 
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.
 

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

Performs digitization of simulated Trigger Scintillator data.

Definition at line 39 of file TrigScintDigiProducer.h.

Member Typedef Documentation

◆ layer

int trigscint::TrigScintDigiProducer::layer

Definition at line 41 of file TrigScintDigiProducer.h.

◆ zboundaries

std::pair<double, double> trigscint::TrigScintDigiProducer::zboundaries

Definition at line 43 of file TrigScintDigiProducer.h.

Constructor & Destructor Documentation

◆ TrigScintDigiProducer()

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

Definition at line 5 of file TrigScintDigiProducer.cxx.

7 : 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::TrigScintDigiProducer::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 9 of file TrigScintDigiProducer.cxx.

9 {
10 // Configure this instance of the producer
11 strips_per_array_ = ps.get<int>("number_of_strips");
12 number_of_arrays_ = ps.get<int>("number_of_arrays");
13 mean_noise_ = ps.get<double>("mean_noise");
14 mev_per_mip_ = ps.get<double>("mev_per_mip");
15 pe_per_mip_ = ps.get<double>("pe_per_mip");
16 input_collection_ = ps.get<std::string>("input_collection");
17 input_pass_name_ = ps.get<std::string>("input_pass_name");
18 output_collection_ = ps.get<std::string>("output_collection");
19 sim_particles_coll_name_ = ps.get<std::string>("sim_particles_coll_name");
20 sim_particles_passname_ = ps.get<std::string>("sim_particles_passname");
21}
std::string output_collection_
Name of the output collection that will be used to stored the digitized trigger scintillator hits.
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.
std::string sim_particles_coll_name_
Name of sim particles collection and pass name.
int strips_per_array_
Number of strips per array.
double mev_per_mip_
Total MeV per MIP.
double mean_noise_
Mean readout noise.
double pe_per_mip_
Total number of photoelectrons per MIP.

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

◆ generateRandomID()

ldmx::TrigScintID trigscint::TrigScintDigiProducer::generateRandomID ( int module)

Definition at line 36 of file TrigScintDigiProducer.cxx.

36 {
37 // Uniform distributions for integer generation
38 std::uniform_int_distribution<int> strips_dist(0, strips_per_array_ - 1);
39 ldmx::TrigScintID temp_id(module, strips_dist(rng_));
40 if (module >= TrigScintSection::NUM_SECTIONS) {
41 ldmx_log(fatal) << "TrigScintSection is not known";
42 }
43
44 return temp_id;
45}
Class that defines the detector ID of the trigger scintillator.
Definition TrigScintID.h:14
std::mt19937 rng_
Random number generator.

◆ onNewRun()

void trigscint::TrigScintDigiProducer::onNewRun ( const ldmx::RunHeader & runHeader)
overridevirtual

Random number generation.

Reimplemented from framework::EventProcessor.

Definition at line 23 of file TrigScintDigiProducer.cxx.

23 {
24 noise_generator_ = std::make_unique<ldmx::NoiseGenerator>(mean_noise_, false);
25 noise_generator_->setNoiseThreshold(1);
26 // Set up seeds
29
30 noise_generator_->seedGenerator(
31 rseed.getSeed("TrigScintDigiProducer::NoiseGenerator"));
32 // Random number generator for module id
33 rng_.seed(rseed.getSeed("TrigScintDigiProducer"));
34}
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
std::unique_ptr< ldmx::NoiseGenerator > noise_generator_
Generate noise hits given the number of channels and mean noise.

References framework::RandomNumberSeedService::CONDITIONS_OBJECT_NAME.

◆ produce()

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

47 {
48 std::map<ldmx::TrigScintID, int> cell_pes, cell_min_p_es;
49 std::map<ldmx::TrigScintID, float> xpos, ypos, zpos, edep, time, beam_frac;
50 std::set<ldmx::TrigScintID> noise_hit_i_ds;
51
52 auto num_rec_hits{0};
53
54 // looper over sim hits and aggregate energy depositions for each detID
55 const auto sim_hits{event.getCollection<ldmx::SimCalorimeterHit>(
57 auto particle_map{event.getMap<int, ldmx::SimParticle>(
58 sim_particles_coll_name_, sim_particles_passname_)};
59
60 int module{-1};
61 for (const auto &sim_hit : sim_hits) {
62 ldmx::TrigScintID id(sim_hit.getID());
63
64 // Just set the module ID to use for noise hits here. Given that
65 // we are currently processing a single module at a time, setting
66 // it within the loop shouldn't matter.
67 module = id.module();
68 std::vector<float> position = sim_hit.getPosition();
69 ldmx_log(trace) << " Module ID = " << id.raw();
70
71 // check if hits is from beam electron and, if so, add to beamFrac
72 for (int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
73 auto contrib = sim_hit.getContrib(i);
74
75 ldmx_log(trace) << "contrib " << i << " trackID: " << contrib.track_id_
76 << " pdgID: " << contrib.pdg_code_
77 << " edep: " << contrib.edep_;
78 ldmx_log(trace) << "\t particle id: "
79 << particle_map[contrib.track_id_].getPdgID()
80 << " particle status: "
81 << particle_map[contrib.track_id_].getGenStatus();
82
83 if (particle_map[contrib.track_id_].getPdgID() == 11 &&
84 particle_map[contrib.track_id_].getGenStatus() == 1) {
85 if (beam_frac.find(id) == beam_frac.end()) {
86 beam_frac[id] = contrib.edep_;
87 } else {
88 beam_frac[id] += contrib.edep_;
89 }
90 }
91 }
92
93 // for now, we take an energy weighted average of the hit in each strip to
94 // simulate the hit position. AJW: these should be dropped, they are likely
95 // to lead to a problem since we can't measure them anyway except roughly y
96 // and z, which is encoded in the ids.
97 if (edep.find(id) == edep.end()) {
98 // first hit, initialize
99 edep[id] = sim_hit.getEdep();
100 time[id] = sim_hit.getTime() * sim_hit.getEdep();
101 xpos[id] = position[0] * sim_hit.getEdep();
102 ypos[id] = position[1] * sim_hit.getEdep();
103 zpos[id] = position[2] * sim_hit.getEdep();
104 num_rec_hits++;
105
106 } else {
107 // not first hit, aggregate, and store the largest radius hit
108 xpos[id] += position[0] * sim_hit.getEdep();
109 ypos[id] += position[1] * sim_hit.getEdep();
110 zpos[id] += position[2] * sim_hit.getEdep();
111 edep[id] += sim_hit.getEdep();
112 // AJW: need to figure out a better way to model this...
113 time[id] += sim_hit.getTime() * sim_hit.getEdep();
114 }
115 }
116
117 // Create the container to hold the digitized trigger scintillator hits.
118 std::vector<ldmx::TrigScintHit> trig_scint_hits;
119
120 // loop over detIDs and simulate number of PEs
121 for (std::map<ldmx::TrigScintID, float>::iterator it = edep.begin();
122 it != edep.end(); ++it) {
123 ldmx::TrigScintID id(it->first);
124
125 double dep_energy = edep[id];
126 time[id] = time[id] / edep[id];
127 xpos[id] = xpos[id] / edep[id];
128 ypos[id] = ypos[id] / edep[id];
129 zpos[id] = zpos[id] / edep[id];
130 // mean number of photoelectrons produced for the given deposited energy
131 double mean_pe = dep_energy / mev_per_mip_ * pe_per_mip_;
132 std::poisson_distribution<int> poisson_dist(mean_pe + mean_noise_);
133 cell_pes[id] = poisson_dist(rng_);
134 // energy corresponding to the number of PEs observed
135 // the minimum number of PEs is the mean number of PEs minus the noise
136 double energy_per_pe = mev_per_mip_ / pe_per_mip_;
137 double cell_energy = energy_per_pe * cell_pes[id];
138
139 // If a cell has a PE count above threshold, persit the hit.
140 // Thresholds are introduced (and configurable) in clustering.
141 // the cell PE >=1 suppresses artifical noise that is below one light
142 // quantum in the SiPM and unphysical.
143 if (cell_pes[id] >= 1) {
145 hit.setID(id.raw());
146 hit.setPE(cell_pes[id]);
147 hit.setMinPE(cell_min_p_es[id]);
148 hit.setAmplitude(cell_pes[id]);
149 hit.setEnergy(cell_energy);
150 hit.setTime(time[id]);
151 hit.setXPos(xpos[id]);
152 hit.setYPos(ypos[id]);
153 hit.setZPos(zpos[id]);
154 hit.setModuleID(module);
155 hit.setBarID(id.bar()); // getFieldValue("bar"));
156 hit.setNoise(false);
157 hit.setBeamEfrac(beam_frac[id] / dep_energy);
158
159 trig_scint_hits.push_back(hit);
160 }
161
162 ldmx_log(debug) << " ID = " << id.raw() << " Edep: " << edep[id]
163 << " numPEs: " << cell_pes[id] << " time: " << time[id]
164 << " z: " << zpos[id] << "\t X: " << xpos[id]
165 << " Y: " << ypos[id] << " Z: " << zpos[id];
166 } // end of loop over detIDs
167
168 // ------------------------------- Noise simulation -----------------------//
169 // ------------------------------------------------------------------------//
170 // only simulating for single array until
171 // all arrays are merged into one collection
172 int num_empty_cells = strips_per_array_ - num_rec_hits;
173 std::vector<double> noise_hits_pe =
174 noise_generator_->generateNoiseHits(num_empty_cells);
175
176 ldmx::TrigScintID temp_id;
177
178 for (auto &noise_hit_pe : noise_hits_pe) {
180 // generate random ID from remaining cells
181 do {
182 temp_id = generateRandomID(module);
183 } while (edep.find(temp_id) != edep.end() ||
184 noise_hit_i_ds.find(temp_id) != noise_hit_i_ds.end());
185
186 ldmx::TrigScintID noise_id = temp_id;
187
188 noise_hit_i_ds.insert(noise_id);
189 hit.setID(noise_id.raw());
190 hit.setPE(noise_hit_pe);
191 hit.setMinPE(noise_hit_pe);
192 hit.setAmplitude(noise_hit_pe);
193 hit.setEnergy(0.);
194 hit.setTime(0.);
195 hit.setXPos(0.);
196 hit.setYPos(0.);
197 hit.setZPos(0.);
198 hit.setModuleID(module);
199 hit.setBarID(noise_id.bar());
200 hit.setNoise(true);
201 hit.setBeamEfrac(0.);
202
203 trig_scint_hits.push_back(hit);
204 }
205 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
206 // - -
207
208 event.add(output_collection_, trig_scint_hits);
209}
void setYPos(float ypos)
Set the Y position of the hit [mm].
void setID(int id)
Set the detector ID.
void setZPos(float zpos)
Set the Z position of the hit [mm].
void setXPos(float xpos)
Set the X position of the hit [mm].
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 setNoise(bool yes)
Set if this hit is a noise hit.
RawValue raw() const
Definition DetectorID.h:68
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Definition HcalHit.h:160
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:24
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.
int bar() const
Get the value of the bar field from the ID.
Definition TrigScintID.h:64

References ldmx::TrigScintID::bar(), ldmx::DetectorID::raw(), ldmx::CalorimeterHit::setAmplitude(), ldmx::TrigScintHit::setBarID(), ldmx::TrigScintHit::setBeamEfrac(), ldmx::CalorimeterHit::setEnergy(), ldmx::CalorimeterHit::setID(), ldmx::HcalHit::setMinPE(), ldmx::TrigScintHit::setModuleID(), ldmx::CalorimeterHit::setNoise(), ldmx::TrigScintHit::setPE(), ldmx::CalorimeterHit::setTime(), ldmx::CalorimeterHit::setXPos(), ldmx::CalorimeterHit::setYPos(), and ldmx::CalorimeterHit::setZPos().

Member Data Documentation

◆ input_collection_

std::string trigscint::TrigScintDigiProducer::input_collection_
private

Name of the input collection containing the sim hits.

Definition at line 74 of file TrigScintDigiProducer.h.

◆ input_pass_name_

std::string trigscint::TrigScintDigiProducer::input_pass_name_
private

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

Definition at line 78 of file TrigScintDigiProducer.h.

◆ mean_noise_

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

Mean readout noise.

Definition at line 95 of file TrigScintDigiProducer.h.

95{0};

◆ mev_per_mip_

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

Total MeV per MIP.

Definition at line 98 of file TrigScintDigiProducer.h.

98{1.40};

◆ noise_generator_

std::unique_ptr<ldmx::NoiseGenerator> trigscint::TrigScintDigiProducer::noise_generator_ {nullptr}
private

Generate noise hits given the number of channels and mean noise.

Definition at line 71 of file TrigScintDigiProducer.h.

71{nullptr};

◆ number_of_arrays_

int trigscint::TrigScintDigiProducer::number_of_arrays_ {3}
private

Number of arrays.

Definition at line 92 of file TrigScintDigiProducer.h.

92{3};

◆ output_collection_

std::string trigscint::TrigScintDigiProducer::output_collection_
private

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

Definition at line 82 of file TrigScintDigiProducer.h.

◆ pe_per_mip_

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

Total number of photoelectrons per MIP.

Definition at line 101 of file TrigScintDigiProducer.h.

101{13.5};

◆ rng_

std::mt19937 trigscint::TrigScintDigiProducer::rng_
private

Random number generator.

Definition at line 68 of file TrigScintDigiProducer.h.

◆ sim_particles_coll_name_

std::string trigscint::TrigScintDigiProducer::sim_particles_coll_name_
private

Name of sim particles collection and pass name.

Definition at line 85 of file TrigScintDigiProducer.h.

◆ sim_particles_passname_

std::string trigscint::TrigScintDigiProducer::sim_particles_passname_
private

Definition at line 86 of file TrigScintDigiProducer.h.

◆ strips_per_array_

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

Number of strips per array.

Definition at line 89 of file TrigScintDigiProducer.h.

89{50};

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