wavecatcher-analysis
Loading...
Searching...
No Matches
ReadRun Class Reference

#include <ReadRun.h>

Inheritance diagram for ReadRun:

Public Member Functions

TH1FBaselineCorrectionResults (int, int, float=-5, float=5, int=200)
 Histograms of the contents of baseline_correction_result.
 
void ChargeCorrelation (float, float, float, float, float, float, int, int, int, bool=false)
 Plot correlation of integrals/amplitudes between two channels.
 
floatChargeList (int, float=20, float=80, float=0, float=300, bool=1)
 Returns array with the individual "charge"/amplitude for all events of one channel.
 
TH1FChargeSpectrum (int, float, float, float=0, float=300, float=-50, float=600, int=750)
 Histogram of the "charge" spectrum for one channel.
 
void CorrectBaseline (float, float=-999)
 Baseline correction constant window.
 
void CorrectBaseline_function (TH1F *, float, float, int)
 Helper function called by CorrectBaseline()
 
void CorrectBaselineMin (int=100, double=0.5, int=0, int=0, int=2)
 Baseline correction using minimum sum ( \(\propto\) mean) in range for correction.
 
void CorrectBaselineMin (vector< float >, double=0, int=2, int=2)
 Baseline correction using minimum sum ( \(\propto\) mean) in range for correction.
 
void CorrectBaselineMinSlopeRMS (int=100, bool=false, double=0.5, int=0, int=0, int=2)
 Baseline correction method searching for non-monotonic, rather constant regions.
 
void CorrectBaselineMinSlopeRMS (vector< float >, double=0, int=2, int=3)
 Baseline correction method searching for non-monotonic, rather constant regions.
 
void FilterAll (double=.3, double=.9, double=.2)
 Filter all waveforms.
 
void FractionEventsAboveThreshold (float=4, bool=true, bool=true, double=0., double=0., bool=false)
 Find events with max/min above/below a certain threshold.
 
int GetChannelIndex (int)
 Match channel number (wavecatcher input channel) to channel index.
 
int GetCurrentChannel (int)
 Get the current channel index for a certain waveform index.
 
int GetCurrentEvent (int)
 Get the current event index for a certain waveform index.
 
int GetEventIndex (unsigned int)
 Returns index of a certain event number (if data files are read in parallel threads)
 
intGetIntWindow (TH1F *, float, float, float, float, int=0)
 Determine indices for integration window for peaks.
 
float GetPeakIntegral (TH1F *, float, float, float, float, int=0)
 Calculate the integral around a peak with several options explained in GetIntWindow().
 
void GetTimingCFD (float=.3, float=100, float=140, double=0., bool=true, int=2, bool=false)
 Determine the timing of the maximum peak with constant fraction discrimination.
 
TH1FGetwf (int)
 Helper that returns the waveform histogram for a certain waveform number number.
 
TH1FGetwf (int, int, int=1)
 Helper that returns the waveform histogram for a certain channel number and a certain event number.
 
doublegetx (double=0.)
 Get array of x axis (time) for standard wavecatcher settings.
 
doublegety (int)
 Get array of y values for a certain waveform.
 
doublegety (int, int)
 Get array of y values for a certain waveform.
 
TH1FHis_GetTimingCFD (int, float, float, int=-999)
 Plot results of GetTimingCFD()
 
TH1FHis_GetTimingCFD_diff (vector< int >, vector< int >, float, float, int=-999)
 Plot timing difference between the mean timings of two channel ranges.
 
void IntegralFilter (vector< float >, vector< bool >, float, float, float=50, float=250, bool=false, bool=false)
 Skip events with threshold on integral.
 
TGraph2DMaxDist (int, float=0, float=300)
 Finds maximum amplitude for a given channel in time window ["from", "to"] and creates 3d map of waveforms ordered by maxima.
 
int Nevents_good ()
 Number of good events that are not skipped.
 
bool PlotChannel (int)
 Check if a channel index should be plotted according to ReadRun::plot_active_channels.
 
void PlotChannelAverages (bool=false)
 Plot averages only of the good, corrected waveforms for each channel.
 
void PlotChannelSums (bool=false, bool=false, double=0., double=0., int=2)
 Plot sums of all raw waveforms for each channel.
 
void PlotWFHeatmaps (float=-20, float=200, int=880, string="", float=0, EColorPalette=kGistEarth)
 Plot stacks of all non-skipped waveforms for all active channels.
 
void Print_GetTimingCFD (float=100, float=140, int=0, int=-999, string="S", bool=true)
 Plot results of GetTimingCFD()
 
void Print_GetTimingCFD_diff (vector< int >, vector< int >, float=100, float=140, int=0, int=-999, float=-999, float=-999, string="RS", bool=true)
 Plot timing difference between the mean timings of two channel ranges.
 
void PrintBaselineCorrectionResults (float=-5, float=5, int=200)
 Print histogram of the baseline correction values for all channels.
 
void PrintChargeSpectrum (float, float, float=0, float=300, float=-50, float=600, int=750, float=0., float=0., int=99, int=0, bool=false)
 Plots the "charge" spectrums of all channels.
 
void PrintChargeSpectrumWF (float, float, float=0, float=300, int=1, float=0., float=0., float=0., float=0.)
 Plot waveforms of all channels for a given event number and add the determined integration windows to the plot.
 
void PrintDCR (float=15, float=85, float=0, float=300, double=3)
 Calculate (SiPM) dark count rate.
 
void PrintMaxDist (float=0, float=300)
 Finds maximum amplitude for a given channel in time window ["from", "to"] and creates 3d map of waveforms ordered by maxima.
 
void PrintSkippedEvents ()
 Prints a list of all skipped events into the terminal for diagnostics.
 
void PrintTimeDist (float=0, float=300, float=0, float=300, int=100, int=0, float=.3)
 Time distribution of maximum, CFD, or 10% - 90% rise time in a certain time window.
 
void PrintWFProjection (float=0, float=320, float=-50, float=50, int=200)
 Plots waveform projection histograms of all channels.
 
void ReadFile (string, bool=false, int=9, string="out.root", bool=false)
 Routine to read files created by the wavecatcher.
 
 ReadRun (int max_no_of_bin_files_to_read=0, int min_no_of_bin_files_to_read=0)
 Constructor of the class.
 
void SaveChargeLists (float=20, float=80, float=0, float=300, bool=1)
 Saves TGraphs to root file with the individual "charge"/amplitude for all events and all channels.
 
void ShiftAllToAverageCF ()
 This function shifts all waveforms to the average signal starting times for each channel.
 
void SkipEventsPerChannel (vector< float >, float=0, float=0, bool=false)
 Skip events above/below individual thresholds per channel.
 
void SkipEventsTimeDiffCut (int, int, double, double, bool=false)
 Skip events where the time difference between two channels is outside of specified range.
 
void SmoothAll (double, int)
 Smoothing all waveforms which are not skipped (for testing, careful when using for analysis!)
 
void SmoothAll (double, string="Gaus")
 Smoothing all waveforms which are not skipped (for testing, careful when using for analysis!)
 
TH1FTimeDist (int, float=0, float=300, float=0, float=300, int=100, int=0, float=.3)
 Time distribution of maximum, CFD, or 10% - 90% rise time in a certain time window.
 
void UnskipAll ()
 Sets skip_event flag to false for all events, removing any previous cuts.
 
TH2FWFHeatmapChannel (int, float=-20, float=200, int=880)
 2D histogram of all non-skipped waveforms for one channel
 
TH1FWFProjectionChannel (int, int=0, int=1024, float=-50, float=50, int=200)
 Waveform projections for one channel.
 
virtual ~ReadRun ()
 Destructor.
 

Static Public Member Functions

static pair< float, boolLinearInterpolation (float, float, float, float, float)
 Simple linear interpolation for x.
 

Public Attributes

vector< intactive_channels
 Stores the numbers of the active channels.
 
float ** amplValuessum
 Collects sums of all waveforms for each channel.
 
vector< vector< float > > baseline_correction_result
 Stores baseline correction results for CorrectBaseline() and related functions.
 
int binNumber = 1024
 Number of bins (always 1024 samples per waveform). Do not change!
 
float DAQ_factor = 250. / 4096.
 DAQ conversion factor for wavecatcher output to mV.
 
string data_path
 Path to data.
 
bool discard_original_eventnr = false
 Can be used to discard the original event numbering of the data.
 
int end_read_at_channel = -1
 See ReadRun::start_read_at_channel.
 
vector< unsigned inteventnr_storage
 Events will be stored here in the order they have been read.
 
vector< TFitResultPtrfit_results
 Stores the fit results of PrintChargeSpectrum() for all channels and all function calls in ascending order.
 
int MaxNoOfBinFilesToRead
 Number of last .bin file to be read in.
 
int maxNWF = 1e7
 Maximum possible number of waveforms in data: number of active channels x number of events.
 
intmaxSumBin
 Stores bin numbers where the sum of waveforms have their maximum.
 
vector< floatmean_integral
 Stores the mean integral/lightyield from PrintChargeSpectrum() for all channels.
 
int MinNoOfBinFilesToRead
 Number first of .bin file to be read in.
 
int nchannels
 Number of active channels in data.
 
int nChannelsWC = 64
 Wavecatcher hardware max. number of channels (reduce/increase if not using the 64 channel crate)
 
int nevents
 Number of triggered events in data.
 
int nwf
 Total number of waveforms read from data: number of active channels x number of events.
 
vector< intplot_active_channels
 Stores the numbers of the active channels which should be plotted.
 
vector< vector< float > > PrintChargeSpectrum_cal = vector(nChannelsWC, vector<float>(2, 1))
 Calibration values to normalize charge spectrum to number of photoelectrons Chennels must be ordered as in plot_active_channels.
The first entry must be the gain and the second the position of the pedestal.
 
vector< floatPrintChargeSpectrum_pars
 Starting values of the fit parameters for PrintChargeSpectrum()
 
TFileroot_out
 Stores results of analysis.
 
TClonesArrayrundata
 Stores data.
 
bool Shift_WFs_in_file_loop = false
 Shift waveforms with CFD so that all events start at the same time Call after initializing class and before calling ReadFile().
Set the constant fraction, the bin to shift the signal to, and the search window with tWF_CF, tWF_CF_bin, and tWF_CF_lo and tWF_CF_hi, respectively.
 
vector< boolskip_event
 Stores the event numbers which should be skipped in the analysis.
 
float SP = .3125
 Sampling: ns per bin of data, sampling rate 3.2 GS/s -> 0.3125 ns.
 
int start_read_at_channel = -1
 Do analysis only for limited range of channels to reduce memory usage.
 
vector< intswitch_polarity_for_channels
 Stores the channel number where the polarity should be inverted. Example use to switch polarity for channel 0 and channel 14: mymeas.switch_polarity_for_channels = {0, 14};. Needs to be called before ReadFile().
 
float tCutEndg
 End of time window for baseline correction when using ReadRun::Using_BaselineCorrection_in_file_loop.
 
float tCutg
 Start of time window for baseline correction when using ReadRun::Using_BaselineCorrection_in_file_loop.
 
vector< TFitResultPtrtiming_fit_results
 Stores the fit results of Print_GetTimingCFD() for all channels.
 
vector< vector< float > > timing_results
 Matrix to store timing of peaks from GetTimingCFD()
 
float tWF_CF = 0.3
 Constant fraction of maximum (between ~0.1 and 1) for ReadRun::Shift_WFs_in_file_loop.
 
int tWF_CF_bin = 375
 Time bin all events will be shifted to for ReadRun::Shift_WFs_in_file_loop Needs to be 300<"tWF_CF_bin"<500 ("tWF_CF_bin"=375 means all peaks will be shifted to 375*.3125 ns=117.1875 ns)
 
int tWF_CF_hi = 500
 End of range of bins where the signal is expected for ReadRun::Shift_WFs_in_file_loop.
 
int tWF_CF_lo = 320
 Start of range of bins where the signal is expected for ReadRun::Shift_WFs_in_file_loop.
 
bool Using_BaselineCorrection_in_file_loop = false
 Set true for baseline correction during data reading. Needs to be called before ReadFile().
 

Protected Member Functions

void checkData () const
 Primitive check to see if data has been loaded.
 

Detailed Description

Examples
read_exampledata.cc, and timing_example.cc.

Definition at line 57 of file ReadRun.h.

Constructor & Destructor Documentation

◆ ReadRun()

ReadRun::ReadRun ( int  max_no_of_bin_files_to_read = 0,
int  min_no_of_bin_files_to_read = 0 
)

Constructor of the class.

Parameters
max_no_of_bin_files_to_readNumber of last .bin file to be read in.
Set it to =>1 in order to constrain the number of .bin files to be read from the target folder.
Intended for quick tests on a fraction of the full dataset or for batch reading if combined with min_no_of_bin_files_to_read.
min_no_of_bin_files_to_readNumber first of .bin file to be read in.
Can be used to batch read large datasets in chunks of files.

Definition at line 24 of file ReadRun.cc.

◆ ~ReadRun()

ReadRun::~ReadRun ( )
virtual

Destructor.

Definition at line 376 of file ReadRun.cc.

Member Function Documentation

◆ BaselineCorrectionResults()

TH1F * ReadRun::BaselineCorrectionResults ( int  channel_index,
int  which,
float  rangestart = -5,
float  rangeend = 5,
int  nbins = 200 
)

Histograms of the contents of baseline_correction_result.

See PrintBaselineCorrectionResults() for parameters.

Returns
Histogram for one channel.

Definition at line 1118 of file ReadRun.cc.

◆ ChargeCorrelation()

void ReadRun::ChargeCorrelation ( float  windowlow,
float  windowhi,
float  start,
float  end,
float  rangestart,
float  rangeend,
int  nbins,
int  channel1,
int  channel2,
bool  ignore_skipped_events = false 
)

Plot correlation of integrals/amplitudes between two channels.

See GetIntWindow() and PrintChargeSpectrum() for parameters.

Integrals of the signals of two channels for each event plottet against each other. A clear correlation is visible: On average, if channel 2 records a large signal also channel 3 records a large signal. Around (0,0) the correlation of the pedestals can be seen (no signal in both channels). Code in example.
Parameters
windowlowIntegrate from "windowlow" ns from max...
windowhi...to "windowhi" ns from max.
startFind max from "start" in ns...
end...to "end" in ns.
rangestartPlot x & y range start
rangeendPlot x & y range end
nbinsNumber of x & y bins of the histogram
channel1First channel number to compare
channel2second channel number to compare
ignore_skipped_eventsSet true to plot only events which passed filtering, else all events will be plotted
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 1765 of file ReadRun.cc.

◆ ChargeList()

float * ReadRun::ChargeList ( int  channel_index,
float  windowlow = 20,
float  windowhi = 80,
float  start = 0,
float  end = 300,
bool  negative_vals = 1 
)

Returns array with the individual "charge"/amplitude for all events of one channel.

See SaveChargeLists() and GetIntWindow().

Parameters
channel_indexIndex of the channel.
windowlowIntegrate from "windowlow" ns from max...
windowhi...to "windowhi" ns from max.
startFind max from "start" in ns...
end...to "end" in ns.
negative_valsIf true will save negative values. If false will set negative values to 0.

Definition at line 1697 of file ReadRun.cc.

◆ ChargeSpectrum()

TH1F * ReadRun::ChargeSpectrum ( int  channel_index,
float  windowlow,
float  windowhi,
float  start = 0,
float  end = 300,
float  rangestart = -50,
float  rangeend = 600,
int  nbins = 750 
)

Histogram of the "charge" spectrum for one channel.

See PrintChargeSpectrum() for parameters.

Returns
Histogram for one channel.

Definition at line 1807 of file ReadRun.cc.

◆ checkData()

void ReadRun::checkData ( ) const
inlineprotected

