23void ReadSampic::ReadFile(
string path,
bool change_polarity,
int change_sign_from_to_ch_num,
string out_file_name,
bool debug,
long long max_nfs_to_read) {
46 string data_settings(
"=== DATA STRUCTURE INFO === REDUCED DATA TYPE: YES === WITHOUT WAVEFORM: NO === TDC-LIKE FILES: NO === COMPACT BINARY DATA: YES === DATA_IN_FILE_TYPE: 1 ===");
72 if (
header_line == 0 &&
line.find(
"SOFTWARE VERSION: V3.5.34") == string::npos &&
line.find(
"SOFTWARE VERSION:") != string::npos) {
73 cout <<
"WARNING: Expected software version V3.5.34 but found:\n" <<
line.c_str() <<
endl;
76 size_t pos =
line.find(
"DATA_IN_FILE_TYPE:");
79 cout <<
"\nWARNING: Unexpected DATA STRUCTURE INFO line.\n Found " <<
line.c_str() <<
endl;
83 else cout <<
"Using HitStructInfoForWaveformOnly_t." <<
endl;
85 if (
line.find(
"SAMPLING FREQUENCY") != string::npos) {
86 size_t pos =
line.find(
"SAMPLING FREQUENCY ");
88 if (
pos != string::npos) {
105 HitStructInfoForWaveformAndMeasurements_t
hitData;
228void ReadSampic::EventBuilder(
double coincidence_time_window, vector<float> thresholds, vector<int> channels,
unsigned int min_coincidences,
bool shift_relative) {
229 cout <<
"---------Started EventBuilder()---------" <<
endl;
267 #pragma omp parallel for reduction(+:n_canditates)
268 for (
int i=0;
i<
nwf;
i++) {
270 hitInfo[
i].IsEventCandidate =
false;
286 for (
int i=0;
i<
nwf;
i++) {
329 cout <<
"Finished EventBuilder() and found " <<
nevents <<
" events in data:" <<
endl;
static void filterChannelUserInput(vector< int > &, const vector< int >)
Check if user input exists in data and remove channels that are not there.
static bool Contains(const vector< T > &vec, const T &val)
Returns true if vector vec contains value val.
static string ListFiles(const char *, const char *)
Helper. Creates a list of .bin data files in data folder to be read in.
int FirstBinFileToRead
Number first of .bin file to be read in.
int nevents
Number of triggered events in data.
float IndexToTime(int)
Convert the bin number of the waveform to the time of the left bin edge
vector< bool > skip_event
Stores the event numbers which should be skipped in the analysis.
vector< int > active_channels
Stores the numbers of the active channels.
vector< vector< float > > rundata
Stores waveforms.
vector< bool > PolarityMap(bool, int)
Channel map of polarity changes during reading. For parameters see ReadFile().
int GetChannelIndex(int)
Match channel number (wavecatcher input channel) to channel index.
TFile * root_out
Stores results of analysis.
int nChannelsWC
Wavecatcher hardware max. number of channels (reduce/increase if not using the 64 channel crate)
int start_read_at_channel
Do analysis only for limited range of channels to reduce memory usage.
virtual int Nevents_good(int=0)
Number of good events that are not skipped.
vector< vector< float > > amplValuessum
Collects sums of all waveforms for each channel.
int nwf
Total number of waveforms read from data: number of active channels x number of events.
int binNumber
Number of bins (usually 1024 samples per waveform).
string data_path
Path to data.
int nchannels
Number of active channels in data.
float SP
Sampling: ns per bin of data, sampling rate 3.2 GS/s -> 0.3125 ns.
int LastBinFileToRead
Number of last .bin file to be read in.
vector< unsigned int > eventnr_storage
Events will be stored here in the order they have been read.
int GetCurrentEvent(int) override
Get the current event index for a certain waveform index.
vector< HitInfoReduced > hitInfo
Stores additional info about wf.
void PlotWF(int, float=0, float=0)
Plot any Waveform (can be called before EventBuilder to check data)
int GetWaveformIndex(int, int) override
Returns index of a certain event number (if data files are read in parallel threads)
void checkData(bool isBaselineCorrection=false) const override
Primitive check to see if data has been loaded.
void EventBuilder(double, vector< float >={}, vector< int > channels={}, unsigned int=1, bool=false)
Construct events based on coincident amplitude thresholds within a time window for different channels...
void ReadFile(string, bool=true, int=0, string="out.root", bool=false, long long=0) override
Routine to read files created by SAMPIC DAQ.
TH1F * Getwf(int, int, int=1) override
Helper that returns the waveform histogram for a certain channel number and a certain event number.
vector< vector< int > > wf_nr_event_storage
Stores all waveform numbers assigned to events.
bool eventsBuilt
Check if the data is grouped in events (SAMPIC needs manual event building)
int GetCurrentChannel(int) override
Get the current channel index for a certain waveform index.
vector< double > event_time_stamps
Stores all event times.
bool SkipEvent(int, int=-1) override
Check if event has skipped flag. Will return true if event flag is false but channel does not exist i...
vector< vector< int > > ch_nr_event_storage
Stores all channel numbers assigned to events.
Stores additional information with the waveforms.