LDMX Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ldmx::HgcrocTriggerCalculations Class Reference

Contains the core logic for the Hgcroc trigger calculations. More...

#include <HgcrocTriggerCalculations.h>

Public Member Functions

 HgcrocTriggerCalculations (const conditions::IntegerTableCondition &ict)
 Construct the chip trigger calculator.
 
void addDigi (unsigned int id, unsigned int tid, int adc, int tot)
 Determine the linear charge for the given channel, using the calibration information, and add it to the map of trigger channel IDs to linear charge measurements.
 
void compressDigis (int cells_per_trig)
 Convert the linear charges to compressed charges, with a division depending on the number of cells summed by HGCROC.
 
const std::map< unsigned int, uint8_t > & compressedEnergies () const
 Access the map of trigger ids to compressed energies.
 

Static Public Member Functions

static unsigned int singleChannelCharge (int adc, int tot, int adc_ped, int adc_thresh, int tot_ped, int tot_thresh, int tot_gain)
 Calculates the linear trigger charge for a single precision channel (before 2x2 or 3x3 summing)
 

Private Attributes

HgcrocTriggerConditions conditions_
 The conditions to be used.
 
std::map< unsigned int, unsigned int > linearCharge_
 A map of trigger channel id to linear charge.
 
std::map< unsigned int, uint8_t > compressedCharge_
 A map of trigger channel id to compressed charge.
 

Detailed Description

Contains the core logic for the Hgcroc trigger calculations.

This class is meant to be created once per event along with the conditions for the chip. These chip conditions are wrapped in an HgcrocTriggerConditions class for easier access. These chip conditions may change from event-to-event, so it is best to allow for this object to change from event-to-event.

Definition at line 109 of file HgcrocTriggerCalculations.h.

Constructor & Destructor Documentation

◆ HgcrocTriggerCalculations()

ldmx::HgcrocTriggerCalculations::HgcrocTriggerCalculations ( const conditions::IntegerTableCondition ict)

Construct the chip trigger calculator.

Here we pass the table of chip conditions that is used to emulate the chip's behavior for all of the different channel IDs.

We also use this opportunity to double check that the column indices in HgcrocTriggerConditions match the column indices imported from the input table.

Parameters
[in]icttable of chip conditions

Definition at line 56 of file HgcrocTriggerCalculations.cxx.

58 : conditions_{ict, true} {}
HgcrocTriggerConditions conditions_
The conditions to be used.

Member Function Documentation

◆ addDigi()

void ldmx::HgcrocTriggerCalculations::addDigi ( unsigned int  id,
unsigned int  tid,
int  adc,
int  tot 
)

Determine the linear charge for the given channel, using the calibration information, and add it to the map of trigger channel IDs to linear charge measurements.

See also
singleChannelCharge for how the precision channel measurement is converted to a linear trig-digi charge
Parameters
idPrecision channel id (used to lookup in the conditions table)
tidTrigger channel id
adcADC measurement of precision channel if not TOT complete
totTOT measurement of precision channel if TOT is complete

Definition at line 60 of file HgcrocTriggerCalculations.cxx.

