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

One sample of a digi channel corresponding to one clock of the HGCROC chip. More...

#include <HgcrocDigiCollection.h>

Public Member Functions

 Sample (bool tot_progress, bool tot_complete, int firstMeas, int seconMeas, int toa, int version=3)
 Helpful alternative constructor.
 
 Sample (uint32_t w, int version=3)
 Basic constructor.
 
 Sample ()
 Default constructor.
 
bool isTOTinProgress () const
 Get the first flag from the sample checking if TOT is in progress during this sample.
 
bool isTOTComplete () const
 Get the second flag from the sample checking if TOT is complete at this sample.
 
int toa () const
 Get the Time Of Arrival of this sample which is always the third position in all readout modes.
 
int tot () const
 Get the TOT measurement from this sample.
 
int adc_tm1 () const
 Get the last ADC measurement from this sample.
 
int adc_t () const
 Get the ADC measurement from this sample.
 
uint32_t raw () const
 Get the raw value of this sample.
 

Private Member Functions

int first () const
 Get the first 10-bit measurement out of the sample.
 
int secon () const
 Get the second 10-bit measurement out of the sample.
 
int third () const
 Get the third 10-bit measurement out of the smaple.
 

Private Attributes

uint32_t word_
 The actual 32-bit word spit out by the chip.
 
int version_
 version to use for {de,en}coding
 

Detailed Description

One sample of a digi channel corresponding to one clock of the HGCROC chip.

Not all of these measurements are valid in each sample. The valid measurements depend on the tot_progress and tot_complete flags.

The TOA measurement is always valid and is inserted as the third measurement in the 32-bit word.

If the TOT measurment is NOT complete, then the other two valid measurements (in order) are

  1. ADC of the previous sample (adc_tm1)
  2. ADC of this sample (adc_t)

If the TOT is NOT in progress and the TOT is complete, then

  1. ADC of the previous sample (adc_tm1)
  2. TOT measurement (tot)

If both flags are true, then

  1. ADC of this sample (adc_t)
  2. TOT measurement (tot)

Usually several samples are used for each channel to re-construct the hit.

Definition at line 71 of file HgcrocDigiCollection.h.

Constructor & Destructor Documentation

◆ Sample() [1/3]

ldmx::HgcrocDigiCollection::Sample::Sample ( bool  tot_progress,
bool  tot_complete,
int  firstMeas,
int  seconMeas,
int  toa,
int  version = 3 
)

Helpful alternative constructor.

Encodes the various measurements into the word depending on the passed flags. Use this constructor inside of the chip emulator when converting voltage pulses into DIGIs.

Note
This is where the measurements to word translation occurs.

◆ Sample() [2/3]

ldmx::HgcrocDigiCollection::Sample::Sample ( uint32_t  w,
int  version = 3 
)
inline

Basic constructor.

Use this constructor when translating binary data coming off the detector into our event model.

Definition at line 91 of file HgcrocDigiCollection.h.

91: word_(w), version_{version} {}
int version_
version to use for {de,en}coding
uint32_t word_
The actual 32-bit word spit out by the chip.

◆ Sample() [3/3]

ldmx::HgcrocDigiCollection::Sample::Sample ( )
inline

Default constructor.

Not used, but required for Event dictionary generation

Definition at line 98 of file HgcrocDigiCollection.h.

98{}

Member Function Documentation

◆ adc_t()

int ldmx::HgcrocDigiCollection::Sample::adc_t ( ) const
inline

Get the ADC measurement from this sample.

Checks which running mode we are in to determine which position the measurement should be taken from.

Returns
10-bit measurement of current ADC

Definition at line 172 of file HgcrocDigiCollection.h.

172 {
173 if (version_ == 2) {
174 return third();
175 }
176
177 if (not isTOTComplete())
178 return secon(); // running modes
179 else
180 return first(); // calibration mode
181 }
int secon() const
Get the second 10-bit measurement out of the sample.
int first() const
Get the first 10-bit measurement out of the sample.
int third() const
Get the third 10-bit measurement out of the smaple.
bool isTOTComplete() const
Get the second flag from the sample checking if TOT is complete at this sample.

References first(), isTOTComplete(), secon(), third(), and version_.

Referenced by hcal::HcalSingleEndRecProducer::extract_measurements(), operator<<(), ecal::EcalTrigPrimDigiProducer::produce(), and hcal::HcalTrigPrimDigiProducer::produce().

◆ adc_tm1()

int ldmx::HgcrocDigiCollection::Sample::adc_tm1 ( ) const
inline

Get the last ADC measurement from this sample.

Note
Does not check if this sample has a valid ADC t-1 measurement.
Returns
10-bit measurement of ADC t-1

Definition at line 162 of file HgcrocDigiCollection.h.

162{ return first(); }

References first().

Referenced by operator<<().

◆ first()

int ldmx::HgcrocDigiCollection::Sample::first ( ) const
inlineprivate

Get the first 10-bit measurement out of the sample.

Returns
10-bit measurement at first position in sample

Definition at line 196 of file HgcrocDigiCollection.h.

196{ return TEN_BIT_MASK & (word_ >> FIRSTMEAS_POS); }
static const int FIRSTMEAS_POS
Bit position of first measurement.
static const int TEN_BIT_MASK
Mask for lowest order ten bits in an int.

