pflib v3.9.4-7-gb2e7f4f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
pflib::algorithm Namespace Reference

housing of higher-level methods for repeatable tasks More...

Functions

template<class EventPacket >
std::array< int, 72 > get_calibs (Target *tgt, ROC &roc, int &target_adc)
 Find calib value where the max adc corresponds to a target value.
 
template std::array< int, 72 > get_calibs< pflib::packing::SingleROCEventPacket > (Target *tgt, ROC &roc, int &target_adc)
 
template std::array< int, 72 > get_calibs< pflib::packing::MultiSampleECONDEventPacket > (Target *tgt, ROC &roc, int &targt_adc)
 
template<class EventPacket >
std::array< double, 72 > get_toa_efficiencies (const std::vector< EventPacket > &data)
 calculate the highest TOA_VREF value for each link, for which there is a non-zero TOA efficiency
 
template std::array< double, 72 > pflib::algorithm::get_toa_efficiencies< pflib::packing::SingleROCEventPacket > (const std::vector< pflib::packing::SingleROCEventPacket > &data)
 
template std::array< double, 72 > pflib::algorithm::get_toa_efficiencies< pflib::packing::MultiSampleECONDEventPacket > (const std::vector< pflib::packing::MultiSampleECONDEventPacket > &data)
 
template<class EventPacket >
static int get_adc (const EventPacket &p, int ch)
 Retrieve the ADC sample for the input channel from the input event packet.
 
template<class EventPacket >
static std::array< int, 72 > get_adc_medians (const std::vector< EventPacket > &data)
 get the medians of the channel ADC values
 
template<class EventPacket >
static void pedestal_runs (Target *tgt, ROC &roc, std::array< int, 72 > &baseline, std::array< int, 72 > &highend, std::array< int, 72 > &lowend, std::array< int, 2 > &target, size_t n_events)
 
std::map< std::string, std::map< std::string, uint64_t > > level_pedestals (Target *tgt, ROC roc)
 Level pedestals so that they are all within noise of their link median.
 
template<class EventPacket >
static void toa_vref_runs (Target *tgt, ROC &roc, size_t n_events, std::array< int, 2 > &target)
 
std::map< std::string, std::map< std::string, uint64_t > > toa_vref_scan (Target *tgt, ROC roc)
 Find TOA threshold voltage reference to align TOA values.
 
std::map< std::string, std::map< std::string, uint64_t > > tot_vref_scan (Target *tgt, ROC roc)
 Find TOT threshold voltage.
 
template<class EventPacket >
double eff_scan (Target *tgt, ROC &roc, int &channel, int &vref_value, size_t &n_events, auto &refvol_page, auto &buffer, int &i_link)
 
template<class EventPacket >
int global_vref_scan (Target *tgt, ROC &roc, int &channel, size_t &n_events, auto &refvol_page, auto &buffer, int &i_link)
 
template<class EventPacket >
int local_vref_scan (Target *tgt, ROC &roc, int &channel, int &vref_value, size_t &n_events, auto &refvol_page, auto &buffer, int &i_link)
 
template<class EventPacket >
std::array< int, 2 > tp50_scan (Target *tgt, ROC &roc, size_t &n_events, std::array< int, 72 > &calibs, std::array< int, 2 > &link_vref_list)
 Find TOT threshold voltage that corresponds to 50% efficiency for a given pulse.
 
template std::array< int, 2 > tp50_scan< pflib::packing::SingleROCEventPacket > (Target *tgt, ROC &roc, size_t &n_events, std::array< int, 72 > &calib, std::array< int, 2 > &link_vref_list)
 
template std::array< int, 2 > tp50_scan< pflib::packing::MultiSampleECONDEventPacket > (Target *tgt, ROC &roc, size_t &n_events, std::array< int, 72 > &calib, std::array< int, 2 > &link_vref_list)
 
template<class EventPacket >
static void trim_tof_runs (Target *tgt, ROC &roc, size_t n_events, std::array< std::array< std::array< double, 72 >, 8 >, 200 > &final_data)
 
std::map< std::string, std::map< std::string, uint64_t > > trim_toa_scan (Target *tgt, ROC roc)
 Find trim_toa to align TOA for each channel.
 
template<class EventPacket >
std::array< int, 72 > trim_tot_scan (Target *tgt, ROC &roc, size_t &n_events, std::array< int, 72 > &calibs, std::array< int, 2 > &tot_vrefs, std::array< int, 72 > &tot_trims)
 Find trim_toa to align TOA for each channel.
 
template std::array< int, 72 > trim_tot_scan< pflib::packing::SingleROCEventPacket > (Target *tgt, ROC &roc, size_t &n_events, std::array< int, 72 > &calibs, std::array< int, 2 > &tot_vrefs, std::array< int, 72 > &tot_trims)
 
template std::array< int, 72 > trim_tot_scan< pflib::packing::MultiSampleECONDEventPacket > (Target *tgt, ROC &roc, size_t &n_events, std::array< int, 72 > &calibs, std::array< int, 2 > &tot_vrefs, std::array< int, 72 > &tot_trims)
 

Detailed Description

housing of higher-level methods for repeatable tasks

Calculate the TRIM_TOA for each channel that best aligns all of them to a common threshold voltage, charge injection pulse (calib).

