CAnalysisBase

Name

CAnalysisBase -- Base class for callout objects

Synopsis


#include <CAnalysisBase.h>

class CAnalysisBase
{
public:
    typedef enum _StateChangeType {
        Begin, End, Pause, Resume
    } StateChangeType;

    typedef enum _StringListType {
        PacketTypes, MonitoredVariables, RunVariables
    } StringListType;

public:
    virtual void onStateChange(
        StateChangeType type, int runNumber, time_t absoluteTime, float runTime,
        std::string title, void* clientData
    );
    virtual void onScalers(
        time_t absoluteTime, float startOffset, float endOffset,
        std::vector<unsigned> scalers, bool incremental, void* clientData
    );

    virtual void onStringLists(
        StringListType type, time_t absoluteTime, float runTime,
        std::vector<std::string> strings, void* clientData
    );

    virtual unsigned onEvent(void* pEvent, void* clientData);

    // Methods throw this to report an error that the framework
    // can continue after.

    class NonFatalException : public std::runtime_error {
        public:
            explicit NonFatalException(const std::string& whatarg) :
                std::runtime_error(whatarg) {}

    };
    // Methods throw this for errors that require the analysis
    // to be aborted (whatever that means in the context of the
    // framework)

    class FatalException : public std::runtime_error {
        public:
            explicit FatalException(const std::string& whatarg) :
                std::runtime_error(whatarg) {}
    };
};

    

METHODS

This section describes both the call signatures of the ScalerProcessor as well as what each method does in some detail.

ScalerProcessor(CTCLInterpreter& interp);

Initializes data structures like per run scaler totals. The interp object is the encapsulated Tcl interpreter in on which the scaler processor will operate. This is normally the SpecTcl main Tcl interpreter which can be gotten via:


#include <SpecTcl.h>

...

auto pApi = SpecTcl::getInstance();

CTCLInterpreter* pInterp = pApi->getInterpreter();

                    

virtual void onStateChange(StateChangeType type, int runNumber, time_t absoluteTime, float runTime, std::string title, void* clientData);

This method is called by the event processor it is attached to when a state change item is encountered. The Run number, elapsed run time and runtitle are unconditionally saved in the RunNumber, ElapsedRunTime, and RunTitle Tcl global variables respectively.

The method then analyzes the type to select a new value for the ScalerRunState Tcl global variable and determines which of the Tcl procs BeginRun, EndRun PauseRun or ResumeRun to call.

The absoluteTime parameter is ignored as is the clientData

virtual void onScalers(time_t absoluteTime, float startOffset, float endOffset, std::vector<unsigned> scalers, bool incremental, void* clientData);

Called when a scaler item is encountered. endTime is placed in the ElapsedRunTime. endOffset and startOffset are used to compute the value of the ElapsedRunTime Tcl global variable.

In this implementation incremental is ignored and the scalers are assumed to be incremental. scalers are used to set the various Scaler_Increments(i) Tcl global variables and running totals over the run are maintained in the Scaler_Totals.

The Update is called after all Tcl global variables have been set.