61 {
62 unsigned int charge = singleChannelCharge(
66 if (charge > 0) {
67 std::map<unsigned int, unsigned int>::iterator ic = linearCharge_.find(tid);
68 if (ic == linearCharge_.end())
69 linearCharge_[tid] = charge;
70 else
71 ic->second += charge;
72 }
73}
static unsigned int singleChannelCharge(int adc, int tot, int adc_ped, int adc_thresh, int tot_ped, int tot_thresh, int tot_gain)
Calculates the linear trigger charge for a single precision channel (before 2x2 or 3x3 summing)
std::map< unsigned int, unsigned int > linearCharge_
A map of trigger channel id to linear charge.
int totThreshold(unsigned int id) const
get the TOT threshold
int totGain(unsigned int id) const
get the TOT gain
int adcPedestal(unsigned int id) const
get the ADC pedestal
int adcThreshold(unsigned int id) const
get the ADC threshold
int totPedestal(unsigned int id) const
get the TOT pedestal

References ldmx::HgcrocTriggerConditions::adcPedestal(), ldmx::HgcrocTriggerConditions::adcThreshold(), conditions_, linearCharge_, singleChannelCharge(), ldmx::HgcrocTriggerConditions::totGain(), ldmx::HgcrocTriggerConditions::totPedestal(), and ldmx::HgcrocTriggerConditions::totThreshold().

Referenced by ecal::EcalTrigPrimDigiProducer::produce(), and hcal::HcalTrigPrimDigiProducer::produce().

◆ compressDigis()

void ldmx::HgcrocTriggerCalculations::compressDigis ( int  cells_per_trig)

Convert the linear charges to compressed charges, with a division depending on the number of cells summed by HGCROC.

Fills the map of trigger channel IDs to compressed charge measurements. Some of the lowest order bits are dropped during compression in order to effectively reach the necessary dynamic range. The number of these bits that are dropped depends on the number of cells in each trigger grouping.

  • 9 --> drop 8 lowest order bits --> multiply unpacked charge by 8 to get full amount
  • 4 --> drop 4 lowest order bits --> mutliply unpacked charge by 4 to get full amount

@raises Exception if the input cells_per_trig is not 4 or 9.

Parameters
cells_per_trigValid values are 4 or 9

Definition at line 75 of file HgcrocTriggerCalculations.cxx.

75 {
76 int shift;
77 if (cells_per_trig == 4)
78 shift = 1;
79 else if (cells_per_trig == 9)
80 shift = 3;
81 else {
82 EXCEPTION_RAISE("HgcrocTriggerException",
83 "Invalid number of precision cells per trigger cell: " +
84 std::to_string(cells_per_trig));
85 }
86
87 for (auto ilinear : linearCharge_) {
88 unsigned int lcharge = ilinear.second;
89 lcharge = lcharge >> shift;
90 uint8_t ccharge = ldmx::HgcrocTrigDigi::linear2Compressed(lcharge);
91 compressedCharge_[ilinear.first] = ccharge;
92 }
93}
static uint8_t linear2Compressed(uint32_t lin)
Static conversion from 18b linear -> compressed.
std::map< unsigned int, uint8_t > compressedCharge_
A map of trigger channel id to compressed charge.

References compressedCharge_, ldmx::HgcrocTrigDigi::linear2Compressed(), and linearCharge_.

Referenced by ecal::EcalTrigPrimDigiProducer::produce(), and hcal::HcalTrigPrimDigiProducer::produce().

◆ compressedEnergies()

const std::map< unsigned int, uint8_t > & ldmx::HgcrocTriggerCalculations::compressedEnergies ( ) const
inline

Access the map of trigger ids to compressed energies.

Returns
const reference to the map of trigger channel ID to compressed charge measurements

Definition at line 182 of file HgcrocTriggerCalculations.h.

182 {
183 return compressedCharge_;
184 }

References compressedCharge_.

Referenced by ecal::EcalTrigPrimDigiProducer::produce(), and hcal::HcalTrigPrimDigiProducer::produce().

◆ singleChannelCharge()

unsigned int ldmx::HgcrocTriggerCalculations::singleChannelCharge ( int  adc,
int  tot,
int  adc_ped,
int  adc_thresh,
int  tot_ped,
int  tot_thresh,
int  tot_gain 
)
static

Calculates the linear trigger charge for a single precision channel (before 2x2 or 3x3 summing)

Parameters
adcADC measurement for the channel
totTOT measurement for the channel or zero if no TOT
adc_pedTrigger pedestal to subtract (8 bits, per channel)
adc_threshADC threshold for noise-suppression in the trigger path (5 bits, global for ROC)
tot_pedTOT pedestal (7 bits, group-of-nine)
tot_threshTOT threshold, use this fixed value as "TOT" if the TOT is below this value (8 bits, group-of-nine)
tot_gainTOT to charge multiplicative factor (5 bits, integer math, global for ROC)
Returns
linear trigger charge from a single precision channel

Definition at line 34 of file HgcrocTriggerCalculations.cxx.

36 {
37 unsigned int charge_adc = 0;
38
39 if (adc > (adc_ped + adc_thresh))
40 charge_adc = adc - adc_ped; // otherwise zero
41
42 unsigned int eff_tot{0};
43 if (tot > tot_thresh && tot > tot_ped)
44 eff_tot = tot - tot_ped;
45 else
46 eff_tot = tot_thresh - tot_ped;
47
48 unsigned int charge_tot{0};
49 charge_tot = eff_tot * tot_gain;
50
51 unsigned int charge_final = (tot != 0) ? (charge_tot) : (charge_adc);
52
53 return charge_final;
54}

Referenced by addDigi().

Member Data Documentation

◆ compressedCharge_

std::map<unsigned int, uint8_t> ldmx::HgcrocTriggerCalculations::compressedCharge_
private

A map of trigger channel id to compressed charge.

Definition at line 192 of file HgcrocTriggerCalculations.h.

Referenced by compressDigis(), and compressedEnergies().

◆ conditions_

HgcrocTriggerConditions ldmx::HgcrocTriggerCalculations::conditions_
private

The conditions to be used.

Definition at line 188 of file HgcrocTriggerCalculations.h.

Referenced by addDigi().

◆ linearCharge_

std::map<unsigned int, unsigned int> ldmx::HgcrocTriggerCalculations::linearCharge_
private

A map of trigger channel id to linear charge.

Definition at line 190 of file HgcrocTriggerCalculations.h.

Referenced by addDigi(), and compressDigis().


The documentation for this class was generated from the following files: