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.getParameter<double>("pedestal");
15 gain_ = ps.getParameter<double>("gain");
16 mevPerMip_ = ps.getParameter<double>("mev_per_mip");
17 pePerMip_ = ps.getParameter<double>("pe_per_mip");
18 inputCollection_ = ps.getParameter<std::string>("input_collection");
19 testCollection_ = ps.getParameter<std::string>("test_collection");
20 inputPassName_ = ps.getParameter<std::string>("input_pass_name");
21 outputCollection_ = ps.getParameter<std::string>("output_collection");
22 sample_of_interest_ = ps.getParameter<int>("sample_of_interest");
23 ldmx_log(debug) << "In TrigScintFirmwareHitProducer: configure done!";
24 ldmx_log(debug) << "\nPedestal: " << pedestal_ << "\nGain: " << gain_
25 << "\nMEV per MIP: " << mevPerMip_
26 << "\nPE per MIP: " << pePerMip_
27 << "\ninput collection: " << inputCollection_
28 << "\ntest collection: " << testCollection_
29 << "\nAre we testing: " << doTest_
30 << "\nInput pass name: " << inputPassName_
31 << "\nOutput collection: " << outputCollection_;
32 return;
33}
34
36 // This processor takes in TS QIE digis and outputs a rec hit collection. It
37 // does so using hitproducer_hw, 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 // hitproducer_hw in hitproducer_hw
41 const auto rechits{
42 event.getCollection<ldmx::TrigScintHit>(testCollection_, inputPassName_)};
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 outHit[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 hitproducer_hw(FIFO, outHit, Peds);
68 std::vector<ldmx::TrigScintHit> trigScintHits;
69 for (int i = 0; i < NHITS; i++) {
70 if (outHit[i].Amp >= 3) {
71 ldmx_log(debug) << "Firmware barID: " << outHit[i].bID
72 << ", PE Number: " << outHit[i].Amp;
74 hit.setModuleID(outHit[i].mID);
75 hit.setBarID(outHit[i].bID);
76 hit.setTime(outHit[i].Time);
77 hit.setPE(outHit[i].Amp);
78 trigScintHits.push_back(hit);
79 }
80 }
81 event.add(outputCollection_, trigScintHits);
82 return;
83}
84
85} // namespace trigscint
86
87DECLARE_PRODUCER_NS(trigscint, TrigScintFirmwareHitProducer);
#define DECLARE_PRODUCER_NS(NS, 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:41
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 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.
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
std::string outputCollection_
Name of the output collection that will be used to stored the digitized trigger scintillator hits.
double pePerMip_
Total number of photoelectrons per MIP.
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 inputPassName_
Name of the pass that the input collection is on (empty string means take any pass)
std::string inputCollection_
add a hit at index idx to a cluster
class for storing QIE output
Definition objdef.h:49
Unsigned Arbitrary Precision Type.
Definition ap_int.h:166