readWDpp
Read binary files from DRS and WDB
Loading...
Searching...
No Matches
readWDpp

Introduction

The readWDpp project is a library which aims to read binary files from a DRS Evaluation Board or WaveDREAM Board. To do this, the library implements many usefull classes that can be used with their methods to read the output files from the boards.

Usage

The main usage is to initialize a DAQFile and DAQEvent, read all the file and at each event extract the value we are interested in.

// mainExample0.cc
#include "readWD.hh"
#include "TH1F.h"
void mainExample0()
{
auto h1 = new TH1F("h1", "Charge histogram", 100, 0, 10);
DAQFile file("path/to/file.dat");
DRSEvent event;
while (file >> event)
{
float charge = event.GetChannel(0, 0).GetCharge();
h1->Fill(charge);
}
h1->Draw();
return;
}
float GetCharge()
Method to evaluate charge in the integration region.
Definition readWD.cc:280
DAQEvent & GetChannel(const int &, const int &)
Select the channel to analyze.
Definition readWD.cc:102
Class to manage the file and the outputing of data in a DAQEvent instance.
Definition readWD.hh:214
Specialization of DAQEvent to a DRS board.
Definition readWD.hh:192
Declaration of classes and methods.

The output will be:

$ root -l mainExample0.cc
root [0]
Processing path/to/file.dat...
Created DAQFile, opened file path/to/file.dat
Initializing file path/to/file.dat
DRS2 --> DRS Evaluation Board
B#2440:
--> C001
Initialization done --> EHDR next
Event serial number: 100
...
Event serial number: 10000
End of file reached
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [1]

The user can read the Examples page to see other applications of the library.

The main classes

The library implements two main classes DAQFile and DAQEvent, these two are the classes that must be used to read the file.

DAQFile

It is recomended at the beginning to create an istance of DAQFile, using the default constructor or passing it the path to the file to be opened. The library will automatically call the method DAQFile::Initialise(), which will read the TIME header and the array of times. After that, the class is thought to be used as an input stream. Redirecting the DAQFile into a DAQEvent instance, one single event is read: voltages and and integrated times are passed into the DAQEvent instance. It is possible to do this operation untill the end of the file is reached.

DAQEvent

The main goal of this class is to implement many usefull methods that the user can call to analyse the data contained in the file. There are two children classes: WDBEvent and DRSEvent. The user must know previously if the file he is going to read comes from a DRS or WDB. This happends because of the different binary structure coming from DRS and WDB, read the page The Binary Output for more informations.

How it works

The first pass is to create two objects: a DAQFile and a DAQEvent's child class.

DAQFile file;
DRSEvent event;

Now you can open a file giving the relative path.

file.Open("path/to/file.dat");
DAQFile & Open(const std::string &)
Method to open a file given the file path and name.
Definition readWD.cc:1188

To read each event is possible to use a while loop. Inside the while loop the user can access any channel by using the method DAQEvent::GetChannel(). After that it is possible to use any method to get the information wanted.

while (file >> event)
{
float charge = event.GetChannel(0, 0).GetCharge();
// ...
}

How the times are stored

In the TIME header there are stored the time bin width, these are copied in the DAQFile::times_ map. Once the instruction file >> event is executed, two nested while scan any board header and channel header, at every channel header found the corresponding delta-times vector is shifted accordingly to the trigger cell found in the event header and integrated, then it is copied in the DAQEvent::times_ map. To understand more about the time alignemnt see DAQEvent::TimeCalibration().