// // File : ReadoutConfig.hh // // Purpose: Declaration of the class ReadoutConfig // // $Id: ReadoutConfig.hh 12326 2011-04-12 06:54:48Z mathes $ // /** @file ReadoutConfig.hh * Declaration of the class ReadoutConfig * @author H.-J. Mathes, FzK */ #ifndef _ReadoutConfig_hh_ #define _ReadoutConfig_hh_ #include #include #include #include // Version_t #include #include #ifndef NO_VERSION # include #endif // NO_VERSION #include // MiREADOUTVERSION namespace MiReadout { /** This enum declares the various options for the GPS clock parametrization * as it is seen by the readout process. */ enum { kGPSStrobeLocal, ///< clock strobe is generated locally kGPSStrobeGPS, ///< clock strobe is provided by the external clock kGPSTimeScaleUTC, ///< clock runs with UTC time scale kGPSTimeScaleGPS, ///< clock runs with GPS time scale }; /** This struct contains all (GPS) frontend clock setting options. */ typedef struct _GPSClockConfigRec { int fStrobeMode; ///< how the clock strobe is generated int fTimeScale; ///< with which time scale the clock is running } GPSClockConfigRec, *GPSClockConfig; /** The default settings for the GPS clock configuration. */ #define DEFAULT_GPSCLOCK_CONFIG \ { MiReadout::kGPSStrobeGPS, MiReadout::kGPSTimeScaleGPS } /** This struct contains all configuration options for the FLT modules. */ typedef struct _FltParametersRec { bool fStatisticEnabled; ///< if FLT statistic algo. is enabled unsigned int fStatisticOffset; ///< offset to be subtracted from ADC reading // change to unsigned int !!! unsigned long fStatisticNSamples; ///< number of samples for FLT statistic algo. unsigned int fIntegrationTime; ///< boxcar integration time unsigned int fCoincidenceTime; ///< FLT signal width at SLT unsigned int fNFADCBins; ///< number of FADC bins } FltParametersRec, *FltParameters; /** The default settings for the FLT configuration (V3). */ #define DEFAULT_FLT_PARAMETERS_V3 \ { false, 150, 65536, 10, 0, FdUtil::Fd::kMI_NFADC_BINS_v3 } /** The default settings for the FLT configuration (V4). */ #define DEFAULT_FLT_PARAMETERS_V4 \ { false, 130, 65536, 10, 0, FdUtil::Fd::kMI_NFADC_BINS_DEFAULT } /** The default settings for the FLT configuration. */ #define DEFAULT_FLT_PARAMETERS ReadoutConfig::GetDefaultFltParameters() /** Structure which is sent to the readout process to parametrize the * SLT data based decision making. * * This structure is sent with the message READOUT_CMD_SET_SLT_PARAMETERS * and is not acknowledged. */ typedef struct _SltParametersRec { /** Version of this struct. */ Version_t fVersion; // --- general flag variables to steer the software readout chain (later) // --- parameters for the 'SLTFullReadout' processor /** Defines at which ADC bin to start reading. */ unsigned int fStartBin; /** Defines at which ADC bin to end reading. */ unsigned int fEndBin; /** Flag, if 'FullReadout' processor is used. */ int fDoFullReadout; // --- parameters for the 'SLTSelectiveReadout' processor /** * Minimum distance to between set pixels to isolate * single pixels and delete them. */ unsigned int fMinDistance; /** Number of columns to extend the readout of a pixel cluster. */ unsigned int fNExtColumns; /** Number of rows to extend the readout of a pixel cluster. */ unsigned int fNExtRows; /** Flag, if the Mirror level TLT should be performed. */ int fDoTlt; /** First SLT time bin where to start the search for patterns. */ unsigned int fFirstSltBin; /** Last SLT time bin where to stop the search for patterns. */ unsigned int fLastSltBin; /** Events above this number of pixels are discarded. */ unsigned int fMaxEventSize; } SltParametersRec, *SltParameters; /** The default settings for the SltParametersRec struct (V3). */ #define DEFAULT_SLT_PARAMETERS_V3 \ { MiREADOUTVERSION, \ 0, /* fStartBin */ \ (FdUtil::Fd::kMI_NFADC_BINS_v3 - 1), /* fEndBin */ \ true, /* fDoFullReadout */ \ 2, /* fMinDistance */ \ 2, /* fNExtColumns */ \ 2, /* fNExtRows */ \ false, /* fDoTlt */ \ 0, /* fFirstSltBin */ \ 99, /* fLastSltBin */ \ 440 /* fMaxEventSize */ \ } /** The default settings for the SltParametersRec struct (V4). */ #define DEFAULT_SLT_PARAMETERS_V4 \ { MiREADOUTVERSION, \ 0, /* fStartBin */ \ (FdUtil::Fd::kMI_NFADC_BINS_DEFAULT - 1), /* fEndBin */ \ true, /* fDoFullReadout */ \ 2, /* fMinDistance */ \ 2, /* fNExtColumns */ \ 2, /* fNExtRows */ \ false, /* fDoTlt */ \ 0, /* fFirstSltBin */ \ 99, /* fLastSltBin */ \ 440 /* fMaxEventSize */ \ } /** The default settings for the SltParametersRec struct. */ #define DEFAULT_SLT_PARAMETERS ReadoutConfig::GetDefaultSltParameters() /** This structure describes the parameters which are used to configure the * software based 3rd level trigger. This structure is sent within the * READOUT_CMD_SET_TLTPAR message and is not acknowledged. */ typedef struct _TltParametersRec { /** Version of this struct. */ Version_t fVersion; /** Time window for the SLT/FLT pulse matching [*100 ns]. */ unsigned int fCoincidenceWindow; /** Flag if rejection should be based on analysis of 0x7f * pattern or not. */ bool fEnableMultipleRejection; /** Number of patterns to be analyzed at least. This is only in effect * when the flag fEnableMultipleRejection is true. */ unsigned int fNumPatternToAnalyse; /** Fraction of rejected events which should be kept. */ unsigned int fKeepRejectedFraction; /** First SLT time bin where to start the search for patterns. */ unsigned int fFirstSltBin; // => SltParameters /** Last SLT time bin where to stop the search for patterns. */ unsigned int fLastSltBin; // => SltParameters /** Events above this number of pixels are discarded. */ unsigned int fMaxEventSize; // => SltParameters /** Cut parameter for GetAveraged100NSPerPixel() test. */ float fCutParameter1; /** Cut parameter for GetPropagationParameters() test. */ float fCutParameter2; } TltParametersRec, *TltParameters; /** The default settings for the TltParametersRec struct. */ #define DEFAULT_TLT_PARAMETERS \ { MiREADOUTVERSION, /* fVersion */\ 15, /* fCoincidenceWindow */ \ true, /* fEnableMultipleRejection */ \ 10, /* fNumPatternToAnalyse */ \ 10 , /* fKeepRejectedFraction */ \ 10, /* fFirstSltBin */ \ 35, /* fLastSltBin */ \ 120, /* fMaxEventSize */ \ 0.40, /* fCutParameter1 */ \ 0.90 /* fCutParameter2 */ \ } } // namespace MiReadout #include // --- forward declaration(s) #include namespace FdUtil { class Inifile; class InifileChain; } /** This class is the interface to the configuration data of the readout * process. * At present the option 'full readout' is used to select either * a full readout or a selective readout. The * option 'tlt readout' can be activate together with one of the before * mentioned options. These options are stored in th e'Default' configuration * which is initialized upon class' construction. * * Further this class steers if the GPS clock (second strobed clock) is * steered by the strobe signal provided by some external clock (GPS) or by * the systems internal clock oscillator. Furthermore it can be steered if * this clock is initialized with a number corresponding to the UTC or the * GPS time scale. * * The format of the ini-file is the following: * \code [General] loglevel= 0 ; logging level of some classes (= printout or not) ; defined in FdUtil::ErrorLogger.hh ; eDebug=-1, eInfo=0, eWarn=1, eError=2, ; eCritical=3, eSevere=4, eFatal=5 ; Default (if omitted) is 0 full= 1 ; enable/disable FullReadout tlt= 0 ; enable/disable TltReadout [FullReadout] firstbin= 0 ; first ADC bin to readout lastbin= 999 ; last ADC bin to readout [SelectiveReadout] colext= 2 ; number of columns to read extra (around found pixel) rowext= 2 ; number of rows to read extra mindist= 1 ; criterion to delete single pixels firstsltbin = 0 ; first time bin in SLT to look for data lastsltbin= 99 ; last time bin in SLT to look for data minpixel= 1 ; events with less pixels are too small and rejected maxpixel= 70 ; events with more pixels are too large and rejected [TltReadout] firstsltbin = 0 ; first time bin in SLT to look for data lastsltbin= 99 ; last time bin in SLT to look for data coincidence= 15 ; number of 100 ns intervals for FLT/SLT matching multireject= 0 ; enable/disable of multiple pattern keepreject= 100 ; fraction of events to keep after rejection largereject= 0 ; enable rejection of large events maxpixel= 70 ; events with more pixels are too large and rejected [ExtTagged] ; this section steers the readout of ExtTrg tagged events ; here we have the same parameters as in the ; [General], [FullReadout] and [SelectiveReadout] sections full= 1 ; enable/disable FullReadout tlt= 0 ; enable/disable TltReadout ; --- parameters for class FullReadout firstbin= 0 ; first ADC bin to readout lastbin= 999 ; last ADC bin to readout ; --- parameters for class SelectiveReadout colext= 1 ; number of columns to read extra (around found pixel) rowext= 1 ; number of rows to read extra mindist= 1 ; criterion to delete single pixels firstsltbin = 0 ; first time bin in SLT to look for data lastsltbin= 99 ; last time bin in SLT to look for data minpixel= 1 ; events with less pixels are too small and rejected maxpixel= 440 ; events with more pixels are too large and rejected [GPSClock] ; section which describes the GPS clock setting mode strobe= gps ; possible values: local, gps set= gps ; possible values: utc, gps [FltStatistic] ; section which describes ths settings for the FLT enable= 1 ; the algorithm running at FLT hardware is enabled offset= 150 ; offset to be subtracted from each FADC bin samples= 65536 ; number of samples to take into account integration= 10 ; FLT boxcar summing time (not used) fadcbins= 2000 ; number of FADC bins (V4) ;fadcbins= 1000 ; number of FADC bins (V3) * \endcode */ // class ReadoutConfig : public FdUtil::VConfiguration { class ReadoutConfig { // access methods *Configuration() ... friend class CorbaRunControl; // classes which must read from the ini-file ... friend class ReadoutMonitor; friend class ReadoutRunBook; friend class FERateLimitedReadout; friend class FEFileReadout; public: /** Get THE instance of the ReadoutConfig object. */ static ReadoutConfig* GetInstance(const char* ="readout.ini", const char* =""); /** Get THE instance of the ReadoutConfig object. */ static ReadoutConfig* GetInstance(const std::string inifile, const std::string profile="") { return GetInstance( inifile.c_str(), profile.c_str() ); } /** Dump the contents of the passed FltParameters struct to the * specified stream. * * If no struct is passed, the contents of the corresponding object * in the class ReadoutConfig is listed. */ static void DumpFltParameters(const MiReadout::FltParametersRec&, const char *where="", std::ostream& ostr=std::cout); /** Dump the contents of the passed GPSClockConfig struct to the * specified stream. */ static void DumpGPSClockConfig(const MiReadout::GPSClockConfigRec&, const char *where="", std::ostream& ostr=std::cout); /** Dump the contents of the stored parameters for the NeighborTriggered * event readout etc. */ void DumpNeighborTriggerParameters(const char *where="", ostream& ostr=std::cout); /** Dump the contents of the passed SltParameters struct to the * specified stream. * * If no struct is passed, the contents of the corresponding object * in the class ReadoutConfig is listed. */ static void DumpSltParameters(const MiReadout::SltParametersRec&, const char *where="", std::ostream& ostr=std::cout); /** Dump the contents of the passed TltParameters struct to the * specified stream. * * If no struct is passed, the contents of the corresponding object * in the class ReadoutConfig is listed. */ static void DumpTltParameters(const MiReadout::TltParametersRec&, const char *where="", std::ostream& ostr=std::cout); /** Get the default FLT parameters (compile time constants). */ static const MiReadout::FltParametersRec& GetDefaultFltParameters() { static MiReadout::FltParametersRec v4_flt = DEFAULT_FLT_PARAMETERS_V4; static MiReadout::FltParametersRec v3_flt = DEFAULT_FLT_PARAMETERS_V3; if ( FdUtil::GetEyeId() == 5 ) // HEAT ? return v4_flt; else return v3_flt; } /** Get the default SLT parameters (compile time constants). */ static const MiReadout::SltParametersRec& GetDefaultSltParameters() { static MiReadout::SltParametersRec v4_slt = DEFAULT_SLT_PARAMETERS_V4; static MiReadout::SltParametersRec v3_slt = DEFAULT_SLT_PARAMETERS_V3; if ( FdUtil::GetEyeId() == 5 ) // HEAT ? return v4_slt; else return v3_slt; } /** Get the default TLT parameters (compile time constants). */ static const MiReadout::TltParametersRec& GetDefaultTltParameters() { static MiReadout::TltParametersRec tlt = DEFAULT_TLT_PARAMETERS; return tlt; } /** Get the logging level read from ini-file. */ FdUtil::ErrorLogger::ESeverityLevel GetLoggingLevel() { return fLoggingLevel; } /** Return a handle to the SltParameters stored in the ReadoutConfig object. * * The values of the returned object should not be modified. */ MiReadout::FltParameters GetFltParameters() { return &fFltParameters; } /** Return a handle to the GPS Clocks configuration parameters. * * The values of the returned object should not be modified. */ MiReadout::GPSClockConfig GetGPSClockConfiguration() { return &fGpsClockConfig; } /** Return a handle to the MStcCutTltParameters stored in the ReadoutConfig * object. * * The values of the returned object should not be modified. */ MiReadout::MStcCutTltParameters GetMStcCutTltParameters() { return &fMStcCutTltPar; } /** Return a handle to the Neighbor TltParameters stored in the * ReadoutConfig object. * * The values of the returned object should not be modified. */ MiReadout::TltParameters GetNeighborTltParameters() { return &fTltParameters["NeighborTriggered"]; } /** Return a handle to the SltParameters stored in the ReadoutConfig * object. * * The values of the returned object should not be modified. */ MiReadout::SltParameters GetSltParameters(const std::string& =""); /** Return a handle to the TltParameters stored in the ReadoutConfig * object. * * The values of the returned object should not be modified. */ MiReadout::TltParameters GetTltParameters(const std::string& =""); /** Return true, if the option 'full readout' is enabled. */ bool IsEnabledFullReadout(); /** Return true, if the option 'selective readout' is enabled. * * If the options 'full readout' and 'selective readout' are active at * the same time, then 'selective readout' will be chosen. */ bool IsEnabledSelectiveReadout(); /** Return true, if the option 'tlt readout' is enabled. */ bool IsEnabledEnabledTltReadout(); /** Set the FLT parameters in the actual configuration. */ void SetFltParameters(MiReadout::FltParameters flt) { fFltParameters = *flt; } /** Set the SLT parameters in the actual configuration. */ void SetSltParameters(MiReadout::SltParameters slt, const std::string& config=""); /** Set the TLT parameters in the actual configuration. */ void SetTltParameters(MiReadout::TltParameters tlt, const std::string& config=""); protected: // --- inherits from general configuration class /** Close the configuration data source. */ virtual void CloseConfiguration(); /** Read the complete configuration from the current configuration medium * (Inifile). */ virtual void LoadConfiguration(); /** Open/Attach the configuration data source. */ virtual void OpenConfiguration(const std::string& name,const char option='r'); /** Dump the current configuration settings to the configuration medium * (not yet implemented). */ virtual void SaveConfiguration(); /** Initialize the internal buffer variables to their default * configuration values. */ virtual void SetDefaultConfiguration(); /** Constructor for the class ReadoutConfig. * * The following things are done: * @li the local configuration variables are initialized to their * compiled in default values. * @li then try to read the actual settings from the passed ini-file */ ReadoutConfig(const char* config_name="readout.ini", const char *profile=""); /** Destructor of the class ReadoutConfig. All allocated resources a * released. */ virtual ~ReadoutConfig(); #if 0 // 'profile' feature not yet used -> commented out /** Create the full name of the ini-file including the profile * specifier. * * Example: readout#profile.ini */ std::string GetCompleteInifileName(const char *ini_file, const char *profile=""); #endif /** Get the handle to the Inifile. */ FdUtil::InifileChain * GetInifile() { return fInifile; } /** Read the section Flt from the ini-file. * * @return true on success, false otherwise */ bool ReadSectionFltStatistic(MiReadout::FltParametersRec&); /** Read the section [FullReadout] from the ini-file. * * @return true on success, false otherwise */ bool ReadSectionFullReadout(MiReadout::SltParametersRec&, const std::string& ="FullReadout"); /** Read the section [General] from the ini-file. * * @return true on success, false otherwise */ bool ReadSectionGeneral(); /** Read the section [GPSClock] from the ini-file. * * @return true on success, false otherwise */ bool ReadSectionGPSClock(MiReadout::GPSClockConfigRec&); /** Read the section [MStcCutTlt] from the ini-file. * * @return true on success, false otherwise */ bool ReadSectionMStcCutTlt(); /** Read the section [Neighbor] from the ini-file. */ bool ReadSectionNeighbor(MiReadout::TltParametersRec&, const std::string& ="NeighborTriggered"); /** Read the section [SelectiveReadout] from the ini-file. */ bool ReadSectionSelectiveReadout(MiReadout::SltParametersRec&, const std::string& ="SelectiveReadout"); /** Read the section [TltReadout] from the ini-file. */ bool ReadSectionTltReadout(MiReadout::TltParametersRec&, const std::string& ="TltReadout"); /** The handle to the Inifile/InifileChain. */ FdUtil::InifileChain *fInifile; private: static ReadoutConfig *fgReadoutConfig; FdUtil::ErrorLogger::ESeverityLevel fLoggingLevel; std::string fInifileName; ///< full name of the ini-file (w. profile) std::string fProfileName; ///< name of the actual profile // --- the configuration variables we have to read MiReadout::FltParametersRec fFltParameters; MiReadout::GPSClockConfigRec fGpsClockConfig; std::map fSltParameters; std::map fTltParameters; MiReadout::MStcCutTltParametersRec fMStcCutTltPar; }; #endif // _ReadoutConfig_hh_