Note
Not currently operational, but a good place to pickup from.

Function Documentation

◆ get_adc_medians()

template<class EventPacket >
static std::array< int, 72 > pflib::algorithm::get_adc_medians ( const std::vector< EventPacket > & data)
static

get the medians of the channel ADC values

This may be helpful in some other contexts, but since it depends on the packing library it cannot go into utility. Just keeping it here for now, maybe move it into its own header/impl in algorithm.

Parameters
[in]databuffer of single-roc packet data
Returns
array of channel ADC values
Note
We assume the caller knows what they are doing. Calib and Common Mode channels are ignored. TOT/TOA and the sample Tp/Tc flags are ignored.

reserve a vector of the appropriate size to avoid repeating allocation time for all 72 channels

◆ get_calibs()

template<class EventPacket >
std::array< int, 72 > pflib::algorithm::get_calibs ( Target * tgt,
ROC & roc,
int & target_adc )

Find calib value where the max adc corresponds to a target value.

Parameters
[in]tgtpointer to Target to interact with roc for setting params target calib value

reserve a vector of the appropriate size to avoid repeating allocation time for all 72 channels

◆ get_toa_efficiencies()

template<class EventPacket >
std::array< double, 72 > pflib::algorithm::get_toa_efficiencies ( const std::vector< EventPacket > & data)

calculate the highest TOA_VREF value for each link, for which there is a non-zero TOA efficiency

reserve a vector of the appropriate size to avoid repeating allocation time for all 72 channels

we assume that the data provided is not empty otherwise the efficiency calculation is meaningless

◆ level_pedestals()

std::map< std::string, std::map< std::string, uint64_t > > pflib::algorithm::level_pedestals ( Target * tgt,
ROC roc )

Level pedestals so that they are all within noise of their link median.

Parameters
[in]tgtpointer to Target to interact with
Note
Only functional for single-ROC targets

do three runs of 100 samples each to have well defined pedestals

◆ pedestal_runs()

template<class EventPacket >
static void pflib::algorithm::pedestal_runs ( Target * tgt,
ROC & roc,
std::array< int, 72 > & baseline,
std::array< int, 72 > & highend,
std::array< int, 72 > & lowend,
std::array< int, 2 > & target,
size_t n_events )
static

TODO for multi-ROC set ups, we could dynamically determine the number

◆ toa_vref_scan()

std::map< std::string, std::map< std::string, uint64_t > > pflib::algorithm::toa_vref_scan ( Target * tgt,
ROC roc )

Find TOA threshold voltage reference to align TOA values.

Parameters
[in]tgtpointer to Target to interact with
Note
Only functional for single-ROC targets

do a run of 100 samples per toa_vref to measure the TOA efficiency when looking at pedestal data

◆ tot_vref_scan()

std::map< std::string, std::map< std::string, uint64_t > > pflib::algorithm::tot_vref_scan ( Target * tgt,
ROC roc )

Find TOT threshold voltage.

Parameters
[in]tgtpointer to Target to interact with
Note
Only functional for single-ROC targets

◆ tp50_scan()

template<class EventPacket >
std::array< int, 2 > pflib::algorithm::tp50_scan ( Target * tgt,
ROC & roc,
size_t & n_events,
std::array< int, 72 > & calibs,
std::array< int, 2 > & link_vref_list )

Find TOT threshold voltage that corresponds to 50% efficiency for a given pulse.

Parameters
[in]tgtpointer to Target to interact with roc calib: target calib tot_vref: previously set tot_vref
Note
Only functional for single-ROC targets

◆ trim_toa_scan()

std::map< std::string, std::map< std::string, uint64_t > > pflib::algorithm::trim_toa_scan ( Target * tgt,
ROC roc )

Find trim_toa to align TOA for each channel.

Parameters
[in]tgtpointer to Target to interact with
Note
Only functional for single-ROC targets

Charge injection scan (100 samples) while varying TRIM_TOA. Purpose is to align TRIM_TOA for each channel. Calculates TOA efficiency while looking at charge injection data. Then uses Siegel Linear Regression to calculate the aligned TRIM_TOA value for each channel to match a common "calib" value.

Note
Reduce the sample size (ex: 100 to 10) to decrease the scan time.

Now that we have the data, we need to analyze it.

We'll be looking for the turn-on (threshold) points for each channel at each trim_toa value. The turn-on (threshold) point is the first point where toa_efficiency goes from 0 to non-zero. The toa_efficiency is simply the number of times TOA triggers divided by the sample size, for a given trim_toa/calib/channel combination.

We'll be using the Siegel Linear Regression because it's less sensitive to outliers, since sometimes changing the trim_toa causes the threshold (turn-on) points to "wrap around".

◆ trim_tot_scan()

template<class EventPacket >
std::array< int, 72 > pflib::algorithm::trim_tot_scan ( Target * tgt,
ROC & roc,
size_t & n_events,
std::array< int, 72 > & calibs,
std::array< int, 2 > & tot_vrefs,
std::array< int, 72 > & tot_trims )

Find trim_toa to align TOA for each channel.

Parameters
[in]tgtpointer to Target to interact with
Note
Only functional for single-ROC targets