Primitive check to see if data has been loaded.

Definition at line 113 of file ReadRun.h.

◆ CorrectBaseline()

void ReadRun::CorrectBaseline ( float  tCut,
float  tCutEnd = -999 
)

Baseline correction constant window.

Corrects the baseline (DC offset) of all waveforms.
Uses the mean between t=0 and t="tCut" or between t="tCut" and t="tCutEnd" as offset.
Call method before ReadFile() if you want it to happen while reading.

Most simple and fast method.
Useful for measurements with very few background events/dark counts.
Using a constant window for the baseline means there might be a background pulse which would lead to wrong correction.

Stores results for all channels and all events in ReadRun::baseline_correction_result.
Results will be visualized for each event in PrintChargeSpectrumWF().

Parameters
tCutTime denoting the end or the beginning (if "tCutEnd" is set) of the integration window.
tCutEndTime denoting the end of the integration window.

Definition at line 707 of file ReadRun.cc.

◆ CorrectBaseline_function()

void ReadRun::CorrectBaseline_function ( TH1F his,
float  tCut,
float  tCutEnd,
int  nwaveform 
)

Helper function called by CorrectBaseline()

See CorrectBaseline()

Definition at line 730 of file ReadRun.cc.

◆ CorrectBaselineMin() [1/2]

void ReadRun::CorrectBaselineMin ( int  nIntegrationWindow = 100,
double  sigma = 0.5,
int  max_bin_for_baseline = 0,
int  start_at = 0,
int  smooth_method = 2 
)

Baseline correction using minimum sum ( \(\propto\) mean) in range for correction.

This is a deprecated version of CorrectBaselineMin. It will be removed in future releases.
Corrects the baseline (DC offset) of all waveforms.
Searches for

\(\mathbf{min}\left( \sum y_i \right) \)

in range {"start_at", "max_bin_for_baseline"}, summing over "nIntegrationWindow" bins.
Make sure the search range is shortly before the triggered signal is expected to arrive.

Helpful for (groups of/irradiated) SiPMs with very high dark count rate (DCR) where the voltage rarely relaxes back to the constant baseline before the next dark count/signal arrives:
\( \Rightarrow DCR \sim 1/t_{signal} \)

Stores results for all channels and all events in ReadRun::baseline_correction_result.
Results will be visualized for each event in PrintChargeSpectrumWF().

Parameters
nIntegrationWindowNumber of bins used for baseline correction. The correction factor will be the signal averaged over this number bins.
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns for gauss kernel and convolution. Set to 0 for no smoothing. Use with care!
max_bin_for_baselineMaximum bin for search window.
start_atMinimum bin for search window.
smooth_method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.

Definition at line 1035 of file ReadRun.cc.

◆ CorrectBaselineMin() [2/2]

void ReadRun::CorrectBaselineMin ( vector< float window,
double  sigma = 0,
int  smooth_method = 2,
int  increment = 2 
)

Baseline correction using minimum sum ( \(\propto\) mean) in range for correction.

Corrects the baseline (DC offset) of all waveforms.
Searches for

\(\mathbf{min}\left( \sum y_i \right) \)

in range {window[1], window[2]}, summing over window[0] ns.
Make sure the search range is shortly before the triggered signal is expected to arrive.

Helpful for (groups of/irradiated) SiPMs with very high dark count rate (DCR) where the voltage rarely relaxes back to the constant baseline before the next dark count/signal arrives:
\( \Rightarrow DCR \sim 1/t_{signal} \)

Stores results for all channels and all events in ReadRun::baseline_correction_result.
Results will be visualized for each event in PrintChargeSpectrumWF().

Parameters
windowVector containing {length for averaging, search start, search end} in ns. Example: {20, 10, 90} would search for the best baseline candidate from 10 ns to 90 ns, averaging over 20 ns.
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns for gauss kernel and convolution. Set to 0 for no smoothing. Use with care!
smooth_method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.
incrementIncrement for search in bins per step. Default value is 3 (=0.9375 ns).
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 938 of file ReadRun.cc.

◆ CorrectBaselineMinSlopeRMS() [1/2]

void ReadRun::CorrectBaselineMinSlopeRMS ( int  nIntegrationWindow = 100,
bool  smooth = false,
double  sigma = 0.5,
int  max_bin_for_baseline = 0,
int  start_at = 0,
int  smooth_method = 2 
)

Baseline correction method searching for non-monotonic, rather constant regions.

This is a deprecated version of CorrectBaselineMinSlopeRMS. It will be removed in future releases.

Corrects the baseline (DC offset) of all waveforms.
Determines the region of "nIntegrationWindow" bins where the squared sum plus the square of the sum of the slope of the (smoothed) waveform reaches its minimum:

\(\mathbf{min}\left( \sum \left(\Delta y_i \right)^2 + \left(\sum \Delta y_i \right)^2 \right) \)

Here, \(\sum \left(\Delta y_i \right)^2 \to 0\) if the region is constant and \(\left( \sum \Delta y_i \right)^2 \to 0\) if the region is constant or oscillating around a constant value. The second term penalizes monotonic regions with a small, but rather constant slope (e. g. tails).

Slow, but versatile since it searches for the optimal baseline candidate region in a defined range.
Will prefer constant sections of the waveform for the estimation of the baseline.
Not well suited if there is not constant baseline in the signal, which can happen if the dark count rate is so high that dark counts overlap (e. g. an array of SiPMs) or if the baseline level fluctuates. In such a case use CorrectBaselineMin()

Stores results for all channels and all events in ReadRun::baseline_correction_result.
Results will be visualized for each event in PrintChargeSpectrumWF().

Parameters
nIntegrationWindowNumber of bins used for baseline correction. The correction factor will be the signal averaged over this number bins.
smoothDeprecated! If true will apply smoothing to all waveforms. This will change all waveforms, which should rather be done with SmoothAll().
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns for gauss kernel and convolution. Set to 0 for no smoothing. Use with care!
max_bin_for_baselineMaximum bin for search window.
start_atMinimum bin for search window.
smooth_method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.

Definition at line 902 of file ReadRun.cc.

◆ CorrectBaselineMinSlopeRMS() [2/2]

void ReadRun::CorrectBaselineMinSlopeRMS ( vector< float window,
double  sigma = 0,
int  smooth_method = 2,
int  increment = 3 
)

Baseline correction method searching for non-monotonic, rather constant regions.

Corrects the baseline (DC offset) of all waveforms.
Determines the region of window[0] ns between window[1] ns and window[2] ns where the squared sum plus the square of the sum of the slope of the (smoothed) waveform reaches its minimum:

\(\mathbf{min}\left( \sum \left(\Delta y_i \right)^2 + \left(\sum \Delta y_i \right)^2 \right) \)

Here, \(\sum \left(\Delta y_i \right)^2 \to 0\) if the region is constant and \(\left( \sum \Delta y_i \right)^2 \to 0\) if the region is constant or oscillating around a constant value. The second term penalizes monotonic regions with a small, but rather constant slope (e. g. tails).

Slow, but versatile since it searches for the optimal baseline candidate region in a defined range.
Will prefer constant sections of the waveform for the estimation of the baseline.
Not well suited if there is not constant baseline in the signal, which can happen if the dark count rate is so high that dark counts overlap (e. g. an array of SiPMs) or if the baseline level fluctuates. In such a case use CorrectBaselineMin()

Stores results for all channels and all events in ReadRun::baseline_correction_result.
Results will be visualized for each event in PrintChargeSpectrumWF().

Parameters
windowVector containing {length for averaging, search start, search end} in ns. Example: {20, 10, 90} would search for the best baseline candidate from 10 ns to 90 ns, averaging over 20 ns.
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns for gauss
smooth_method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.
incrementIncrement for search in bins per step. Default value is 3 (=0.9375 ns).
Examples
read_exampledata.cc.

Definition at line 784 of file ReadRun.cc.

◆ FilterAll()

