wavecatcher-analysis
Loading...
Searching...
No Matches
read_exampledata.cc
#include <TROOT.h>
// call .x read_exampledata.cc(0) from root prompt or root -x "read_exampledata.cc(0)"
void read_exampledata(int which = 0)
{
string path("examples/");
// select measurement data. ALL .bin files in this folder will be used!
switch (which) {
case(0): {
path += "exampledata/";
break;
}
default: {
cout << "\nerror: path to data not specified" << endl; // default
break;
}
}
// initialize class
ReadRun mymeas(0);
mymeas.switch_polarity_for_channels = { 9, 14, 15};
// read data
mymeas.ReadFile(path, true, 99, "examples/exampledata_results.root");
// uncomment lines below to only plot trigger channels
//mymeas.plot_active_channels.push_back(14);
//mymeas.plot_active_channels.push_back(15);
// apply baseline correction to ALL waveforms
// searches for the minimum of sum((y_{i+1} - y_{i})^2)+sum(y_{i+1} - y_{i})^2 over 30 ns, starting at t=0 ns until t=80 ns
mymeas.CorrectBaselineMinSlopeRMS({ 30, 0, 80 });
// test if baseline correction worked (should be centered around 0)
mymeas.PrintWFProjection(0, 80, -3.5, 3.5, 50);
// plot sums of all raw events per channel (see channel 9 has an offset)
mymeas.PlotChannelSums();
// plot all waveforms in a single histogram
mymeas.PlotWFHeatmaps(-20, 300, 160, "log");
// investigate charge spectrum. should see photo electron peaks here
float intwindowminus = 10.; // lower integration window in ns rel. to max
float intwindowplus = 30.; // upper integration window in ns rel. to max
float findmaxfrom = 80.; // assume pulse after trigger arrives between here ...
float findmaxto = 140.; // ... and here (depends on trigger delay setting etc., for dark counts the signal is random so we look at the whole recorded time range)
// mymeas.PrintChargeSpectrum_Cal[0][0] = 9500;
mymeas.PrintChargeSpectrum_cal = {{9500,0},{9500,0},{9500,0}};
// plot charge spectra (histogram of signal integrals)
mymeas.PrintChargeSpectrum(intwindowminus, intwindowplus, findmaxfrom, findmaxto, -1, 5, 200);//-100, 2.5e3, 200);
// cut out pedestal events by setting a threshold of 200 mV*ns of the integrals of the last two trigger channels
// note that this removes about 70% of all events for this example data!!
mymeas.IntegralFilter({ 0, 200, 200 }, { false, false, false }, intwindowminus, intwindowplus, findmaxfrom, findmaxto);
// get a rough estimate of the timing of the main peaks to make sure the choice of the time window makes sense
mymeas.PrintTimeDist(50, 170, findmaxfrom, findmaxto, 60, 1, .5);
// plot the average corrected waveforms per channel not taking into account events cut out by IntegralFilter()
// plot waveforms of individual events
int example_event = 68;
//plot range
double ymin = -5;
double ymax = 150;
// plot the waveforms for event 68 with integration window and baseline correction info
mymeas.PrintChargeSpectrumWF(intwindowminus, intwindowplus, findmaxfrom, findmaxto, example_event, ymin, ymax);
// save more events to root file
gROOT->SetBatch(kTRUE);
for (int i = 1; i < mymeas.nevents; i += static_cast<int>(mymeas.nevents / 10)) {
mymeas.PrintChargeSpectrumWF(intwindowminus, intwindowplus, findmaxfrom, findmaxto, i, ymin, ymax);
}
gROOT->SetBatch(kFALSE);
// now select only the signal channel 9
mymeas.plot_active_channels = { 9 };
// set starting values for the fit of a landau gauss convolution
mymeas.PrintChargeSpectrum_pars = { 100, 9.5e3, 2e4, 700 };
// fit and plot the fit results for channel 9
mymeas.PrintChargeSpectrum(intwindowminus, intwindowplus, findmaxfrom, findmaxto, 6e3, 1.35e4, 200, 7e3, 1.3e4, 9, 1);
}
int nevents
Number of triggered events in data.
Definition ReadRun.h:263
void CorrectBaselineMinSlopeRMS(vector< float >, double=0, int=2, int=3)
Baseline correction method searching for non-monotonic, rather constant regions.
Definition ReadRun.cc:784
vector< float > PrintChargeSpectrum_pars
Starting values of the fit parameters for PrintChargeSpectrum()
Definition ReadRun.h:176
void PrintWFProjection(float=0, float=320, float=-50, float=50, int=200)
Plots waveform projection histograms of all channels.
Definition ReadRun.cc:1079
void PlotChannelAverages(bool=false)
Plot averages only of the good, corrected waveforms for each channel.
Definition ReadRun.cc:454
void ReadFile(string, bool=false, int=9, string="out.root", bool=false)
Routine to read files created by the wavecatcher.
Definition ReadRun.cc:66
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...
Definition ReadRun.cc:1613
vector< int > switch_polarity_for_channels
Stores the channel number where the polarity should be inverted. Example use to switch polarity for c...
Definition ReadRun.h:300
void IntegralFilter(vector< float >, vector< bool >, float, float, float=50, float=250, bool=false, bool=false)
Skip events with threshold on integral.
Definition ReadRun.cc:1443
vector< vector< float > > PrintChargeSpectrum_cal
Calibration values to normalize charge spectrum to number of photoelectrons Chennels must be ordered ...
Definition ReadRun.h:367
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.
Definition ReadRun.cc:1861
void PlotWFHeatmaps(float=-20, float=200, int=880, string="", float=0, EColorPalette=kGistEarth)
Plot stacks of all non-skipped waveforms for all active channels.
Definition ReadRun.cc:556
void PlotChannelSums(bool=false, bool=false, double=0., double=0., int=2)
Plot sums of all raw waveforms for each channel.
Definition ReadRun.cc:396
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.
Definition ReadRun.cc:2191
vector< int > plot_active_channels
Stores the numbers of the active channels which should be plotted.
Definition ReadRun.h:295