stream  0.10.0
stream analysis framework
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
base::ProcMgr Class Reference

Central data and process manager. More...

#include <base/ProcMgr.h>

Inheritance diagram for base::ProcMgr:
TRootProcMgr TFirstStepProcessor

Public Member Functions

 ProcMgr ()
virtual ~ProcMgr ()
ProcMgrAddProcessor (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.
StreamProcGetProc (unsigned n) const
 Get processor by sequence number.
StreamProcFindProc (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)
void UserPostLoop (Processor *only_proc=nullptr)

Static Public Member Functions

static ProcMgrinstance ()
 Return global instance of processor manager, provided by framework.
static void ClearInstancePointer (ProcMgr *mgr=nullptr)
 clear instance pointer
static ProcMgrAddProc (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::EventfTrigEvent {nullptr}
 ! current event, filled when performing triggered analysis
int fDebug {0}
 ! debug level

Static Protected Attributes

static ProcMgrfInstance = 0
 ! instance


class Processor

Detailed Description

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

Member Function Documentation

◆ AddToTrigEvent()

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

◆ CollectNewTriggers()

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

◆ FindProc()

base::StreamProc * base::ProcMgr::FindProc ( const char *  name) const

Find processor by name.

Find processor.

◆ MakeH1()

base::H1handle base::ProcMgr::MakeH1 ( const char *  name,
const char *  title,
int  nbins,
double  left,
double  right,
const char *  xtitle = 0 

Creates 1-dimensional histogram.

namehistogram name
titlehistogram title
nbinsnumber of histogram bins
leftleft range of histogram
rightright range of histogram
xtitleaxis 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.

◆ MakeH2()

base::H2handle base::ProcMgr::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.

namehistogram name
titlehistogram title
nbins1number of histogram bins on X axis
left1left X range
right1right X range
nbins2number of histogram bins on Y axis
left2left Y range
right2right Y range
optionstypically 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.

◆ ProduceNextEvent()

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

◆ ScanDataForNewTriggers()

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

◆ SetHistFilling()

void base::ProcMgr::SetHistFilling ( int  lvl)

Set histogram fill level for all processors.

In HADAQ plugin following values are supported:

  • 0 - no histograms
  • 1 - basic histograms in HLD/TRB
  • 2 - generic histograms for each TDC
  • 3 - include histograms for each active TDC channel
  • 4 - also special time reference histograms for channels (when configured)

◆ SetRawAnalysis()

void base::ProcMgr::SetRawAnalysis ( bool  on = true)

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

◆ SetSecondName()

void base::ProcMgr::SetSecondName ( const std::string &  name = "second.C")

Set name of second macro, which executed after first.C.

Normally it is second.C

◆ SetStoreKind()

void base::ProcMgr::SetStoreKind ( unsigned  kind = 1)

Set store kind for all processors.

With HADAQ following values are used

  • 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

◆ SetTimeSorting()

void base::ProcMgr::SetTimeSorting ( bool  on)

Set sorting flag for all registered processors.

Enable time sorting.

◆ SetTriggeredAnalysis()

void base::ProcMgr::SetTriggeredAnalysis ( bool  on = true)

Enabled/disable triggered analysis is configured.

If on - analyzed data will be processed as triggered, no time correlation is performed

◆ SyncIdDiff()

int base::ProcMgr::SyncIdDiff ( unsigned  id1,
unsigned  id2 
) const

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.

The documentation for this class was generated from the following files: