// // File : MiRunHeader.hh // // Purpose: Declaration of Mirror run header class // // $Id: MiRunHeader.hh 12082 2011-02-21 17:11:29Z mathes $ // /** @file MiRunHeader.hh * Declaration of the class TMirrorRunHeader. * @author H.-J. Mathes, FzK */ #ifndef _MiRunHeader_hh_ #define _MiRunHeader_hh_ #include #include #include // std::time_t #include //#include #include #include using std::time_t; // --- forward declaration(s) class TShmRunHeader; /** Run header class. * * @anchor MiRun * Each time when a RUN is started an object of this type is created * and its data fields are filled appropiately. This object contains * information about: * @li the run number of the present RUN * @li the RUNs start time * @li a verbose comment * @li a set of up to kMAX_RUNHEADER_OPTIONS optional parameters * * The RUN option parameters are either integer or float values which might * be set by the user. The interpretation of these parameters is in the * resposibility of the user and in the responsibility of the programmer * of the readout process. * * Note:
* This structure stores the times internally in GPS format ! * * @todo * @li include boxcar summing width into run parameters * @li include statistics parameters into run parameters * @li ? include software trigger parameters ? */ class TMirrorRunHeader : public TObject { friend class TShmRunHeader; /** Number of option entries in the run header. */ static const unsigned int kMAX_RUNHEADER_OPTIONS = 32; public: /** The possible indices for RunHeader option vector. */ enum ERunHeaderOption { // --- software configuration RUNH_OPT_READOUT_VERSION = 0, // MIREADOUT_VERSION_CODE RUNH_OPT_FDHWLIB_VERSION, // FE::getVersion() // --- hardware options RUNH_OPT_FLT_INTEGRATION_TIME = 2, RUNH_OPT_FLT_STATISTIC_SAMPLES, RUNH_OPT_FLT_STATISTIC_OFFSET, // --- options set by the PixelSelector RUNH_OPT_SLT_MIN_DISTANCE = 5, RUNH_OPT_SLT_N_EXT_COLUMNS, RUNH_OPT_SLT_N_EXT_ROWS, RUNH_OPT_SLT_FIRST_SLT_BIN, RUNH_OPT_SLT_LAST_SLT_BIN, RUNH_OPT_SLT_MAX_EVENT_SIZE, // --- options set by the TLT RUNH_OPT_TLT_COINCIDENCE_WINDOW = 11, RUNH_OPT_TLT_MULTI_REJECTION_ENABLED, RUNH_OPT_TLT_N_PATTERN, RUNH_OPT_TLT_KEEP_REJECT_FRACTION, RUNH_OPT_TLT_FIRST_SLT_BIN, RUNH_OPT_TLT_LAST_SLT_BIN, RUNH_OPT_TLT_MAX_EVENT_SIZE, RUNH_OPT_TLT_CUT_PARAMETER1, RUNH_OPT_TLT_CUT_PARAMETER2, // --- more options RUNH_OPT_FLT_VERSION = 30, RUNH_OPT_SLT_VERSION = 31 }; public: /** Default constructor of the class TMirrorRunHeader. */ TMirrorRunHeader(); #ifndef __CINT__ /** Constructor from class TShmRunHeader in shared memory. */ TMirrorRunHeader(TShmRunHeader*); #endif // __CINT__ /** Copy constructor of the class TMirrorRunHeader. */ TMirrorRunHeader(const TMirrorRunHeader&); /** Destructor of the class TMirrorRunHeader. */ virtual ~TMirrorRunHeader(); /** Special operator=() which performs a deep copy. */ TMirrorRunHeader& operator=(const TMirrorRunHeader&); public: /** Clear the contents of a TMirrorRunTHeader object. */ virtual void Clear(Option_t * ="") { Init(); } /** Print the contents of the run header to the specified stream. */ void Show(std::ostream& ostr=std::cout) const; // --- getters ... /** Get the comment string of the run header. */ const char* GetComment() const { return fRunHeader->fComment; } /** Get the maximum number of option parameters which can be * stored in the run header. */ unsigned int GetMaxNumOptions() const { return kMAX_RUNHEADER_OPTIONS; } /** Get the actual number of option parameters stored in the run header. */ unsigned int GetNumOptions() const { return fRunHeader->fNOptions; } #if (defined __GNUC__) && !(__GNUC__ < 3) // don't override method of base class, avoid warning -Woverloaded-virtual using TObject::GetOption; #endif // __GNUC__ /** Get integer option parameter 'num'. */ void GetOption(unsigned int,int&) const; /** Get unsigned integer option parameter 'num'. */ void GetOption(unsigned int,unsigned int&) const; /** Get float option parameter 'num'. */ void GetOption(unsigned int,float&) const; /** Get the number of the actual RUN. */ unsigned int GetRunNo() const { return fRunHeader->fRunNumber; } /** Get the time when the RUN was started. */ time_t GetStartTime() const { return fRunHeader->fStartTime; } // --- setters ... /** Set the RUN number. */ void SetRunNo(unsigned int run_no) { fRunHeader->fRunNumber = run_no; } /** Set the time when the RUN was started to the passed value. */ void SetStartTime(time_t t) { fRunHeader->fStartTime = t; } /** Set the time when the RUN was started by using the builtin * system function time(). */ void SetStartTime() { fRunHeader->fStartTime = FdUtil::TimeConvert::GetGPSTime(); } /** Set the comment string in the run header. */ void SetComment(const char* comment) { std::strncpy( fRunHeader->fComment, comment, std::strlen( comment ) + 1 ); } /** Set the integer option parameter 'num'. */ void SetOption(unsigned int,int); /** Set the unsigned integer option parameter 'num'. */ void SetOption(unsigned int,unsigned int); /** Set the float option parameter 'num'. */ void SetOption(unsigned int,float); public: // --- convenient getters/setters float GetFdhwlibVersion() { float option; GetOption( RUNH_OPT_FDHWLIB_VERSION, option ); return option; } int GetReadoutVersion() { int option; GetOption( RUNH_OPT_READOUT_VERSION, option ); return option; } void SetFdhwlibVersion(float version) { SetOption( RUNH_OPT_FDHWLIB_VERSION, version ); } void SetFltIntegrationTime(unsigned int i_time) { SetOption( RUNH_OPT_FLT_INTEGRATION_TIME, i_time ); } void SetFltStatisticSamples(unsigned int samples ) { SetOption( RUNH_OPT_FLT_STATISTIC_SAMPLES, samples ); } void SetFltStatisticOffset(unsigned int offset ) { SetOption( RUNH_OPT_FLT_STATISTIC_OFFSET, offset ); } void SetReadoutVersion(int version) { SetOption( RUNH_OPT_READOUT_VERSION, version ); } void SetSltMinDistance(unsigned int dist ) { SetOption( RUNH_OPT_SLT_MIN_DISTANCE, dist ); } void SetSltNExtColumns(unsigned int ext_col ) { SetOption( RUNH_OPT_SLT_N_EXT_COLUMNS, ext_col ); } void SetSltNExtRows(unsigned int ext_row ) { SetOption( RUNH_OPT_SLT_N_EXT_ROWS, ext_row ); } void SetSltFirstBin(unsigned int first ) { SetOption( RUNH_OPT_SLT_FIRST_SLT_BIN, first ); } void SetSltLastBin(unsigned int last ) { SetOption( RUNH_OPT_SLT_LAST_SLT_BIN, last ); } void SetSltMaxEventSize(unsigned int max_size ) { SetOption( RUNH_OPT_SLT_MAX_EVENT_SIZE, max_size ); } void SetTltCoincidenceWindow(unsigned int window ) { SetOption( RUNH_OPT_TLT_COINCIDENCE_WINDOW, window ); } void SetTltMultiRejectionEnable(int enable ) { SetOption( RUNH_OPT_TLT_MULTI_REJECTION_ENABLED, enable ? 1 : 0 ); } void SetTltNPattern(unsigned int n_pattern ) { SetOption( RUNH_OPT_TLT_N_PATTERN, n_pattern ); } void SetTltKeepRejectedFraction(float fraction ) { SetOption( RUNH_OPT_TLT_KEEP_REJECT_FRACTION, fraction ); } void SetTltFirstBin(unsigned int first ) { SetOption( RUNH_OPT_TLT_FIRST_SLT_BIN, first ); } void SetTltLastBin(unsigned int last ) { SetOption( RUNH_OPT_TLT_LAST_SLT_BIN, last ); } void SetTltMaxEventSize(unsigned int max_size ) { SetOption( RUNH_OPT_TLT_MAX_EVENT_SIZE, max_size ); } void SetTltCutParameter1(float par ) { SetOption( RUNH_OPT_TLT_CUT_PARAMETER1, par ); } void SetTltCutParameter2(float par ) { SetOption( RUNH_OPT_TLT_CUT_PARAMETER2, par ); } protected: /** Preset the data structure with default values. */ virtual void Init(); private: typedef union _MiRunOption { int fIntOption; // integer run option unsigned int fUIntOption; // unsigned integer run option float fFloatOption; // float run option } MiRunOptionRec, *MiRunOption; typedef struct _MiRunHeaderRec { unsigned int fRunNumber; time_t fStartTime; unsigned int fNOptions; MiRunOptionRec fOption[kMAX_RUNHEADER_OPTIONS]; char fComment[256]; } MiRunHeaderRec, *MiRunHeader; /** Constructor from pointer to internal struct MiRunHeaderRec. */ TMirrorRunHeader(MiRunHeader); private: enum Constructor_t { kCREATE, kRUNHEADER, kSHM_RUNHEADER }; enum Constructor_t fConstructorType; //! MiRunHeader fRunHeader; //! ptr. to internal struct ClassDef(TMirrorRunHeader,MiEVENTVERSIONv2) }; #endif // _MiRunHeader_hh_