stream  0.10.0
stream analysis framework
Example with automatic TDC creation
#include "base/ProcMgr.h"
#include "hadaq/HldProcessor.h"
#include "hadaq/TdcProcessor.h"
#include "hadaq/TrbProcessor.h"
void first()
{
// base::ProcMgr::instance()->SetTriggeredAnalysis(true);
// all new instances get this value
// this limits used for liner calibrations when nothing else is available
// default channel numbers and edges mask
// 1 - use only rising edge, falling edge is ignore
// 2 - falling edge enabled and fully independent from rising edge
// 3 - falling edge enabled and uses calibration from rising edge
// 4 - falling edge enabled and common statistic is used for calibration
// [min..max] range for TDC ids
// [min..max] range for HUB ids
// when first argument true - TRB/TDC will be created on-the-fly
// second parameter is function name, called after elements are created
hadaq::HldProcessor* hld = new hadaq::HldProcessor(true, "after_create");
// first parameter if filename prefix for calibration files
// and calibration mode (empty string - no file I/O)
// second parameter is hits count for autocalibration
// 0 - only load calibration
// -1 - accumulate data and store calibrations only at the end
// -77 - accumulate data and store linear calibrations only at the end
// >0 - automatic calibration after N hits in each active channel
// if value ends with 77 like 10077 linear calibration will be calculated
// >1000000000 - automatic calibration after N hits only once, 1e9 excluding
// third parameter is trigger type mask used for calibration
// (1 << 0xD) - special 0XD trigger with internal pulser, used also for TOT calibration
// 0x3FFF - all kinds of trigger types will be used for calibration (excluding 0xE and 0xF)
// 0x80000000 in mask enables usage of temperature correction
hld->ConfigureCalibration("", 100000, (1 << 0xD));
// only accept trigger type 0x1 when storing file
// new hadaq::HldFilter(0x1);
// create ROOT file store
// base::ProcMgr::instance()->CreateStore("td.root");
// 0 - disable store
// 1 - std::vector<hadaq::TdcMessageExt> - includes original TDC message
// 2 - std::vector<hadaq::MessageFloat> - compact form, without channel 0, stamp as float (relative to ch0)
// 3 - std::vector<hadaq::MessageDouble> - compact form, with channel 0, absolute time stamp as double
// when configured as output in DABC, one specifies:
// <OutputPort name="Output2" url="stream://file.root?maxsize=5000&kind=3"/>
}
// extern "C" required by DABC to find function from compiled code
extern "C" void after_create(hadaq::HldProcessor* hld)
{
printf("Called after all sub-components are created\n");
if (hld==0) return;
for (unsigned k=0;k<hld->NumberOfTRB();k++) {
hadaq::TrbProcessor* trb = hld->GetTRB(k);
if (trb==0) continue;
printf("Configure %s!\n", trb->GetName());
trb->SetPrintErrors(10);
}
for (unsigned k=0;k<hld->NumberOfTDC();k++) {
hadaq::TdcProcessor* tdc = hld->GetTDC(k);
if (tdc==0) continue;
printf("Configure %s!\n", tdc->GetName());
// tdc->SetUseLastHit(true);
for (unsigned nch=2;nch<tdc->NumChannels();nch++)
tdc->SetRefChannel(nch, 1, 0xffff, 2000, -10., 10.);
}
}
void SetHistFilling(int lvl)
Set histogram fill level for all processors.
Definition: ProcMgr.cxx:103
void SetRawAnalysis(bool on=true)
Enable/disable raw analysis.
Definition: ProcMgr.h:186
static ProcMgr * instance()
Return global instance of processor manager, provided by framework.
Definition: ProcMgr.cxx:46
virtual void SetStoreKind(unsigned kind=1)
Set store kind for all processors.
Definition: ProcMgr.cxx:119
const char * GetName() const
Get processor name.
Definition: base/Processor.h:220
HLD processor.
Definition: HldProcessor.h:93
TdcProcessor * GetTDC(unsigned indx) const
Get TDC by index.
Definition: HldProcessor.cxx:122
TrbProcessor * GetTRB(unsigned indx) const
Get TRB by index.
Definition: HldProcessor.cxx:89
void ConfigureCalibration(const std::string &fileprefix, long period, unsigned trig=0xFFFF)
Configure calibration modes.
Definition: HldProcessor.cxx:159
unsigned NumberOfTDC() const
Return number of TDCs in all TRBs.
Definition: HldProcessor.cxx:111
unsigned NumberOfTRB() const
Return number of TRBs.
Definition: HldProcessor.cxx:81
TDC processor.
Definition: TdcProcessor.h:32
unsigned NumChannels() const
Returns number of TDC channels.
Definition: TdcProcessor.h:484
void SetRefChannel(unsigned ch, unsigned refch, unsigned reftdc=0xffff, int npoints=5000, double left=-10., double right=10., bool twodim=false)
Set reference signal for the TDC channel ch.
Definition: TdcProcessor.cxx:516
TRB processor.
Definition: TrbProcessor.h:46
static void SetHUBRange(unsigned min, unsigned max)
Define range for HUBs, used when auto mode is enabled.
Definition: TrbProcessor.h:285
static void SetDefaults(unsigned numch=65, unsigned edges=0x1, bool ignore_sync=true)
Set defaults for the next creation of TDC processors.
Definition: TrbProcessor.cxx:35
void SetPrintErrors(int cnt=100)
Set number of errors which could be printed.
Definition: TrbProcessor.h:191
static void SetTDCRange(unsigned min, unsigned max)
Define range for TDCs, used when auto mode is enabled.
Definition: TrbProcessor.h:278
static void SetFineLimits(unsigned min, unsigned max)
Method set static limits, which are used for simple interpolation of time for fine counter.
Definition: TdcMessage.h:294