References ldmx::HgcrocDigiCollection::FIRSTMEAS_POS, ldmx::HgcrocDigiCollection::TEN_BIT_MASK, and word_.

Referenced by adc_t(), and adc_tm1().

◆ isTOTComplete()

bool ldmx::HgcrocDigiCollection::Sample::isTOTComplete ( ) const
inline

Get the second flag from the sample checking if TOT is complete at this sample.

Returns
true if TOT is complete and should use this sample to get TOT measurement

Definition at line 117 of file HgcrocDigiCollection.h.

117 {
118 return (ONE_BIT_MASK & (word_ >> SECONFLAG_POS));
119 }
static const int SECONFLAG_POS
Bit position of second flag.
static const int ONE_BIT_MASK
Mask for lowest order bit in an int.

References ldmx::HgcrocDigiCollection::ONE_BIT_MASK, ldmx::HgcrocDigiCollection::SECONFLAG_POS, and word_.

Referenced by adc_t(), ldmx::HgcrocDigiCollection::HgcrocDigi::isADC(), operator<<(), ecal::EcalTrigPrimDigiProducer::produce(), and hcal::HcalTrigPrimDigiProducer::produce().

◆ isTOTinProgress()

bool ldmx::HgcrocDigiCollection::Sample::isTOTinProgress ( ) const
inline

Get the first flag from the sample checking if TOT is in progress during this sample.

Returns
true if TOT is in progress during this sample

Definition at line 106 of file HgcrocDigiCollection.h.

106 {
107 return (ONE_BIT_MASK & (word_ >> FIRSTFLAG_POS));
108 }
static const int FIRSTFLAG_POS
Bit position of first flag.

References ldmx::HgcrocDigiCollection::FIRSTFLAG_POS, ldmx::HgcrocDigiCollection::ONE_BIT_MASK, and word_.

Referenced by ldmx::HgcrocDigiCollection::HgcrocDigi::isADC(), and operator<<().

◆ raw()

uint32_t ldmx::HgcrocDigiCollection::Sample::raw ( ) const
inline

Get the raw value of this sample.

Returns
32-bit full value fo the sample

Definition at line 188 of file HgcrocDigiCollection.h.

188{ return word_; }

References word_.

◆ secon()

int ldmx::HgcrocDigiCollection::Sample::secon ( ) const
inlineprivate

Get the second 10-bit measurement out of the sample.

Returns
10-bit measurement at second position in sample

Definition at line 203 of file HgcrocDigiCollection.h.

203{ return TEN_BIT_MASK & (word_ >> SECONMEAS_POS); }
static const int SECONMEAS_POS
Bit position of second measurement.

References ldmx::HgcrocDigiCollection::SECONMEAS_POS, ldmx::HgcrocDigiCollection::TEN_BIT_MASK, and word_.

Referenced by adc_t(), toa(), and tot().

◆ third()

int ldmx::HgcrocDigiCollection::Sample::third ( ) const
inlineprivate

Get the third 10-bit measurement out of the smaple.

Returns
10-bit measurement at second position in sample

Definition at line 209 of file HgcrocDigiCollection.h.

209{ return TEN_BIT_MASK & word_; }

References ldmx::HgcrocDigiCollection::TEN_BIT_MASK, and word_.

Referenced by adc_t(), and toa().

◆ toa()

int ldmx::HgcrocDigiCollection::Sample::toa ( ) const
inline

Get the Time Of Arrival of this sample which is always the third position in all readout modes.

Returns
10-bit measurement of TOA

Definition at line 127 of file HgcrocDigiCollection.h.

127 {
128 if (version_ == 2) {
129 return secon();
130 } else {
131 return third();
132 }
133 }

References secon(), third(), and version_.

Referenced by hcal::HcalSingleEndRecProducer::extract_measurements(), hcal::HcalRecProducer::getTOA(), and operator<<().

◆ tot()

int ldmx::HgcrocDigiCollection::Sample::tot ( ) const
inline

Get the TOT measurement from this sample.

Note
Does not check if this is the TOT Complete sample!

Expands the 10-bit measurment inside the sample into the 12-bit actual measurement of TOT.

Returns
12-bit measurement of TOT

Definition at line 145 of file HgcrocDigiCollection.h.

145 {
146 if (version_ == 2) {
147 return 0xfff & (word_ >> FIRSTMEAS_POS);
148 }
149
150 int meas = secon();
151 if (meas > 512) meas = (meas - 512) * 8;
152 return meas;
153 }

References ldmx::HgcrocDigiCollection::FIRSTMEAS_POS, secon(), version_, and word_.

Referenced by hcal::HcalSingleEndRecProducer::extract_measurements(), operator<<(), ecal::EcalTrigPrimDigiProducer::produce(), hcal::HcalTrigPrimDigiProducer::produce(), and ldmx::HgcrocDigiCollection::HgcrocDigi::tot().

Member Data Documentation

◆ version_

int ldmx::HgcrocDigiCollection::Sample::version_
private

version to use for {de,en}coding

Definition at line 215 of file HgcrocDigiCollection.h.

Referenced by adc_t(), toa(), and tot().

◆ word_

uint32_t ldmx::HgcrocDigiCollection::Sample::word_
private

The actual 32-bit word spit out by the chip.

Definition at line 213 of file HgcrocDigiCollection.h.

Referenced by first(), isTOTComplete(), isTOTinProgress(), raw(), secon(), third(), and tot().


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