stream
0.10.0
stream analysis framework
|
TRB processor. More...
#include <hadaq/TrbProcessor.h>
Public Member Functions | |
TrbProcessor (unsigned brdid=0, HldProcessor *hld=nullptr, int hfill=-1) | |
Constructor, one could specify histogram fill level. | |
virtual | ~TrbProcessor () |
Destructor. | |
HldProcessor * | GetHLD () const |
Returns instance of hadaq::HldProcessor to which it belongs. | |
void | SetAutoCreate (bool on=true) |
enable autocreation mode if necessary, works for single event | |
void | SetHadaqCTSId (unsigned id) |
Set id of CTS sub-sub event. | |
void | AddHadaqHUBId (unsigned id) |
Add HUB id. | |
void | SetHadaqHUBId (unsigned id1, unsigned id2=0, unsigned id3=0, unsigned id4=0) |
Set up to 4 different HUB ids. | |
void | SetHadaqTDCId (unsigned) |
deprecated, keep for backward compatibility, can be ignored | |
void | SetHadaqSUBId (unsigned) |
deprecated, keep for backward compatibility, can be ignored | |
virtual void | UserPreLoop () |
Pre loop function. | |
virtual void | UserPostLoop () |
Post loop function. | |
virtual void | SetTriggerWindow (double left, double right) |
Set trigger window for all TDCs. | |
virtual void | SetStoreKind (unsigned kind=1) |
Configure store kind. | |
virtual bool | FirstBufferScan (const base::Buffer &buf) |
First scan of buffer - main entry point for data. | |
void | SetPrintRawData (bool on=true) |
Enables printing of raw data. | |
bool | IsPrintRawData () const |
Return true if printing of raw data enabled. | |
void | SetPrintErrors (int cnt=100) |
Set number of errors which could be printed. | |
bool | CheckPrintError () |
Checks if error can be print out. | |
void | SetCrossProcess (bool on=true) |
Enable Cross-processing - hits correlation between different TDCs. | |
bool | IsCrossProcess () const |
Returns true if cross-processing enabled. | |
void | SetCh0Enabled (bool on=true) |
Enable/disable ch0 store in output event for all TDC processors. | |
void | SetSyncIds (unsigned mask, unsigned value) |
Set sync mask and value which, should be obtained from trigger type to detect CBM sync message in CTS sub-event Code is following: if ((trig_type & mask) == value) syncnum = sub->LastData(); | |
void | SetUseTriggerAsSync (bool on=true) |
Use TRB trigger number as SYNC message. More... | |
bool | IsUseTriggerAsSync () const |
Returns true if trigger number should be used to sync events over all TRBs. | |
void | SetCompensateEpochReset (bool on=true) |
When enabled, artificially create contiguous epoch value. | |
unsigned | NumSubProc () const |
Returns number of sub-processors. | |
SubProcessor * | GetSubProc (unsigned indx) const |
Returns sub-processor by its index. | |
TdcProcessor * | GetTDC (unsigned tdcid, bool fullid=false) const |
Returns TDC processor according to it ID. | |
unsigned | NumberOfTDC () const |
Returns number of TDC processors. | |
TdcProcessor * | GetTDCWithIndex (unsigned indx) const |
Get TDC processor by index. | |
void | AddBufferToTDC (hadaqs::RawSubevent *sub, hadaq::SubProcessor *tdcproc, unsigned ix, unsigned datalen) |
Provide buffer to sub-processor. | |
TdcProcessor * | FindTDC (unsigned tdcid) const |
Find TDC with provided id. | |
int | CreateTDC (unsigned id1, unsigned id2=0, unsigned id3=0, unsigned id4=0) |
Create up to 4 TDC with pre-configured default parameters. | |
void | CreateCTS_TDC () |
Create TDC processor, which extracts TDC information from CTS header. | |
void | DisableCalibrationFor (unsigned firstch, unsigned lastch=0) |
Disable calibration of specified channels for all existing TDCs. | |
void | SetAutoCalibrations (long cnt=100000) |
Set auto calibration for all existing TDCs. | |
void | SetWriteCalibrations (const char *fileprefix, bool every_time=false, bool use_linear=false) |
Set write calibration for all existing TDCs. | |
bool | LoadCalibrations (const char *fileprefix) |
Load calibrations for all existing TDCs as argument file prefix (without TDC id) should be specified. | |
void | ConfigureCalibration (const std::string &name, long period, unsigned trigmask=0xFFFF) |
Configure calibration. | |
void | SetCalibrTriggerMask (unsigned trigmask=0xFFFF) |
Set trigger ids mask which should be used for calibration Value 0x3FF enables calibration for all kinds of events Value (1 << 0xD) enable calibration for 0xD trigger. | |
bool | CollectMissingTDCs (hadaqs::RawSubevent *sub, std::vector< unsigned > &ids) |
Using data structure in raw event, collect ids of missing TDCs. More... | |
void | ClearFastTDCVector () |
Clear helper vector of TDCs processor for fast access. | |
unsigned | TransformSubEvent (hadaqs::RawSubevent *sub, void *tgtbuf=nullptr, unsigned tgtlen=0, bool only_hist=false, std::vector< unsigned > *newids=nullptr) |
Transform (calibrate) raw data Creates output HLD structure, used in HADES DAQ. More... | |
unsigned | EmulateTransform (hadaqs::RawSubevent *sub, int dummycnt, bool only_hist=false) |
Emulate transform (calibrate) raw data - only for debugging. | |
void | CreatePerTDCHistos () |
Create overview histograms where each TDC corresponds one bin. | |
bool | HasPerTDCHistos () const |
Are there per-TDC histograms. | |
void | ClearDAQHistos () |
Clear all DAQ-related histograms. | |
hadaqs::RawSubevent & | GetLastSubeventHdr () |
Return reference on last subevent header. | |
hadaq::TrbMessage & | GetTrbMsg () |
Return reference on last filled message. | |
Public Member Functions inherited from base::StreamProc | |
virtual | ~StreamProc () |
destructor | |
void | SetTimeSorting (bool on) |
Enable/disable time sorting of data in output event. | |
bool | IsTimeSorting () const |
Is time sorting enabled. | |
void | SetTriggerMargin (double margin=0.) |
Set minimal distance between two triggers. | |
void | CreateTriggerHist (unsigned multipl=40, unsigned nbins=2500, double left=-1e-6, double right=4e-6) |
create histograms for triggers | |
void | SetRawScanOnly () |
Method set raw-scan only mode for processor Processor will not be used for any data selection. | |
bool | IsRawScanOnly () const |
Is only raw scan will be performed. | |
bool | IsRawAnalysis () const |
Is raw analysis only. | |
bool | IsTriggeredAnalysis () const |
Is triggered events analysis. | |
bool | IsStreamAnalysis () const |
Is full stream analysis. | |
bool | IsSynchronisationRequired () const |
Method indicate if any kind of time-synchronization technique should be applied for the processor. More... | |
unsigned | minNumSyncRequired () const |
Returns minimal number of syncs required for time synchronisation. | |
virtual bool | AddNextBuffer (const Buffer &buf) |
Provide next port of data to the processor. More... | |
virtual bool | ScanNewBuffers () |
Scanning all new buffers in the queue. More... | |
virtual bool | ScanNewBuffersTm () |
With new calibration set (where possible) time of buffers. More... | |
virtual void | SkipAllData () |
Method to remove all buffers, all triggers and so on. More... | |
virtual bool | SkipBuffers (unsigned cnt) |
Force processor to skip buffers from input. More... | |
unsigned | numSyncs () const |
Returns total number of sync markers. | |
unsigned | numReadySyncs () const |
Returns number of read sync markers. | |
SyncMarker & | getSync (unsigned n) |
Returns sync marker. | |
unsigned | findSyncWithId (unsigned syncid) const |
find sync marker | |
virtual bool | CollectTriggers (GlobalMarksQueue &queue) |
Method to deliver detected triggers from processor to central manager. More... | |
virtual bool | DistributeTriggers (const GlobalMarksQueue &queue) |
This is method to get back identified triggers from central manager. More... | |
virtual bool | ScanDataForNewTriggers () |
Here each processor should scan data again for new triggers Method made virtual while some subprocessors will do it in connection with others. More... | |
unsigned | NumReadySubevents () const |
Returns number of already build events. | |
virtual bool | AppendSubevent (base::Event *evt) |
Append data for first trigger to the main event. More... | |
virtual bool | SecondBufferScan (const base::Buffer &) |
Second generic scan of buffer Here selection of data for region-of-interest should be performed. | |
virtual void | Store (Event *) |
Generic method to store processor data, In case of ROOT one should copy event data in temporary structures, which are mapped to the branch. | |
virtual void | ResetStore () |
Generic method to store processor data, In case of ROOT one should copy event data in temporary structures, which are mapped to the branch. | |
Public Member Functions inherited from base::Processor | |
virtual | ~Processor () |
destructor | |
ProcMgr * | mgr () const |
Return manager instance. | |
const char * | GetName () const |
Get processor name. | |
unsigned | GetID () const |
Get processor ID. | |
void | SetHistFilling (int lvl=99) |
Set histogram filling level. | |
bool | IsHistFilling () const |
Is histogram filling enabled. | |
int | HistFillLevel () const |
Get histogram filling level. | |
unsigned | GetStoreKind () const |
Get store kind. | |
bool | IsStoreEnabled () const |
Is store enabled. | |
void | SetStoreEnabled (bool on=true) |
Enable store - set store kind 1. | |
Static Public Member Functions | |
static void | SetDefaults (unsigned numch=65, unsigned edges=0x1, bool ignore_sync=true) |
Set defaults for the next creation of TDC processors. More... | |
static unsigned | GetDefaultNumCh () |
Retun default number of TDC channels. | |
static void | SetTDCRange (unsigned min, unsigned max) |
Define range for TDCs, used when auto mode is enabled. | |
static void | SetHUBRange (unsigned min, unsigned max) |
Define range for HUBs, used when auto mode is enabled. | |
Static Public Member Functions inherited from base::StreamProc | |
static void | SetMarksQueueCapacity (unsigned sz) |
Set markers queue capacity. | |
static void | SetBufsQueueCapacity (unsigned sz) |
Set buffers queue capacity. | |
Protected Member Functions | |
virtual bool | doTriggerSelection () const |
Returns true when processor used to select trigger signal TRB3 not yet able to perform trigger selection. | |
void | AccountTriggerId (unsigned id) |
Assign current trigger id. | |
void | AddSub (SubProcessor *tdc, unsigned id) |
Way to register sub-processor, like for TDC. More... | |
virtual void | ScanSubEvent (hadaqs::RawSubevent *sub, unsigned trb3runid, unsigned trb3seqid) |
Scan FPGA-TDC data, distribute over sub-processors. More... | |
void | BeforeEventScan () |
Function called before each event scan. | |
void | AfterEventScan () |
Function called after event scan - TDCs analyze data they got. | |
void | AfterEventFill () |
if SetCrossProcess() enabled - fill histograms across TDCs | |
void | BuildFastTDCVector () |
Build vector of TDCs processor for fast access. | |
virtual void | CreateBranch (TTree *t) |
Create branch in TTree to store hadaq::TrbMessage. | |
void | EventError (const char *msg) |
Add event-related error message - adds event info. | |
void | EventLog (const char *msg) |
Add event-related log message - adds event info. | |
void | SetCrossProcessAll () |
Cal SetCrossProcess for all existing TRB processors. | |
Protected Member Functions inherited from base::StreamProc | |
StreamProc (const char *name="", unsigned brdid=DummyBrdId, bool basehist=true) | |
Make constructor protected - no way to create base class instance. More... | |
void | SetSynchronisationKind (SyncKind kind=sync_Inter) |
Method indicate if any kind of time-synchronization technique should be applied for the processor. More... | |
void | AddSyncMarker (SyncMarker &marker) |
add sync marker | |
bool | AddTriggerMarker (LocalTimeMarker &marker, double tm_range=0.) |
Add new local trigger. More... | |
GlobalTime_t | LocalToGlobalTime (GlobalTime_t localtm, unsigned *sync_index=0) |
Method converts local time (in ns representation) to global time. More... | |
bool | IsSyncIndexWithInterpolation (unsigned indx) const |
Method return true when sync_index is means interpolation of time. | |
virtual GlobalTime_t | ProvidePotentialFlushTime (GlobalTime_t last_marker) |
Method should return time, which could be flushed from the processor. More... | |
bool | VerifyFlushTime (const base::GlobalTime_t &flush_time) |
Method must ensure that processor scanned such time and can really skip this data. More... | |
virtual double | MaximumDisorderTm () const |
Time constant, defines how far disorder of messages can go. | |
unsigned | TestHitTime (const base::GlobalTime_t &hittime, bool normal_hit, bool can_close_event=true) |
Method decides to which trigger window belong hit normal_hit - indicates that time is belong to data, which than can be assigned to output can_close_event - when true, hit time can be used to decide that event is ready. More... | |
template<class EventClass , class MessageClass > | |
void | AddMessage (unsigned indx, EventClass *ev, const MessageClass &msg) |
add new message to event | |
bool | eraseSyncAt (unsigned indx) |
Removes sync at specified position. More... | |
bool | eraseFirstSyncs (unsigned sync_num) |
Remove specified number of syncs. More... | |
Protected Member Functions inherited from base::Processor | |
Processor (const char *name="", unsigned brdid=DummyBrdId) | |
Make constructor protected - no way to create base class instance. More... | |
void | SetBoardId (unsigned id) |
Set board id. | |
void | SetPathPrefix (const std::string &prefix) |
Set path prefix for histogramsid. | |
void | SetSubPrefix (const char *subname="", int indx=-1, const char *subname2="", int indx2=-1) |
Set subprefix for histograms and conditions. More... | |
void | SetSubPrefix2 (const char *subname="", int indx=-1, const char *subname2="", int indx2=-1) |
Set subprefix for histograms and conditions, index uses 2 symbols. More... | |
H1handle | MakeH1 (const char *name, const char *title, int nbins, double left, double right, const char *xtitle=0) |
Adds processor prefix to histogram name and calls base::ProcMgr::MakeH1 method. | |
void | FillH1 (H1handle h1, double x, double weight=1.) |
Fill 1-D histogram. | |
void | FastFillH1 (H1handle h1, int x, double weight=1.) |
Fast fill 1-D histogram. More... | |
double | GetH1Content (H1handle h1, int nbin) |
Get bin content of 1-D histogram. | |
void | SetH1Content (H1handle h1, int nbin, double v=0.) |
Set bin content of 1-D histogram. | |
int | GetH1NBins (H1handle h1) |
Get bins numbers for 1-D histogram. | |
void | ClearH1 (H1handle h1) |
Clear 1-D histogram. | |
void | CopyH1 (H1handle tgt, H1handle src) |
Copy 1-D histogram from src to tgt. | |
void | SetH1Title (H1handle h1, const char *title) |
Set 1-D histogram title. | |
H2handle | MakeH2 (const char *name, const char *title, int nbins1, double left1, double right1, int nbins2, double left2, double right2, const char *options=0) |
Adds processor prefix to histogram name and calls base::ProcMgr::MakeH2 method. | |
void | FillH2 (H1handle h2, double x, double y, double weight=1.) |
Fill 2-D histogram. | |
void | FastFillH2 (H1handle h2, int x, int y) |
Fast fill 2-D histogram. More... | |
void | SetH2Content (H2handle h2, int nbin1, int nbin2, double v=0.) |
Set bin content of 2-D histogram. | |
double | GetH2Content (H2handle h2, int bin1, int bin2) |
Get bin content of 2-D histogram. | |
bool | GetH2NBins (H2handle h2, int &nBins1, int &nBins2) |
Get number of bins for 2-D histogram. | |
void | ClearH2 (base::H2handle h2) |
Clear 2-D histogram. | |
void | SetH2Title (H2handle h2, const char *title) |
Change title of 2-D histogram. | |
C1handle | MakeC1 (const char *name, double left, double right, H1handle h1=0) |
Create condition. | |
void | ChangeC1 (C1handle c1, double left, double right) |
Change condition limits. | |
int | TestC1 (C1handle c1, double value, double *dist=0) |
Test condition. | |
double | GetC1Limit (C1handle c1, bool isleft=true) |
Get condition limit. | |
virtual bool | RegisterObject (TObject *tobj, const char *subfolder=0) |
Register object. | |
Protected Attributes | |
HldProcessor * | fHldProc {nullptr} |
pointer on HLD processor | |
SubProcMap | fMap |
map of sub-processors | |
unsigned | fHadaqCTSId {0} |
identifier of CTS header in HADAQ event | |
std::vector< unsigned > | fHadaqHUBId |
identifier of HUB header in HADQ event | |
unsigned | fLastTriggerId {0} |
last seen trigger id | |
unsigned | fLostTriggerCnt {0} |
lost trigger counts | |
unsigned | fTakenTriggerCnt {0} |
registered trigger counts | |
base::H1handle | fEvSize {nullptr} |
HADAQ event size. | |
unsigned | fSubevHLen {0} |
maximal length of subevent in bytes | |
unsigned | fSubevHDiv {0} |
integer division for subevent | |
base::H1handle | fSubevSize {nullptr} |
HADAQ subevent size. | |
base::H1handle | fLostRate {nullptr} |
lost rate | |
base::H1handle | fTrigType {nullptr} |
trigger type | |
base::H1handle | fErrBits {nullptr} |
error bit statistics | |
base::H1handle | fMsgPerBrd {nullptr} |
! messages per board | |
base::H1handle | fErrPerBrd {nullptr} |
! errors per board | |
base::H1handle | fHitsPerBrd {nullptr} |
! data hits per board | |
base::H2handle | fCalHitsPerBrd {nullptr} |
! calibration hits per board, used only in HADES | |
base::H2handle | fToTPerBrd {nullptr} |
! ToT values for each TDC channel | |
bool | fPrintRawData |
true when raw data should be printed | |
bool | fCrossProcess |
if true, cross-processing will be enabled | |
int | fPrintErrCnt |
number of error messages, which could be printed | |
unsigned | fSyncTrigMask |
mask which should be applied for trigger type | |
unsigned | fSyncTrigValue |
value from trigger type (after mask) which corresponds to sync message | |
unsigned | fCalibrTriggerMask |
trigger mask used for calibration | |
bool | fUseTriggerAsSync |
when true, trigger number used as sync message between TRBs | |
bool | fCompensateEpochReset |
when true, artificially create contiguous epoch value | |
bool | fAutoCreate |
when true, automatically crates TDC processors | |
TrbMessage | fMsg |
used for TTree store | |
TrbMessage * | pMsg {nullptr} |
used for TTree store | |
unsigned | fMinTdc |
minimal id of TDC | |
unsigned | fMaxTdc |
maximal id of TDC | |
std::vector< hadaq::TdcProcessor * > | fTdcsVect |
array of TDCs | |
hadaqs::RawSubevent | fLastSubevHdr |
! copy of last subevent header (without data) | |
unsigned | fCurrentRunId |
! current runid | |
unsigned | fCurrentEventId |
! current processed event id, used in log msg | |
Protected Attributes inherited from base::StreamProc | |
BuffersQueue | fQueue |
! buffers queue | |
unsigned | fQueueScanIndex |
index of next buffer which should be scanned | |
unsigned | fQueueScanIndexTm |
index of buffer to scan and set correct times of the buffer head | |
AnalysisKind | fAnalysisKind |
defines that processor is doing | |
SyncKind | fSynchronisationKind |
kind of synchronization | |
SyncMarksQueue | fSyncs |
list of sync markers | |
unsigned | fSyncScanIndex |
sync scan index, indicate number of syncs which can really be used for synchronization | |
bool | fSyncFlag |
boolean, used in sync adjustment procedure | |
LocalMarkersQueue | fLocalMarks |
queue with local markers | |
double | fTriggerAcceptMaring |
time margin (in local time) to accept new trigger | |
GlobalTime_t | fLastLocalTriggerTm |
time of last local trigger | |
GlobalMarksQueue | fGlobalMarks |
list of global triggers in work | |
unsigned | fGlobalTrigScanIndex |
index with first trigger which is not yet ready | |
unsigned | fGlobalTrigRightIndex |
temporary value, used during second buffers scan | |
bool | fTimeSorting |
defines if time sorting should be used for the messages | |
base::H1handle | fTriggerTm |
! histogram with time relative to the trigger | |
base::H1handle | fMultipl |
! histogram of event multiplicity | |
base::C1handle | fTriggerWindow |
window used for data selection | |
Protected Attributes inherited from base::Processor | |
std::string | fName |
processor name, used for event naming | |
unsigned | fID |
identifier, used mostly for debugging | |
ProcMgr * | fMgr |
direct pointer on manager | |
std::string | fPathPrefix |
histogram path prefix, used for histogram folder name | |
std::string | fPrefix |
prefix, used for histogram names | |
std::string | fSubPrefixD |
sub-prefix for histogram directory | |
std::string | fSubPrefixN |
sub-prefix for histogram names | |
int | fHistFilling |
level of histogram filling | |
unsigned | fStoreKind |
if >0, store will be enabled for processor | |
bool | fIntHistFormat |
if true, internal histogram format is used | |
Static Protected Attributes | |
static unsigned | gNumChannels = 65 |
default number of channels | |
static unsigned | gEdgesMask = 0x1 |
default edges mask | |
static bool | gIgnoreSync = false |
ignore sync in analysis, very rare used for sync with other data sources | |
static unsigned | gTDCMin = 0x0000 |
min TDC id when doing autoscan | |
static unsigned | gTDCMax = 0x0FFF |
max TDC id when doing autoscan | |
static unsigned | gHUBMin = 0x8100 |
min HUB id when doing autoscan | |
static unsigned | gHUBMax = 0x81FF |
max HUB id when doing autoscan | |
Static Protected Attributes inherited from base::StreamProc | |
static unsigned | fMarksQueueCapacity = 10000 |
maximum number of items in the marksers queue | |
static unsigned | fBufsQueueCapacity = 100 |
maximum number of items in the queue | |
Friends | |
class | TdcProcessor |
class | SubProcessor |
class | HldProcessor |
Additional Inherited Members | |
Public Types inherited from base::StreamProc | |
enum | SyncKind { sync_None , sync_Inter , sync_Left , sync_Right } |
kind of synchronization More... | |
Protected Types inherited from base::StreamProc | |
typedef RecordsQueue< base::Buffer, false > | BuffersQueue |
buffers queue | |
typedef RecordsQueue< base::SyncMarker, false > | SyncMarksQueue |
sync markers queue | |
Protected Types inherited from base::Processor | |
enum | { DummyBrdId = 0xffffffff } |
TRB processor.
This is generic processor for data, coming from TRB board Normally one requires specific sub-processor for frontend like TDC or any other Idea that TrbProcessor can interpret HADAQ event/subevent structures and will distribute data to sub-processors.
|
protected |
Way to register sub-processor, like for TDC.
Add sub-processor (like TDC or ADC)
bool hadaq::TrbProcessor::CollectMissingTDCs | ( | hadaqs::RawSubevent * | sub, |
std::vector< unsigned > & | ids | ||
) |
Using data structure in raw event, collect ids of missing TDCs.
<! Extract data portion from the whole packet (in a loop)
|
protectedvirtual |
Scan FPGA-TDC data, distribute over sub-processors.
Scan subevent.
this is first scan of subevent from TRB3 data our task is statistic over all messages we will found also for trigger-type 1 we should add SYNC message to each processor
<! Extract data portion from the whole packet (in a loop)
<! ================== Dummy header and inside ==========================
<! In theory here must be only one word - termination package with the status
<! ================= any other header ========================
Reimplemented in hadaq::MonitorProcessor.
|
static |
Set defaults for the next creation of TDC processors.
numch | provides number of channels and edges. |
edges | define how falling edges are used
|
ignore_sync | defines if sync messages are ignored (true by default) */ |
|
inline |
Use TRB trigger number as SYNC message.
By this we synchronize all TDCs on all TRB boards by trigger number
unsigned hadaq::TrbProcessor::TransformSubEvent | ( | hadaqs::RawSubevent * | sub, |
void * | tgtbuf = nullptr , |
||
unsigned | tgtlen = 0 , |
||
bool | only_hist = false , |
||
std::vector< unsigned > * | newids = nullptr |
||
) |
Transform (calibrate) raw data Creates output HLD structure, used in HADES DAQ.
<! ================= FPGA TDC header ========================