stream
0.10.0
stream analysis framework
|
Central data and process manager. More...
#include <base/ProcMgr.h>
Public Member Functions | |
ProcMgr () | |
constructor | |
virtual | ~ProcMgr () |
destructor | |
ProcMgr * | AddProcessor (Processor *proc) |
add processor | |
void | SetSecondName (const std::string &name="second.C") |
Set name of second macro, which executed after first.C. More... | |
void | ClearSecondName () |
Clear name of second macro, will not be executed at all. | |
const std::string & | GetSecondName () const |
Returns number of second macro. | |
bool | RegisterProc (StreamProc *proc, unsigned kind, unsigned brdid) |
Enter processor for processing data of specified kind. | |
unsigned | NumProc () const |
Get number of registered processors. | |
StreamProc * | GetProc (unsigned n) const |
Get processor by sequence number. | |
StreamProc * | FindProc (const char *name) const |
Find processor by name. More... | |
void | SetHistFilling (int lvl) |
Set histogram fill level for all processors. More... | |
void | SetDebug (int lvl=0) |
Set debug level. | |
int | GetDebug () const |
Returns debug level. | |
virtual void | SetStoreKind (unsigned kind=1) |
Set store kind for all processors. More... | |
virtual bool | InternalHistFormat () const |
When returns true, indicates that simple histogram format is used. | |
virtual void | AddRunLog (const char *msg) |
Add run log. | |
virtual void | AddErrLog (const char *msg) |
Add error log. | |
virtual bool | DoLog () |
Returns true if logging is enabled. | |
virtual void | PrintLog (const char *msg) |
print log message | |
virtual void | SetSortedOrder (bool=true) |
Set if histograms folders should be created in sorted alphabetical order, default false. | |
virtual bool | IsSortedOrder () |
Returns true if histograms folders created in sorted alphabetical order. | |
virtual H1handle | MakeH1 (const char *name, const char *title, int nbins, double left, double right, const char *xtitle=0) |
Creates 1-dimensional histogram. More... | |
virtual bool | GetH1NBins (H1handle h1, int &nbins) |
get number of histogram bins | |
virtual void | FillH1 (H1handle h1, double x, double weight=1.) |
Fill histogram. | |
virtual double | GetH1Content (H1handle h1, int bin) |
get histogram context | |
virtual void | SetH1Content (H1handle h1, int bin, double v=0.) |
set histogram content | |
virtual void | ClearH1 (H1handle h1) |
Clear 1D histogram. | |
virtual void | CopyH1 (H1handle tgt, H1handle src) |
Copy 1D histogram. | |
virtual void | SetH1Title (H1handle h1, const char *title) |
Set histogram title. | |
virtual void | TagH1Time (H1handle h1) |
Tag histogram time. | |
virtual H2handle | MakeH2 (const char *name, const char *title, int nbins1, double left1, double right1, int nbins2, double left2, double right2, const char *options=0) |
Creates 2-dimensional histogram. More... | |
virtual bool | GetH2NBins (H2handle h2, int &nbins1, int &nbins2) |
get number of bins for 2D histogram | |
virtual void | FillH2 (H2handle h2, double x, double y, double weight=1.) |
Fill 2D histogram. | |
virtual double | GetH2Content (H2handle h2, int bin1, int bin2) |
Get content for 2D histogram. | |
virtual void | SetH2Content (H2handle h2, int bin1, int bin2, double v=0.) |
Set content for 2D histogram. | |
virtual void | ClearH2 (H2handle h2) |
Clear 2D histogram. | |
virtual void | SetH2Title (H2handle h1, const char *title) |
Set histogram title. | |
virtual void | TagH2Time (H2handle h2) |
Tag histogram time. | |
virtual void | ClearAllHistograms () |
Clear all histograms. | |
virtual C1handle | MakeC1 (const char *name, double left, double right, base::H1handle h1=nullptr) |
create condition | |
virtual void | ChangeC1 (C1handle c1, double left, double right) |
change condition limits | |
virtual int | TestC1 (C1handle c1, double value, double *dist=nullptr) |
Condition check 0 - inside, -1 left , +1 - right If variable dist specified, will contain distance to left (-1) or right (+1) boundary */. | |
virtual double | GetC1Limit (C1handle c1, bool isleft=true) |
get condition limit | |
virtual bool | CreateStore (const char *storename) |
create data store, for the moment - ROOT tree | |
virtual bool | CloseStore () |
Close store. | |
virtual bool | CreateBranch (const char *name, const char *class_name, void **obj) |
Create branch. | |
virtual bool | CreateBranch (const char *name, void *member, const char *kind) |
Create branch. | |
virtual bool | StoreEvent () |
Store event. | |
virtual bool | RegisterObject (TObject *tobj, const char *subfolder=nullptr) |
method to register ROOT objects, object should be derived from TObject class if returns true, object is registered and will be owned by framework | |
virtual bool | CallFunc (const char *funcname, void *arg) |
method to call function by name | |
bool | IsRawAnalysis () const |
Returns true if raw analysis is configured. | |
void | SetRawAnalysis (bool on=true) |
Enable/disable raw analysis. More... | |
bool | IsTriggeredAnalysis () const |
Returns true if triggered analysis is configured. | |
void | SetTriggeredAnalysis (bool on=true) |
Enabled/disable triggered analysis is configured. More... | |
bool | IsStreamAnalysis () const |
Returns true if full timed stream analysis is configured. | |
void | SetTimeSorting (bool on) |
Set sorting flag for all registered processors. More... | |
void | SetTimeMasterIndex (unsigned indx) |
Specify processor index, which is used as time reference for all others. | |
void | ProvideRawData (const Buffer &buf) |
Method to provide raw data on base of data kind to the processor. | |
bool | AnalyzeSyncMarkers () |
Check current sync markers TODO: configure which processor is time master TODO: work with unsynchronized SYNC messages - not always the same id in the front TODO: process not only last sync message. | |
bool | CollectNewTriggers () |
Method to collect triggers. More... | |
bool | ScanDataForNewTriggers () |
Method to produce data for new triggers. More... | |
bool | AnalyzeNewData (base::Event *&evt) |
Analyze new data, if triggered analysis configured - immediately produce new event. | |
bool | HasTrigEvent () const |
Returns true if trigger even exists. | |
bool | AddToTrigEvent (const std::string &name, base::SubEvent *sub) |
add subevent with the name to the trigger event More... | |
bool | ProduceNextEvent (base::Event *&evt) |
Very central method - select if possible data for next event. More... | |
virtual bool | ProcessEvent (base::Event *evt) |
Process event - consequently calls all event processors. | |
void | UserPreLoop (Processor *only_proc=nullptr, bool call_when_running=false) |
pre-loop | |
void | UserPostLoop (Processor *only_proc=nullptr) |
post-loop | |
Static Public Member Functions | |
static ProcMgr * | instance () |
Return global instance of processor manager, provided by framework. | |
static void | ClearInstancePointer (ProcMgr *mgr=nullptr) |
clear instance pointer | |
static ProcMgr * | AddProc (Processor *proc) |
add processor to instance | |
Protected Types | |
enum | { MaxBrdId = 256 } |
enum | { NoSyncIndex = 0xfffffffe , DummyIndex = 0xffffffff } |
typedef std::map< unsigned, StreamProc * > | StreamProcMap |
map of stream processors | |
Protected Member Functions | |
virtual unsigned | SyncIdRange () const |
range for sync messages | |
int | SyncIdDiff (unsigned id1, unsigned id2) const |
Method calculated difference id2-id1, used for sync markers identification Sync ID overflow is taken into account. More... | |
void | DeleteAllProcessors () |
Delete all processors. | |
Protected Attributes | |
std::string | fSecondName |
! name of second.C script | |
std::vector< StreamProc * > | fProc |
! all stream processors | |
StreamProcMap | fMap |
! map for fast access | |
std::vector< EventProc * > | fEvProc |
! all event processors | |
GlobalMarksQueue | fTriggers |
!< list of current triggers | |
unsigned | fTimeMasterIndex |
! processor index, which time is used for all other subsystems | |
AnalysisKind | fAnalysisKind |
! ignore all events, only single scan, not output events | |
TTree * | fTree {nullptr} |
! abstract tree pointer, will be used in ROOT implementation | |
int | fDfltHistLevel |
! default histogram fill level for any new created processor | |
int | fDfltStoreKind |
! default store kind for any new created processor | |
base::Event * | fTrigEvent {nullptr} |
! current event, filled when performing triggered analysis | |
int | fDebug {0} |
! debug level | |
Static Protected Attributes | |
static ProcMgr * | fInstance = 0 |
! instance | |
Friends | |
class | Processor |
Central data and process manager.
Class base::ProcMgr is central manager of processors and interface to any external frameworks like ROOT or Go4 or ... It is singleton - the only instance for whole system
bool base::ProcMgr::AddToTrigEvent | ( | const std::string & | name, |
base::SubEvent * | sub | ||
) |
add subevent with the name to the trigger event
method used to add data, extracted with first scan, to the special triggered event if subevent not accepted, it will be deleted
bool base::ProcMgr::CollectNewTriggers | ( | ) |
Method to collect triggers.
central place where triggers should be produced in addition, we should perform flushing of data therefore if triggers are not produced for long time, one should create special "flush" trigger which force flushing of the data
base::StreamProc * base::ProcMgr::FindProc | ( | const char * | name | ) | const |
Find processor by name.
Find processor.
|
virtual |
Creates 1-dimensional histogram.
name | histogram name |
title | histogram title |
nbins | number of histogram bins |
left | left range of histogram |
right | right range of histogram |
xtitle | axis title |
Parameter xtitle used to deliver different optional arguments syntax will be like: arg_name:arg_value;arg2_name:arg2_value; For instance, labels for each bin: xbin:EPOCH,HIT,SYNC,AUX,,,SYS;
Reimplemented in TFirstStepProcessor.
|
virtual |
Creates 2-dimensional histogram.
name | histogram name |
title | histogram title |
nbins1 | number of histogram bins on X axis |
left1 | left X range |
right1 | right X range |
nbins2 | number of histogram bins on Y axis |
left2 | left Y range |
right2 | right Y range |
options | typically X and Y axis title like "x_values;y_values" |
Parameter options can also be used to deliver different optional arguments. Syntax will be like: arg_name:arg_value;arg2_name:arg2_value; For instance, labels for each x bin: "xbin:EPOCH,HIT,SYNC,AUX,,,SYS;"
Reimplemented in TFirstStepProcessor.
bool base::ProcMgr::ProduceNextEvent | ( | base::Event *& | evt | ) |
Very central method - select if possible data for next event.
Only can be done that each processor is agree to deliver data within trigger interval. It may not be a case when messages from future buffers may be required */
at this moment each processor should finish with buffers scanning for special cases (like MBS or EPICS) processor itself should declare that triggers in between are correctly filled
bool base::ProcMgr::ScanDataForNewTriggers | ( | ) |
Method to produce data for new triggers.
here we want that each processor scan its data again for new triggers which we already distribute to each processor. In fact, this could run in individual thread of each processor
void base::ProcMgr::SetHistFilling | ( | int | lvl | ) |
Set histogram fill level for all processors.
In HADAQ plugin following values are supported:
|
inline |
Enable/disable raw analysis.
If on - only data scan is performed, no any output events with second scan can be produced. No second.C will be involved
|
inline |
Set name of second macro, which executed after first.C.
Normally it is second.C
|
virtual |
Set store kind for all processors.
With HADAQ following values are used
void base::ProcMgr::SetTimeSorting | ( | bool | on | ) |
Set sorting flag for all registered processors.
Enable time sorting.
|
inline |
Enabled/disable triggered analysis is configured.
If on - analyzed data will be processed as triggered, no time correlation is performed
|
protected |
Method calculated difference id2-id1, used for sync markers identification Sync ID overflow is taken into account.
Calculate difference between two sync ids taking into account possible overflow.