void ReadRun::FilterAll ( double  sigma1 = .3,
double  sigma2 = .9,
double  factor = .2 
)

Filter all waveforms.

Experimental. See Filters::ResponseFilter() or Filters::SecondOrderUnderdampedFilter().

Parameters
sigma1First.
sigma2Second.
factorFactor for negative part (0 < factor < 1).

Definition at line 641 of file ReadRun.cc.

◆ FractionEventsAboveThreshold()

void ReadRun::FractionEventsAboveThreshold ( float  threshold = 4,
bool  max = true,
bool  greater = true,
double  from = 0.,
double  to = 0.,
bool  verbose = false 
)

Find events with max/min above/below a certain threshold.

Needs to be called before the charge spectrum etc functions.
Baseline correction should be called before this function.

Parameters
thresholdThreshold in mV.
maxIf true uses max, else uses min.
greaterIf true looks for events with max/min>threshold, else looks for events with max/min<threshold.
fromStart search at "from" in ns.
toEnd search at "to" in ns.
verboseSet true for extra verbosity.

Definition at line 1328 of file ReadRun.cc.

◆ GetChannelIndex()

int ReadRun::GetChannelIndex ( int  channel_number)

Match channel number (wavecatcher input channel) to channel index.

Parameters
channel_numberNumber of the channel as defined in the wavecatcher software
Returns
Corresponding index for this channel

Definition at line 2615 of file ReadRun.cc.

◆ GetCurrentChannel()

int ReadRun::GetCurrentChannel ( int  waveform_index)

Get the current channel index for a certain waveform index.

Parameters
waveform_index
Returns
Current channel index

Definition at line 2630 of file ReadRun.cc.

◆ GetCurrentEvent()

int ReadRun::GetCurrentEvent ( int  waveform_index)

Get the current event index for a certain waveform index.

Parameters
waveform_index
Returns
Current event index

Definition at line 2637 of file ReadRun.cc.

◆ GetEventIndex()

int ReadRun::GetEventIndex ( unsigned int  eventnr)

Returns index of a certain event number (if data files are read in parallel threads)

Parameters
eventnrEvent number as stored in the data.
Returns
Corresponding event number in the internal data structure.

Definition at line 2597 of file ReadRun.cc.

◆ GetIntWindow()

int * ReadRun::GetIntWindow ( TH1F his,
float  windowlow,
float  windowhi,
float  start,
float  end,
int  channel = 0 
)

Determine indices for integration window for peaks.

Default usage: Find maximum in range ("start", "end") and return bin numbers for [0] the max, [1] t_max - "windowlow", and [2] t_max + "windowhi".
If ("start" < 0 || "end" < 0) doesn't return max and integration window is fixed relative to the maximum of the sum of all waveforms:
t(max(sum_spectrum[channel])) +/- "windowhi"/"windowlow"
If ("windowlow" == "start" && "windowhi" == "end") doesn't return max and sets fixed integration window from "start" until "end" for all channels.

Parameters
hisHistogram to integrate.
windowlowIntegration time left to the maximum of the peak.
windowhiIntegration time right to the maximum of the peak.
startRange for finding maximum.
endRange for finding maximum.
channelChannel index in case the integration should be around the maximum of the sum of all waveforms
Returns
Array { max, \( n_{t,start} \) , \( n_{t,end} \) }

Definition at line 1534 of file ReadRun.cc.

◆ GetPeakIntegral()

float ReadRun::GetPeakIntegral ( TH1F his,
float  windowlow,
float  windowhi,
float  start,
float  end,
int  channel_index = 0 
)

Calculate the integral around a peak with several options explained in GetIntWindow().

Calculated over an integer number of bins.
If start = end = 0 will return the amplitude of the peak.
If start < 0 || end < 0 will return the integral over the fixed integration window around the maximum of the sum spectrum for each channel.
If windowlow == start && windowhi == end will return the integral over the fixed integration window for all channels.

Parameters
hisHistogram with peak.
windowlowIntegration time left to the maximum of the peak.
windowhiIntegration time right to the maximum of the peak.
startRange for finding maximum.
endRange for finding maximum.
channel_indexChannel index in case the integration should be around the maximum of the sum of all waveforms.
Returns
Integral/amplitude.

Definition at line 1588 of file ReadRun.cc.

◆ GetTimingCFD()

void ReadRun::GetTimingCFD ( float  cf_r = .3,
float  start_at_t = 100,
float  end_at_t = 140,
double  sigma = 0.,
bool  find_CF_from_start = true,
int  smooth_method = 2,
bool  use_spline = false 
)

Determine the timing of the maximum peak with constant fraction discrimination.

Determines timing in the time interval ["start_at_t", "end_at_t"] with CFD for fraction of maximum "cf_r".
Stores timing information for all channels and all events in ReadRun::timing_results.
Per event results will be visualized in PrintChargeSpectrumWF().
Cumulative per channel results can be visualized with Print_GetTimingCFD().
Results can be used for time difference cuts with SkipEventsTimeDiffCut().

Parameters
cf_rFraction of maximum for CFD.
If set > 1 it will be used as a fixed threshold in mV, so it will no longer use CFD.
start_at_tTime in ns to start searching.
end_at_tTime in ns to end searching.
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns for gauss kernel and convolution. This will bias the results! Do not use (or use very carefully, only for noisy data)! Set to 0 if you do not want to use smoothing.
find_CF_from_startIf true will start search from "start_at_t" to find the first arriving photon (default setting).
If false search backwards from the time of the maximum.
smooth_method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.
use_splineIf false will use linear interpolation between the two bins closest to cf_r.
If true will use a 5th order spline and bisection method for interpolation. Performs a bit better in most cases compared to only linear interpolation.
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 1188 of file ReadRun.cc.

◆ Getwf() [1/2]

TH1F * ReadRun::Getwf ( int  wf_nr)

Helper that returns the waveform histogram for a certain waveform number number.

Parameters
wf_nrWaveform number
Returns
Waveform histogram

Definition at line 2547 of file ReadRun.cc.

◆ Getwf() [2/2]

TH1F * ReadRun::Getwf ( int  channelnr,
int  eventnr,
int  color = 1 
)

Helper that returns the waveform histogram for a certain channel number and a certain event number.

Parameters
channelnrChannel number index (not the actual channel number)
eventnrEvent number
colorChoose color of histogram
Returns
Waveform histogram

Definition at line 2557 of file ReadRun.cc.

◆ getx()

double * ReadRun::getx ( double  shift = 0.)

Get array of x axis (time) for standard wavecatcher settings.

Parameters
shiftOffset
Returns
Time array

Definition at line 2569 of file ReadRun.cc.

◆ gety() [1/2]

double * ReadRun::gety ( int  waveform_index)

Get array of y values for a certain waveform.

Parameters
waveform_indexWaveform index
Returns
Y values of waveform

Definition at line 2580 of file ReadRun.cc.

◆ gety() [2/2]

double * ReadRun::gety ( int  channelnr,
int  eventnr 
)

Get array of y values for a certain waveform.

Parameters
channelnrChannel number index (not the actual channel number)
eventnrEvent number
Returns
Y values of waveform

Definition at line 2589 of file ReadRun.cc.

◆ His_GetTimingCFD()

TH1F * ReadRun::His_GetTimingCFD ( int  channel_index,
float  rangestart,
float  rangeend,
int  nbins = -999 
)

Plot results of GetTimingCFD()

See Print_GetTimingCFD() for parameters.

Returns
Timing histogram for one channel

Definition at line 2277 of file ReadRun.cc.

◆ His_GetTimingCFD_diff()

TH1F * ReadRun::His_GetTimingCFD_diff ( vector< int channels1,
vector< int channels2,
float  rangestart,
float  rangeend,
int  nbins = -999 
)

Plot timing difference between the mean timings of two channel ranges.

See Print_GetTimingCFD_diff() for parameters.

Returns
Histogram with event-wise timing differences between two channel ranges

Definition at line 2350 of file ReadRun.cc.

◆ IntegralFilter()

