LDMX Software
TrigScintFirmwareHitProducer.cxx
1
3
4#include <iterator>
5#include <map>
6
7#include "TrigScint/Firmware/hitproducer.h"
8#include "TrigScint/Firmware/objdef.h"
9
10namespace trigscint {
11
14 pedestal_ = ps.get<double>("pedestal");
15 gain_ = ps.get<double>("gain");
16 mev_per_mip_ = ps.get<double>("mev_per_mip");
17 pe_per_mip_ = ps.get<double>("pe_per_mip");
18 input_collection_ = ps.get<std::string>("input_collection");
19 test_collection_ = ps.get<std::string>("test_collection");
20 input_pass_name_ = ps.get<std::string>("input_pass_name");
21 output_collection_ = ps.get<std::string>("output_collection");
22 sample_of_interest_ = ps.get<int>("sample_of_interest");
23 ldmx_log(debug) << "In TrigScintFirmwareHitProducer: configure done!";
24 ldmx_log(debug) << "\nPedestal: " << pedestal_ << "\nGain: " << gain_
25 << "\nMEV per MIP: " << mev_per_mip_
26 << "\nPE per MIP: " << pe_per_mip_
27 << "\ninput collection: " << input_collection_
28 << "\ntest collection: " << test_collection_
29 << "\nAre we testing: " << do_test_
30 << "\nInput pass name: " << input_pass_name_
31 << "\nOutput collection: " << output_collection_;
32 return;
33}
34
36 // This processor takes in TS QIE digis and outputs a rec hit collection. It
37 // does so using hitproducerHw, which is a validated piece of HLS code whose
38 // purpose is to emulate existing reconstruction software in firmware for
39 // triggering. I will more fully explain the operation and choices made in
40 // hitproducerHw in hitproducerHw
41 const auto rechits{event.getCollection<ldmx::TrigScintHit>(test_collection_,
43 for (const auto &hit : rechits) {
44 ldmx_log(debug) << "Analysis barID: " << hit.getBarID()
45 << ", PE Number: " << hit.getPE();
46 }
47 const auto digis{event.getCollection<trigscint::TrigScintQIEDigis>(
49 Hit out_hit[NHITS];
50 ap_uint<14> fifo[NCHAN][NTIMES];
51 ap_uint<8> peds[NCHAN];
52 for (int i = 0; i < NCHAN; i++) {
53 peds[i] = 0;
54 fifo[i][0] = (peds[i] << 6) + 63;
55 fifo[i][1] = (peds[i] << 6) + 63;
56 fifo[i][2] = (peds[i] << 6) + 63;
57 fifo[i][3] = (peds[i] << 6) + 63;
58 fifo[i][4] = (peds[i] << 6) + 63;
59 }
60 for (const auto &digi : digis) {
61 std::vector<int> adcs = digi.getADC();
62 std::vector<int> tdcs = digi.getTDC();
63 for (int i = 0; i < NTIMES; i++) {
64 fifo[digi.getChanID()][i] = (ap_uint<14>)((adcs[i] << 6) + (tdcs[i]));
65 }
66 }
67 hitproducerHw(fifo, out_hit, peds);
68 std::vector<ldmx::TrigScintHit> trig_scint_hits;
69 for (int i = 0; i < NHITS; i++) {
70 if (out_hit[i].amp_ >= 3) {
71 ldmx_log(debug) << "Firmware barID: " << out_hit[i].b_id_
72 << ", PE Number: " << out_hit[i].amp_;
74 hit.setModuleID(out_hit[i].m_id_);
75 hit.setBarID(out_hit[i].b_id_);
76 hit.setTime(out_hit[i].time_);
77 hit.setPE(out_hit[i].amp_);
78 trig_scint_hits.push_back(hit);
79 }
80 }
81 event.add(output_collection_, trig_scint_hits);
82 return;
83}
84
85} // namespace trigscint
86
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Staging of Real Hits.
Implements an event buffer system for storing event data.
Definition Event.h:42
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 setPE(const float PE)
Set hit pe.
void setBarID(const int barID)
Set hit bar ID.
void setModuleID(const int moduleID)
Set hit module ID.
std::string output_collection_
Name of the output collection that will be used to stored the digitized trigger scintillator hits.
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
int sample_of_interest_
Total number of photoelectrons per MIP.
void produce(framework::Event &event) override
Process the event and put new data products into it.
std::string input_collection_
add a hit at index idx to a cluster
std::string input_pass_name_
Name of the pass that the input collection is on (empty string means take any pass)
double pe_per_mip_
Total number of photoelectrons per MIP.
class for storing QIE output
Definition objdef.h:49
Unsigned Arbitrary Precision Type.
Definition ap_int.h:166