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.getParameter<double>("pedestal");
20 gain_ = parameters.getParameter<double>("gain");
21 mevPerMip_ = parameters.getParameter<double>("mev_per_mip");
22 pePerMip_ = parameters.getParameter<double>("pe_per_mip");
23 inputCollection_ = parameters.getParameter<std::string>("input_collection");
24 inputPassName_ = parameters.getParameter<std::string>("input_pass_name");
25 outputCollection_ = parameters.getParameter<std::string>("output_collection");
26 verbose_ = parameters.getParameter<bool>("verbose");
27 sample_of_interest_ = parameters.getParameter<int>("sample_of_interest");
28}
29
30void TrigScintRecHitProducer::produce(framework::Event &event) {
31 // initialize QIE object for linearizing ADCs
32 SimQIE qie;
33
34 // Ensure the sample of interest <4
35 /* // this assumes we are in well-behaved simulation land, not test beam
36 wilderness if(sample_of_interest_>3) { ldmx_log(error)<<"sample_of_interest_
37 should be one of 0,1,2,3\n"
38 <<"Currently, sample_of_interest = "<<sample_of_interest_
39 <<"\n";
40 return;
41 }
42 */
43
44 // looper over sim hits and aggregate energy depositions
45 // for each detID
46 const auto digis{event.getCollection<trigscint::TrigScintQIEDigis>(
47 inputCollection_, inputPassName_)};
48
49 std::vector<ldmx::TrigScintHit> trigScintHits;
50 for (const auto &digi : digis) {
52 auto adc{digi.getADC()};
53 auto tdc{digi.getTDC()};
54
55 hit.setModuleID(0);
56 hit.setBarID(digi.getChanID());
57 hit.setBeamEfrac(-1.);
58
59 // leave amplitude as sum of the first two
60 hit.setAmplitude(
61 qie.ADC2Q(adc[sample_of_interest_]) +
62 qie.ADC2Q(adc[sample_of_interest_ + 1])); // femptocoulombs
63
64 if (tdc[sample_of_interest_] > 49)
65 hit.setTime(-999.);
66 else
67 hit.setTime(tdc[sample_of_interest_] * 0.5);
68
69 float integratedCharge = 0;
70 // integrate pulse over all time samples. will subtract pedestal next
71 for (const auto &adcVal : adc) {
72 integratedCharge += qie.ADC2Q(adcVal);
73 }
74 uint nSamp = adc.size();
75 float pedSubtrQ = integratedCharge - nSamp * pedestal_;
76 hit.setEnergy(pedSubtrQ * 6250. / gain_ * mevPerMip_ / pePerMip_); // MeV
77 hit.setPE(pedSubtrQ * 6250. / gain_);
78 trigScintHits.push_back(hit);
79 }
80 // Create the container to hold the
81 // digitized trigger scintillator hits.
82
83 event.add(outputCollection_, trigScintHits);
84}
85} // namespace trigscint
86
87DECLARE_PRODUCER_NS(trigscint, TrigScintRecHitProducer);
#define DECLARE_PRODUCER_NS(NS, 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:41
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
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