LDMX Software
TrigScintRecHitProducer.cxx
2
3#include <iostream>
4
5#include "Framework/Exception/Exception.h"
7
8namespace trigscint {
9
10TrigScintRecHitProducer::TrigScintRecHitProducer(const std::string &name,
11 framework::Process &process)
12 : Producer(name, process) {}
13
14TrigScintRecHitProducer::~TrigScintRecHitProducer() {}
15
16void TrigScintRecHitProducer::configure(
18 // Configure this instance of the producer
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
29void TrigScintRecHitProducer::produce(framework::Event &event) {
30 // Initialize QIE object for linearizing ADCs
31 SimQIE qie;
32
33 // Retrieve the collection of QIE digis
34 const auto digis{event.getCollection<trigscint::TrigScintQIEDigis>(
35 input_collection_, input_pass_name_)};
36
37 std::vector<ldmx::TrigScintHit> trig_scint_hits;
38
39 // Loop over digis and process each one
40 for (const auto &digi : digis) {
42 auto adc{digi.getADC()};
43 auto tdc{digi.getTDC()};
44
45 hit.setModuleID(0);
46 hit.setBarID(digi.getChanID());
47 hit.setBeamEfrac(-1.);
48
49 // Set amplitude as the sum of the first two samples
50 hit.setAmplitude(
51 qie.adc2Q(adc[sample_of_interest_]) +
52 qie.adc2Q(adc[sample_of_interest_ + 1])); // femptocoulombs
53
54 // Set time based on TDC value
55 if (tdc[sample_of_interest_] > 49)
56 hit.setTime(-999.);
57 else
58 hit.setTime(tdc[sample_of_interest_] * 0.5);
59
60 float integrated_charge = 0;
61
62 // Integrate pulse over all time samples and subtract pedestal
63 for (const auto &adc_val : adc) {
64 integrated_charge += qie.adc2Q(adc_val);
65 }
66 uint n_samp = adc.size();
67 float ped_subtr_q = integrated_charge - n_samp * pedestal_;
68
69 // Set energy and photoelectrons
70 hit.setEnergy(ped_subtr_q * 6250. / gain_ * mev_per_mip_ /
71 pe_per_mip_); // MeV
72 hit.setPE(ped_subtr_q * 6250. / gain_);
73
74 trig_scint_hits.push_back(hit);
75 }
76
77 // Add the processed hits to the event
78 event.add(output_collection_, trig_scint_hits);
79}
80
81} // namespace trigscint
82
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Conditions object for random number seeds.
Class that builds recHits.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
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 simulating QIE chip output
Definition SimQIE.h:17
float adc2Q(int ADC)
Converting ADC back to charge.
Definition SimQIE.cxx:52
class for storing QIE output
Organizes digis into TrigScintHits, linearizes TDC and ADC info, and converts amplitudes to PEs.