void ReadRun::IntegralFilter ( vector< float thresholds,
vector< bool highlow,
float  windowlow,
float  windowhi,
float  start = 50,
float  end = 250,
bool  use_AND_condition = false,
bool  verbose = false 
)

Skip events with threshold on integral.

Compare with SkipEventsPerChannel()
Needs to be called before the charge spectrum etc functions in order to have an effect on them.
Baseline correction should be called before this function.

Parameters
thresholdsVector should contain a threshold for each active channel saved in the data, in ascending order (ch0, ch1 ...). Negative thresholds mean events below threshold will be cut. A threshold of 0 means the channel will not be evaluated. If only one value is given this value will be used for all active channels.
highlowVector should contain a bool for each active channel. True means events with integrals above threshold will be cut, false means below threshold. If only one value is given this value will be used for all active channels.
windowlowIntegration time left to the maximum of the peak.
windowhiIntegration time right to the maximum of the peak.
startRange for finding maximum.
endRange for finding maximum.
use_AND_conditionIf set true it will overrule previously applied cuts and un-skip events that pass integral criterium.
verboseSet true for extra verbosity.
Examples
read_exampledata.cc, timing_example.cc, and timing_example_rebin.cc.

Definition at line 1443 of file ReadRun.cc.

◆ LinearInterpolation()

pair< float, bool > ReadRun::LinearInterpolation ( float  ym,
float  x1,
float  x2,
float  y1,
float  y2 
)
static

Simple linear interpolation for x.

Will return the mean of x1 and x2 if y1=y2.

Parameters
ymY value for evaluation
x1X1
x2X2
y1Y1
y2Y2
Returns
x value at "ym"

Definition at line 2658 of file ReadRun.cc.

◆ MaxDist()

TGraph2D * ReadRun::MaxDist ( int  channel_index,
float  from = 0,
float  to = 300 
)

Finds maximum amplitude for a given channel in time window ["from", "to"] and creates 3d map of waveforms ordered by maxima.

Use PrintMaxDist() to plot all channels. Use only for small datasets as it will contain all of the data

Returns
TGraph2D of all histograms ordered by maximum amplitude

Definition at line 2227 of file ReadRun.cc.

◆ Nevents_good()

int ReadRun::Nevents_good ( )

Number of good events that are not skipped.

Definition at line 1510 of file ReadRun.cc.

◆ PlotChannel()

bool ReadRun::PlotChannel ( int  i)

Check if a channel index should be plotted according to ReadRun::plot_active_channels.

Parameters
iChannel index.

Definition at line 2643 of file ReadRun.cc.

◆ PlotChannelAverages()

void ReadRun::PlotChannelAverages ( bool  normalize = false)

Plot averages only of the good, corrected waveforms for each channel.

Similar to PlotChannelSums(), but will average all non-skipped waveforms.
Can be used to inspect average waveforms after baseline correction etc. has been applied. To do so, call function after calling correction and event filter functions.

This function plots the sum of all non-skipped waveforms for each channel, with corrections. Compare with the result for PlotChannelSums(). Code in example.
Parameters
normalizeIf true will normalize the maximum to 1.
Examples
read_exampledata.cc, timing_example.cc, and timing_example_rebin.cc.

Definition at line 454 of file ReadRun.cc.

◆ PlotChannelSums()

void ReadRun::PlotChannelSums ( bool  smooth = false,
bool  normalize = false,
double  shift = 0.,
double  sigma = 0.,
int  smooth_method = 2 
)

Plot sums of all raw waveforms for each channel.

To plot the average waveforms after baseline correction etc. use PlotChannelAverages().

This function plots the sum of all waveforms for each channel, without any corrections. Channel 9 was measured with an offset as visible here. Code in example.
Parameters
smoothIf true it will apply smoothing to plots.
Do not use without very good reason as it biases the results.
normalizeIf true will normalize the maximum to 1.
shiftShift histogram by "shift" ns
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns for gauss kernel and convolution.
smooth_method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.
Examples
read_exampledata.cc.

Definition at line 396 of file ReadRun.cc.

◆ PlotWFHeatmaps()

void ReadRun::PlotWFHeatmaps ( float  ymin = -20,
float  ymax = 200,
int  n_bins_y = 880,
string  z_opt = "",
float  z_max = 0,
EColorPalette  palette = kGistEarth 
)

Plot stacks of all non-skipped waveforms for all active channels.

Classical SiPM dark count/calibration plot in the style of a phosphor oscilloscope screen.
Helpful to see the prevalence of certain signal/baseline shapes etc.
Take care not to plot too many channels at once to maintain visibility and performance (-> ReadRun::plot_active_channels).

