1#include "Hcal/HcalSingleEndRecProducer.h"
12 int toa_sample{0}, toa_startbx{0};
15 [[maybe_unused]]
int bx_to_time{0};
18 [[maybe_unused]]
int max_sample{0};
20 for (std::size_t i_sample{0}; i_sample < digi.size(); i_sample++) {
22 if (i_sample > 0) sum_adc += (digi.
at(i_sample).
adc_t() - pedestal);
25 sum_tot += digi.
at(i_sample).
tot();
28 if (digi.
at(i_sample).
toa() > 0) {
29 if (digi.
at(i_sample).
toa() >= bx_shift) {
30 toa_sample = i_sample;
32 toa_sample = i_sample + 1;
41 if (digi.
at(i_sample).
adc_t() - pedestal > max_meas) {
42 max_meas = digi.
at(i_sample).
adc_t() - pedestal;
43 max_sample = i_sample;
47 double toa = toa_startbx;
54 return std::make_tuple(toa, sum_adc, sum_tot);
70 const auto& hcalGeometry = getCondition<ldmx::HcalGeometry>(
73 const auto& conditions{
79 std::vector<ldmx::HcalHit> hcalRecHits;
83 for (
auto const& digi : hcalDigis) {
88 double num_mips_equivalent{0};
89 auto [toa, sum_adc, sum_tot] =
91 conditions.toaCalib(digi.id(), 0));
92 auto is_adc = conditions.is_adc(digi.id(), sum_tot);
94 double adc_calib = sum_adc / conditions.adcGain(digi.id(), 0);
95 num_mips_equivalent = adc_calib;
97 double tot_calib = conditions.linearize(digi.id(), sum_tot);
98 num_mips_equivalent = tot_calib / conditions.adcGain(digi.id(), 0);
101 double reconstructed_energy =
105 double hitTime = toa;
108 auto position = hcalGeometry.getStripCenterPosition(
id);
112 recHit.
setID(
id.raw());
126 hcalRecHits.push_back(recHit);
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Implements an event buffer system for storing event data.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
static const std::string CONDITIONS_NAME
the name of the HcalReconConditions table (must match python registration name)
double mip_energy_
energy per MIP [MeV]
double pe_per_mip_
number of PEs per MIP
std::tuple< double, double, int > extract_measurements(const ldmx::HgcrocDigiCollection::HgcrocDigi &digi, double pedestal, double bx_shift)
extract toa, sum adc, and sum tot from the input raw digi
std::string pass_name_
name of pass of digis to use
void produce(framework::Event &event) override
Process the event and put new data products into it.
void configure(framework::config::Parameters &p) override
Callback for the EventProcessor to configure itself from the given set of parameters.
std::string rec_coll_name_
name of rechits to reconstruct
std::string coll_name_
name of digis to reconstruct
unsigned int isoi_
sample of interest index
double clock_cycle_
length of clock cycle [ns]
std::string rec_pass_name_
name of pass of rechits to use
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].
Extension of HcalAbstractID providing access to HCal digi information.
int strip() const
Get the value of the 'strip' field from the ID.
int section() const
Get the value of the 'section' field from the ID.
int layer() const
Get the value of the layer field from the ID.
int end() const
Get the value of the 'end' field from the ID.
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....
Stores reconstructed hit information from the HCAL.
void setSection(int section)
Set the section for this hit.
void setEnd(int end)
Set the end (0 neg, 1 pos side).
void setIsADC(int isADC)
Set if the hit is reconstructed using ADC.
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
void setStrip(int strip)
Set the strip for this hit.
void setLayer(int layer)
Set the layer for this hit.
void setPE(float pe)
Set the number of photoelectrons estimated for this hit.
Implements detector ids for HCal subdetector.
One DIGI signal coming from the HGC ROC.
HgcrocDigiCollection::Sample at(unsigned int i_sample) const
get the sample at a specific index in the digi
int adc_t() const
Get the ADC measurement from this sample.
int tot() const
Get the TOT measurement from this sample.
int toa() const
Get the Time Of Arrival of this sample which is always the third position in all readout modes.
Represents a collection of the digi hits readout by an HGCROC.
unsigned int getSampleOfInterestIndex() const
Get index of sample of interest.