BCalibrate module
In BARS calibrations are applied with a BCalibrate module.
Description
Here's what BCalibrate does:
- Reads calibrations from calibration table files.
- If the required file is not present, it produces an error during preprocess.
- If the calibration tables are malformatted, it produces an error during preprocess.
- During process, it applies all calibrations to the impulses in
BExtractedImpulseTel
as described here.
Required containers
BCalibrate requires two containers to be present to operate:
BExtractedImpulseTel
for events to calibrate.BStaticConfig
for information about the number of channels to calibrate.
Usage
Here's a basic example that reads events, calibrates them and then saves calibrated data:
#include "MEvtLoop.h"
#include "MParList.h"
#include "MTaskList.h"
#include "BReadTree.h"
#include "BReadStaticConfig.h"
#include "BCalibrate.h"
void main()
{
// Read events
BReadTree reader("Events", "my-joint-events-file.root");
// Read static config for cluster 0, 2016
BReadStaticConfig cfgread;
cfgread.SetConfigPath(BARS::Cfg);
cfgread.SetSeason(2016);
cfgread.SetConfigName("BStaticConfig");
// Calibrate events
BCalibrate calib;
calib.SetSeason(2016);
calib.SetCluster(0);
calib.SetACalibName("some-amplitude-calib-label");
calib.SetQCalibName("some-charge-calib-label");
calib.SetTCalibName("some-time-calib-label");
calib.SetOCalibName("some-offset-calib-label");
// Save output
MWriteRootFile writer("my-output-file.root", "RECREATE", "Magic root-file", 2);
writer.AddContainer("BEvent", "Events");
// Specify order of execution
MTaskList tasks;
tasks.AddToList(&reader);
tasks.AddToList(&cfgread);
tasks.AddToList(&calib);
tasks.AddToList(&writer);
// Run event loop
MParList plist;
plist.AddToList(&tasks);
MEvtLoop magic;
magic.SetParList(&plist);
magic.Eventloop();
}
You can provide an absolute path to the calibration table instead of a label like this:
calib.SetOCalibPath("/path/to/my/offset/calib/file");
calib.SetACalibPath("/path/to/my/amplitude/calib/file");
calib.SetTCalibPath("/path/to/my/time/calib/file");
calib.SetQCalibPath("/path/to/my/charge/calib/file");
If you provide neither path nor label for a calibration, BCalibrate
will use nocalib
.
In the following example, no calibrations will be applied (however time will be converted from FADC codes to nanoseconds):
#include "MEvtLoop.h"
#include "MParList.h"
#include "MTaskList.h"
#include "BReadTree.h"
#include "BReadStaticConfig.h"
#include "BCalibrate.h"
void main()
{
// Read events
BReadTree reader("Events", "my-joint-events-file.root");
// Read static config for cluster 0, 2016
BReadStaticConfig cfgread;
cfgread.SetConfigPath(BARS::Cfg);
cfgread.SetSeason(2016);
cfgread.SetConfigName("BStaticConfig");
// Calibrate events
BCalibrate calib;
calib.SetSeason(2016);
calib.SetCluster(0);
// Save output
MWriteRootFile writer("my-output-file.root", "RECREATE", "Magic root-file", 2);
writer.AddContainer("BEvent", "Events");
// Specify order of execution
MTaskList tasks;
tasks.AddToList(&reader);
tasks.AddToList(&cfgread);
tasks.AddToList(&calib);
tasks.AddToList(&writer);
// Run event loop
MParList plist;
plist.AddToList(&tasks);
MEvtLoop magic;
magic.SetParList(&plist);
magic.Eventloop();
}
Using run-specific charge calibration acquired by DQM
You can use charge calibration from DQM like this:
calib.SetQCalibPath(BARS::Data::File(BARS::Data::DQM_QCALIB));