Waveforms of all events filled into a single histogram. Code in example.
Parameters
yminMin. y range
ymaxMax. y range
n_bins_yNumber of bins along y
z_opt"log": Set z logarithmic.
"COLZ0": Do not plot bins with zero entries.
z_maxMax. z range. Set to zero to use auto range (default).
paletteRoot color palette (see https://root.cern.ch/doc/master/classTColor.html).
Examples
read_exampledata.cc.

Definition at line 556 of file ReadRun.cc.

◆ Print_GetTimingCFD()

void ReadRun::Print_GetTimingCFD ( float  rangestart = 100,
float  rangeend = 140,
int  do_fit = 0,
int  nbins = -999,
string  fitoption = "S",
bool  set_errors = true 
)

Plot results of GetTimingCFD()

Beginning of the signals for all good events determined with constant fraction discrimination. The red lines are gauss functions fitted to the distrutions. Code in example.
Parameters
rangestartStart of x range for plot in ns.
rangeendEnd of x range for plot in ns.
do_fitIf 1: fits a gaussian.
Else do not fit.
Fit results per channel are stored in ReadRun::timing_fit_results.
nbinsNumber of bins for histogram. Will use 320 MHz sampling rate for binning if nbins = -999.
fitoptionROOT fit option, default is "S". See Fit(): https://root.cern/doc/master/classTH1.html
set_errorsAssign errors to the bins. Will assign errors of 1 to empty bins and \( \sqrt(N) \) if they are not empty. Can improve the chi^2 fit.
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 2300 of file ReadRun.cc.

◆ Print_GetTimingCFD_diff()

void ReadRun::Print_GetTimingCFD_diff ( vector< int channels1,
vector< int channels2,
float  rangestart = 100,
float  rangeend = 140,
int  do_fit = 0,
int  nbins = -999,
float  fitrangestart = -999,
float  fitrangeend = -999,
string  fitoption = "RS",
bool  set_errors = true 
)

Plot timing difference between the mean timings of two channel ranges.

Plots the difference between the peak times between the mean times of two ranges of channels for each event.
It calculates \( \Delta t = <t_{second,i}> - <t_{first,i}> \) .


The vectors of channels to compare are added with curly brackets:

‍mymeas.Print_GetTimingCFD_diff({ 26, 14 }, { 19 }, 0, 20, 2, 200);

would plot \( \Delta t = t_{ch19} - (t_{ch26} + t_{ch14})/2 \) from 0 ns to 20 ns with 200 bins (100 ps bin width). Another example is given in the plot below.

Event-wise time differences of the start of the signals of two channels. Code in example.
Parameters
channels1Vector of first channel numbers (wavecatcher channel numbers).
channels2Vector of second channel numbers to compare.
rangestartStart of x range for plot in ns.
rangeendEnd of x range for plot in ns.
do_fitIf 1: Fit a gaussian.
If 2: Fit a gaussian-exponential convolution (Fitf_exp_gauss) to account for different arrival times of photons due to different possible light paths in the scintillator/light guide
and/or delay due to self-absorption and reemission of photons in the scintillator.
To be used for long light paths in the scintillator. See https://doi.org/10.1016/S0029-554X(79)90170-8 .
This option only works for sufficient asymmetry \(\tau > \sigma/2\). Otherwise, the exponential decay time becomes too small to be fitted.
If the asymmetry is too small (skewness<0.15) option 1 will be used by default.
If 3: Fits the sum of two gaussians where the second gauss serves as a rough background estimate. Background means events that should have been filtered out.
Else: Do not fit.
nbinsNumber of bins for histogram.
fitrangestartStart of fitting range.
fitrangeendEnd of fitting range.
fitoptionROOT fitting option. Default is "RS" (chi^2). You can try to use the likelihood method with "LRS" if the data is very clean. Outliers will influence the results for the likelihood method so it is advisable to limit the fit range to exclude outliers for "LRS".
set_errorsAssign errors to the bins. Will assign errors of 1 to empty bins and \( \sqrt(N) \) if they are not empty. Can improve the chi^2 fit.
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 2438 of file ReadRun.cc.

◆ PrintBaselineCorrectionResults()

void ReadRun::PrintBaselineCorrectionResults ( float  rangestart = -5,
float  rangeend = 5,
int  nbins = 200 
)

Print histogram of the baseline correction values for all channels.

Currently only optimized for the correction values themselves.

Parameters
rangestartPlot x range start.
rangeendPlot x range end.
nbinsNumber of bins in range.
Examples
timing_example.cc.

Definition at line 1138 of file ReadRun.cc.

◆ PrintChargeSpectrum()

void ReadRun::PrintChargeSpectrum ( float  windowlow,
float  windowhi,
float  start = 0,
float  end = 300,
float  rangestart = -50,
float  rangeend = 600,
int  nbins = 750,
float  fitrangestart = 0.,
float  fitrangeend = 0.,
int  max_channel_nr_to_fit = 99,
int  which_fitf = 0,
bool  use_log_y = false 
)

Plots the "charge" spectrums of all channels.

Integrate all pulses in range ("start", "end") from t_max - "windowlow" to t_max + "windowhi" for a given channel and return the charge histogram with x range ("rangestart", "rangeend") and the number of bins "nbins".
It is not really charge, but either amplitude (mV) or integral (mV x ns). See ChargeSpectrum() and GetIntWindow().
Can be normalised to the number of photoelectrons by defining the calibration values in PrintChargeSpectrum_cal.

Simple example of the integrated signals for a single channel. The resulting integrated signals are fitted with a Landau-Gauss convolution (-> energy deposition of a minimum ionizing particle in a thin absorber). Code in example.
Integrated signals for a SiPM in blue and a fit with the fit function Fitf for SiPMs missing after-pulses and dark counts in red. The spectrum is not well fit by the simplified model. You can try different fit models in the example cosmics-fit.ipynb.
Parameters
windowlowIntegrate from "windowlow" ns from max...
windowhi...to "windowhi" ns from max.
startFind max from "start" in ns...
end...to "end" in ns.
rangestartPlot x range start
rangeendPlot x range end
nbinsNumber of bins of histogram
fitrangestartFit range start
fitrangeendFit range end
max_channel_nr_to_fitFit only channels with index < "max_channel_nr_to_fit". Set to -1 to skip fitting.
which_fitfChoose fit function:
0 - do not fit
1 - Fitf_langaus: landau gauss convolution for large number of photons
2 - Fitf_biased: if pedestal is biased because of peak finder algorithm
3 - Fitf_full: SiPM fit function with exponential delayed after pulsing
4 - Fitf_PMT_ideal: ideal PMT fit function
5 - Fitf_PMT: PMT fit function
6 - Fitf_PMT_pedestal: PMT fit function with biased pedestal
7 - Fitf_plus_DC: default SiPM fit function + dark count spectrum (for lots of false triggers)
else - Fitf: default SiPM fit function
use_log_ySet all y axes to log scale (for dark count spectra)
Examples
read_exampledata.cc, timing_example.cc, and timing_example_rebin.cc.

Definition at line 1861 of file ReadRun.cc.

◆ PrintChargeSpectrumWF()

void ReadRun::PrintChargeSpectrumWF ( float  windowlow,
float  windowhi,
float  start = 0,
float  end = 300,
int  eventnr = 1,
float  ymin = 0.,
float  ymax = 0.,
float  xmin = 0.,
float  xmax = 0. 
)

Plot waveforms of all channels for a given event number and add the determined integration windows to the plot.

See GetIntWindow() for explanation of parameters.
Will also add CFD timing if GetTimingCFD() was called before.

image html PrintChargeSpectrumWF.png "Waveforms in all channels for a single event. Code in example."

Parameters
windowlowIntegrate from "windowlow" ns from max...
windowhi...to "windowhi" ns from max.
startFind max from "start" in ns...
end...to "end" in ns.
eventnrEvent number
yminY axis minimum
ymaxY axis maximum
xminX axis maximum
xmaxX axis maximum
Examples
read_exampledata.cc, timing_example.cc, and timing_example_rebin.cc.

Definition at line 1613 of file ReadRun.cc.

◆ PrintDCR()

void ReadRun::PrintDCR ( float  windowlow = 15,
float  windowhi = 85,
float  rangestart = 0,
float  rangeend = 300,
double  threshold = 3 
)

Calculate (SiPM) dark count rate.

See PrintChargeSpectrum() for parameters.

Parameters
threshold1.5 photoelectron threshold

Definition at line 2103 of file ReadRun.cc.

◆ PrintMaxDist()

void ReadRun::PrintMaxDist ( float  from = 0,
float  to = 300 
)

Finds maximum amplitude for a given channel in time window ["from", "to"] and creates 3d map of waveforms ordered by maxima.

Prints MaxDist() for all channels. Use only for small datasets as it will contain all of the data

Parameters
fromFrom
toTo

Definition at line 2254 of file ReadRun.cc.

◆ PrintSkippedEvents()

void ReadRun::PrintSkippedEvents ( )

Prints a list of all skipped events into the terminal for diagnostics.

Definition at line 1491 of file ReadRun.cc.

◆ PrintTimeDist()

void ReadRun::PrintTimeDist ( float  from = 0,
float  to = 300,
float  rangestart = 0,
float  rangeend = 300,
int  nbins = 100,
int  which = 0,
float  cf_r = .3 
)

Time distribution of maximum, CFD, or 10% - 90% rise time in a certain time window.

Find peak time for a given channel in time window ["from", "to"] and return the peak time histogram with x range ["rangestart", "rangeend"] and the number of bins "nbins".
Plots TimeDist() for all channels.


For CFD it is advised to use GetTimingCFD() with Print_GetTimingCFD() instead of this function.

Parameters
fromStart of time interval in ns
toEnd of time interval in ns
rangestartStart of x range of histogram
rangeendEnd of x range of histogram
nbinsNumber of bins of histogram
whichOptions:
0 - Gives time of maximum.
1 - Gives constant fraction discrimination with fraction "cf_r" of maximum, searching backwards from the maximum until "from".
else - gives the 10% - 90% rise time.
cf_rFraction of max for CFD.
Examples
read_exampledata.cc.

Definition at line 2191 of file ReadRun.cc.

◆ PrintWFProjection()

void ReadRun::PrintWFProjection ( float  from = 0,
float  to = 320,
float  rangestart = -50,
float  rangeend = 50,
int  nbins = 200 
)

Plots waveform projection histograms of all channels.

Useful to check baseline correction. Will show if the baseline correction works as intended (gaussian shape) or if the standard deviation of the baseline is too large.

An asymmetry in the distribution might point to many dark counts in the window or a bad choice of parameters for the baseline correction. In that case the baseline correction should be revisited.

Parameters
fromDo projection in time window (from...
to...to) in ns. This window should reflect the search window used for baseline correction.
rangestartPlot x range start in mV.
rangeendPlot x range end in mV.
nbinsNumber of bins in range.
Examples
read_exampledata.cc, and timing_example.cc.

Definition at line 1079 of file ReadRun.cc.

◆ ReadFile()

void ReadRun::ReadFile ( string  path,
bool  change_polarity = false,
int  change_sign_from_to_ch_num = 9,
string  out_file_name = "out.root",
bool  debug = false 
)

Routine to read files created by the wavecatcher.

Reads the data and can already do simple data manipulation during reading:

  • Change polarity of range of channels with parameters (explained below).
  • Shift all waveforms to a constant fraction such they all start at the same time (-> see ReadRun::Shift_WFs_in_file_loop )
  • Simple baseline correction by calling CorrectBaseline() before calling ReadFile().
    Stores the data as ROOT histograms in TClonesArray rundata.

Reader modified from WaveCatcher binary -> root converter by manu chauv.nosp@m.eau@.nosp@m.cenbg.nosp@m..in2.nosp@m.p3.fr

Parameters
pathPath to the data. All files in this folder containing .bin in the file name will be read in.
change_polaritySet true to change polarity (sign) of certain channels (see change_sign_from_to_ch_num below). You can also define a list of channels where the polarity should be switched with switch_polarity_for_channels.
change_sign_from_to_ch_numAll channels \( \geq \) change_sign_from_to_ch_num will be inverted if change_polarity is true.
If negative number all channels \( \leq \) abs(change_sign_from_to_ch_num) will be inverted if change_polarity is true.
out_file_nameName of the .root file which stores the results, e. g. results.root.
debugSet true to increase the verbosity.
Examples
read_exampledata.cc, timing_example.cc, and timing_example_rebin.cc.

Definition at line 66 of file ReadRun.cc.

◆ SaveChargeLists()

void ReadRun::SaveChargeLists ( float  windowlow = 20,
float  windowhi = 80,
float  start = 0,
float  end = 300,
bool  negative_vals = 1 
)

Saves TGraphs to root file with the individual "charge"/amplitude for all events and all channels.

Event with a skip_event flag will be removed. Call before filtering or call UnskipAll() before to get all events.
See GetIntWindow().

Parameters
windowlowIntegrate from "windowlow" ns from max...
windowhi...to "windowhi" ns from max.
startFind max from "start" in ns...
end...to "end" in ns.
negative_valsIf true will save negative values. If false will set negative values to 0.

Definition at line 1717 of file ReadRun.cc.

◆ ShiftAllToAverageCF()

void ReadRun::ShiftAllToAverageCF ( )

This function shifts all waveforms to the average signal starting times for each channel.

The signal starting times are determined with constant fraction discrimination. Before calling this function, please call GetTimingCFD() with suitable parameters for your data.
Additionally, PrintChargeSpectrumWF() should be called before calling this function since the timing reference (blue line) won't be shifted.

Definition at line 661 of file ReadRun.cc.

◆ SkipEventsPerChannel()

void ReadRun::SkipEventsPerChannel ( vector< float thresholds,
float  rangestart = 0,
float  rangeend = 0,
bool  verbose = false 
)

Skip events above/below individual thresholds per channel.

Needs to be called before the charge spectrum etc functions.
Baseline correction should be called before this function.

Parameters
thresholdsVector should contain a threshold for each active channel saved in the data, in ascending order (ch0, ch1 ...). Negative thresholds mean events below threshold will be cut. If only one value is given this value will be used for all active channels.
rangestartRange start in ns
rangeendRange end in ns
verboseSet true for extra verbosity.

Definition at line 1393 of file ReadRun.cc.

◆ SkipEventsTimeDiffCut()

void ReadRun::SkipEventsTimeDiffCut ( int  first_channel_abs,
int  second_channel_abs,
double  time_diff_min,
double  time_diff_max,
bool  verbose = false 
)

Skip events where the time difference between two channels is outside of specified range.

Skip events where the time difference between channel "first_channel" and channel "second_channel" is less than "time_diff_min" or more than "time_diff_max"
Needs to be called before the charge spectrum etc functions.
Baseline correction should be called before this function.

Parameters
first_channel_absFirst channel.
second_channel_absSecond channel.
time_diff_minSkip events for \( \Delta t<t_{diff,min} \)
time_diff_maxSkip events for \( \Delta t>t_{diff,max} \)
verboseSet true for extra verbosity.
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 1285 of file ReadRun.cc.

◆ SmoothAll() [1/2]

void ReadRun::SmoothAll ( double  sigma,
int  method 
)

Smoothing all waveforms which are not skipped (for testing, careful when using for analysis!)

See Filters::SmoothArray().

Parameters
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns.
method0: Use running average (box kernel smoothing). Simple, very fast.
2: Use 3 sigma gaussian kernel smoothing. Preferred method, fast.
Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 599 of file ReadRun.cc.

◆ SmoothAll() [2/2]

void ReadRun::SmoothAll ( double  sigma,
string  method = "Gaus" 
)

Smoothing all waveforms which are not skipped (for testing, careful when using for analysis!)

See Filters::SmoothArray().

Parameters
sigmaNumber of bins before and after central bin for running average OR gauss sigma in ns.
method"Box": Use running average (box kernel smoothing). Simple, very fast.
"Gaus": Use 3 sigma gaussian kernel smoothing. Preferred method, fast.

Definition at line 620 of file ReadRun.cc.

◆ TimeDist()

TH1F * ReadRun::TimeDist ( int  channel_index,
float  from = 0,
float  to = 300,
float  rangestart = 0,
float  rangeend = 300,
int  nbins = 100,
int  which = 0,
float  cf_r = .3 
)

Time distribution of maximum, CFD, or 10% - 90% rise time in a certain time window.

See PrintTimeDist() for parameters.

Definition at line 2127 of file ReadRun.cc.

◆ UnskipAll()

void ReadRun::UnskipAll ( )

Sets skip_event flag to false for all events, removing any previous cuts.

Definition at line 1504 of file ReadRun.cc.

◆ WFHeatmapChannel()

TH2F * ReadRun::WFHeatmapChannel ( int  channel_index,
float  ymin = -20,
float  ymax = 200,
int  n_bins_y = 880 
)

2D histogram of all non-skipped waveforms for one channel

See PlotWFHeatmaps()

Parameters
channel_indexIndex of the channel
yminMin. y range
ymaxMax. y range
n_bins_yNumber of bins along y
Returns
TH2F

Definition at line 524 of file ReadRun.cc.

◆ WFProjectionChannel()

TH1F * ReadRun::WFProjectionChannel ( int  channel_index,
int  from_n = 0,
int  to_n = 1024,
float  rangestart = -50,
float  rangeend = 50,
int  nbins = 200 
)

Waveform projections for one channel.

See PrintWFProjection() for parameters.

Returns
Histogram of the projections of non-skipped waveforms for one channel.

Definition at line 1052 of file ReadRun.cc.

Member Data Documentation

◆ active_channels

vector<int> ReadRun::active_channels

Stores the numbers of the active channels.

Definition at line 290 of file ReadRun.h.

◆ amplValuessum

float** ReadRun::amplValuessum

Collects sums of all waveforms for each channel.

Definition at line 127 of file ReadRun.h.

◆ baseline_correction_result

vector<vector<float> > ReadRun::baseline_correction_result

Stores baseline correction results for CorrectBaseline() and related functions.

Definition at line 320 of file ReadRun.h.

◆ binNumber

int ReadRun::binNumber = 1024

Number of bins (always 1024 samples per waveform). Do not change!

Definition at line 280 of file ReadRun.h.

◆ DAQ_factor

float ReadRun::DAQ_factor = 250. / 4096.

DAQ conversion factor for wavecatcher output to mV.

From https://owncloud.lal.in2p3.fr/public.php?service=files&t=56e4a2c53a991cb08f73d03f1ce58ba2

Definition at line 278 of file ReadRun.h.

◆ data_path

string ReadRun::data_path

Path to data.

Can be used to save analysis results in the data folder

Definition at line 230 of file ReadRun.h.

◆ discard_original_eventnr

bool ReadRun::discard_original_eventnr = false

Can be used to discard the original event numbering of the data.

Set to true if you want to read several runs at once. The events will be numbered in the order they are read in. The original event numbers of the different runs will be lost. CAUTION: All .bin files of the different runs need to contain the same number of channels.

Definition at line 247 of file ReadRun.h.

◆ end_read_at_channel

int ReadRun::end_read_at_channel = -1

See ReadRun::start_read_at_channel.

Definition at line 260 of file ReadRun.h.

◆ eventnr_storage

vector<unsigned int> ReadRun::eventnr_storage

Events will be stored here in the order they have been read.

Definition at line 130 of file ReadRun.h.

◆ fit_results

vector<TFitResultPtr> ReadRun::fit_results

Stores the fit results of PrintChargeSpectrum() for all channels and all function calls in ascending order.

Definition at line 303 of file ReadRun.h.

◆ MaxNoOfBinFilesToRead

int ReadRun::MaxNoOfBinFilesToRead

Number of last .bin file to be read in.

Can be used to test analysis on a small sample of the data or for batch reading if combined with MinNoOfBinFilesToRead.

Definition at line 235 of file ReadRun.h.

◆ maxNWF

int ReadRun::maxNWF = 1e7

Maximum possible number of waveforms in data: number of active channels x number of events.

Default is 10 million waveforms. Increase this number for very large runs.

Definition at line 271 of file ReadRun.h.

◆ maxSumBin

int* ReadRun::maxSumBin

Stores bin numbers where the sum of waveforms have their maximum.

Can be used for fixed integration window relative to maximum of the sum of all waveforms per channel (ReadRun::amplValuessum)

Definition at line 287 of file ReadRun.h.

◆ mean_integral

vector<float> ReadRun::mean_integral

Stores the mean integral/lightyield from PrintChargeSpectrum() for all channels.

Definition at line 306 of file ReadRun.h.

◆ MinNoOfBinFilesToRead

int ReadRun::MinNoOfBinFilesToRead

Number first of .bin file to be read in.

Can be used to batch read large datasets in chunks of files.

Definition at line 239 of file ReadRun.h.

◆ nchannels

int ReadRun::nchannels

Number of active channels in data.

Definition at line 265 of file ReadRun.h.

◆ nChannelsWC

int ReadRun::nChannelsWC = 64

Wavecatcher hardware max. number of channels (reduce/increase if not using the 64 channel crate)

Definition at line 282 of file ReadRun.h.

◆ nevents

int ReadRun::nevents

Number of triggered events in data.

Examples
read_exampledata.cc, timing_example.cc, and timing_example_rebin.cc.

Definition at line 263 of file ReadRun.h.

◆ nwf

int ReadRun::nwf

Total number of waveforms read from data: number of active channels x number of events.

Definition at line 267 of file ReadRun.h.

◆ plot_active_channels

vector<int> ReadRun::plot_active_channels

Stores the numbers of the active channels which should be plotted.

You can select the channels you want with plot_active_channels.push_back(channel_to_plot); to add them to the list.
If undefined all channels will be plotted.

Examples
read_exampledata.cc.

Definition at line 295 of file ReadRun.h.

◆ PrintChargeSpectrum_cal

vector<vector<float> > ReadRun::PrintChargeSpectrum_cal = vector(nChannelsWC, vector<float>(2, 1))

Calibration values to normalize charge spectrum to number of photoelectrons Chennels must be ordered as in plot_active_channels.
The first entry must be the gain and the second the position of the pedestal.

Examples
read_exampledata.cc.

Definition at line 367 of file ReadRun.h.

◆ PrintChargeSpectrum_pars

vector<float> ReadRun::PrintChargeSpectrum_pars

Starting values of the fit parameters for PrintChargeSpectrum()

Examples
read_exampledata.cc.

Definition at line 176 of file ReadRun.h.

◆ root_out

TFile* ReadRun::root_out

Stores results of analysis.

Definition at line 338 of file ReadRun.h.

◆ rundata

TClonesArray* ReadRun::rundata

Stores data.

Definition at line 124 of file ReadRun.h.

◆ Shift_WFs_in_file_loop

bool ReadRun::Shift_WFs_in_file_loop = false

Shift waveforms with CFD so that all events start at the same time Call after initializing class and before calling ReadFile().
Set the constant fraction, the bin to shift the signal to, and the search window with tWF_CF, tWF_CF_bin, and tWF_CF_lo and tWF_CF_hi, respectively.

Definition at line 353 of file ReadRun.h.

◆ skip_event

vector<bool> ReadRun::skip_event

Stores the event numbers which should be skipped in the analysis.

To identify events to be filtered use functions IntegralFilter(), SkipEventsPerChannel(), and SkipEventsTimeDiffCut().

Examples
timing_example.cc, and timing_example_rebin.cc.

Definition at line 311 of file ReadRun.h.

◆ SP

float ReadRun::SP = .3125

Sampling: ns per bin of data, sampling rate 3.2 GS/s -> 0.3125 ns.

Definition at line 274 of file ReadRun.h.

◆ start_read_at_channel

int ReadRun::start_read_at_channel = -1

Do analysis only for limited range of channels to reduce memory usage.

For large datasets with many channels and many events
Only read and analyze channels from ReadRun::start_read_at_channel to ReadRun::end_read_at_channel.
The recorded channel with the lowest wavecatcher channel number is 0 (e.g. recorded channels 3 and 4, so start would be 0 and end 1).
If set to -1 (default) all channels will be read in one go.
Else channels from "start_read_at_channel" to "end_read_at_channel" will be read.
If "end_read_at_channel" is not defined will only read channel specified in "start_read_at_channel".

Definition at line 258 of file ReadRun.h.

◆ switch_polarity_for_channels

vector<int> ReadRun::switch_polarity_for_channels

Stores the channel number where the polarity should be inverted. Example use to switch polarity for channel 0 and channel 14: mymeas.switch_polarity_for_channels = {0, 14};. Needs to be called before ReadFile().

Examples
read_exampledata.cc.

Definition at line 300 of file ReadRun.h.

◆ tCutEndg

float ReadRun::tCutEndg

End of time window for baseline correction when using ReadRun::Using_BaselineCorrection_in_file_loop.

Definition at line 348 of file ReadRun.h.

◆ tCutg

float ReadRun::tCutg

Start of time window for baseline correction when using ReadRun::Using_BaselineCorrection_in_file_loop.

Definition at line 346 of file ReadRun.h.

◆ timing_fit_results

vector<TFitResultPtr> ReadRun::timing_fit_results

Stores the fit results of Print_GetTimingCFD() for all channels.

Definition at line 335 of file ReadRun.h.

◆ timing_results

vector<vector<float> > ReadRun::timing_results

Matrix to store timing of peaks from GetTimingCFD()

First index is the index of the waveform.
Second index is:
0: CFD bin number 1: CFD time 2: Y-value of the maximum 3: Bin number of the maximum 4: Constant fraction (maximum * cf_r) 5: Start of search window 6: End of search window

Definition at line 333 of file ReadRun.h.

◆ tWF_CF

float ReadRun::tWF_CF = 0.3

Constant fraction of maximum (between ~0.1 and 1) for ReadRun::Shift_WFs_in_file_loop.

Definition at line 355 of file ReadRun.h.

◆ tWF_CF_bin

int ReadRun::tWF_CF_bin = 375

Time bin all events will be shifted to for ReadRun::Shift_WFs_in_file_loop Needs to be 300<"tWF_CF_bin"<500 ("tWF_CF_bin"=375 means all peaks will be shifted to 375*.3125 ns=117.1875 ns)

Definition at line 358 of file ReadRun.h.

◆ tWF_CF_hi

int ReadRun::tWF_CF_hi = 500

End of range of bins where the signal is expected for ReadRun::Shift_WFs_in_file_loop.

Definition at line 362 of file ReadRun.h.

◆ tWF_CF_lo

int ReadRun::tWF_CF_lo = 320

Start of range of bins where the signal is expected for ReadRun::Shift_WFs_in_file_loop.

Definition at line 360 of file ReadRun.h.

◆ Using_BaselineCorrection_in_file_loop

bool ReadRun::Using_BaselineCorrection_in_file_loop = false

Set true for baseline correction during data reading. Needs to be called before ReadFile().

Definition at line 344 of file ReadRun.h.


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