Belle II Software development
DQMHistAnalysisTOPModule Class Referencefinal

Class for TOP histogram analysis. More...

#include <DQMHistAnalysisTOP.h>

Inheritance diagram for DQMHistAnalysisTOPModule:
DQMHistAnalysisModule Module PathElement

Public Types

enum  EStatus {
  c_StatusTooFew = 0 ,
  c_StatusDefault = 1 ,
  c_StatusGood = 2 ,
  c_StatusWarning = 3 ,
  c_StatusError = 4
}
 Status flag of histogram/canvas. More...
 
enum  EStatusColor {
  c_ColorTooFew = kGray ,
  c_ColorDefault = kWhite ,
  c_ColorGood = kGreen ,
  c_ColorWarning = kYellow ,
  c_ColorError = kRed
}
 Status colors of histogram/canvas (corresponding to status) More...
 
enum  ERefScaling {
  c_RefScaleNone = 0 ,
  c_RefScaleEntries = 1 ,
  c_RefScaleMax = 2
}
 Reference plot scaling type. More...
 
typedef std::map< std::string, HistObjectHistList
 The type of list of histograms.
 
typedef std::map< std::string, MonitoringObjectMonObjList
 The type of list of MonitoringObjects.
 
typedef std::map< std::string, HistDeltaDeltaList
 The type of list of delta settings and histograms.
 
typedef std::map< std::string, bool > CanvasUpdatedList
 The type of list of canvas updated status.
 
typedef std::map< std::string, RefHistObjectRefList
 The type of list of references.
 
enum  EModulePropFlags {
  c_Input = 1 ,
  c_Output = 2 ,
  c_ParallelProcessingCertified = 4 ,
  c_HistogramManager = 8 ,
  c_InternalSerializer = 16 ,
  c_TerminateInAllProcesses = 32 ,
  c_DontCollectStatistics = 64
}
 Each module can be tagged with property flags, which indicate certain features of the module. More...
 
typedef ModuleCondition::EAfterConditionPath EAfterConditionPath
 Forward the EAfterConditionPath definition from the ModuleCondition.
 

Public Member Functions

 DQMHistAnalysisTOPModule ()
 Constructor.
 
void initialize () override final
 Initializer.
 
void beginRun () override final
 Called when entering a new run.
 
void event () override final
 This method is called for each event.
 
void endRun () override final
 This method is called if the current run ends.
 
void terminate () override final
 This method is called at the end of the event processing.
 
void clearlist (void)
 Clear all static global lists.
 
TH1 * findHistInCanvas (const std::string &hname, TCanvas **canvas=nullptr)
 Find histogram in corresponding canvas.
 
TH1 * getDelta (const std::string &fullname, int n=0, bool onlyIfUpdated=true)
 Get Delta histogram.
 
TH1 * getDelta (const std::string &dirname, const std::string &histname, int n=0, bool onlyIfUpdated=true)
 Get Delta histogram.
 
int registerEpicsPV (const std::string &pvname, const std::string &keyname="")
 EPICS related Functions.
 
int registerExternalEpicsPV (const std::string &pvname, const std::string &keyname="")
 Register a PV with its name and a key name.
 
void setEpicsPV (const std::string &keyname, double value)
 Write value to a EPICS PV.
 
void setEpicsPV (const std::string &keyname, int value)
 Write value to a EPICS PV.
 
void setEpicsPV (int index, double value)
 Write value to a EPICS PV.
 
void setEpicsPV (int index, int value)
 Write value to a EPICS PV.
 
void setEpicsStringPV (const std::string &keyname, const std::string &value)
 Write string to a EPICS PV.
 
void setEpicsStringPV (int index, std::string value)
 Write string to a EPICS PV.
 
double getEpicsPV (const std::string &keyname)
 Read value from a EPICS PV.
 
double getEpicsPV (int index)
 Read value from a EPICS PV.
 
std::string getEpicsStringPV (const std::string &keyname, bool &status)
 Read value from a EPICS PV.
 
std::string getEpicsStringPV (int index, bool &status)
 Read value from a EPICS PV.
 
int updateEpicsPVs (float timeout)
 Update all EPICS PV (flush to network)
 
chid getEpicsPVChID (const std::string &keyname)
 Get EPICS PV Channel Id.
 
chid getEpicsPVChID (int index)
 Get EPICS PV Channel Id.
 
bool requestLimitsFromEpicsPVs (chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
 Get Alarm Limits from EPICS PV.
 
bool requestLimitsFromEpicsPVs (const std::string &keyname, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
 Get Alarm Limits from EPICS PV.
 
bool requestLimitsFromEpicsPVs (int index, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
 Get Alarm Limits from EPICS PV.
 
void setUseEpics (bool flag)
 Setter for EPICS usage.
 
void cleanupEpicsPVs (void)
 Unsubscribe from EPICS PVs on terminate.
 
void checkPVStatus (void)
 Check the status of all PVs and report if disconnected or not found.
 
void CheckEpicsError (int state, const std::string &message, const std::string &name)
 check the return status and check PV in case of error
 
void CheckEpicsError (int state, const std::string &message, chid id)
 check the return status and check PV in case of error
 
virtual std::vector< std::string > getFileNames (bool outputFiles)
 Return a list of output filenames for this modules.
 
const std::string & getName () const
 Returns the name of the module.
 
const std::string & getType () const
 Returns the type of the module (i.e.
 
const std::string & getPackage () const
 Returns the package this module is in.
 
const std::string & getDescription () const
 Returns the description of the module.
 
void setName (const std::string &name)
 Set the name of the module.
 
void setPropertyFlags (unsigned int propertyFlags)
 Sets the flags for the module properties.
 
LogConfiggetLogConfig ()
 Returns the log system configuration.
 
void setLogConfig (const LogConfig &logConfig)
 Set the log system configuration.
 
void setLogLevel (int logLevel)
 Configure the log level.
 
void setDebugLevel (int debugLevel)
 Configure the debug messaging level.
 
void setAbortLevel (int abortLevel)
 Configure the abort log level.
 
void setLogInfo (int logLevel, unsigned int logInfo)
 Configure the printed log information for the given level.
 
void if_value (const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 Add a condition to the module.
 
void if_false (const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 A simplified version to add a condition to the module.
 
void if_true (const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 A simplified version to set the condition of the module.
 
bool hasCondition () const
 Returns true if at least one condition was set for the module.
 
const ModuleConditiongetCondition () const
 Return a pointer to the first condition (or nullptr, if none was set)
 
const std::vector< ModuleCondition > & getAllConditions () const
 Return all set conditions for this module.
 
bool evalCondition () const
 If at least one condition was set, it is evaluated and true returned if at least one condition returns true.
 
std::shared_ptr< PathgetConditionPath () const
 Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).
 
Module::EAfterConditionPath getAfterConditionPath () const
 What to do after the conditional path is finished.
 
std::vector< std::shared_ptr< Path > > getAllConditionPaths () const
 Return all condition paths currently set (no matter if the condition is true or not).
 
bool hasProperties (unsigned int propertyFlags) const
 Returns true if all specified property flags are available in this module.
 
bool hasUnsetForcedParams () const
 Returns true and prints error message if the module has unset parameters which the user has to set in the steering file.
 
const ModuleParamListgetParamList () const
 Return module param list.
 
template<typename T>
ModuleParam< T > & getParam (const std::string &name) const
 Returns a reference to a parameter.
 
bool hasReturnValue () const
 Return true if this module has a valid return value set.
 
int getReturnValue () const
 Return the return value set by this module.
 
std::shared_ptr< PathElementclone () const override
 Create an independent copy of this module.
 
std::shared_ptr< boost::python::list > getParamInfoListPython () const
 Returns a python list of all parameters.
 

Static Public Member Functions

static HistListgetHistList ()
 Get the list of the histograms.
 
static MonObjListgetMonObjList ()
 Get the list of MonitoringObjects.
 
static const DeltaListgetDeltaList ()
 Get the list of the delta histograms.
 
static const CanvasUpdatedListgetCanvasUpdatedList ()
 Get the list of the canvas update status.
 
static const std::string & getRunType (void)
 Get the list of the reference histograms.
 
static int getEventProcessed (void)
 Get the number of processed events.
 
static void setRunType (const std::string &t)
 Set the Run Type.
 
static void setEventProcessed (int e)
 Set the number of processed events.
 
static TCanvas * findCanvas (TString cname)
 Find canvas by name.
 
static TH1 * findHist (const std::string &histname, bool onlyIfUpdated=false)
 Get histogram from list (no other search).
 
static TH1 * findHist (const std::string &dirname, const std::string &histname, bool onlyIfUpdated=false)
 Find histogram.
 
static TH1 * findRefHist (const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
 Get referencehistogram from list (no other search).
 
static TH1 * findRefHist (const std::string &dirname, const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
 Find reference histogram.
 
static TH1 * scaleReference (ERefScaling scaling, const TH1 *hist, TH1 *ref)
 Using the original and reference, create scaled version.
 
static TH1 * findHistInFile (TFile *file, const std::string &histname)
 Find histogram in specific TFile (e.g.
 
static MonitoringObjectfindMonitoringObject (const std::string &objName)
 Find MonitoringObject.
 
static double getSigma68 (TH1 *h)
 Helper function to compute half of the central interval covering 68% of a distribution.
 
static bool addHist (const std::string &dirname, const std::string &histname, TH1 *h)
 Add histogram.
 
static void addRefHist (const std::string &dirname, TH1 *hist)
 Add reference histogram.
 
static MonitoringObjectgetMonitoringObject (const std::string &name)
 Get MonitoringObject with given name (new object is created if non-existing)
 
static void clearCanvases (void)
 Clear content of all Canvases.
 
static void initHistListBeforeEvent (void)
 Reset the list of histograms.
 
static void clearHistList (void)
 Clears the list of histograms.
 
static void clearRefList (void)
 Clears the list of ref histograms.
 
static void resetDeltaList (void)
 Reset Delta.
 
static void addDeltaPar (const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
 Add Delta histogram parameters.
 
static bool hasDeltaPar (const std::string &dirname, const std::string &histname)
 Check if Delta histogram parameters exist for histogram.
 
static void UpdateCanvas (const std::string &name, bool updated=true)
 Mark canvas as updated (or not)
 
static void UpdateCanvas (TCanvas *canvas, bool updated=true)
 Mark canvas as updated (or not)
 
static void ExtractRunType (std::vector< TH1 * > &hs)
 Extract Run Type from histogram title, called from input module.
 
static void ExtractNEvent (std::vector< TH1 * > &hs)
 Extract event processed from daq histogram, called from input module.
 
static void setUseEpicsReadOnly (bool flag)
 Setter EPICS flag in read only mode.
 
static bool getUseEpics (void)
 Getter for EPICS usage.
 
static bool getUseEpicsReadOnly (void)
 Getter EPICS flag in read only mode.
 
static std::string & getPVPrefix (void)
 get global prefix for EPICS PVs
 
static void setPVPrefix (const std::string &prefix)
 set global prefix for EPICS PVs
 
static EStatus makeStatus (bool enough, bool warn_flag, bool error_flag)
 Helper function to judge the status for coloring and EPICS.
 
static void colorizeCanvas (TCanvas *canvas, EStatus status)
 Helper function for Canvas colorization.
 
static EStatusColor getStatusColor (EStatus status)
 Return color for canvas state.
 
static void printPVStatus (chid pv, bool onlyError=true)
 check the status of a PVs and report if disconnected or not found
 
static std::vector< std::string > StringSplit (const std::string &s, const char delim)
 Helper function for string token split.
 
static void exposePythonAPI ()
 Exposes methods of the Module class to Python.
 

Static Public Attributes

static DeltaList s_deltaList
 The list of Delta Histograms and settings.
 

Protected Member Functions

virtual void def_initialize ()
 Wrappers to make the methods without "def_" prefix callable from Python.
 
virtual void def_beginRun ()
 Wrapper method for the virtual function beginRun() that has the implementation to be used in a call from Python.
 
virtual void def_event ()
 Wrapper method for the virtual function event() that has the implementation to be used in a call from Python.
 
virtual void def_endRun ()
 This method can receive that the current run ends as a call from the Python side.
 
virtual void def_terminate ()
 Wrapper method for the virtual function terminate() that has the implementation to be used in a call from Python.
 
void setDescription (const std::string &description)
 Sets the description of the module.
 
void setType (const std::string &type)
 Set the module type.
 
template<typename T>
void addParam (const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
 Adds a new parameter to the module.
 
template<typename T>
void addParam (const std::string &name, T &paramVariable, const std::string &description)
 Adds a new enforced parameter to the module.
 
void setReturnValue (int value)
 Sets the return value for this module as integer.
 
void setReturnValue (bool value)
 Sets the return value for this module as bool.
 
void setParamList (const ModuleParamList &params)
 Replace existing parameter list.
 

Private Types

enum  EAlarmStates {
  c_Gray = 0 ,
  c_Green = 1 ,
  c_Yellow = 2 ,
  c_Red = 3
}
 Alarm states enumerator. More...
 

Private Member Functions

void updateWindowVsSlotCanvas ()
 Updates canvas of window_vs_slot w/ alarming.
 
void updateEventMonitorCanvas ()
 Updates canvas of event desynchronization monitor w/ alarming.
 
void updateNGoodHitsCanvas ()
 Updates canvas of number of good hits per event w/ alarming (injection BG)
 
void updateEventT0Canvas ()
 Updates canvas of event T0 w/ alarming.
 
void updateBunchOffsetCanvas ()
 Updates canvas of bunch offset w/ alarming.
 
void updateTimingCanvas ()
 Updates canvas of timing plot w/ alarming.
 
const TH1F * makeDeadAndHotFractionsPlot ()
 Makes a plot of dead and hot channel fractions per slot.
 
void makePhotonYieldsAndBGRatePlots (const TH1F *activeFraction)
 Make plots of dead-and-hot-channel corrected photon yields and BG rates per slot.
 
void makeJunkFractionPlot ()
 Makes a plot of fractions of junk hits per boardstack.
 
void makePMTHitRatesPlots ()
 Makes plots of the number of PMT hits per event.
 
void makeInjectionBGPlots ()
 Makes projections of injection BG plots.
 
void setMiraBelleVariables (const std::string &variableName, const TH1 *histogram)
 Sets MiraBelle variables from the histogram with bins corresponding to slot numbers.
 
int getAlarmState (double value, const std::vector< double > &alarmLevels, bool bigRed=true) const
 Returns alarm state.
 
int getAlarmColor (unsigned alarmState) const
 Converts alarm state to color.
 
int getOffcialAlarmStatus (unsigned alarmState) const
 Converts alarm state to official status (see EStatus of the base class)
 
void setAlarmLines ()
 Sets all alarm lines.
 
void setEpicsVariables ()
 Calculates and sets epics variables.
 
void updateLimits ()
 Updates limits defined by module parameters using EpicsPVs.
 
void setIncludedBoardstacks (const std::vector< std::string > &excludedBoardstacks)
 Sets flags for boardstacks to be included in alarming.
 
int registerEpicsPVwithPrefix (const std::string &prefix, const std::string &pvname, const std::string &keyname="")
 Register a PV with its name and a key name.
 
std::list< ModulePtrgetModules () const override
 no submodules, return empty list
 
std::string getPathString () const override
 return the module name.
 
void setParamPython (const std::string &name, const boost::python::object &pyObj)
 Implements a method for setting boost::python objects.
 
void setParamPythonDict (const boost::python::dict &dictionary)
 Implements a method for reading the parameter values from a boost::python dictionary.
 

Static Private Member Functions

static bool sameHistDefinition (TH1 *h1, TH1 *h2)
 Checks if histograms are defined in the same way (nbins, xmin, xmax)
 
static void setZAxisRange (const std::string &name, double scale)
 Sets z-axis range of 2D histograms.
 
static void makeBGSubtractedTimingPlot (const std::string &name, const TH2F *trackHits, int slot)
 Makes background subtracted time distribution plot.
 
static void makeFlagFractPlot (const std::string &hname, TH1 *histogram, TCanvas *canvas)
 Makes a plot of fraction of events with the flag is set.
 
static void setAlarmLines (const std::vector< double > &alarmLevels, double xmin, double xmax, std::vector< TLine * > &alarmLines, bool bigRed=true)
 Sets alarm lines.
 
static std::pair< double, double > getDeadAndHotCuts (const TH1 *h)
 Returns cut levels for dead and hot channels.
 

Private Attributes

std::vector< int > m_asicWindowsBand = {215, 235}
 lower and upper bin of a band denoting good windows
 
std::vector< double > m_asicWindowsAlarmLevels = {0.002, 0.02}
 alarm levels for fraction of windows outside the band
 
std::vector< double > m_eventMonitorAlarmLevels = {1e-4, 2e-3}
 alarm levels for fraction of desynchronized digits
 
std::vector< double > m_junkHitsAlarmLevels = {0.05, 0.25}
 alarm levels for the fraction of junk hits
 
std::vector< double > m_deadChannelsAlarmLevels = {0.1, 0.35}
 alarm levels for the fraction of dead + hot channels
 
std::vector< double > m_backgroundAlarmLevels = {5.0, 10.0}
 alarm levels for background rates [MHz/PMT]
 
std::vector< double > m_photonYieldsAlarmLevels = {15.0, 25.0}
 alarm levels for the number of photons per track
 
std::vector< std::string > m_excludedBoardstacks
 list of boarstacks to be excluded from alarming
 
std::string m_pvPrefix
 Epics PV prefix.
 
std::vector< double > m_injectionBGAlarmLevels = {5, 10}
 alarm levels for injection background (in % of events)
 
std::vector< double > m_timingAlarmLevels = {0.15, 0.30}
 alarm levels for time distribution (fraction of area difference)
 
std::vector< double > m_eventT0MeanAlarmLevels = {8, 20}
 alarm levels for mean of event T0 [ns]
 
std::vector< double > m_eventT0RmsAlarmLevels = {10, 20}
 alarm levels for r.m.s.
 
std::vector< double > m_offsetMeanAlarmLevels = {0.2, 0.5}
 alarm levels for mean of bunch offset [ns]
 
std::vector< double > m_offsetRmsAlarmLevels = {0.25, 0.50}
 alarm levels for r.m.s.
 
std::vector< int > m_alarmColors = {c_ColorTooFew, c_ColorGood, c_ColorWarning, c_ColorError}
 alarm colors (see base class)
 
std::vector< int > m_officialStates = {c_StatusTooFew, c_StatusGood, c_StatusWarning, c_StatusError}
 official alarm states
 
std::vector< bool > m_includedBoardstacks
 boardstacks included in alarming
 
std::map< std::string, int > m_bsmap
 a map of boardstack names to ID's
 
int m_alarmStateOverall = 0
 overall alarm state of histograms to be sent by EpicsPV
 
double m_averageRate = 0
 average BG rate (to pass to EpicsPV)
 
bool m_IsNullRun = false
 Run type flag for null runs.
 
std::string m_runType
 Run type.
 
double m_numEvents = 0
 number of events processed with TOPDQM module
 
TH1D * m_photonYields = nullptr
 photon yields per slot
 
TH1D * m_backgroundRates = nullptr
 background rates per slot
 
TCanvas * m_c_photonYields = nullptr
 Canvas: photon yields per slot.
 
TCanvas * m_c_backgroundRates = nullptr
 Canvas: background rates per slot.
 
TH1F * m_hotFraction = nullptr
 fraction of hot channels per slot (included boardstacks only)
 
TH1F * m_deadFraction = nullptr
 fraction of dead channels per slot (included boardstacks only)
 
TH1F * m_excludedFraction = nullptr
 fraction of dead and hot channels per slot in excluded boardstacks only
 
TH1F * m_activeFraction = nullptr
 fraction of active channels per slot
 
THStack * m_stack = nullptr
 stack for drawing dead, hot and active channel fractions
 
TLegend * m_legend = nullptr
 legend for dead and hot channels
 
TCanvas * m_c_deadAndHot = nullptr
 Canvas: fractin of dead and hot channels.
 
TH1F * m_junkFraction = nullptr
 fraction of junk hits per boardstack
 
TH1F * m_excludedBSHisto = nullptr
 histogram to show excluded boardstacks on junk fraction plot
 
TCanvas * m_c_junkFraction = nullptr
 Canvas: fraction of junk hits per boardstack.
 
std::vector< TH1F * > m_pmtHitRates
 histograms of PMT hits per event (index = slot - 1)
 
std::vector< TCanvas * > m_c_pmtHitRates
 Canvases of PMT hits per event (index = slot - 1)
 
std::map< std::string, TCanvas * > m_c_injBGs
 Canvases for projections of injection BG histograms.
 
std::map< std::string, TProfile * > m_profiles
 profiles of injection BG
 
std::map< std::string, TH1D * > m_projections
 projections of injection BG
 
TH1D * m_skipProcFlagFract = nullptr
 fraction of events w/ skip processing flag set vs.
 
TH1D * m_injVetoFlagFract = nullptr
 fraction of events w/ injection veto flag set vs.
 
TCanvas * m_c_skipProcFlagFract = nullptr
 Canvas: fraction of events w/ skip processing flag set vs.
 
TCanvas * m_c_injVetoFlagFract = nullptr
 Canvas: fraction of events w/ injection veto flag set vs.
 
std::vector< TLine * > m_asicWindowsBandLines
 lines denoting a band of good windows
 
std::vector< TLine * > m_verticalLines
 vertical lines splitting slots
 
std::vector< TLine * > m_junkHitsAlarmLines
 lines representing alarm levels
 
std::vector< TLine * > m_deadChannelsAlarmLines
 lines representing alarm levels
 
std::vector< TLine * > m_backgroundAlarmLines
 lines representing alarm levels
 
std::vector< TLine * > m_photonYieldsAlarmLines
 lines representing alarm levels
 
TLine * m_injBGCutLine = nullptr
 a line denoting the cut on the number of hits for injection BG counting
 
TPaveText * m_text1 = nullptr
 text to be written to window_vs_slot
 
TPaveText * m_text2 = nullptr
 text to be written to event desynchonization monitor
 
TPaveText * m_text3 = nullptr
 text to be written to background rates
 
TPaveText * m_text4 = nullptr
 text to be written to number of good hits per event
 
std::map< std::string, double > m_mirabelleVariables
 variables for MiraBelle
 
MonitoringObjectm_monObj = nullptr
 MiraBelle monitoring object.
 
std::string m_name
 The name of the module, saved as a string (user-modifiable)
 
std::string m_type
 The type of the module, saved as a string.
 
std::string m_package
 Package this module is found in (may be empty).
 
std::string m_description
 The description of the module.
 
unsigned int m_propertyFlags
 The properties of the module as bitwise or (with |) of EModulePropFlags.
 
LogConfig m_logConfig
 The log system configuration of the module.
 
ModuleParamList m_moduleParamList
 List storing and managing all parameter of the module.
 
bool m_hasReturnValue
 True, if the return value is set.
 
int m_returnValue
 The return value.
 
std::vector< ModuleConditionm_conditions
 Module condition, only non-null if set.
 

Static Private Attributes

static HistList s_histList
 The list of Histograms.
 
static MonObjList s_monObjList
 The list of MonitoringObjects.
 
static CanvasUpdatedList s_canvasUpdatedList
 The list of canvas updated status.
 
static RefList s_refList
 The list of references.
 
static int s_eventProcessed = 0
 Number of Events processed to fill histograms.
 
static std::string s_runType = ""
 The Run type.
 
static bool m_useEpics = false
 Flag if to use EPICS do not set by yourself, use EpicsEnable module to set.
 
static bool m_epicsReadOnly
 Flag if to use EPICS in ReadOnly mode (for reading limits) do not set by yourself, use EpicsEnable module to set.
 
static std::string m_PVPrefix = "TEST:"
 The Prefix for EPICS PVs.
 

Detailed Description

Class for TOP histogram analysis.

Definition at line 33 of file DQMHistAnalysisTOP.h.

Member Typedef Documentation

◆ CanvasUpdatedList

typedef std::map<std::string, bool> CanvasUpdatedList
inherited

The type of list of canvas updated status.

Definition at line 91 of file DQMHistAnalysis.h.

◆ DeltaList

typedef std::map<std::string, HistDelta> DeltaList
inherited

The type of list of delta settings and histograms.

Definition at line 86 of file DQMHistAnalysis.h.

◆ EAfterConditionPath

Forward the EAfterConditionPath definition from the ModuleCondition.

Definition at line 88 of file Module.h.

◆ HistList

typedef std::map<std::string, HistObject> HistList
inherited

The type of list of histograms.

Definition at line 77 of file DQMHistAnalysis.h.

◆ MonObjList

typedef std::map<std::string, MonitoringObject> MonObjList
inherited

The type of list of MonitoringObjects.

Definition at line 81 of file DQMHistAnalysis.h.

◆ RefList

typedef std::map<std::string, RefHistObject> RefList
inherited

The type of list of references.

Definition at line 96 of file DQMHistAnalysis.h.

Member Enumeration Documentation

◆ EAlarmStates

enum EAlarmStates
private

Alarm states enumerator.

Definition at line 73 of file DQMHistAnalysisTOP.h.

73 {
74 c_Gray = 0, // undefined
75 c_Green = 1, // good
76 c_Yellow = 2, // warning
77 c_Red = 3 // alarm
78 };

◆ EModulePropFlags

enum EModulePropFlags
inherited

Each module can be tagged with property flags, which indicate certain features of the module.

Enumerator
c_Input 

This module is an input module (reads data).

c_Output 

This module is an output module (writes data).

c_ParallelProcessingCertified 

This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)

c_HistogramManager 

This module is used to manage histograms accumulated by other modules.

c_InternalSerializer 

This module is an internal serializer/deserializer for parallel processing.

c_TerminateInAllProcesses 

When using parallel processing, call this module's terminate() function in all processes().

This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.

c_DontCollectStatistics 

No statistics is collected for this module.

Definition at line 77 of file Module.h.

77 {
78 c_Input = 1,
79 c_Output = 2,
80 c_ParallelProcessingCertified = 4,
81 c_HistogramManager = 8,
82 c_InternalSerializer = 16,
83 c_TerminateInAllProcesses = 32,
84 c_DontCollectStatistics = 64,
85 };
@ c_Output
Output Process.
Definition ProcHelper.h:19
@ c_Input
Input Process.
Definition ProcHelper.h:17

◆ ERefScaling

enum ERefScaling
inherited

Reference plot scaling type.

Enumerator
c_RefScaleNone 

no scaling

c_RefScaleEntries 

to number of entries (integral)

c_RefScaleMax 

to maximum (bin entry)

Definition at line 68 of file DQMHistAnalysis.h.

68 {
69 c_RefScaleNone = 0,
70 c_RefScaleEntries = 1,
71 c_RefScaleMax = 2
72 };

◆ EStatus

enum EStatus
inherited

Status flag of histogram/canvas.

Enumerator
c_StatusTooFew 

Not enough entries/event to judge.

c_StatusDefault 

default for non-coloring

c_StatusGood 

Analysis result: Good.

c_StatusWarning 

Analysis result: Warning, there may be minor issues.

c_StatusError 

Analysis result: Severe issue found.

Definition at line 46 of file DQMHistAnalysis.h.

46 {
47 c_StatusTooFew = 0,
48 c_StatusDefault = 1,
49 c_StatusGood = 2,
50 c_StatusWarning = 3,
51 c_StatusError = 4
52 };

◆ EStatusColor

enum EStatusColor
inherited

Status colors of histogram/canvas (corresponding to status)

Enumerator
c_ColorTooFew 

Not enough entries/event to judge.

c_ColorDefault 

default for non-coloring

c_ColorGood 

Analysis result: Good.

c_ColorWarning 

Analysis result: Warning, there may be minor issues.

c_ColorError 

Analysis result: Severe issue found.

Definition at line 57 of file DQMHistAnalysis.h.

57 {
58 c_ColorTooFew = kGray,
59 c_ColorDefault = kWhite,
60 c_ColorGood = kGreen,
61 c_ColorWarning = kYellow,
62 c_ColorError = kRed
63 };

Constructor & Destructor Documentation

◆ DQMHistAnalysisTOPModule()

Constructor.

Definition at line 34 of file DQMHistAnalysisTOP.cc.

35{
36 // Set description
37 setDescription("Histogram analysis module for TOP DQM.");
38
39 // Add parameters
40 addParam("asicWindowsBand", m_asicWindowsBand,
41 "lower and upper bin of a band denoting good windows", m_asicWindowsBand);
42 addParam("asicWindowsAlarmLevels", m_asicWindowsAlarmLevels,
43 "alarm levels for the fraction of windows outside the band (yellow, red)", m_asicWindowsAlarmLevels);
44 addParam("eventMonitorAlarmLevels", m_eventMonitorAlarmLevels,
45 "alarm levels for the fraction of desynchronized digits (yellow, red)", m_eventMonitorAlarmLevels);
46 addParam("junkHitsAlarmLevels", m_junkHitsAlarmLevels,
47 "alarm levels for the fraction of junk hits (yellow, red)", m_junkHitsAlarmLevels);
48 addParam("deadChannelsAlarmLevels", m_deadChannelsAlarmLevels,
49 "alarm levels for the fraction of dead + hot channels (yellow, red)", m_deadChannelsAlarmLevels);
50 addParam("backgroundAlarmLevels", m_backgroundAlarmLevels,
51 "alarm levels for background rates [MHz/PMT] (yellow, red)", m_backgroundAlarmLevels);
52 addParam("photonYieldsAlarmLevels", m_photonYieldsAlarmLevels,
53 "alarm levels for the number of photons per track (red, yellow)", m_photonYieldsAlarmLevels);
54 addParam("excludedBoardstacks", m_excludedBoardstacks,
55 "boarstacks to be excluded from alarming. Names are given like '5c', '13d' etc.", m_excludedBoardstacks);
56 addParam("pvPrefix", m_pvPrefix, "Epics PV prefix", std::string("TOP:"));
57 addParam("injectionBGAlarmLevels", m_injectionBGAlarmLevels,
58 "alarm levels for injection background (in % of events)", m_injectionBGAlarmLevels);
59 addParam("timingAlarmLevels", m_timingAlarmLevels,
60 "alarm levels for time distribution (residual fraction w.r.t reference plot)", m_timingAlarmLevels);
61 addParam("eventT0MeanAlarmLevels", m_eventT0MeanAlarmLevels,
62 "alarm levels for mean of event T0 [ns]", m_eventT0MeanAlarmLevels);
63 addParam("eventT0RmsAlarmLevels", m_eventT0RmsAlarmLevels,
64 "alarm levels for r.m.s. of event T0 [ns]", m_eventT0RmsAlarmLevels);
65 addParam("offsetMeanAlarmLevels", m_offsetMeanAlarmLevels,
66 "alarm levels for mean of bunch offset [ns]", m_offsetMeanAlarmLevels);
67 addParam("offsetRmsAlarmLevels", m_offsetRmsAlarmLevels,
68 "alarm levels for r.m.s. of bunch offset [ns]", m_offsetRmsAlarmLevels);
69
70 B2DEBUG(20, "DQMHistAnalysisTOP: Constructor done.");
71}
DQMHistAnalysisModule()
Constructor / Destructor.
std::vector< int > m_asicWindowsBand
lower and upper bin of a band denoting good windows
std::vector< double > m_offsetRmsAlarmLevels
alarm levels for r.m.s.
std::vector< double > m_deadChannelsAlarmLevels
alarm levels for the fraction of dead + hot channels
std::vector< double > m_asicWindowsAlarmLevels
alarm levels for fraction of windows outside the band
std::vector< double > m_offsetMeanAlarmLevels
alarm levels for mean of bunch offset [ns]
std::string m_pvPrefix
Epics PV prefix.
std::vector< double > m_eventMonitorAlarmLevels
alarm levels for fraction of desynchronized digits
std::vector< double > m_eventT0MeanAlarmLevels
alarm levels for mean of event T0 [ns]
std::vector< double > m_photonYieldsAlarmLevels
alarm levels for the number of photons per track
std::vector< double > m_injectionBGAlarmLevels
alarm levels for injection background (in % of events)
std::vector< std::string > m_excludedBoardstacks
list of boarstacks to be excluded from alarming
std::vector< double > m_eventT0RmsAlarmLevels
alarm levels for r.m.s.
std::vector< double > m_backgroundAlarmLevels
alarm levels for background rates [MHz/PMT]
std::vector< double > m_junkHitsAlarmLevels
alarm levels for the fraction of junk hits
std::vector< double > m_timingAlarmLevels
alarm levels for time distribution (fraction of area difference)
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559

Member Function Documentation

◆ addDeltaPar()

void addDeltaPar ( const std::string & dirname,
const std::string & histname,
HistDelta::EDeltaType t,
int p,
unsigned int a = 1 )
staticinherited

Add Delta histogram parameters.

Parameters
dirnamedirectory
histnamename of histogram
ttype of delta histogramming
pnumerical parameter depending on type, e.g. number of entries
aamount of histograms in the past

Definition at line 95 of file DQMHistAnalysis.cc.

97{
98 std::string fullname;
99 if (dirname.size() > 0) {
100 fullname = dirname + "/" + histname;
101 } else {
102 fullname = histname;
103 }
104 s_deltaList[fullname].set(t, p, a);
105}
static DeltaList s_deltaList
The list of Delta Histograms and settings.

◆ addHist()

bool addHist ( const std::string & dirname,
const std::string & histname,
TH1 * h )
staticinherited

Add histogram.

Parameters
dirnameThe name of the directory.
histnameThe name of the histogram.
hThe TH1 pointer for the histogram.
Returns
histogram was updated flag

Definition at line 59 of file DQMHistAnalysis.cc.

60{
61 std::string fullname;
62 if (dirname.size() > 0) {
63 fullname = dirname + "/" + histname;
64 } else {
65 fullname = histname;
66 }
67
68 if (s_histList[fullname].update(h)) {
69 // only if histogram changed, check if delta histogram update needed
70 auto it = s_deltaList.find(fullname);
71 if (it != s_deltaList.end()) {
72 B2DEBUG(20, "Found Delta" << fullname);
73 it->second.update(h); // update
74 }
75 return true; // histogram changed
76 }
77
78 return false; // histogram didn't change
79}
static HistList s_histList
The list of Histograms.

◆ addRefHist()

void addRefHist ( const std::string & dirname,
TH1 * hist )
staticinherited

Add reference histogram.

Parameters
dirnameThe name of the directory.
histThe TH1 pointer for the reference.

Definition at line 81 of file DQMHistAnalysis.cc.

82{
83 string histname = hist->GetName();
84 std::string name = dirname + "/" + histname;
85 auto& n = s_refList[name];
86 n.m_orghist_name = name;
87 n.m_refhist_name = "ref/" + name;
88 hist->SetName((n.m_refhist_name).c_str());
89 hist->SetDirectory(0);
90 n.setRefHist(hist); // transfer ownership!
91 n.setRefCopy(nullptr);
92 n.setCanvas(nullptr);
93}
static RefList s_refList
The list of references.

◆ beginRun()

void beginRun ( void )
finaloverridevirtual

Called when entering a new run.

Reimplemented from Module.

Definition at line 220 of file DQMHistAnalysisTOP.cc.

221{
222 m_mirabelleVariables.clear();
223
224 B2DEBUG(20, "DQMHistAnalysisTOP: beginRun called.");
225}
std::map< std::string, double > m_mirabelleVariables
variables for MiraBelle

◆ CheckEpicsError() [1/2]

void CheckEpicsError ( int state,
const std::string & message,
chid id = nullptr )
inherited

check the return status and check PV in case of error

Parameters
statereturn state of epics function
messagemessage to print out
idthe chid of the affected PV

Definition at line 807 of file DQMHistAnalysis.cc.

808{
809 if (state != ECA_NORMAL) {
810 std::string name;
811 if (id) name = ca_name(id);
812 B2WARNING(message << ": " << name);
813 printPVStatus(id, false);
814 }
815}
static void printPVStatus(chid pv, bool onlyError=true)
check the status of a PVs and report if disconnected or not found

◆ CheckEpicsError() [2/2]

void CheckEpicsError ( int state,
const std::string & message,
const std::string & name )
inherited

check the return status and check PV in case of error

Parameters
statereturn state of epics function
messagemessage to print out
namethe (key)name of the affected PV

Definition at line 799 of file DQMHistAnalysis.cc.

800{
801 if (state != ECA_NORMAL) {
802 B2WARNING(message << ": " << name);
803 printPVStatus(m_epicsNameToChID[name], false);
804 }
805}

◆ checkPVStatus()

void checkPVStatus ( void )
inherited

Check the status of all PVs and report if disconnected or not found.

Definition at line 763 of file DQMHistAnalysis.cc.

764{
765 B2INFO("Check PV Connections");
766
767 for (const auto& it : m_epicsChID) {
768 printPVStatus(it);
769 }
770 B2INFO("Check PVs done");
771}

◆ cleanupEpicsPVs()

void cleanupEpicsPVs ( void )
inherited

Unsubscribe from EPICS PVs on terminate.

Definition at line 644 of file DQMHistAnalysis.cc.

645{
646 // this should be called in terminate function of analysis modules
647#ifdef _BELLE2_EPICS
648 if (getUseEpics()) {
649 for (auto& it : m_epicsChID) CheckEpicsError(ca_clear_channel(it), "ca_clear_channel failure", it);
650 updateEpicsPVs(5.0);
651 // Make sure we clean up both afterwards!
652 m_epicsChID.clear();
653 m_epicsNameToChID.clear();
654 }
655#endif
656}
static bool getUseEpics(void)
Getter for EPICS usage.
void CheckEpicsError(int state, const std::string &message, const std::string &name)
check the return status and check PV in case of error
int updateEpicsPVs(float timeout)
Update all EPICS PV (flush to network)

◆ clearCanvases()

void clearCanvases ( void )
staticinherited

Clear content of all Canvases.

Definition at line 309 of file DQMHistAnalysis.cc.

310{
311 TIter nextckey(gROOT->GetListOfCanvases());
312 TObject* cobj = nullptr;
313
314 while ((cobj = dynamic_cast<TObject*>(nextckey()))) {
315 if (cobj->IsA()->InheritsFrom("TCanvas")) {
316 TCanvas* cnv = dynamic_cast<TCanvas*>(cobj);
317 cnv->Clear();
319 }
320 }
321}
static void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
@ c_StatusDefault
default for non-coloring

◆ clearHistList()

void clearHistList ( void )
staticinherited

Clears the list of histograms.

Definition at line 337 of file DQMHistAnalysis.cc.

338{
339 s_histList.clear();
340}

◆ clearlist()

void clearlist ( void )
inherited

Clear all static global lists.

Definition at line 50 of file DQMHistAnalysis.cc.

51{
52 s_histList.clear();
53 s_refList.clear();
54// s_monObjList;
55 s_deltaList.clear();
56 s_canvasUpdatedList.clear();
57}
static CanvasUpdatedList s_canvasUpdatedList
The list of canvas updated status.

◆ clearRefList()

void clearRefList ( void )
staticinherited

Clears the list of ref histograms.

Definition at line 342 of file DQMHistAnalysis.cc.

343{
344 s_refList.clear();
345}

◆ clone()

std::shared_ptr< PathElement > clone ( ) const
overridevirtualinherited

Create an independent copy of this module.

Note that parameters are shared, so changing them on a cloned module will also affect the original module.

Implements PathElement.

Definition at line 179 of file Module.cc.

180{
183 newModule->setName(getName());
184 newModule->m_package = m_package;
185 newModule->m_propertyFlags = m_propertyFlags;
186 newModule->m_logConfig = m_logConfig;
187 newModule->m_conditions = m_conditions;
188
189 return newModule;
190}
std::shared_ptr< Module > registerModule(const std::string &moduleName, std::string sharedLibPath="") noexcept(false)
Creates an instance of a module and registers it to the ModuleManager.
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
void setParameters(const ModuleParamList &params)
Set values for parameters from other parameter list.
const ModuleParamList & getParamList() const
Return module param list.
Definition Module.h:362
const std::string & getName() const
Returns the name of the module.
Definition Module.h:186
const std::string & getType() const
Returns the type of the module (i.e.
Definition Module.cc:41
unsigned int m_propertyFlags
The properties of the module as bitwise or (with |) of EModulePropFlags.
Definition Module.h:511
ModuleParamList m_moduleParamList
List storing and managing all parameter of the module.
Definition Module.h:515
void setName(const std::string &name)
Set the name of the module.
Definition Module.h:213
LogConfig m_logConfig
The log system configuration of the module.
Definition Module.h:513
std::vector< ModuleCondition > m_conditions
Module condition, only non-null if set.
Definition Module.h:520
std::string m_package
Package this module is found in (may be empty).
Definition Module.h:509
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition Module.h:43

◆ colorizeCanvas()

void colorizeCanvas ( TCanvas * canvas,
EStatus status )
staticinherited

Helper function for Canvas colorization.

Parameters
canvasCanvas to change
statusstatus to color

Definition at line 750 of file DQMHistAnalysis.cc.

751{
752 if (!canvas) return;
753 auto color = DQMHistAnalysisModule::getStatusColor(stat);
754
755 canvas->Pad()->SetFillColor(color);
756
757 canvas->Pad()->SetFrameFillColor(10); // White (kWhite is not used since it results in transparent!)
758 canvas->Pad()->SetFrameFillStyle(1001);// White
759 canvas->Pad()->Modified();
760 canvas->Pad()->Update();
761}
static EStatusColor getStatusColor(EStatus status)
Return color for canvas state.

◆ def_beginRun()

virtual void def_beginRun ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function beginRun() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 425 of file Module.h.

425{ beginRun(); }

◆ def_endRun()

virtual void def_endRun ( )
inlineprotectedvirtualinherited

This method can receive that the current run ends as a call from the Python side.

For regular C++-Modules that forwards the call to the regular endRun() method.

Reimplemented in PyModule.

Definition at line 438 of file Module.h.

438{ endRun(); }

◆ def_event()

virtual void def_event ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function event() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 431 of file Module.h.

431{ event(); }

◆ def_initialize()

virtual void def_initialize ( )
inlineprotectedvirtualinherited

Wrappers to make the methods without "def_" prefix callable from Python.

Overridden in PyModule. Wrapper method for the virtual function initialize() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 419 of file Module.h.

419{ initialize(); }

◆ def_terminate()

virtual void def_terminate ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function terminate() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 444 of file Module.h.

444{ terminate(); }

◆ endRun()

void endRun ( void )
finaloverridevirtual

This method is called if the current run ends.

Reimplemented from Module.

Definition at line 311 of file DQMHistAnalysisTOP.cc.

312{
313 // add MiraBelle monitoring
314
315 for (const auto& var : m_mirabelleVariables) {
316 m_monObj->setVariable(var.first, var.second);
317 B2DEBUG(20, var.first << " " << var.second);
318 }
319
320 B2DEBUG(20, "DQMHistAnalysisTOP : endRun called");
321}
MonitoringObject * m_monObj
MiraBelle monitoring object.

◆ evalCondition()

bool evalCondition ( ) const
inherited

If at least one condition was set, it is evaluated and true returned if at least one condition returns true.

If no condition or result value was defined, the method returns false. Otherwise, the condition is evaluated and true returned, if at least one condition returns true. To speed up the evaluation, the condition strings were already parsed in the method if_value().

Returns
True if at least one condition and return value exists and at least one condition expression was evaluated to true.

Definition at line 96 of file Module.cc.

97{
98 if (m_conditions.empty()) return false;
99
100 //okay, a condition was set for this Module...
101 if (!m_hasReturnValue) {
102 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
103 }
104
105 for (const auto& condition : m_conditions) {
106 if (condition.evaluate(m_returnValue)) {
107 return true;
108 }
109 }
110 return false;
111}
int m_returnValue
The return value.
Definition Module.h:518
bool m_hasReturnValue
True, if the return value is set.
Definition Module.h:517

◆ event()

void event ( void )
finaloverridevirtual

This method is called for each event.

Reimplemented from Module.

Definition at line 228 of file DQMHistAnalysisTOP.cc.

229{
230 // get type of the run (TODO: to be replaced with base class function when fixed)
231 auto* rtype = findHist("DQMInfo/rtype");
232 m_runType = rtype ? rtype->GetTitle() : "";
233 m_IsNullRun = (m_runType == "null");
234
235 // get number of events processed with TOPDQM module
236 auto* goodHitsPerEvent = findHist("TOP/goodHitsPerEventAll");
237 m_numEvents = goodHitsPerEvent ? goodHitsPerEvent->GetEntries() : 0;
238
239 bool zeroSupp = gStyle->GetHistMinimumZero();
240 gStyle->SetHistMinimumZero(true);
241
242 // update alarm levels and other parameters from EpicsPVs
243 updateLimits();
244
245 // reset overall alarm state
246 m_alarmStateOverall = c_Gray;
247
248 // Update window_vs_slot canvas w/ alarming
250
251 // Update event desynchronization monitor w/ alarming
253
254 // Update number of good hits per event w/ alarming (injection BG)
256
257 // Update event T0 w/ alarming
259
260 // Update bunch offset w/ alarming
262
263 // Fraction of dead and hot channels
264 const auto* activeFraction = makeDeadAndHotFractionsPlot();
265
266 // Photon yields and background rates, corrected for dead and hot channels
267 makePhotonYieldsAndBGRatePlots(activeFraction);
268
269 // Fractions of junk hits
271
272 // Set z-axis range to 3 times the average for good hits, 30 times the average for junk hits
273 setZAxisRange("TOP/good_hits_xy_", 3);
274 setZAxisRange("TOP/bad_hits_xy_", 30);
275 setZAxisRange("TOP/good_hits_asics_", 3);
276 setZAxisRange("TOP/bad_hits_asics_", 30);
277
278 // Background subtracted time distributions (only for physics runs)
279 if (m_runType == "physics") {
280 const auto* trackHits = static_cast<TH2F*>(findHist("TOP/trackHits"));
281 makeBGSubtractedTimingPlot("goodHitTimes", trackHits, 0);
282 for (int slot = 1; slot <= 16; slot++) {
283 makeBGSubtractedTimingPlot("good_timing_" + to_string(slot), trackHits, slot);
284 }
285 }
286
287 // Update timing plot w/ alarming
289
290 // PMT hit rates
292
293 // Injection BG
295
296 // normalize histogram for injection veto flags check
297 auto* injVetoFlagDiff = static_cast<TH1F*>(findHist("TOP/injVetoFlagDiff"));
298 if (injVetoFlagDiff) injVetoFlagDiff->Scale(1 / injVetoFlagDiff->Integral(), "nosw2");
299
300 // make flag fraction plots
303
304 // Set Epics variables
306
307 gStyle->SetHistMinimumZero(zeroSupp);
308}
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void updateEventMonitorCanvas()
Updates canvas of event desynchronization monitor w/ alarming.
TH1D * m_skipProcFlagFract
fraction of events w/ skip processing flag set vs.
static void setZAxisRange(const std::string &name, double scale)
Sets z-axis range of 2D histograms.
void makePMTHitRatesPlots()
Makes plots of the number of PMT hits per event.
void updateEventT0Canvas()
Updates canvas of event T0 w/ alarming.
const TH1F * makeDeadAndHotFractionsPlot()
Makes a plot of dead and hot channel fractions per slot.
static void makeBGSubtractedTimingPlot(const std::string &name, const TH2F *trackHits, int slot)
Makes background subtracted time distribution plot.
void updateTimingCanvas()
Updates canvas of timing plot w/ alarming.
int m_alarmStateOverall
overall alarm state of histograms to be sent by EpicsPV
static void makeFlagFractPlot(const std::string &hname, TH1 *histogram, TCanvas *canvas)
Makes a plot of fraction of events with the flag is set.
void makeInjectionBGPlots()
Makes projections of injection BG plots.
TCanvas * m_c_skipProcFlagFract
Canvas: fraction of events w/ skip processing flag set vs.
TCanvas * m_c_injVetoFlagFract
Canvas: fraction of events w/ injection veto flag set vs.
void makePhotonYieldsAndBGRatePlots(const TH1F *activeFraction)
Make plots of dead-and-hot-channel corrected photon yields and BG rates per slot.
void makeJunkFractionPlot()
Makes a plot of fractions of junk hits per boardstack.
void updateWindowVsSlotCanvas()
Updates canvas of window_vs_slot w/ alarming.
TH1D * m_injVetoFlagFract
fraction of events w/ injection veto flag set vs.
double m_numEvents
number of events processed with TOPDQM module
void updateBunchOffsetCanvas()
Updates canvas of bunch offset w/ alarming.
void setEpicsVariables()
Calculates and sets epics variables.
bool m_IsNullRun
Run type flag for null runs.
void updateNGoodHitsCanvas()
Updates canvas of number of good hits per event w/ alarming (injection BG)
void updateLimits()
Updates limits defined by module parameters using EpicsPVs.

◆ exposePythonAPI()

void exposePythonAPI ( )
staticinherited

Exposes methods of the Module class to Python.

Definition at line 325 of file Module.cc.

326{
327 // to avoid confusion between std::arg and boost::python::arg we want a shorthand namespace as well
328 namespace bp = boost::python;
329
330 docstring_options options(true, true, false); //userdef, py sigs, c++ sigs
331
332 void (Module::*setReturnValueInt)(int) = &Module::setReturnValue;
333
334 enum_<Module::EAfterConditionPath>("AfterConditionPath",
335 R"(Determines execution behaviour after a conditional path has been executed:
336
337.. attribute:: END
338
339 End processing of this path after the conditional path. (this is the default for if_value() etc.)
340
341.. attribute:: CONTINUE
342
343 After the conditional path, resume execution after this module.)")
344 .value("END", Module::EAfterConditionPath::c_End)
345 .value("CONTINUE", Module::EAfterConditionPath::c_Continue)
346 ;
347
348 /* Do not change the names of >, <, ... we use them to serialize conditional paths */
349 enum_<Belle2::ModuleCondition::EConditionOperators>("ConditionOperator")
356 ;
357
358 enum_<Module::EModulePropFlags>("ModulePropFlags",
359 R"(Flags to indicate certain low-level features of modules, see :func:`Module.set_property_flags()`, :func:`Module.has_properties()`. Most useful flags are:
360
361.. attribute:: PARALLELPROCESSINGCERTIFIED
362
363 This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)
364
365.. attribute:: HISTOGRAMMANAGER
366
367 This module is used to manage histograms accumulated by other modules
368
369.. attribute:: TERMINATEINALLPROCESSES
370
371 When using parallel processing, call this module's terminate() function in all processes. This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.
372)")
373 .value("INPUT", Module::EModulePropFlags::c_Input)
374 .value("OUTPUT", Module::EModulePropFlags::c_Output)
375 .value("PARALLELPROCESSINGCERTIFIED", Module::EModulePropFlags::c_ParallelProcessingCertified)
376 .value("HISTOGRAMMANAGER", Module::EModulePropFlags::c_HistogramManager)
377 .value("INTERNALSERIALIZER", Module::EModulePropFlags::c_InternalSerializer)
378 .value("TERMINATEINALLPROCESSES", Module::EModulePropFlags::c_TerminateInAllProcesses)
379 ;
380
381 //Python class definition
382 class_<Module, PyModule> module("Module", R"(
383Base class for Modules.
384
385A module is the smallest building block of the framework.
386A typical event processing chain consists of a Path containing
387modules. By inheriting from this base class, various types of
388modules can be created. To use a module, please refer to
389:func:`Path.add_module()`. A list of modules is available by running
390``basf2 -m`` or ``basf2 -m package``, detailed information on parameters is
391given by e.g. ``basf2 -m RootInput``.
392
393The 'Module Development' section in the manual provides detailed information
394on how to create modules, setting parameters, or using return values/conditions:
395https://xwiki.desy.de/xwiki/rest/p/f4fa4/#HModuleDevelopment
396
397)");
398 module
399 .def("__str__", &Module::getPathString)
400 .def("name", &Module::getName, return_value_policy<copy_const_reference>(),
401 "Returns the name of the module. Can be changed via :func:`set_name() <Module.set_name()>`, use :func:`type() <Module.type()>` for identifying a particular module class.")
402 .def("type", &Module::getType, return_value_policy<copy_const_reference>(),
403 "Returns the type of the module (i.e. class name minus 'Module')")
404 .def("set_name", &Module::setName, args("name"), R"(
405Set custom name, e.g. to distinguish multiple modules of the same type.
406
407>>> path.add_module('EventInfoSetter')
408>>> ro = path.add_module('RootOutput', branchNames=['EventMetaData'])
409>>> ro.set_name('RootOutput_metadata_only')
410>>> print(path)
411[EventInfoSetter -> RootOutput_metadata_only]
412
413)")
414 .def("description", &Module::getDescription, return_value_policy<copy_const_reference>(),
415 "Returns the description of this module.")
416 .def("package", &Module::getPackage, return_value_policy<copy_const_reference>(),
417 "Returns the package this module belongs to.")
418 .def("available_params", &_getParamInfoListPython,
419 "Return list of all module parameters as `ModuleParamInfo` instances")
420 .def("has_properties", &Module::hasProperties, (bp::arg("properties")),
421 R"DOCSTRING(Allows to check if the module has the given properties out of `ModulePropFlags` set.
422
423>>> if module.has_properties(ModulePropFlags.PARALLELPROCESSINGCERTIFIED):
424>>> ...
425
426Parameters:
427 properties (int): bitmask of `ModulePropFlags` to check for.
428)DOCSTRING")
429 .def("set_property_flags", &Module::setPropertyFlags, args("property_mask"),
430 "Set module properties in the form of an OR combination of `ModulePropFlags`.");
431 {
432 // python signature is too crowded, make ourselves
433 docstring_options subOptions(true, false, false); //userdef, py sigs, c++ sigs
434 module
435 .def("if_value", &Module::if_value,
436 (bp::arg("expression"), bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
437 R"DOCSTRING(if_value(expression, condition_path, after_condition_path=AfterConditionPath.END)
438
439Sets a conditional sub path which will be executed after this
440module if the return value set in the module passes the given ``expression``.
441
442Modules can define a return value (int or bool) using ``setReturnValue()``,
443which can be used in the steering file to split the Path based on this value, for example
444
445>>> module_with_condition.if_value("<1", another_path)
446
447In case the return value of the ``module_with_condition`` for a given event is
448less than 1, the execution will be diverted into ``another_path`` for this event.
449
450You could for example set a special return value if an error occurs, and divert
451the execution into a path containing :b2:mod:`RootOutput` if it is found;
452saving only the data producing/produced by the error.
453
454After a conditional path has executed, basf2 will by default stop processing
455the path for this event. This behaviour can be changed by setting the
456``after_condition_path`` argument.
457
458Parameters:
459 expression (str): Expression to determine if the conditional path should be executed.
460 This should be one of the comparison operators ``<``, ``>``, ``<=``,
461 ``>=``, ``==``, or ``!=`` followed by a numerical value for the return value
462 condition_path (Path): path to execute in case the expression is fulfilled
463 after_condition_path (AfterConditionPath): What to do once the ``condition_path`` has been executed.
464)DOCSTRING")
465 .def("if_false", &Module::if_false,
466 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
467 R"DOC(if_false(condition_path, after_condition_path=AfterConditionPath.END)
468
469Sets a conditional sub path which will be executed after this module if
470the return value of the module evaluates to False. This is equivalent to
471calling `if_value` with ``expression=\"<1\"``)DOC")
472 .def("if_true", &Module::if_true,
473 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
474 R"DOC(if_true(condition_path, after_condition_path=AfterConditionPath.END)
475
476Sets a conditional sub path which will be executed after this module if
477the return value of the module evaluates to True. It is equivalent to
478calling `if_value` with ``expression=\">=1\"``)DOC");
479 }
480 module
481 .def("has_condition", &Module::hasCondition,
482 "Return true if a conditional path has been set for this module "
483 "using `if_value`, `if_true` or `if_false`")
484 .def("get_all_condition_paths", &_getAllConditionPathsPython,
485 "Return a list of all conditional paths set for this module using "
486 "`if_value`, `if_true` or `if_false`")
487 .def("get_all_conditions", &_getAllConditionsPython,
488 "Return a list of all conditional path expressions set for this module using "
489 "`if_value`, `if_true` or `if_false`")
490 .add_property("logging", make_function(&Module::getLogConfig, return_value_policy<reference_existing_object>()),
491 &Module::setLogConfig)
@ c_GE
Greater or equal than: ">=".
@ c_SE
Smaller or equal than: "<=".
@ c_GT
Greater than: ">".
@ c_NE
Not equal: "!=".
@ c_EQ
Equal: "=" or "==".
@ c_ST
Smaller than: "<".
void if_value(const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
Add a condition to the module.
Definition Module.cc:79
void if_true(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to set the condition of the module.
Definition Module.cc:90
Module()
Constructor.
Definition Module.cc:30
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition Module.cc:220
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Definition Module.h:81
@ c_Input
This module is an input module (reads data).
Definition Module.h:78
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
@ c_InternalSerializer
This module is an internal serializer/deserializer for parallel processing.
Definition Module.h:82
@ c_Output
This module is an output module (writes data).
Definition Module.h:79
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
Definition Module.h:83
void if_false(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to add a condition to the module.
Definition Module.cc:85
ModuleCondition::EAfterConditionPath EAfterConditionPath
Forward the EAfterConditionPath definition from the ModuleCondition.
Definition Module.h:88

◆ ExtractNEvent()

void ExtractNEvent ( std::vector< TH1 * > & hs)
staticinherited

Extract event processed from daq histogram, called from input module.

Definition at line 376 of file DQMHistAnalysis.cc.

377{
379 for (size_t i = 0; i < hs.size(); i++) {
380 if (hs[i]->GetName() == std::string("DAQ/Nevent")) {
381 s_eventProcessed = hs[i]->GetEntries();
382 return;
383 }
384 }
385 B2ERROR("ExtractEvent: Histogram \"DAQ/Nevent\" missing");
386}
static int s_eventProcessed
Number of Events processed to fill histograms.

◆ ExtractRunType()

void ExtractRunType ( std::vector< TH1 * > & hs)
staticinherited

Extract Run Type from histogram title, called from input module.

Definition at line 364 of file DQMHistAnalysis.cc.

365{
366 s_runType = "";
367 for (size_t i = 0; i < hs.size(); i++) {
368 if (hs[i]->GetName() == std::string("DQMInfo/rtype")) {
369 s_runType = hs[i]->GetTitle();
370 return;
371 }
372 }
373 B2ERROR("ExtractRunType: Histogram \"DQMInfo/rtype\" missing");
374}
static std::string s_runType
The Run type.

◆ findCanvas()

TCanvas * findCanvas ( TString cname)
staticinherited

Find canvas by name.

Parameters
cnameName of the canvas
Returns
The pointer to the canvas, or nullptr if not found.

Definition at line 146 of file DQMHistAnalysis.cc.

147{
148 TIter nextkey(gROOT->GetListOfCanvases());
149 TObject* obj{};
150
151 while ((obj = dynamic_cast<TObject*>(nextkey()))) {
152 if (obj->IsA()->InheritsFrom("TCanvas")) {
153 if (obj->GetName() == canvas_name)
154 return dynamic_cast<TCanvas*>(obj);
155 }
156 }
157 return nullptr;
158}

◆ findHist() [1/2]

TH1 * findHist ( const std::string & dirname,
const std::string & histname,
bool onlyIfUpdated = false )
staticinherited

Find histogram.

Parameters
dirnameThe name of the directory.
histnameThe name of the histogram.
onlyIfUpdatedreq only updated hists, return nullptr otherwise
Returns
The found histogram, or nullptr if not found.

Definition at line 174 of file DQMHistAnalysis.cc.

175{
176 if (dirname.size() > 0) {
177 return findHist(dirname + "/" + histname, updated);
178 }
179 return findHist(histname, updated);
180}

◆ findHist() [2/2]

TH1 * findHist ( const std::string & histname,
bool onlyIfUpdated = false )
staticinherited

Get histogram from list (no other search).

Parameters
histnameThe name of the histogram (incl dir).
onlyIfUpdatedreq only updated hists, return nullptr otherwise
Returns
The found histogram, or nullptr if not found.

Definition at line 160 of file DQMHistAnalysis.cc.

161{
162 if (s_histList.find(histname) != s_histList.end()) {
163 if (was_updated && !s_histList[histname].isUpdated()) return nullptr;
164 if (s_histList[histname].getHist()) {
165 return s_histList[histname].getHist();
166 } else {
167 B2ERROR("Histogram " << histname << " in histogram list but nullptr.");
168 }
169 }
170 B2INFO("Histogram " << histname << " not in list.");
171 return nullptr;
172}

◆ findHistInCanvas()

TH1 * findHistInCanvas ( const std::string & hname,
TCanvas ** canvas = nullptr )
inherited

Find histogram in corresponding canvas.

Parameters
hnameName of the histogram (dir+name)
canvasptr to specific canvas ptr or nullptr
Returns
The pointer to the histogram, or nullptr if not found.

Definition at line 228 of file DQMHistAnalysis.cc.

229{
230 TCanvas* cnv = nullptr;
231 // try to get canvas from outside
232 if (cobj) cnv = *cobj;
233 // if no canvas search for it
234 if (cnv == nullptr) {
235 // parse the dir+histo name and create the corresponding canvas name
236 auto s = StringSplit(histo_name, '/');
237 if (s.size() != 2) {
238 B2ERROR("findHistInCanvas: histoname not valid (missing dir?), should be 'dirname/histname': " << histo_name);
239 return nullptr;
240 }
241 auto dirname = s.at(0);
242 auto hname = s.at(1);
243 std::string canvas_name = dirname + "/c_" + hname;
244 cnv = findCanvas(canvas_name);
245 // set canvas pointer for outside
246 if (cnv && cobj) *cobj = cnv;
247 }
248
249 // get histogram pointer
250 if (cnv != nullptr) {
251 TIter nextkey(cnv->GetListOfPrimitives());
252 TObject* obj{};
253 while ((obj = dynamic_cast<TObject*>(nextkey()))) {
254 if (obj->IsA()->InheritsFrom("TH1")) {
255 if (obj->GetName() == histo_name)
256 return dynamic_cast<TH1*>(obj);
257 }
258 }
259 }
260 return nullptr;
261}
static TCanvas * findCanvas(TString cname)
Find canvas by name.
static std::vector< std::string > StringSplit(const std::string &s, const char delim)
Helper function for string token split.

◆ findHistInFile()

TH1 * findHistInFile ( TFile * file,
const std::string & histname )
staticinherited

Find histogram in specific TFile (e.g.

ref file).

Parameters
fileThe TFile to search.
histnameThe name of the histogram, can incl directory
Returns
The found histogram, or nullptr if not found.

Definition at line 263 of file DQMHistAnalysis.cc.

264{
265 // find histogram by name in file, histname CAN contain directory!
266 // will return nullptr if file is zeroptr, not found or not correct type
267 if (file && file->IsOpen()) {
268 auto obj = file->Get(histname.data());
269 if (obj != nullptr) {
270 // check class type
271 if (obj->IsA()->InheritsFrom("TH1")) {
272 B2DEBUG(20, "Histogram " << histname << " found in file");
273 return dynamic_cast<TH1*>(obj);
274 } else {
275 B2INFO("Found Object " << histname << " in file is not a histogram");
276 }
277 } else {
278 B2INFO("Histogram " << histname << " not found in file");
279 }
280 }
281 return nullptr;
282}

◆ findMonitoringObject()

MonitoringObject * findMonitoringObject ( const std::string & objName)
staticinherited

Find MonitoringObject.

Parameters
objNameThe name of the MonitoringObject.
Returns
The found MonitoringObject, or nullptr if not found.

Definition at line 284 of file DQMHistAnalysis.cc.

285{
286 if (s_monObjList.find(objName) != s_monObjList.end()) {
287 return &s_monObjList[objName];
288 }
289 B2INFO("MonitoringObject " << objName << " not in memfile.");
290 return nullptr;
291}
static MonObjList s_monObjList
The list of MonitoringObjects.

◆ findRefHist() [1/2]

TH1 * findRefHist ( const std::string & dirname,
const std::string & histname,
ERefScaling scaling = ERefScaling::c_RefScaleNone,
const TH1 * hist = nullptr )
staticinherited

Find reference histogram.

Parameters
dirnameThe name of the directory.
histnameThe name of the histogram.
scalingenum what scaling to use
histhistogram to scale to
Returns
The found histogram, or nullptr if not found.

Definition at line 219 of file DQMHistAnalysis.cc.

221{
222 if (dirname.size() > 0) {
223 return findRefHist(dirname + "/" + histname, scaling, hist);
224 }
225 return findRefHist(histname, scaling, hist);
226}
static TH1 * findRefHist(const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
Get referencehistogram from list (no other search).

◆ findRefHist() [2/2]

TH1 * findRefHist ( const std::string & histname,
ERefScaling scaling = ERefScaling::c_RefScaleNone,
const TH1 * hist = nullptr )
staticinherited

Get referencehistogram from list (no other search).

Parameters
histnameThe name of the histogram (incl dir).
scalingenum what scaling to use
histhistogram to scale to
Returns
The found histogram, or nullptr if not found.

Definition at line 208 of file DQMHistAnalysis.cc.

209{
210 if (s_refList.find(histname) != s_refList.end()) {
211 // get a copy of the reference which we can modify
212 // (it is still owned and managed by the framework)
213 // then do the scaling
214 return scaleReference(scaling, hist, s_refList[histname].getReference());
215 }
216 return nullptr;
217}
static TH1 * scaleReference(ERefScaling scaling, const TH1 *hist, TH1 *ref)
Using the original and reference, create scaled version.

◆ getAfterConditionPath()

Module::EAfterConditionPath getAfterConditionPath ( ) const
inherited

What to do after the conditional path is finished.

(defaults to c_End if no condition is set)

Definition at line 133 of file Module.cc.

134{
135 if (m_conditions.empty()) return EAfterConditionPath::c_End;
136
137 //okay, a condition was set for this Module...
138 if (!m_hasReturnValue) {
139 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
140 }
141
142 for (const auto& condition : m_conditions) {
143 if (condition.evaluate(m_returnValue)) {
144 return condition.getAfterConditionPath();
145 }
146 }
147
148 return EAfterConditionPath::c_End;
149}

◆ getAlarmColor()

int getAlarmColor ( unsigned alarmState) const
inlineprivate

Converts alarm state to color.

Parameters
alarmStatealarm state
Returns
alarm color

Definition at line 189 of file DQMHistAnalysisTOP.h.

190 {
191 if (alarmState < m_alarmColors.size()) return m_alarmColors[alarmState];
192 return m_alarmColors[c_Gray];
193 }

◆ getAlarmState()

int getAlarmState ( double value,
const std::vector< double > & alarmLevels,
bool bigRed = true ) const
private

Returns alarm state.

Parameters
valuevalue to translate to color
alarmLevelsalarm levels
bigRedon true red color for large values, else red color for small values
Returns
alarm state (to be used as an index of m_alarmColors array)

Definition at line 948 of file DQMHistAnalysisTOP.cc.

949{
950 if (m_IsNullRun or m_numEvents < 1000) return c_Gray;
951
952 if (bigRed) {
953 if (value < alarmLevels[0]) return c_Green;
954 else if (value < alarmLevels[1]) return c_Yellow;
955 else return c_Red;
956 } else {
957 if (value < alarmLevels[0]) return c_Red;
958 else if (value < alarmLevels[1]) return c_Yellow;
959 else return c_Green;
960 }
961}

◆ getAllConditionPaths()

std::vector< std::shared_ptr< Path > > getAllConditionPaths ( ) const
inherited

Return all condition paths currently set (no matter if the condition is true or not).

Definition at line 150 of file Module.cc.

151{
152 std::vector<std::shared_ptr<Path>> allConditionPaths;
153 for (const auto& condition : m_conditions) {
154 allConditionPaths.push_back(condition.getPath());
155 }
156
157 return allConditionPaths;
158}

◆ getAllConditions()

const std::vector< ModuleCondition > & getAllConditions ( ) const
inlineinherited

Return all set conditions for this module.

Definition at line 323 of file Module.h.

324 {
325 return m_conditions;
326 }

◆ getCanvasUpdatedList()

static const CanvasUpdatedList & getCanvasUpdatedList ( )
inlinestaticinherited

Get the list of the canvas update status.

Returns
The list of the canvases.

Definition at line 202 of file DQMHistAnalysis.h.

202{ return s_canvasUpdatedList;};

◆ getCondition()

const ModuleCondition * getCondition ( ) const
inlineinherited

Return a pointer to the first condition (or nullptr, if none was set)

Definition at line 313 of file Module.h.

314 {
315 if (m_conditions.empty()) {
316 return nullptr;
317 } else {
318 return &m_conditions.front();
319 }
320 }

◆ getConditionPath()

std::shared_ptr< Path > getConditionPath ( ) const
inherited

Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).

Definition at line 113 of file Module.cc.

114{
115 PathPtr p;
116 if (m_conditions.empty()) return p;
117
118 //okay, a condition was set for this Module...
119 if (!m_hasReturnValue) {
120 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
121 }
122
123 for (const auto& condition : m_conditions) {
124 if (condition.evaluate(m_returnValue)) {
125 return condition.getPath();
126 }
127 }
128
129 // if none of the conditions were true, return a null pointer.
130 return p;
131}
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition Path.h:35

◆ getDeadAndHotCuts()

std::pair< double, double > getDeadAndHotCuts ( const TH1 * h)
staticprivate

Returns cut levels for dead and hot channels.

Parameters
hpixel or channel distribution of hits (1D or 2D histogram)
Returns
cut levels (first = dead, second = hot)

Definition at line 1010 of file DQMHistAnalysisTOP.cc.

1011{
1012 std::vector<double> binContents;
1013 for (int k = 1; k <= h->GetNbinsY(); k++) {
1014 for (int i = 1; i <= h->GetNbinsX(); i++) {
1015 binContents.push_back(h->GetBinContent(i, k));
1016 }
1017 }
1018
1019 double mean = 0;
1020 double rms = h->GetMaximum();
1021 for (int iter = 0; iter < 5; iter++) {
1022 double sumy = 0;
1023 double sumyy = 0;
1024 int n = 0;
1025 for (auto y : binContents) {
1026 if (y == 0 or fabs(y - mean) > 3 * rms) continue;
1027 sumy += y;
1028 sumyy += y * y;
1029 n++;
1030 }
1031 if (n == 0) continue;
1032 mean = sumy / n;
1033 rms = sqrt(sumyy / n - mean * mean);
1034 }
1035
1036 return std::make_pair(mean / 5, std::max(mean * 2, mean + 6 * rms));
1037}
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28

◆ getDelta() [1/2]

TH1 * getDelta ( const std::string & dirname,
const std::string & histname,
int n = 0,
bool onlyIfUpdated = true )
inherited

Get Delta histogram.

Parameters
dirnamedirectory
histnamename of histogram
nindex of delta histogram, 0 is most recent one
onlyIfUpdatedreq only updated deltas, return nullptr otherwise
Returns
delta histogram or nullptr

Definition at line 118 of file DQMHistAnalysis.cc.

119{
120 std::string fullname;
121 if (dirname.size() > 0) {
122 fullname = dirname + "/" + histname;
123 } else {
124 fullname = histname;
125 }
126 return getDelta(fullname, n, onlyIfUpdated);
127}
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.

◆ getDelta() [2/2]

TH1 * getDelta ( const std::string & fullname,
int n = 0,
bool onlyIfUpdated = true )
inherited

Get Delta histogram.

Parameters
fullnamedirectory+name of histogram
nindex of delta histogram, 0 is most recent one
onlyIfUpdatedreq only updated deltas, return nullptr otherwise
Returns
delta histogram or nullptr

Definition at line 129 of file DQMHistAnalysis.cc.

130{
131 auto it = s_deltaList.find(fullname);
132 if (it != s_deltaList.end()) {
133 return it->second.getDelta(n, onlyIfUpdated);
134 }
135 B2WARNING("Delta hist " << fullname << " not found");
136 return nullptr;
137}

◆ getDeltaList()

static const DeltaList & getDeltaList ( )
inlinestaticinherited

Get the list of the delta histograms.

Returns
The list of the delta histograms.

Definition at line 196 of file DQMHistAnalysis.h.

196{ return s_deltaList;};

◆ getDescription()

const std::string & getDescription ( ) const
inlineinherited

Returns the description of the module.

Definition at line 201 of file Module.h.

201{return m_description;}

◆ getEpicsPV() [1/2]

double getEpicsPV ( const std::string & keyname)
inherited

Read value from a EPICS PV.

Parameters
keynamekey name (or full PV name) of PV
Returns
value or NAN if not existing

Definition at line 507 of file DQMHistAnalysis.cc.

508{
509 double value{NAN};
510 if (!m_useEpics) return value;
511#ifdef _BELLE2_EPICS
512 if (m_epicsNameToChID[keyname] == nullptr) {
513 B2ERROR("Epics PV " << keyname << " not registered!");
514 return value;
515 }
516 // From EPICS doc. When ca_get or ca_array_get are invoked the returned channel value can't be assumed to be stable
517 // in the application supplied buffer until after ECA_NORMAL is returned from ca_pend_io. If a connection is lost
518 // outstanding get requests are not automatically reissued following reconnect.
519 auto r = ca_get(DBR_DOUBLE, m_epicsNameToChID[keyname], (void*)&value);
520 if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
521 if (r == ECA_NORMAL) {
522 return value;
523 } else {
524 CheckEpicsError(r, "Read PV failed in ca_get or ca_pend_io failure", keyname);
525 }
526#endif
527 return NAN;
528}
static bool m_useEpics
Flag if to use EPICS do not set by yourself, use EpicsEnable module to set.

◆ getEpicsPV() [2/2]

double getEpicsPV ( int index)
inherited

Read value from a EPICS PV.

Parameters
indexindex of PV
Returns
value or NAN if not existing

Definition at line 530 of file DQMHistAnalysis.cc.

531{
532 double value{NAN};
533 if (!m_useEpics) return value;
534#ifdef _BELLE2_EPICS
535 if (index < 0 || index >= (int)m_epicsChID.size()) {
536 B2ERROR("Epics PV with " << index << " not registered!");
537 return value;
538 }
539 // From EPICS doc. When ca_get or ca_array_get are invoked the returned channel value can't be assumed to be stable
540 // in the application supplied buffer until after ECA_NORMAL is returned from ca_pend_io. If a connection is lost
541 // outstanding get requests are not automatically reissued following reconnect.
542 auto r = ca_get(DBR_DOUBLE, m_epicsChID[index], (void*)&value);
543 if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
544 if (r == ECA_NORMAL) {
545 return value;
546 } else {
547 CheckEpicsError(r, "Read PV failed in ca_get or ca_pend_io failure", m_epicsChID[index]);
548 }
549#endif
550 return NAN;
551}

◆ getEpicsPVChID() [1/2]

chid getEpicsPVChID ( const std::string & keyname)
inherited

Get EPICS PV Channel Id.

Parameters
keynamekey name (or full PV name) of PV
Returns
Channel ID is written on success, otherwise nullptr

Definition at line 603 of file DQMHistAnalysis.cc.

604{
605#ifdef _BELLE2_EPICS
606 if (m_useEpics) {
607 if (m_epicsNameToChID[keyname] != nullptr) {
608 return m_epicsNameToChID[keyname];
609 } else {
610 B2ERROR("Epics PV " << keyname << " not registered!");
611 }
612 }
613#endif
614 return nullptr;
615}

◆ getEpicsPVChID() [2/2]

chid getEpicsPVChID ( int index)
inherited

Get EPICS PV Channel Id.

Parameters
indexindex of PV
Returns
Channel ID is written on success, otherwise nullptr

Definition at line 617 of file DQMHistAnalysis.cc.

618{
619#ifdef _BELLE2_EPICS
620 if (m_useEpics) {
621 if (index >= 0 && index < (int)m_epicsChID.size()) {
622 return m_epicsChID[index];
623 } else {
624 B2ERROR("Epics PV with " << index << " not registered!");
625 }
626 }
627#endif
628 return nullptr;
629}

◆ getEpicsStringPV() [1/2]

std::string getEpicsStringPV ( const std::string & keyname,
bool & status )
inherited

Read value from a EPICS PV.

Parameters
keynamekey name (or full PV name) of PV
statusreturn status (true on success)
Returns
string value (empty string if non existing)

Definition at line 553 of file DQMHistAnalysis.cc.

554{
555 status = false;
556 char value[40] = "";
557 if (!m_useEpics) return std::string(value);
558#ifdef _BELLE2_EPICS
559 if (m_epicsNameToChID[keyname] == nullptr) {
560 B2ERROR("Epics PV " << keyname << " not registered!");
561 return std::string(value);
562 }
563 // From EPICS doc. When ca_get or ca_array_get are invoked the returned channel value can't be assumed to be stable
564 // in the application supplied buffer until after ECA_NORMAL is returned from ca_pend_io. If a connection is lost
565 // outstanding get requests are not automatically reissued following reconnect.
566 auto r = ca_get(DBR_STRING, m_epicsNameToChID[keyname], value);
567 if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
568 if (r == ECA_NORMAL) {
569 status = true;
570 return std::string(value);
571 } else {
572 CheckEpicsError(r, "Read PV (string) failed in ca_get or ca_pend_io failure", keyname);
573 }
574#endif
575 return std::string(value);
576}

◆ getEpicsStringPV() [2/2]

std::string getEpicsStringPV ( int index,
bool & status )
inherited

Read value from a EPICS PV.

Parameters
indexindex of PV
statusreturn status (true on success)
Returns
string value (empty string if non existing)

Definition at line 578 of file DQMHistAnalysis.cc.

579{
580 status = false;
581 char value[40] = "";
582 if (!m_useEpics) return std::string(value);
583#ifdef _BELLE2_EPICS
584 if (index < 0 || index >= (int)m_epicsChID.size()) {
585 B2ERROR("Epics PV with " << index << " not registered!");
586 return std::string(value);
587 }
588 // From EPICS doc. When ca_get or ca_array_get are invoked the returned channel value can't be assumed to be stable
589 // in the application supplied buffer until after ECA_NORMAL is returned from ca_pend_io. If a connection is lost
590 // outstanding get requests are not automatically reissued following reconnect.
591 auto r = ca_get(DBR_STRING, m_epicsChID[index], value);
592 if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
593 if (r == ECA_NORMAL) {
594 status = true;
595 return std::string(value);
596 } else {
597 CheckEpicsError(r, "Read PV (string) failed in ca_get or ca_pend_io failure", m_epicsChID[index]);
598 }
599#endif
600 return std::string(value);
601}

◆ getEventProcessed()

static int getEventProcessed ( void )
inlinestaticinherited

Get the number of processed events.

(Attention, asynch histogram updates!)

Returns
Processed events.

Definition at line 221 of file DQMHistAnalysis.h.

221{ return s_eventProcessed;};

◆ getFileNames()

virtual std::vector< std::string > getFileNames ( bool outputFiles)
inlinevirtualinherited

Return a list of output filenames for this modules.

This will be called when basf2 is run with "--dry-run" if the module has set either the c_Input or c_Output properties.

If the parameter outputFiles is false (for modules with c_Input) the list of input filenames should be returned (if any). If outputFiles is true (for modules with c_Output) the list of output files should be returned (if any).

If a module has sat both properties this member is called twice, once for each property.

The module should return the actual list of requested input or produced output filenames (including handling of input/output overrides) so that the grid system can handle input/output files correctly.

This function should return the same value when called multiple times. This is especially important when taking the input/output overrides from Environment as they get consumed when obtained so the finalized list of output files should be stored for subsequent calls.

Reimplemented in RootInputModule, RootOutputModule, and StorageRootOutputModule.

Definition at line 133 of file Module.h.

134 {
135 return std::vector<std::string>();
136 }

◆ getHistList()

static HistList & getHistList ( )
inlinestaticinherited

Get the list of the histograms.

Returns
The list of the histograms.

Definition at line 184 of file DQMHistAnalysis.h.

184{ return s_histList;};

◆ getLogConfig()

LogConfig & getLogConfig ( )
inlineinherited

Returns the log system configuration.

Definition at line 224 of file Module.h.

224{return m_logConfig;}

◆ getModules()

std::list< ModulePtr > getModules ( ) const
inlineoverrideprivatevirtualinherited

no submodules, return empty list

Implements PathElement.

Definition at line 505 of file Module.h.

505{ return std::list<ModulePtr>(); }

◆ getMonitoringObject()

MonitoringObject * getMonitoringObject ( const std::string & name)
staticinherited

Get MonitoringObject with given name (new object is created if non-existing)

Parameters
namename of MonitoringObject to get
Returns
The MonitoringObject

Definition at line 139 of file DQMHistAnalysis.cc.

140{
141 auto obj = &s_monObjList[objName];
142 obj->SetName(objName.c_str());
143 return obj;
144}

◆ getMonObjList()

static MonObjList & getMonObjList ( )
inlinestaticinherited

Get the list of MonitoringObjects.

Returns
The list of the MonitoringObjects.

Definition at line 190 of file DQMHistAnalysis.h.

190{ return s_monObjList;};

◆ getName()

const std::string & getName ( ) const
inlineinherited

Returns the name of the module.

This can be changed via e.g. set_name() in the steering file to give more useful names if there is more than one module of the same type.

For identifying the type of a module, using getType() (or type() in Python) is recommended.

Definition at line 186 of file Module.h.

186{return m_name;}

◆ getOffcialAlarmStatus()

int getOffcialAlarmStatus ( unsigned alarmState) const
inlineprivate

Converts alarm state to official status (see EStatus of the base class)

Parameters
alarmStatealarm state
Returns
alarm status

Definition at line 200 of file DQMHistAnalysisTOP.h.

201 {
202 if (alarmState < m_officialStates.size()) return m_officialStates[alarmState];
203 return c_StatusDefault;
204 }

◆ getPackage()

const std::string & getPackage ( ) const
inlineinherited

Returns the package this module is in.

Definition at line 196 of file Module.h.

196{return m_package;}

◆ getParamInfoListPython()

std::shared_ptr< boost::python::list > getParamInfoListPython ( ) const
inherited

Returns a python list of all parameters.

Each item in the list consists of the name of the parameter, a string describing its type, a python list of all default values and the description of the parameter.

Returns
A python list containing the parameters of this parameter list.

Definition at line 279 of file Module.cc.

280{
282}
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.

◆ getParamList()

const ModuleParamList & getParamList ( ) const
inlineinherited

Return module param list.

Definition at line 362 of file Module.h.

362{ return m_moduleParamList; }

◆ getPathString()

std::string getPathString ( ) const
overrideprivatevirtualinherited

return the module name.

Implements PathElement.

Definition at line 192 of file Module.cc.

193{
194
195 std::string output = getName();
196
197 for (const auto& condition : m_conditions) {
198 output += condition.getString();
199 }
200
201 return output;
202}

◆ getPVPrefix()

static std::string & getPVPrefix ( void )
inlinestaticinherited

get global prefix for EPICS PVs

Returns
prefix in use

Definition at line 610 of file DQMHistAnalysis.h.

610{return m_PVPrefix;};

◆ getReturnValue()

int getReturnValue ( ) const
inlineinherited

Return the return value set by this module.

This value is only meaningful if hasReturnValue() is true

Definition at line 380 of file Module.h.

380{ return m_returnValue; }

◆ getRunType()

static const std::string & getRunType ( void )
inlinestaticinherited

Get the list of the reference histograms.

Returns
The list of the reference histograms. Get the Run Type.
Run type string.

Definition at line 215 of file DQMHistAnalysis.h.

215{ return s_runType;};

◆ getSigma68()

double getSigma68 ( TH1 * h)
staticinherited

Helper function to compute half of the central interval covering 68% of a distribution.

This quantity is an alternative to the standard deviation.

Parameters
hhistogram
Returns
Half of the central interval covering 68% of a distribution.

Definition at line 293 of file DQMHistAnalysis.cc.

294{
295 double probs[2] = {0.16, 1 - 0.16};
296 double quant[2] = {0, 0};
297 h->GetQuantiles(2, quant, probs);
298 const double sigma68 = (-quant[0] + quant[1]) / 2;
299 return sigma68;
300}

◆ getStatusColor()

DQMHistAnalysisModule::EStatusColor getStatusColor ( EStatus status)
staticinherited

Return color for canvas state.

Parameters
statuscanvas status
Returns
alarm color

Definition at line 723 of file DQMHistAnalysis.cc.

724{
725 // white color is the default, if no colorize
727 switch (stat) {
728 case c_StatusTooFew:
729 color = c_ColorTooFew; // Magenta or Gray
730 break;
731 case c_StatusDefault:
732 color = c_ColorDefault; // default no colors
733 break;
734 case c_StatusGood:
735 color = c_ColorGood; // Good
736 break;
737 case c_StatusWarning:
738 color = c_ColorWarning; // Warning
739 break;
740 case c_StatusError:
741 color = c_ColorError; // Severe
742 break;
743 default:
744 color = c_ColorDefault; // default no colors
745 break;
746 }
747 return color;
748}
EStatusColor
Status colors of histogram/canvas (corresponding to status)
@ c_ColorWarning
Analysis result: Warning, there may be minor issues.
@ c_ColorError
Analysis result: Severe issue found.
@ c_ColorTooFew
Not enough entries/event to judge.
@ c_ColorGood
Analysis result: Good.
@ c_ColorDefault
default for non-coloring
@ c_StatusTooFew
Not enough entries/event to judge.
@ c_StatusError
Analysis result: Severe issue found.
@ c_StatusWarning
Analysis result: Warning, there may be minor issues.
@ c_StatusGood
Analysis result: Good.

◆ getType()

const std::string & getType ( ) const
inherited

Returns the type of the module (i.e.

class name minus 'Module')

Definition at line 41 of file Module.cc.

42{
43 if (m_type.empty())
44 B2FATAL("Module type not set for " << getName());
45 return m_type;
46}
std::string m_type
The type of the module, saved as a string.
Definition Module.h:508

◆ getUseEpics()

static bool getUseEpics ( void )
inlinestaticinherited

Getter for EPICS usage.

Returns
flag is in use

Definition at line 593 of file DQMHistAnalysis.h.

593{return m_useEpics;};

◆ getUseEpicsReadOnly()

static bool getUseEpicsReadOnly ( void )
inlinestaticinherited

Getter EPICS flag in read only mode.

Returns
flag if read only

Definition at line 599 of file DQMHistAnalysis.h.

599{return m_epicsReadOnly;};

◆ hasCondition()

bool hasCondition ( ) const
inlineinherited

Returns true if at least one condition was set for the module.

Definition at line 310 of file Module.h.

310{ return not m_conditions.empty(); };

◆ hasDeltaPar()

bool hasDeltaPar ( const std::string & dirname,
const std::string & histname )
staticinherited

Check if Delta histogram parameters exist for histogram.

Parameters
dirnamedirectory
histnamename of histogram
Returns
true if parameters have been set already

Definition at line 107 of file DQMHistAnalysis.cc.

108{
109 std::string fullname;
110 if (dirname.size() > 0) {
111 fullname = dirname + "/" + histname;
112 } else {
113 fullname = histname;
114 }
115 return s_deltaList.find(fullname) != s_deltaList.end(); // contains() if we switch to C++20
116}

◆ hasProperties()

bool hasProperties ( unsigned int propertyFlags) const
inherited

Returns true if all specified property flags are available in this module.

Parameters
propertyFlagsOred EModulePropFlags which should be compared with the module flags.

Definition at line 160 of file Module.cc.

161{
162 return (propertyFlags & m_propertyFlags) == propertyFlags;
163}

◆ hasReturnValue()

bool hasReturnValue ( ) const
inlineinherited

Return true if this module has a valid return value set.

Definition at line 377 of file Module.h.

377{ return m_hasReturnValue; }

◆ hasUnsetForcedParams()

bool hasUnsetForcedParams ( ) const
inherited

Returns true and prints error message if the module has unset parameters which the user has to set in the steering file.

Definition at line 166 of file Module.cc.

167{
169 std::string allMissing = "";
170 for (const auto& s : missing)
171 allMissing += s + " ";
172 if (!missing.empty())
173 B2ERROR("The following required parameters of Module '" << getName() << "' were not specified: " << allMissing <<
174 "\nPlease add them to your steering file.");
175 return !missing.empty();
176}
std::vector< std::string > getUnsetForcedParams() const
Returns list of unset parameters (if they are required to have a value.

◆ if_false()

void if_false ( const std::shared_ptr< Path > & path,
EAfterConditionPath afterConditionPath = EAfterConditionPath::c_End )
inherited

A simplified version to add a condition to the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

It is equivalent to the if_value() method, using the expression "<1". This method is meant to be used together with the setReturnValue(bool value) method.

Parameters
pathShared pointer to the Path which will be executed if the return value is false.
afterConditionPathWhat to do after executing 'path'.

Definition at line 85 of file Module.cc.

86{
87 if_value("<1", path, afterConditionPath);
88}

◆ if_true()

void if_true ( const std::shared_ptr< Path > & path,
EAfterConditionPath afterConditionPath = EAfterConditionPath::c_End )
inherited

A simplified version to set the condition of the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

It is equivalent to the if_value() method, using the expression ">=1". This method is meant to be used together with the setReturnValue(bool value) method.

Parameters
pathShared pointer to the Path which will be executed if the return value is true.
afterConditionPathWhat to do after executing 'path'.

Definition at line 90 of file Module.cc.

91{
92 if_value(">=1", path, afterConditionPath);
93}

◆ if_value()

void if_value ( const std::string & expression,
const std::shared_ptr< Path > & path,
EAfterConditionPath afterConditionPath = EAfterConditionPath::c_End )
inherited

Add a condition to the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

See https://xwiki.desy.de/xwiki/rest/p/a94f2 or ModuleCondition for a description of the syntax.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

Parameters
expressionThe expression of the condition.
pathShared pointer to the Path which will be executed if the condition is evaluated to true.
afterConditionPathWhat to do after executing 'path'.

Definition at line 79 of file Module.cc.

80{
81 m_conditions.emplace_back(expression, path, afterConditionPath);
82}

◆ initHistListBeforeEvent()

void initHistListBeforeEvent ( void )
staticinherited

Reset the list of histograms.

Definition at line 323 of file DQMHistAnalysis.cc.

324{
325 for (auto& it : s_histList) {
326 // attention, we must use reference, otherwise we work on a copy
327 it.second.resetBeforeEvent();
328 }
329 for (auto& it : s_deltaList) {
330 // attention, we must use reference, otherwise we work on a copy
331 it.second.setNotUpdated();
332 }
333
334 s_canvasUpdatedList.clear();
335}

◆ initialize()

void initialize ( void )
finaloverridevirtual

Initializer.

Reimplemented from Module.

Definition at line 74 of file DQMHistAnalysisTOP.cc.

75{
76
77 // check module parameters
78
79 if (m_asicWindowsBand.size() != 2) B2ERROR("Parameter list 'asicWindowsBand' must contain two numbers");
80 if (m_asicWindowsAlarmLevels.size() != 2) B2ERROR("Parameter list 'asicWindowsAlarmLevels' must contain two numbers");
81 if (m_eventMonitorAlarmLevels.size() != 2) B2ERROR("Parameter list 'eventMonitorAlarmLevels' must contain two numbers");
82 if (m_junkHitsAlarmLevels.size() != 2) B2ERROR("Parameter list 'junkHitsAlarmLevels' must contain two numbers");
83 if (m_deadChannelsAlarmLevels.size() != 2) B2ERROR("Parameter list 'deadChannelsAlarmLevels' must contain two numbers");
84 if (m_backgroundAlarmLevels.size() != 2) B2ERROR("Parameter list 'backgroundAlarmLevels' must contain two numbers");
85 if (m_photonYieldsAlarmLevels.size() != 2) B2ERROR("Parameter list 'photonYieldsAlarmLevels' must contain two numbers");
86 if (m_injectionBGAlarmLevels.size() != 2) B2ERROR("Parameter list 'injectionBGAlarmLevels' must contain two numbers");
87 if (m_timingAlarmLevels.size() != 2) B2ERROR("Parameter list 'timingAlarmLevels' must contain two numbers");
88 if (m_eventT0MeanAlarmLevels.size() != 2) B2ERROR("Parameter list 'eventT0MeanAlarmLevels' must contain two numbers");
89 if (m_eventT0RmsAlarmLevels.size() != 2) B2ERROR("Parameter list 'eventT0RmsAlarmLevels' must contain two numbers");
90 if (m_offsetMeanAlarmLevels.size() != 2) B2ERROR("Parameter list 'offsetMeanAlarmLevels' must contain two numbers");
91 if (m_offsetRmsAlarmLevels.size() != 2) B2ERROR("Parameter list 'offsetRmsAlarmLevels' must contain two numbers");
92
93 // make a map of boardstack names to ID's
94
95 int id = 1;
96 for (int slot = 1; slot <= 16; slot++) {
97 string slotstr = to_string(slot);
98 for (std::string bs : {"a", "b", "c", "d"}) {
99 m_bsmap[slotstr + bs] = id;
100 id++;
101 }
102 }
103
104 // parse excluded boardstacks
105
107
108 // MiraBelle monitoring
109
111
112 // Epics used to pass values to shifter's page (output only)
113
114 registerEpicsPV(m_pvPrefix + "badBoardstacks", "badBoardstacks");
115 registerEpicsPV(m_pvPrefix + "badCarriers", "badCarriers");
116 registerEpicsPV(m_pvPrefix + "badAsics", "badAsics");
117 registerEpicsPV(m_pvPrefix + "badPMTs", "badPMTs");
118 registerEpicsPV(m_pvPrefix + "numExcludedBS", "numExcludedBS");
119 registerEpicsPV(m_pvPrefix + "histoAlarmState", "histoAlarmState"); // to pass overall state to central alarm overview panel
120
121 // Epics used to get limits from configuration file - override module parameters (input only)
122
123 registerEpicsPV(m_pvPrefix + "asicWindowsBand", "asicWindowsBand");
124 registerEpicsPV(m_pvPrefix + "asicWindowsAlarmLevels", "asicWindowsAlarmLevels");
125 registerEpicsPV(m_pvPrefix + "eventMonitorAlarmLevels", "eventMonitorAlarmLevels");
126 registerEpicsPV(m_pvPrefix + "junkHitsAlarmLevels", "junkHitsAlarmLevels");
127 registerEpicsPV(m_pvPrefix + "deadChannelsAlarmLevels", "deadChannelsAlarmLevels");
128 registerEpicsPV(m_pvPrefix + "backgroundAlarmLevels", "backgroundAlarmLevels"); // also output
129 registerEpicsPV(m_pvPrefix + "photonYieldsAlarmLevels", "photonYieldsAlarmLevels");
130 registerEpicsPV(m_pvPrefix + "excludedBoardstacks", "excludedBoardstacks");
131
132 registerEpicsPV(m_pvPrefix + "injectionBGAlarmLevels", "injectionBGAlarmLevels"); // also output
133 registerEpicsPV(m_pvPrefix + "timingAlarmLevels", "timingAlarmLevels");
134 registerEpicsPV(m_pvPrefix + "eventT0MeanAlarmLevels", "eventT0MeanAlarmLevels");
135 registerEpicsPV(m_pvPrefix + "eventT0RmsAlarmLevels", "eventT0RmsAlarmLevels");
136 registerEpicsPV(m_pvPrefix + "offsetMeanAlarmLevels", "offsetMeanAlarmLevels");
137 registerEpicsPV(m_pvPrefix + "offsetRmsAlarmLevels", "offsetRmsAlarmLevels");
138
139 // new canvases, histograms and graphic primitives
140
141 gROOT->cd();
142
143 m_c_photonYields = new TCanvas("TOP/c_photonYields", "c_photonYields");
144 m_c_backgroundRates = new TCanvas("TOP/c_backgroundRates", "c_backgroundRates");
145
146 m_deadFraction = new TH1F("TOP/deadFraction", "Fraction of dead channels in included boardstacks", 16, 0.5, 16.5);
147 m_deadFraction->SetXTitle("slot number");
148 m_deadFraction->SetYTitle("fraction");
149 m_hotFraction = new TH1F("TOP/hotFraction", "Fraction of hot channels in included boardstacks", 16, 0.5, 16.5);
150 m_hotFraction->SetXTitle("slot number");
151 m_hotFraction->SetYTitle("fraction");
152 m_excludedFraction = new TH1F("TOP/excludedFraction", "Fraction of hot and dead channels in excluded bordstacks", 16, 0.5, 16.5);
153 m_excludedFraction->SetXTitle("slot number");
154 m_excludedFraction->SetYTitle("fraction");
155 m_activeFraction = new TH1F("TOP/activeFraction", "Fraction of active channels", 16, 0.5, 16.5);
156 m_activeFraction->SetXTitle("slot number");
157 m_activeFraction->SetYTitle("fraction");
158 m_c_deadAndHot = new TCanvas("TOP/c_deadAndHotChannels", "c_deadAndHotChannels");
159
160 m_junkFraction = new TH1F("TOP/junkFraction", "Fraction of junk hits per boardstack", 64, 0.5, 16.5);
161 m_junkFraction->SetXTitle("slot number");
162 m_junkFraction->SetYTitle("fraction");
163 // note: titles are intentionally the same since this one is plotted first
164 m_excludedBSHisto = new TH1F("TOP/excludedBSHisto", "Fraction of junk hits per boardstack", 64, 0.5, 16.5);
165 m_excludedBSHisto->SetXTitle("slot number");
166 m_excludedBSHisto->SetYTitle("fraction");
167 m_c_junkFraction = new TCanvas("TOP/c_junkFraction", "c_junkFraction");
168
169 for (int slot = 1; slot <= 16; slot++) {
170 string hname = "TOP/pmtHitRates_" + to_string(slot);
171 string htitle = "PMT hits per event for slot #" + to_string(slot);
172 auto* h = new TH1F(hname.c_str(), htitle.c_str(), 32, 0.5, 32.5);
173 h->SetXTitle("PMT number");
174 h->SetYTitle("Number of good hits per event");
175 m_pmtHitRates.push_back(h);
176 string cname = "TOP/c_pmtHitRates_" + to_string(slot);
177 string ctitle = "c_pmtHitRates_" + to_string(slot);
178 m_c_pmtHitRates.push_back(new TCanvas(cname.c_str(), ctitle.c_str()));
179 }
180
181 for (std::string name : {
182 "nhitInjLER", "nhitInjHER", "nhitInjLERcut", "nhitInjHERcut",
183 "eventInjLER", "eventInjHER", "eventInjLERcut", "eventInjHERcut"
184 }) {
185 for (std::string proj : {"_px", "_py"}) {
186 std::string cname = "TOP/c_" + name + proj;
187 m_c_injBGs[cname] = new TCanvas(cname.c_str(), (name + proj).c_str());
188 }
189 }
190
191 m_c_skipProcFlagFract = new TCanvas("TOP/c_skipProcFlagFract", "c_skipProcFlagFract");
192 m_c_injVetoFlagFract = new TCanvas("TOP/c_injVetoFlagFract", "c_injVetoFlagFract");
193
194 m_text1 = new TPaveText(0.125, 0.8, 0.675, 0.88, "NDC");
195 m_text1->SetFillColorAlpha(kWhite, 0);
196 m_text1->SetBorderSize(0);
197 m_text2 = new TPaveText(0.55, 0.8, 0.85, 0.89, "NDC");
198 m_text2->SetFillColorAlpha(kWhite, 0);
199 m_text2->SetBorderSize(0);
200 m_text3 = new TPaveText(0.47, 0.8, 0.85, 0.89, "NDC");
201 m_text3->SetFillColorAlpha(kWhite, 0);
202 m_text3->SetBorderSize(0);
203 m_text4 = new TPaveText(0.125, 0.8, 0.675, 0.88, "NDC");
204 m_text4->SetFillColorAlpha(kWhite, 0);
205 m_text4->SetBorderSize(0);
206
207 for (int slot = 1; slot < 16; slot++) {
208 auto* line = new TLine(slot + 0.5, 0, slot + 0.5, 1);
209 line->SetLineWidth(1);
210 line->SetLineStyle(2);
211 m_verticalLines.push_back(line);
212 }
213
215
216 B2DEBUG(20, "DQMHistAnalysisTOP: initialized.");
217}
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
TCanvas * m_c_photonYields
Canvas: photon yields per slot.
TH1F * m_excludedFraction
fraction of dead and hot channels per slot in excluded boardstacks only
TPaveText * m_text2
text to be written to event desynchonization monitor
TCanvas * m_c_junkFraction
Canvas: fraction of junk hits per boardstack.
TPaveText * m_text3
text to be written to background rates
std::vector< TCanvas * > m_c_pmtHitRates
Canvases of PMT hits per event (index = slot - 1)
TPaveText * m_text1
text to be written to window_vs_slot
TPaveText * m_text4
text to be written to number of good hits per event
std::vector< TLine * > m_verticalLines
vertical lines splitting slots
TCanvas * m_c_backgroundRates
Canvas: background rates per slot.
std::map< std::string, TCanvas * > m_c_injBGs
Canvases for projections of injection BG histograms.
void setAlarmLines()
Sets all alarm lines.
TH1F * m_activeFraction
fraction of active channels per slot
void setIncludedBoardstacks(const std::vector< std::string > &excludedBoardstacks)
Sets flags for boardstacks to be included in alarming.
TH1F * m_deadFraction
fraction of dead channels per slot (included boardstacks only)
TH1F * m_hotFraction
fraction of hot channels per slot (included boardstacks only)
TH1F * m_junkFraction
fraction of junk hits per boardstack
TCanvas * m_c_deadAndHot
Canvas: fractin of dead and hot channels.
std::map< std::string, int > m_bsmap
a map of boardstack names to ID's
std::vector< TH1F * > m_pmtHitRates
histograms of PMT hits per event (index = slot - 1)
TH1F * m_excludedBSHisto
histogram to show excluded boardstacks on junk fraction plot

◆ makeBGSubtractedTimingPlot()

void makeBGSubtractedTimingPlot ( const std::string & name,
const TH2F * trackHits,
int slot )
staticprivate

Makes background subtracted time distribution plot.

Parameters
namethe name of the histogram
trackHitshistogram used to scale background in case it is available
slotslot number

Definition at line 796 of file DQMHistAnalysisTOP.cc.

797{
798 auto* canvas = findCanvas("TOP/c_" + name);
799 if (not canvas) return;
800
801 auto* h = static_cast<TH1F*>(findHist("TOP/" + name));
802 if (not h) return;
803
804 auto* hb = static_cast<TH1F*>(findHist("TOP/" + name + "BG"));
805 if (not hb) return;
806
807 if (trackHits) {
808 // use the ratio of events w/ and w/o track in the slot to scale the background
809 double s = (slot == 0) ? trackHits->Integral(1, 16, 2, 2) : trackHits->GetBinContent(slot, 2);
810 if (s == 0) return;
811 double sb = (slot == 0) ? trackHits->Integral(1, 16, 1, 1) : trackHits->GetBinContent(slot, 1);
812 if (sb == 0) return;
813 h->Add(h, hb, 1, -s / sb);
814 } else {
815 // use the content of bins at t < 0 to scale the background
816 int i0 = h->GetXaxis()->FindBin(0.); // bin at t = 0
817 double s = h->Integral(1, i0);
818 if (s == 0) return;
819 double sb = hb->Integral(1, i0);
820 if (sb == 0) return;
821 if (s / sb > 1) return; // this can happen due to low statistics and is not reliable
822 h->Add(h, hb, 1, -s / sb);
823 }
824
825 TString title = TString(h->GetTitle()) + " (BG subtracted)";
826 h->SetTitle(title);
827
828 canvas->Clear();
829 canvas->cd();
830 h->Draw();
831 canvas->Modified();
832}

◆ makeDeadAndHotFractionsPlot()

const TH1F * makeDeadAndHotFractionsPlot ( )
private

Makes a plot of dead and hot channel fractions per slot.

Returns
fraction of active channels per slot

Definition at line 543 of file DQMHistAnalysisTOP.cc.

544{
545 m_deadFraction->Reset();
546 m_hotFraction->Reset();
547 m_excludedFraction->Reset();
548 m_activeFraction->Reset();
549 double inactiveFract = 0; // max inactive channel fraction when some boardstacks are excluded from alarming
550
551 for (int slot = 1; slot <= 16; slot++) {
552 auto* h = static_cast<TH1F*>(findHist("TOP/good_channel_hits_" + std::to_string(slot)));
553 if (not h) continue;
554
555 auto cuts = getDeadAndHotCuts(h);
556 double deadCut = cuts.first;
557 double hotCut = cuts.second;
558 double deadFract = 0;
559 double hotFract = 0;
560 double deadFractIncl = 0;
561 double hotFractIncl = 0;
562 for (int chan = 0; chan < h->GetNbinsX(); chan++) {
563 double y = h->GetBinContent(chan + 1);
564 int bs = chan / 128 + (slot - 1) * 4;
565 bool included = m_includedBoardstacks[bs];
566 if (y <= deadCut) {
567 deadFract += 1;
568 if (included) deadFractIncl += 1;
569 } else if (y > hotCut) {
570 hotFract += 1;
571 if (included) hotFractIncl += 1;
572 }
573 }
574 deadFract /= h->GetNbinsX();
575 hotFract /= h->GetNbinsX();
576 deadFractIncl /= h->GetNbinsX();
577 hotFractIncl /= h->GetNbinsX();
578 m_deadFraction->SetBinContent(slot, deadFractIncl);
579 m_hotFraction->SetBinContent(slot, hotFractIncl);
580 m_excludedFraction->SetBinContent(slot, deadFract - deadFractIncl + hotFract - hotFractIncl);
581 m_activeFraction->SetBinContent(slot, 1 - deadFract - hotFract);
582 inactiveFract = std::max(inactiveFract, deadFractIncl + hotFractIncl);
583 }
584
585 setMiraBelleVariables("ActiveChannelFraction_slot", m_activeFraction);
586
587 int alarmState = c_Gray;
588 if (m_activeFraction->Integral() > 0) {
589 alarmState = getAlarmState(inactiveFract, m_deadChannelsAlarmLevels);
590 }
591
592 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
593
594 m_deadFraction->SetFillColor(1);
595 m_deadFraction->SetLineColor(1);
596 m_deadFraction->GetXaxis()->SetNdivisions(16);
597
598 m_hotFraction->SetFillColor(2);
599 m_hotFraction->SetLineColor(2);
600 m_hotFraction->GetXaxis()->SetNdivisions(16);
601
602 m_excludedFraction->SetFillColor(kGray);
603 m_excludedFraction->SetLineColor(kGray);
604 m_excludedFraction->GetXaxis()->SetNdivisions(16);
605
606 m_activeFraction->SetFillColor(0);
607 m_activeFraction->GetXaxis()->SetNdivisions(16);
608
609 auto* canvas = m_c_deadAndHot;
610 canvas->Clear();
611 canvas->cd();
612 canvas->Pad()->SetFrameFillColor(10);
613 if (not m_stack) {
614 m_stack = new THStack("TOP/stack", "Fraction of dead and hot channels");
619 }
620 m_stack->Draw();
621
622 for (auto* line : m_deadChannelsAlarmLines) line->Draw("same");
623
624 if (not m_legend) {
625 m_legend = new TLegend(0.8, 0.87, 0.99, 0.99);
626 m_legend->AddEntry(m_hotFraction, "hot");
627 m_legend->AddEntry(m_deadFraction, "dead");
628 m_legend->AddEntry(m_excludedFraction, "excluded");
629 }
630 m_legend->Draw("same");
631
632 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
633 canvas->Modified();
634
635 return m_activeFraction;
636}
THStack * m_stack
stack for drawing dead, hot and active channel fractions
std::vector< TLine * > m_deadChannelsAlarmLines
lines representing alarm levels
static std::pair< double, double > getDeadAndHotCuts(const TH1 *h)
Returns cut levels for dead and hot channels.
std::vector< bool > m_includedBoardstacks
boardstacks included in alarming
int getAlarmColor(unsigned alarmState) const
Converts alarm state to color.
int getAlarmState(double value, const std::vector< double > &alarmLevels, bool bigRed=true) const
Returns alarm state.
TLegend * m_legend
legend for dead and hot channels
void setMiraBelleVariables(const std::string &variableName, const TH1 *histogram)
Sets MiraBelle variables from the histogram with bins corresponding to slot numbers.

◆ makeFlagFractPlot()

void makeFlagFractPlot ( const std::string & hname,
TH1 * histogram,
TCanvas * canvas )
staticprivate

Makes a plot of fraction of events with the flag is set.

Parameters
hnamename of 2D histogram (y-axis = flag value)
histogramresulting histogram w/ fractions
canvascanvas to plot

Definition at line 916 of file DQMHistAnalysisTOP.cc.

917{
918 if (histogram) delete histogram;
919 auto* h = static_cast<TH2F*>(findHist(hname));
920 if (not h) return;
921
922 histogram = h->ProjectionX((hname + "Fract").c_str(), 2, 2);
923 auto* px = h->ProjectionX("tmp");
924 histogram->Divide(histogram, px, 1, 1, "B");
925 delete px;
926 histogram->SetTitle(TString(h->GetTitle()) + " is set");
927 histogram->SetYTitle("fraction of events");
928 histogram->SetMarkerStyle(24);
929 histogram->SetMinimum(0);
930
931 if (not canvas) return;
932 canvas->Clear();
933 canvas->cd();
934 histogram->Draw();
935 canvas->Modified();
936}

◆ makeInjectionBGPlots()

void makeInjectionBGPlots ( )
private

Makes projections of injection BG plots.

Definition at line 868 of file DQMHistAnalysisTOP.cc.

869{
870 for (std::string name : {"nhitInjLER", "nhitInjHER", "nhitInjLERcut", "nhitInjHERcut"}) {
871 std::string hname = "TOP/" + name;
872 auto* h = static_cast<TProfile2D*>(findHist(hname));
873 if (not h) continue;
874 for (std::string proj : {"_px", "_py"}) {
875 std::string cname = "TOP/c_" + name + proj;
876 auto* canvas = m_c_injBGs[cname];
877 if (not canvas) continue;
878 canvas->Clear();
879 canvas->cd();
880 auto& hproj = m_profiles[cname];
881 if (hproj) delete hproj;
882 hproj = (proj == "_px") ? h->ProfileX((hname + proj).c_str()) : h->ProfileY((hname + proj).c_str());
883 std::string xtitle = (proj == "_px") ? h->GetXaxis()->GetTitle() : h->GetYaxis()->GetTitle();
884 hproj->SetXTitle(xtitle.c_str());
885 hproj->SetYTitle(h->GetZaxis()->GetTitle());
886 hproj->SetMinimum(0);
887 hproj->Draw("hist");
888 canvas->Modified();
889 }
890 }
891
892 for (std::string name : {"eventInjLER", "eventInjHER", "eventInjLERcut", "eventInjHERcut"}) {
893 std::string hname = "TOP/" + name;
894 auto* h = static_cast<TH2F*>(findHist(hname));
895 if (not h) continue;
896 for (std::string proj : {"_px", "_py"}) {
897 std::string cname = "TOP/c_" + name + proj;
898 auto* canvas = m_c_injBGs[cname];
899 if (not canvas) continue;
900 canvas->Clear();
901 canvas->cd();
902 auto& hproj = m_projections[cname];
903 if (hproj) delete hproj;
904 hproj = (proj == "_px") ? h->ProjectionX((hname + proj).c_str()) : h->ProjectionY((hname + proj).c_str());
905 std::string xtitle = (proj == "_px") ? h->GetXaxis()->GetTitle() : h->GetYaxis()->GetTitle();
906 hproj->SetXTitle(xtitle.c_str());
907 hproj->SetYTitle(h->GetZaxis()->GetTitle());
908 hproj->SetMinimum(0);
909 hproj->Draw("hist");
910 canvas->Modified();
911 }
912 }
913
914}
std::map< std::string, TH1D * > m_projections
projections of injection BG
std::map< std::string, TProfile * > m_profiles
profiles of injection BG

◆ makeJunkFractionPlot()

void makeJunkFractionPlot ( )
private

Makes a plot of fractions of junk hits per boardstack.

Definition at line 728 of file DQMHistAnalysisTOP.cc.

729{
730 m_junkFraction->Reset();
731 m_excludedBSHisto->Reset();
732 auto* allHits = static_cast<TH1D*>(m_junkFraction->Clone("tmp"));
733 for (int slot = 1; slot <= 16; slot++) {
734 auto* good = static_cast<TH1F*>(findHist("TOP/good_channel_hits_" + std::to_string(slot)));
735 if (not good) continue;
736 auto* bad = static_cast<TH1F*>(findHist("TOP/bad_channel_hits_" + std::to_string(slot)));
737 if (not bad) continue;
738 for (int i = 0; i < 512; i++) {
739 int bs = i / 128;
740 allHits->Fill(slot + bs / 4. - 0.5, good->GetBinContent(i + 1) + bad->GetBinContent(i + 1));
741 m_junkFraction->Fill(slot + bs / 4. - 0.5, bad->GetBinContent(i + 1));
742 }
743 }
744
745 m_junkFraction->Divide(m_junkFraction, allHits, 1, 1, "B");
746
747 int alarmState = c_Gray;
748 if (allHits->Integral() > 0) {
749 double hmax = 0;
750 for (size_t i = 0; i < m_includedBoardstacks.size(); i++) {
751 if (m_includedBoardstacks[i]) hmax = std::max(hmax, m_junkFraction->GetBinContent(i + 1));
752 else m_excludedBSHisto->SetBinContent(i + 1, 1);
753 }
754 alarmState = getAlarmState(hmax, m_junkHitsAlarmLevels);
755 }
756 delete allHits;
757 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
758
759 auto* canvas = m_c_junkFraction;
760 canvas->Clear();
761 canvas->cd();
762 canvas->Pad()->SetFrameFillColor(10);
763 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
764 m_excludedBSHisto->SetFillColor(kGray);
765 m_excludedBSHisto->SetLineColor(kGray);
766 m_excludedBSHisto->GetXaxis()->SetNdivisions(16);
767 m_excludedBSHisto->GetYaxis()->SetRangeUser(0, 1);
768 m_excludedBSHisto->Draw();
769 m_junkFraction->SetMarkerStyle(24);
770 m_junkFraction->GetXaxis()->SetNdivisions(16);
771 m_junkFraction->GetYaxis()->SetRangeUser(0, 1); // Note: m_junkFraction->GetMaximum() will now give 1 and not the histogram maximum!
772 m_junkFraction->Draw("same");
773 for (auto* line : m_verticalLines) line->Draw("same");
774 for (auto* line : m_junkHitsAlarmLines) line->Draw("same");
775 canvas->Modified();
776}
std::vector< TLine * > m_junkHitsAlarmLines
lines representing alarm levels

◆ makePhotonYieldsAndBGRatePlots()

void makePhotonYieldsAndBGRatePlots ( const TH1F * activeFraction)
private

Make plots of dead-and-hot-channel corrected photon yields and BG rates per slot.

Parameters
activeFractionfraction of active channels per slot

Definition at line 639 of file DQMHistAnalysisTOP.cc.

640{
641 for (auto* canvas : {m_c_photonYields, m_c_backgroundRates}) {
642 canvas->Clear();
643 canvas->Pad()->SetFrameFillColor(10);
644 canvas->Pad()->SetFillColor(getAlarmColor(c_Gray));
645 canvas->Modified();
646 }
647 m_averageRate = 0;
648
649 auto* signalHits = static_cast<TProfile*>(findHist("TOP/signalHits"));
650 if (not signalHits) return;
651
652 auto* backgroundHits = static_cast<TProfile*>(findHist("TOP/backgroundHits"));
653 if (not backgroundHits) return;
654
655 if (m_photonYields) delete m_photonYields;
656 m_photonYields = signalHits->ProjectionX("TOP/photonYields");
658 m_backgroundRates = backgroundHits->ProjectionX("TOP/backgroundRates");
659 auto* activeFract = static_cast<TH1F*>(activeFraction->Clone("tmp"));
660 for (int i = 1; i <= activeFract->GetNbinsX(); i++) activeFract->SetBinError(i, 0);
661
663 m_photonYields->Divide(m_photonYields, activeFract);
664 setMiraBelleVariables("PhotonsPerTrack_slot", m_photonYields);
665
666 int alarmState = c_Gray;
667 if (signalHits->GetEntries() > 0 and activeFraction->Integral() > 0) {
668 double hmin = 1000;
669 for (int i = 1; i <= m_photonYields->GetNbinsX(); i++) {
670 if (signalHits->GetBinEntries(i) < 10) continue;
671 hmin = std::min(hmin, m_photonYields->GetBinContent(i) + 3 * m_photonYields->GetBinError(i));
672 }
673 if (hmin < 1000) alarmState = getAlarmState(hmin, m_photonYieldsAlarmLevels, false);
674 }
675 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
676
677 m_photonYields->SetTitle("Number of photons per track");
678 m_photonYields->SetYTitle("photons per track");
679 m_photonYields->SetMarkerStyle(24);
680 m_photonYields->GetXaxis()->SetNdivisions(16);
681
682 auto* canvas = m_c_photonYields;
683 canvas->cd();
684 m_photonYields->SetMinimum(0);
685 m_photonYields->Draw();
686 for (auto* line : m_photonYieldsAlarmLines) line->Draw("same");
687 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
688 canvas->Modified();
689
690 m_backgroundRates->Scale(1.0 / 50.0e-3 / 32); // measured in 50 ns window, 32 PMT's ==> rate in MHz/PMT
691 m_backgroundRates->Divide(m_backgroundRates, activeFract);
692 setMiraBelleVariables("BackgroundRate_slot", m_backgroundRates);
693
694 alarmState = c_Gray;
695 m_text3->Clear();
696 if (backgroundHits->GetEntries() > 100 and activeFraction->Integral() > 0) {
697 int status = m_backgroundRates->Fit("pol0", "Q0");
698 if (status == 0) {
699 auto* fun = m_backgroundRates->GetFunction("pol0");
700 if (fun) {
701 m_averageRate = fun->GetParameter(0);
702 double error = fun->GetParError(0);
703 alarmState = getAlarmState(m_averageRate - 3 * error, m_backgroundAlarmLevels);
704 m_text3->AddText(Form("Average: %.2f MHz/PMT", m_averageRate));
705 }
706 }
707 }
708 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
709
710 m_backgroundRates->SetTitle("Background rates");
711 m_backgroundRates->SetYTitle("background rate [MHz/PMT]");
712 m_backgroundRates->SetMarkerStyle(24);
713 m_backgroundRates->GetXaxis()->SetNdivisions(16);
714
715 canvas = m_c_backgroundRates;
716 canvas->cd();
717 m_backgroundRates->SetMinimum(0);
718 m_backgroundRates->Draw();
719 for (auto* line : m_backgroundAlarmLines) line->Draw("same");
720 m_text3->Draw();
721 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
722 canvas->Modified();
723
724 delete activeFract;
725}
std::vector< TLine * > m_photonYieldsAlarmLines
lines representing alarm levels
TH1D * m_photonYields
photon yields per slot
TH1D * m_backgroundRates
background rates per slot
double m_averageRate
average BG rate (to pass to EpicsPV)
std::vector< TLine * > m_backgroundAlarmLines
lines representing alarm levels

◆ makePMTHitRatesPlots()

void makePMTHitRatesPlots ( )
private

Makes plots of the number of PMT hits per event.

Definition at line 835 of file DQMHistAnalysisTOP.cc.

836{
837 auto* h0 = static_cast<TH1F*>(findHist("TOP/goodHitsPerEventAll"));
838 if (not h0) return;
839 double numEvents = h0->GetEntries();
840 if (numEvents == 0) return;
841
842 int numSlots = m_pmtHitRates.size();
843 for (int slot = 1; slot <= numSlots; slot++) {
844 string name = "TOP/good_hits_xy_" + to_string(slot);
845 auto* hxy = static_cast<TH2F*>(findHist(name));
846 if (not hxy) continue;
847 std::vector<double> pmts(32, 0);
848 for (int row = 0; row < 8; row++) {
849 for (int col = 0; col < 64; col++) {
850 int pmt = col / 4 + (row / 4) * 16;
851 pmts[pmt] += hxy->GetBinContent(col + 1, row + 1);
852 }
853 }
854 auto* h = m_pmtHitRates[slot - 1];
855 for (size_t i = 0; i < pmts.size(); i++) {
856 h->SetBinContent(i + 1, pmts[i] / numEvents);
857 }
858 auto* canvas = m_c_pmtHitRates[slot - 1];
859 canvas->Clear();
860 canvas->cd();
861 h->SetMinimum(0);
862 h->Draw();
863 canvas->Modified();
864 }
865}

◆ makeStatus()

DQMHistAnalysisModule::EStatus makeStatus ( bool enough,
bool warn_flag,
bool error_flag )
staticinherited

Helper function to judge the status for coloring and EPICS.

Parameters
enoughenough events for judging
warn_flagoutside of expected range
error_flagoutside of warning range
Returns
the status

Definition at line 705 of file DQMHistAnalysis.cc.

706{
707 // white color is the default, if no colorize
708 if (!enough) {
709 return (c_StatusTooFew);
710 } else {
711 if (error_flag) {
712 return (c_StatusError);
713 } else if (warn_flag) {
714 return (c_StatusWarning);
715 } else {
716 return (c_StatusGood);
717 }
718 }
719
720 return (c_StatusDefault); // default, but should not be reached
721}

◆ printPVStatus()

void printPVStatus ( chid pv,
bool onlyError = true )
staticinherited

check the status of a PVs and report if disconnected or not found

Parameters
pvthe chid of the PV to check
onlyErrorprint only if in error condition (default)

Definition at line 773 of file DQMHistAnalysis.cc.

774{
775 if (pv == nullptr) {
776 B2WARNING("PV chid was nullptr");
777 return;
778 }
779 auto state = ca_state(pv);
780 switch (state) {
781 case cs_never_conn: /* valid chid, server not found or unavailable */
782 B2WARNING("Channel never connected " << ca_name(pv));
783 break;
784 case cs_prev_conn: /* valid chid, previously connected to server */
785 B2WARNING("Channel was connected, but now is not " << ca_name(pv));
786 break;
787 case cs_closed: /* channel deleted by user */
788 B2WARNING("Channel deleted already " << ca_name(pv));
789 break;
790 case cs_conn: /* valid chid, connected to server */
791 if (!onlyError) B2INFO("Channel connected and OK " << ca_name(pv));
792 break;
793 default:
794 B2WARNING("Undefined status for channel " << ca_name(pv));
795 break;
796 }
797}

◆ registerEpicsPV()

int registerEpicsPV ( const std::string & pvname,
const std::string & keyname = "" )
inherited

EPICS related Functions.

Register a PV with its name and a key name

Parameters
pvnamefull PV name
keynamekey name for easier access
Returns
an index which can be used to access the PV instead of key name, -1 if failure

Definition at line 388 of file DQMHistAnalysis.cc.

389{
390 return registerEpicsPVwithPrefix(m_PVPrefix, pvname, keyname);
391}
static std::string m_PVPrefix
The Prefix for EPICS PVs.
int registerEpicsPVwithPrefix(const std::string &prefix, const std::string &pvname, const std::string &keyname="")
Register a PV with its name and a key name.

◆ registerEpicsPVwithPrefix()

int registerEpicsPVwithPrefix ( const std::string & prefix,
const std::string & pvname,
const std::string & keyname = "" )
privateinherited

Register a PV with its name and a key name.

Parameters
prefixprefix to PV name
pvnamefull PV name without prefix
keynamekey name for easier access
Returns
an index which can be used to access the PV instead of key name, -1 if failure

Definition at line 398 of file DQMHistAnalysis.cc.

400{
401 if (!m_useEpics) return -1;
402#ifdef _BELLE2_EPICS
403 if (m_epicsNameToChID[pvname] != nullptr) {
404 B2ERROR("Epics PV " << pvname << " already registered!");
405 return -1;
406 }
407 if (keyname != "" && m_epicsNameToChID[keyname] != nullptr) {
408 B2ERROR("Epics PV with key " << keyname << " already registered!");
409 return -1;
410 }
411
412 m_epicsChID.emplace_back();
413 auto ptr = &m_epicsChID.back();
414 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback), "ca_context_create");
415 // the subscribed name includes the prefix, the map below does *not*
416 CheckEpicsError(ca_create_channel((prefix + pvname).data(), NULL, NULL, 10, ptr), "ca_create_channel failure", pvname);
417
418 m_epicsNameToChID[pvname] = *ptr;
419 if (keyname != "") m_epicsNameToChID[keyname] = *ptr;
420 return m_epicsChID.size() - 1; // return index to last added item
421#else
422 return -1;
423#endif
424}

◆ registerExternalEpicsPV()

int registerExternalEpicsPV ( const std::string & pvname,
const std::string & keyname = "" )
inherited

Register a PV with its name and a key name.

Parameters
pvnamefull PV name
keynamekey name for easier access
Returns
an index which can be used to access the PV instead of key name, -1 if failure

Definition at line 393 of file DQMHistAnalysis.cc.

394{
395 return registerEpicsPVwithPrefix(std::string(""), pvname, keyname);
396}

◆ requestLimitsFromEpicsPVs() [1/3]

bool requestLimitsFromEpicsPVs ( chid id,
double & lowerAlarm,
double & lowerWarn,
double & upperWarn,
double & upperAlarm )
inherited

Get Alarm Limits from EPICS PV.

Parameters
idChannel ID
&lowerAlarmreturn low Alarm limit (lolo) if set, not changed otherwise
&lowerWarnreturn low Warning limit (low) if set, not changed otherwise
&upperWarnreturn upper Warning limit (high) if set, not changed otherwise
&upperAlarmreturn upper Alarm limit (hihi) if set, not changed otherwise
Returns
true if limits could be read (even if there are none set)

Definition at line 670 of file DQMHistAnalysis.cc.

672{
673 // get warn and error limit only if pv exists
674 // overwrite only if limit is defined (not NaN)
675 // user should initialize with NaN before calling, unless
676 // some "default" values should be set otherwise
677 if (pv != nullptr) {
678 struct dbr_ctrl_double tPvData;
679 // From EPICS doc. When ca_get or ca_array_get are invoked the returned channel value can't be assumed to be stable
680 // in the application supplied buffer until after ECA_NORMAL is returned from ca_pend_io. If a connection is lost
681 // outstanding get requests are not automatically reissued following reconnect.
682 auto r = ca_get(DBR_CTRL_DOUBLE, pv, &tPvData);
683 if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
684 if (r == ECA_NORMAL) {
685 if (!std::isnan(tPvData.lower_alarm_limit)) {
686 lowerAlarm = tPvData.lower_alarm_limit;
687 }
688 if (!std::isnan(tPvData.lower_warning_limit)) {
689 lowerWarn = tPvData.lower_warning_limit;
690 }
691 if (!std::isnan(tPvData.upper_warning_limit)) {
692 upperWarn = tPvData.upper_warning_limit;
693 }
694 if (!std::isnan(tPvData.upper_alarm_limit)) {
695 upperAlarm = tPvData.upper_alarm_limit;
696 }
697 return true;
698 } else {
699 CheckEpicsError(r, "Reading PV Limits failed in ca_get or ca_pend_io failure", pv);
700 }
701 }
702 return false;
703}

◆ requestLimitsFromEpicsPVs() [2/3]

bool requestLimitsFromEpicsPVs ( const std::string & keyname,
double & lowerAlarm,
double & lowerWarn,
double & upperWarn,
double & upperAlarm )
inherited

Get Alarm Limits from EPICS PV.

Parameters
keynamekey name (or full PV name) of PV
&lowerAlarmreturn low Alarm limit (lolo) if set, not changed otherwise
&lowerWarnreturn low Warning limit (low) if set, not changed otherwise
&upperWarnreturn upper Warning limit (high) if set, not changed otherwise
&upperAlarmreturn upper Alarm limit (hihi) if set, not changed otherwise
Returns
true if limits could be read (even if there are none set)

Definition at line 658 of file DQMHistAnalysis.cc.

660{
661 return requestLimitsFromEpicsPVs(getEpicsPVChID(name), lowerAlarm, lowerWarn, upperWarn, upperAlarm);
662}
chid getEpicsPVChID(const std::string &keyname)
Get EPICS PV Channel Id.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.

◆ requestLimitsFromEpicsPVs() [3/3]

bool requestLimitsFromEpicsPVs ( int index,
double & lowerAlarm,
double & lowerWarn,
double & upperWarn,
double & upperAlarm )
inherited

Get Alarm Limits from EPICS PV.

Parameters
indexindex of PV
&lowerAlarmreturn low Alarm limit (lolo) if set, not changed otherwise
&lowerWarnreturn low Warning limit (low) if set, not changed otherwise
&upperWarnreturn upper Warning limit (high) if set, not changed otherwise
&upperAlarmreturn upper Alarm limit (hihi) if set, not changed otherwise
Returns
true if limits could be read (even if there are none set)

Definition at line 664 of file DQMHistAnalysis.cc.

666{
667 return requestLimitsFromEpicsPVs(getEpicsPVChID(index), lowerAlarm, lowerWarn, upperWarn, upperAlarm);
668}

◆ resetDeltaList()

void resetDeltaList ( void )
staticinherited

Reset Delta.

Definition at line 347 of file DQMHistAnalysis.cc.

348{
349 for (auto& d : s_deltaList) {
350 d.second.reset();
351 }
352}

◆ sameHistDefinition()

bool sameHistDefinition ( TH1 * h1,
TH1 * h2 )
staticprivate

Checks if histograms are defined in the same way (nbins, xmin, xmax)

Parameters
h1first histogram
h2second histogram
Returns
true if (nbins, xmin, xmax) match

Definition at line 535 of file DQMHistAnalysisTOP.cc.

536{
537 if (h1->GetNbinsX() != h2->GetNbinsX()) return false;
538 if (h1->GetXaxis()->GetXmin() != h2->GetXaxis()->GetXmin()) return false;
539 if (h1->GetXaxis()->GetXmax() != h2->GetXaxis()->GetXmax()) return false;
540 return true;
541}

◆ scaleReference()

TH1 * scaleReference ( ERefScaling scaling,
const TH1 * hist,
TH1 * ref )
staticinherited

Using the original and reference, create scaled version.

Parameters
scalingscaling algorithm
histpointer to histogram
refpointer to reference
Returns
scaled reference

Definition at line 182 of file DQMHistAnalysis.cc.

183{
184 // if hist/ref is nullptr, nothing to do
185 if (!hist || !ref)
186 return ref;
187
188 switch (scaling) {
189 // default: do nothing
190 case ERefScaling::c_RefScaleNone: //do nothing
191 break;
192 case ERefScaling::c_RefScaleEntries: // Integral
193 // only if we have entries in reference
194 if (hist->Integral() != 0 and ref->Integral() != 0) {
195 ref->Scale(hist->Integral() / ref->Integral());
196 }
197 break;
198 case ERefScaling::c_RefScaleMax: // Maximum
199 // only if we have entries in reference
200 if (hist->GetMaximum() != 0 and ref->GetMaximum() != 0) {
201 ref->Scale(hist->GetMaximum() / ref->GetMaximum());
202 }
203 break;
204 }
205 return ref;
206}
@ c_RefScaleEntries
to number of entries (integral)
@ c_RefScaleMax
to maximum (bin entry)

◆ setAbortLevel()

void setAbortLevel ( int abortLevel)
inherited

Configure the abort log level.

Definition at line 67 of file Module.cc.

68{
69 m_logConfig.setAbortLevel(static_cast<LogConfig::ELogLevel>(abortLevel));
70}
ELogLevel
Definition of the supported log levels.
Definition LogConfig.h:26
void setAbortLevel(ELogLevel abortLevel)
Configure the abort level.
Definition LogConfig.h:112

◆ setAlarmLines() [1/2]

void setAlarmLines ( )
private

Sets all alarm lines.

Definition at line 987 of file DQMHistAnalysisTOP.cc.

988{
989 for (size_t i = 0; i < m_asicWindowsBand.size(); i++) {
990 double y = m_asicWindowsBand[i];
991 if (i < m_asicWindowsBandLines.size()) {
992 auto* line = m_asicWindowsBandLines[i];
993 line->SetY1(y);
994 line->SetY2(y);
995 } else {
996 auto* line = new TLine(0.5, y, 16.5, y);
997 line->SetLineWidth(2);
998 line->SetLineColor(kRed);
999 m_asicWindowsBandLines.push_back(line);
1000 }
1001 }
1002
1007}
std::vector< TLine * > m_asicWindowsBandLines
lines denoting a band of good windows

◆ setAlarmLines() [2/2]

void setAlarmLines ( const std::vector< double > & alarmLevels,
double xmin,
double xmax,
std::vector< TLine * > & alarmLines,
bool bigRed = true )
staticprivate

Sets alarm lines.

Parameters
alarmLevelsalarm levels
xminminimal x
xmaxmaximal x
alarmLinesalarm lines [out]
bigRedon true red color for large values, else red color for small values

Definition at line 964 of file DQMHistAnalysisTOP.cc.

966{
967 std::vector<int> colors = {kOrange, kRed};
968 if (not bigRed) std::reverse(colors.begin(), colors.end());
969 for (size_t i = 0; i < std::min(colors.size(), alarmLevels.size()); i++) {
970 if (i < alarmLines.size()) {
971 auto* line = alarmLines[i];
972 line->SetX1(xmin);
973 line->SetX2(xmax);
974 line->SetY1(alarmLevels[i]);
975 line->SetY2(alarmLevels[i]);
976 } else {
977 auto* line = new TLine(xmin, alarmLevels[i], xmax, alarmLevels[i]);
978 line->SetLineWidth(2);
979 line->SetLineStyle(2);
980 line->SetLineColor(colors[i]);
981 alarmLines.push_back(line);
982 }
983 }
984}

◆ setDebugLevel()

void setDebugLevel ( int debugLevel)
inherited

Configure the debug messaging level.

Definition at line 61 of file Module.cc.

62{
63 m_logConfig.setDebugLevel(debugLevel);
64}
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition LogConfig.h:98

◆ setDescription()

void setDescription ( const std::string & description)
protectedinherited

Sets the description of the module.

Parameters
descriptionA description of the module.

Definition at line 214 of file Module.cc.

215{
216 m_description = description;
217}
std::string m_description
The description of the module.
Definition Module.h:510

◆ setEpicsPV() [1/4]

void setEpicsPV ( const std::string & keyname,
double value )
inherited

Write value to a EPICS PV.

Parameters
keynamekey name (or full PV name) of PV
valuevalue to write

Definition at line 426 of file DQMHistAnalysis.cc.

427{
428 if (!m_useEpics || m_epicsReadOnly) return;
429#ifdef _BELLE2_EPICS
430 if (m_epicsNameToChID[keyname] == nullptr) {
431 B2ERROR("Epics PV " << keyname << " not registered!");
432 return;
433 }
434 CheckEpicsError(ca_put(DBR_DOUBLE, m_epicsNameToChID[keyname], (void*)&value), "ca_set failure", keyname);
435#endif
436}
static bool m_epicsReadOnly
Flag if to use EPICS in ReadOnly mode (for reading limits) do not set by yourself,...

◆ setEpicsPV() [2/4]

void setEpicsPV ( const std::string & keyname,
int value )
inherited

Write value to a EPICS PV.

Parameters
keynamekey name (or full PV name) of PV
valuevalue to write

Definition at line 438 of file DQMHistAnalysis.cc.

439{
440 if (!m_useEpics || m_epicsReadOnly) return;
441#ifdef _BELLE2_EPICS
442 if (m_epicsNameToChID[keyname] == nullptr) {
443 B2ERROR("Epics PV " << keyname << " not registered!");
444 return;
445 }
446 CheckEpicsError(ca_put(DBR_SHORT, m_epicsNameToChID[keyname], (void*)&value), "ca_set failure", keyname);
447#endif
448}

◆ setEpicsPV() [3/4]

void setEpicsPV ( int index,
double value )
inherited

Write value to a EPICS PV.

Parameters
indexindex of PV
valuevalue to write

Definition at line 468 of file DQMHistAnalysis.cc.

469{
470 if (!m_useEpics || m_epicsReadOnly) return;
471#ifdef _BELLE2_EPICS
472 if (index < 0 || index >= (int)m_epicsChID.size()) {
473 B2ERROR("Epics PV with " << index << " not registered!");
474 return;
475 }
476 CheckEpicsError(ca_put(DBR_DOUBLE, m_epicsChID[index], (void*)&value), "ca_set failure", m_epicsChID[index]);
477#endif
478}

◆ setEpicsPV() [4/4]

void setEpicsPV ( int index,
int value )
inherited

Write value to a EPICS PV.

Parameters
indexindex of PV
valuevalue to write

Definition at line 480 of file DQMHistAnalysis.cc.

481{
482 if (!m_useEpics || m_epicsReadOnly) return;
483#ifdef _BELLE2_EPICS
484 if (index < 0 || index >= (int)m_epicsChID.size()) {
485 B2ERROR("Epics PV with " << index << " not registered!");
486 return;
487 }
488 CheckEpicsError(ca_put(DBR_SHORT, m_epicsChID[index], (void*)&value), "ca_set failure", m_epicsChID[index]);
489#endif
490}

◆ setEpicsStringPV() [1/2]

void setEpicsStringPV ( const std::string & keyname,
const std::string & value )
inherited

Write string to a EPICS PV.

Parameters
keynamekey name (or full PV name) of PV
valuestring to write

Definition at line 450 of file DQMHistAnalysis.cc.

451{
452 if (!m_useEpics || m_epicsReadOnly) return;
453#ifdef _BELLE2_EPICS
454 if (m_epicsNameToChID[keyname] == nullptr) {
455 B2ERROR("Epics PV " << keyname << " not registered!");
456 return;
457 }
458 if (value.length() > 40) {
459 B2ERROR("Epics string PV " << keyname << " too long (>40 characters)!");
460 return;
461 }
462 char text[40];
463 strcpy(text, value.c_str());
464 CheckEpicsError(ca_put(DBR_STRING, m_epicsNameToChID[keyname], text), "ca_set failure", keyname);
465#endif
466}

◆ setEpicsStringPV() [2/2]

void setEpicsStringPV ( int index,
std::string value )
inherited

Write string to a EPICS PV.

Parameters
indexindex of PV
valuestring to write

Definition at line 492 of file DQMHistAnalysis.cc.

493{
494 if (!m_useEpics || m_epicsReadOnly) return;
495#ifdef _BELLE2_EPICS
496 if (index < 0 || index >= (int)m_epicsChID.size()) {
497 B2ERROR("Epics PV with " << index << " not registered!");
498 return;
499 }
500 char text[41];
501 strncpy(text, value.c_str(), 40);
502 text[40] = 0;
503 CheckEpicsError(ca_put(DBR_STRING, m_epicsChID[index], text), "ca_set failure", m_epicsChID[index]);
504#endif
505}

◆ setEpicsVariables()

void setEpicsVariables ( )
private

Calculates and sets epics variables.

Definition at line 1040 of file DQMHistAnalysisTOP.cc.

1041{
1042 int badBoardstacks = 0;
1043 int badCarriers = 0;
1044 int badAsics = 0;
1045 for (int slot = 1; slot <= 16; slot++) {
1046 std::string hname = "TOP/good_hits_asics_" + to_string(slot);
1047 auto* h = static_cast<TH2F*>(findHist(hname));
1048 if (not h) continue;
1049
1050 auto cuts = getDeadAndHotCuts(h);
1051 double deadCut = cuts.first;
1052 double hotCut = cuts.second;
1053 std::vector<int> asics(64, 0);
1054 std::vector<int> carriers(16, 0);
1055 std::vector<int> boardstacks(4, 0);
1056 for (int asic = 0; asic < 64; asic++) {
1057 int carrier = asic / 4;
1058 int boardstack = carrier / 4;
1059 for (int chan = 0; chan < 8; chan++) {
1060 double y = h->GetBinContent(asic + 1, chan + 1);
1061 if (y > deadCut and y <= hotCut) {
1062 asics[asic]++;
1063 carriers[carrier]++;
1064 boardstacks[boardstack]++;
1065 }
1066 }
1067 }
1068 for (int n : asics) if (n == 0) badAsics++;
1069 for (int n : carriers) if (n == 0) badCarriers++;
1070 for (int n : boardstacks) if (n == 0) badBoardstacks++;
1071 }
1072 badAsics -= badCarriers * 4;
1073 badCarriers -= badBoardstacks * 4;
1074
1075 int badPMTs = 0;
1076 for (int slot = 1; slot <= 16; slot++) {
1077 std::string hname = "TOP/good_hits_xy_" + to_string(slot);
1078 auto* h = static_cast<TH2F*>(findHist(hname));
1079 if (not h) continue;
1080
1081 auto cuts = getDeadAndHotCuts(h);
1082 double deadCut = cuts.first;
1083 double hotCut = cuts.second;
1084 std::vector<int> pmts(32, 0);
1085 for (int row = 0; row < 8; row++) {
1086 for (int col = 0; col < 64; col++) {
1087 double y = h->GetBinContent(col + 1, row + 1);
1088 if (y > deadCut and y <= hotCut) {
1089 int pmt = col / 4 + (row / 4) * 16;
1090 pmts[pmt]++;
1091 }
1092 }
1093 }
1094 for (int n : pmts) if (n == 0) badPMTs++;
1095 }
1096 badPMTs -= badBoardstacks * 8;
1097
1098 setEpicsPV("badBoardstacks", badBoardstacks);
1099 setEpicsPV("badCarriers", badCarriers);
1100 setEpicsPV("badAsics", badAsics);
1101 setEpicsPV("badPMTs", badPMTs);
1102 int numBS = 0;
1103 for (auto included : m_includedBoardstacks) if (not included) numBS++;
1104 setEpicsPV("numExcludedBS", numBS);
1106 setEpicsPV("backgroundAlarmLevels", m_averageRate);
1107
1108 B2DEBUG(20, "badBoardstacks: " << badBoardstacks);
1109 B2DEBUG(20, "badCarriers: " << badCarriers);
1110 B2DEBUG(20, "badAsics: " << badAsics);
1111 B2DEBUG(20, "badPMTs: " << badPMTs);
1112 B2DEBUG(20, "excludedBS: " << numBS);
1113 B2DEBUG(20, "histoAlarmState: " << getOffcialAlarmStatus(m_alarmStateOverall));
1114 B2DEBUG(20, "backgroundAlarmLevels" << m_averageRate);
1115}
void setEpicsPV(const std::string &keyname, double value)
Write value to a EPICS PV.
int getOffcialAlarmStatus(unsigned alarmState) const
Converts alarm state to official status (see EStatus of the base class)

◆ setEventProcessed()

static void setEventProcessed ( int e)
inlinestaticinherited

Set the number of processed events.

(Attention, asynch histogram updates!)

e Processed events.

Definition at line 233 of file DQMHistAnalysis.h.

233{s_eventProcessed = e;};

◆ setIncludedBoardstacks()

void setIncludedBoardstacks ( const std::vector< std::string > & excludedBoardstacks)
private

Sets flags for boardstacks to be included in alarming.

Parameters
excludedBoardstackslist of boarstacks to be excluded from alarming

Definition at line 1186 of file DQMHistAnalysisTOP.cc.

1187{
1188 m_includedBoardstacks.clear();
1189 m_includedBoardstacks.resize(64, true);
1190
1191 for (const auto& bsname : excludedBoardstacks) {
1192 int id = m_bsmap[bsname];
1193 if (id > 0) m_includedBoardstacks[id - 1] = false;
1194 else B2ERROR("Invalid boardstack name: " << bsname);
1195 }
1196}

◆ setLogConfig()

void setLogConfig ( const LogConfig & logConfig)
inlineinherited

Set the log system configuration.

Definition at line 229 of file Module.h.

229{m_logConfig = logConfig;}

◆ setLogInfo()

void setLogInfo ( int logLevel,
unsigned int logInfo )
inherited

Configure the printed log information for the given level.

Parameters
logLevelThe log level (one of LogConfig::ELogLevel)
logInfoWhat kind of info should be printed? ORed combination of LogConfig::ELogInfo flags.

Definition at line 73 of file Module.cc.

74{
75 m_logConfig.setLogInfo(static_cast<LogConfig::ELogLevel>(logLevel), logInfo);
76}
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition LogConfig.h:127

◆ setLogLevel()

void setLogLevel ( int logLevel)
inherited

Configure the log level.

Definition at line 55 of file Module.cc.

56{
57 m_logConfig.setLogLevel(static_cast<LogConfig::ELogLevel>(logLevel));
58}
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition LogConfig.cc:25

◆ setMiraBelleVariables()

void setMiraBelleVariables ( const std::string & variableName,
const TH1 * histogram )
private

Sets MiraBelle variables from the histogram with bins corresponding to slot numbers.

Parameters
variableNamevariable name
histogramhistogram with bins corresponding to slot numbers

Definition at line 938 of file DQMHistAnalysisTOP.cc.

939{
940 for (int slot = 1; slot <= 16; slot++) {
941 auto vname = variableName + std::to_string(slot);
942 double value = histogram ? histogram->GetBinContent(slot) : 0;
943 m_mirabelleVariables[vname] = value;
944 }
945}

◆ setName()

void setName ( const std::string & name)
inlineinherited

Set the name of the module.

Note
The module name is set when using the REG_MODULE macro, but the module can be renamed before calling process() using the set_name() function in your steering file.
Parameters
nameThe name of the module

Definition at line 213 of file Module.h.

213{ m_name = name; };

◆ setParamList()

void setParamList ( const ModuleParamList & params)
inlineprotectedinherited

Replace existing parameter list.

Definition at line 500 of file Module.h.

500{ m_moduleParamList = params; }

◆ setParamPython()

void setParamPython ( const std::string & name,
const boost::python::object & pyObj )
privateinherited

Implements a method for setting boost::python objects.

The method supports the following types: list, dict, int, double, string, bool The conversion of the python object to the C++ type and the final storage of the parameter value is done in the ModuleParam class.

Parameters
nameThe unique name of the parameter.
pyObjThe object which should be converted and stored as the parameter value.

Definition at line 234 of file Module.cc.

235{
236 LogSystem& logSystem = LogSystem::Instance();
237 logSystem.updateModule(&(getLogConfig()), getName());
238 try {
240 } catch (std::runtime_error& e) {
241 throw std::runtime_error("Cannot set parameter '" + name + "' for module '"
242 + m_name + "': " + e.what());
243 }
244
245 logSystem.updateModule(nullptr);
246}
void updateModule(const LogConfig *moduleLogConfig=nullptr, const std::string &moduleName="")
Sets the log configuration to the given module log configuration and sets the module name This method...
Definition LogSystem.h:200
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition LogSystem.cc:28
LogConfig & getLogConfig()
Returns the log system configuration.
Definition Module.h:224
std::string m_name
The name of the module, saved as a string (user-modifiable)
Definition Module.h:507
void setParamPython(const std::string &name, const PythonObject &pyObj)
Implements a method for setting boost::python objects.

◆ setParamPythonDict()

void setParamPythonDict ( const boost::python::dict & dictionary)
privateinherited

Implements a method for reading the parameter values from a boost::python dictionary.

The key of the dictionary has to be the name of the parameter and the value has to be of one of the supported parameter types.

Parameters
dictionaryThe python dictionary from which the parameter values are read.

Definition at line 249 of file Module.cc.

250{
251
252 LogSystem& logSystem = LogSystem::Instance();
253 logSystem.updateModule(&(getLogConfig()), getName());
254
255 boost::python::list dictKeys = dictionary.keys();
256 int nKey = boost::python::len(dictKeys);
257
258 //Loop over all keys in the dictionary
259 for (int iKey = 0; iKey < nKey; ++iKey) {
260 boost::python::object currKey = dictKeys[iKey];
261 boost::python::extract<std::string> keyProxy(currKey);
262
263 if (keyProxy.check()) {
264 const boost::python::object& currValue = dictionary[currKey];
265 setParamPython(keyProxy, currValue);
266 } else {
267 B2ERROR("Setting the module parameters from a python dictionary: invalid key in dictionary!");
268 }
269 }
270
271 logSystem.updateModule(nullptr);
272}
void setParamPython(const std::string &name, const boost::python::object &pyObj)
Implements a method for setting boost::python objects.
Definition Module.cc:234

◆ setPropertyFlags()

void setPropertyFlags ( unsigned int propertyFlags)
inherited

Sets the flags for the module properties.

Parameters
propertyFlagsbitwise OR of EModulePropFlags

Definition at line 208 of file Module.cc.

209{
210 m_propertyFlags = propertyFlags;
211}

◆ setPVPrefix()

static void setPVPrefix ( const std::string & prefix)
inlinestaticinherited

set global prefix for EPICS PVs

Parameters
prefixPrefix to set

Definition at line 616 of file DQMHistAnalysis.h.

616{ m_PVPrefix = prefix;};

◆ setReturnValue() [1/2]

void setReturnValue ( bool value)
protectedinherited

Sets the return value for this module as bool.

The bool value is saved as an integer with the convention 1 meaning true and 0 meaning false. The value can be used in the steering file to divide the analysis chain into several paths.

Parameters
valueThe value of the return value.

Definition at line 227 of file Module.cc.

228{
229 m_hasReturnValue = true;
230 m_returnValue = value;
231}

◆ setReturnValue() [2/2]

void setReturnValue ( int value)
protectedinherited

Sets the return value for this module as integer.

The value can be used in the steering file to divide the analysis chain into several paths.

Parameters
valueThe value of the return value.

Definition at line 220 of file Module.cc.

221{
222 m_hasReturnValue = true;
223 m_returnValue = value;
224}

◆ setRunType()

static void setRunType ( const std::string & t)
inlinestaticinherited

Set the Run Type.

t Run type string.

Definition at line 227 of file DQMHistAnalysis.h.

227{s_runType = t;};

◆ setType()

void setType ( const std::string & type)
protectedinherited

Set the module type.

Only for use by internal modules (which don't use the normal REG_MODULE mechanism).

Definition at line 48 of file Module.cc.

49{
50 if (!m_type.empty())
51 B2FATAL("Trying to change module type from " << m_type << " is not allowed, the value is assumed to be fixed.");
52 m_type = type;
53}

◆ setUseEpics()

void setUseEpics ( bool flag)
inlineinherited

Setter for EPICS usage.

Parameters
flagset in use

Definition at line 581 of file DQMHistAnalysis.h.

581{m_useEpics = flag;};

◆ setUseEpicsReadOnly()

static void setUseEpicsReadOnly ( bool flag)
inlinestaticinherited

Setter EPICS flag in read only mode.

Parameters
flagset read only

Definition at line 587 of file DQMHistAnalysis.h.

587{m_epicsReadOnly = flag;};

◆ setZAxisRange()

void setZAxisRange ( const std::string & name,
double scale )
staticprivate

Sets z-axis range of 2D histograms.

Parameters
namethe name of histograms
scalescale factor for the histogram z-axis range (maximum = average * scale)

Definition at line 779 of file DQMHistAnalysisTOP.cc.

780{
781 double totalHits = 0;
782 std::vector<TH2F*> histos;
783 for (int slot = 1; slot <= 16; slot++) {
784 TH2F* h = static_cast<TH2F*>(findHist(name + std::to_string(slot)));
785 if (not h) continue;
786 histos.push_back(h);
787 totalHits += h->Integral();
788 }
789 if (histos.empty()) return;
790 double average = totalHits / 512 / histos.size(); // per pixel or asic channel
791
792 for (auto* h : histos) h->GetZaxis()->SetRangeUser(0, std::max(average * scale, 1.0));
793}

◆ StringSplit()

std::vector< std::string > StringSplit ( const std::string & s,
const char delim )
staticinherited

Helper function for string token split.

Parameters
sString to split
delimdelimiter
Returns
vector of strings

Definition at line 302 of file DQMHistAnalysis.cc.

303{
304 std::vector <std::string> out;
305 boost::split(out, in, [delim](char c) {return c == delim;});
306 return out;
307}

◆ terminate()

void terminate ( void )
finaloverridevirtual

This method is called at the end of the event processing.

Reimplemented from Module.

Definition at line 324 of file DQMHistAnalysisTOP.cc.

325{
326 B2DEBUG(20, "terminate called");
327}

◆ updateBunchOffsetCanvas()

void updateBunchOffsetCanvas ( )
private

Updates canvas of bunch offset w/ alarming.

Definition at line 469 of file DQMHistAnalysisTOP.cc.

470{
471 int alarmState = c_Gray;
472
473 auto* h = static_cast<TH1F*>(findHist("TOP/bunchOffset"));
474 if (h) {
475 double totalEvts = h->GetEntries();
476 if (totalEvts > 100) {
477 double mean = h->GetMean();
478 double rms = h->GetRMS();
479 alarmState = std::max(getAlarmState(fabs(mean), m_offsetMeanAlarmLevels), getAlarmState(rms, m_offsetRmsAlarmLevels));
480 }
481 }
482
483 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
484
485 auto* canvas = findCanvas("TOP/c_bunchOffset");
486 if (canvas) {
487 canvas->cd();
488 canvas->Pad()->SetFrameFillColor(10);
489 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
490 canvas->Modified();
491 }
492}

◆ UpdateCanvas() [1/2]

void UpdateCanvas ( const std::string & name,
bool updated = true )
staticinherited

Mark canvas as updated (or not)

Parameters
namename of Canvas
updatedwas updated

Definition at line 354 of file DQMHistAnalysis.cc.

355{
356 s_canvasUpdatedList[name] = updated;
357}

◆ UpdateCanvas() [2/2]

void UpdateCanvas ( TCanvas * canvas,
bool updated = true )
staticinherited

Mark canvas as updated (or not)

Parameters
canvasCanvas from which to take the name for update
updatedwas updated

Definition at line 359 of file DQMHistAnalysis.cc.

360{
361 if (c) UpdateCanvas(c->GetName(), updated);
362}
static void UpdateCanvas(const std::string &name, bool updated=true)
Mark canvas as updated (or not)

◆ updateEpicsPVs()

int updateEpicsPVs ( float timeout)
inherited

Update all EPICS PV (flush to network)

Parameters
timeoutmaximum time until timeout in s
Returns
status of ca_pend_io

Definition at line 631 of file DQMHistAnalysis.cc.

632{
633 int state = ECA_NORMAL;
634 if (!m_useEpics) return state;
635#ifdef _BELLE2_EPICS
636 if (wait > 0.) {
637 state = ca_pend_io(wait);
638 SEVCHK(state, "ca_pend_io failure");
639 }
640#endif
641 return state;
642}

◆ updateEventMonitorCanvas()

void updateEventMonitorCanvas ( )
private

Updates canvas of event desynchronization monitor w/ alarming.

Definition at line 369 of file DQMHistAnalysisTOP.cc.

370{
371 int alarmState = c_Gray;
372 m_text2->Clear();
373
374 auto* evtMonitor = static_cast<TH1F*>(findHist("TOP/BoolEvtMonitor"));
375 if (evtMonitor) {
376 double totalEvts = evtMonitor->Integral();
377 double badEvts = evtMonitor->GetBinContent(2);
378 if (totalEvts > 0) {
379 double badRatio = badEvts / totalEvts;
380 alarmState = getAlarmState(badRatio, m_eventMonitorAlarmLevels);
381 m_text2->AddText(Form("Fraction: %.4f %%", badRatio * 100.0));
382 }
383 }
384
385 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
386
387 auto* canvas = findCanvas("TOP/c_BoolEvtMonitor");
388 if (canvas) {
389 canvas->cd();
390 m_text2->Draw();
391 canvas->Pad()->SetFrameFillColor(10);
392 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
393 canvas->Modified();
394 }
395}

◆ updateEventT0Canvas()

void updateEventT0Canvas ( )
private

Updates canvas of event T0 w/ alarming.

Definition at line 443 of file DQMHistAnalysisTOP.cc.

444{
445 int alarmState = c_Gray;
446
447 auto* h = static_cast<TH1F*>(findHist("TOP/eventT0"));
448 if (h) {
449 double totalEvts = h->GetEntries();
450 if (totalEvts > 100) {
451 double mean = h->GetMean();
452 double rms = h->GetRMS();
453 alarmState = std::max(getAlarmState(fabs(mean), m_eventT0MeanAlarmLevels), getAlarmState(rms, m_eventT0RmsAlarmLevels));
454 }
455 }
456
457 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
458
459 auto* canvas = findCanvas("TOP/c_eventT0");
460 if (canvas) {
461 canvas->cd();
462 canvas->Pad()->SetFrameFillColor(10);
463 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
464 canvas->Modified();
465 }
466}

◆ updateLimits()

void updateLimits ( )
private

Updates limits defined by module parameters using EpicsPVs.

This includes asicWindowsBand, alarmLevels and excluded boardstacks.

Definition at line 1117 of file DQMHistAnalysisTOP.cc.

1118{
1119 double unused = 0;
1120
1121 double yLo = m_asicWindowsBand[0];
1122 double yHi = m_asicWindowsBand[1];
1123 requestLimitsFromEpicsPVs("asicWindowsBand", yLo, unused, unused, yHi);
1124 m_asicWindowsBand[0] = yLo;
1125 m_asicWindowsBand[1] = yHi;
1126
1127 requestLimitsFromEpicsPVs("asicWindowsAlarmLevels", unused, unused, m_asicWindowsAlarmLevels[0], m_asicWindowsAlarmLevels[1]);
1128 requestLimitsFromEpicsPVs("eventMonitorAlarmLevels", unused, unused, m_eventMonitorAlarmLevels[0], m_eventMonitorAlarmLevels[1]);
1129 requestLimitsFromEpicsPVs("junkHitsAlarmLevels", unused, unused, m_junkHitsAlarmLevels[0], m_junkHitsAlarmLevels[1]);
1130 requestLimitsFromEpicsPVs("deadChannelsAlarmLevels", unused, unused, m_deadChannelsAlarmLevels[0], m_deadChannelsAlarmLevels[1]);
1131 requestLimitsFromEpicsPVs("backgroundAlarmLevels", unused, unused, m_backgroundAlarmLevels[0], m_backgroundAlarmLevels[1]);
1132 requestLimitsFromEpicsPVs("photonYieldsAlarmLevels", m_photonYieldsAlarmLevels[0], m_photonYieldsAlarmLevels[1], unused, unused);
1133
1134 requestLimitsFromEpicsPVs("injectionBGAlarmLevels", unused, unused, m_injectionBGAlarmLevels[0], m_injectionBGAlarmLevels[1]);
1135 requestLimitsFromEpicsPVs("timingAlarmLevels", unused, unused, m_timingAlarmLevels[0], m_timingAlarmLevels[1]);
1136 requestLimitsFromEpicsPVs("eventT0MeanAlarmLevels", unused, unused, m_eventT0MeanAlarmLevels[0], m_eventT0MeanAlarmLevels[1]);
1137 requestLimitsFromEpicsPVs("eventT0RmsAlarmLevels", unused, unused, m_eventT0RmsAlarmLevels[0], m_eventT0RmsAlarmLevels[1]);
1138 requestLimitsFromEpicsPVs("offsetMeanAlarmLevels", unused, unused, m_offsetMeanAlarmLevels[0], m_offsetMeanAlarmLevels[1]);
1139 requestLimitsFromEpicsPVs("offsetRmsAlarmLevels", unused, unused, m_offsetRmsAlarmLevels[0], m_offsetRmsAlarmLevels[1]);
1140
1141 setAlarmLines();
1142
1143 bool status = false;
1144 std::string excludedBS = getEpicsStringPV("excludedBoardstacks", status);
1145
1146 if (status) {
1147 m_excludedBoardstacks.clear();
1148 std::string name;
1149 for (auto c : excludedBS) {
1150 if (isspace(c)) continue;
1151 else if (ispunct(c)) {
1152 if (not name.empty()) {
1153 m_excludedBoardstacks.push_back(name);
1154 name.clear();
1155 }
1156 } else name.push_back(c);
1157 }
1158 if (not name.empty()) {
1159 m_excludedBoardstacks.push_back(name);
1160 }
1162 }
1163
1164 B2DEBUG(20, "asicWindowsBand: [" << m_asicWindowsBand[0] << ", " << m_asicWindowsBand[1] << "]");
1165 B2DEBUG(20, "asicWindowsAlarmLevels: [" << m_asicWindowsAlarmLevels[0] << ", " << m_asicWindowsAlarmLevels[1] << "]");
1166 B2DEBUG(20, "eventMonitorAlarmLevels: [" << m_eventMonitorAlarmLevels[0] << ", " << m_eventMonitorAlarmLevels[1] << "]");
1167 B2DEBUG(20, "junkHitsAlarmLevels: [" << m_junkHitsAlarmLevels[0] << ", " << m_junkHitsAlarmLevels[1] << "]");
1168 B2DEBUG(20, "deadChannelsAlarmLevels: [" << m_deadChannelsAlarmLevels[0] << ", " << m_deadChannelsAlarmLevels[1] << "]");
1169 B2DEBUG(20, "backgroundAlarmLevels: [" << m_backgroundAlarmLevels[0] << ", " << m_backgroundAlarmLevels[1] << "]");
1170 B2DEBUG(20, "photonYieldsAlarmLevels: [" << m_photonYieldsAlarmLevels[0] << ", " << m_photonYieldsAlarmLevels[1] << "]");
1171
1172 B2DEBUG(20, "injectionBGAlarmLevels: [" << m_injectionBGAlarmLevels[0] << ", " << m_injectionBGAlarmLevels[1] << "]");
1173 B2DEBUG(20, "timingAlarmLevels: [" << m_timingAlarmLevels[0] << ", " << m_timingAlarmLevels[1] << "]");
1174 B2DEBUG(20, "eventT0MeanAlarmLevels: [" << m_eventT0MeanAlarmLevels[0] << ", " << m_eventT0MeanAlarmLevels[1] << "]");
1175 B2DEBUG(20, "eventT0RmsAlarmLevels: [" << m_eventT0RmsAlarmLevels[0] << ", " << m_eventT0RmsAlarmLevels[1] << "]");
1176 B2DEBUG(20, "offsetMeanAlarmLevels: [" << m_offsetMeanAlarmLevels[0] << ", " << m_offsetMeanAlarmLevels[1] << "]");
1177 B2DEBUG(20, "offsetRmsAlarmLevels: [" << m_offsetRmsAlarmLevels[0] << ", " << m_offsetRmsAlarmLevels[1] << "]");
1178
1179 std::string ss;
1180 for (const auto& s : m_excludedBoardstacks) ss += "'" + s + "', ";
1181 if (ss.size() > 2) {ss.pop_back(); ss.pop_back();}
1182 B2DEBUG(20, "excludedBoardstacks: [" << ss << "]");
1183
1184}
std::string getEpicsStringPV(const std::string &keyname, bool &status)
Read value from a EPICS PV.

◆ updateNGoodHitsCanvas()

void updateNGoodHitsCanvas ( )
private

Updates canvas of number of good hits per event w/ alarming (injection BG)

Definition at line 398 of file DQMHistAnalysisTOP.cc.

399{
400 int alarmState = c_Gray;
401 m_text4->Clear();
402
403 double fract = 0;
404 double xcut = 0;
405 double ymax = 0;
406 auto* h = static_cast<TH1F*>(findHist("TOP/goodHitsPerEventAll"));
407 if (h) {
408 double totalEvts = h->GetEntries();
409 if (totalEvts > 1000) {
410 // fraction of events with more than xcut hits - these are mostly containing injection BG
411 xcut = h->GetBinCenter(h->GetMaximumBin()) + 900;
412 ymax = h->GetMaximum() / 2;
413 fract = h->Integral(h->FindBin(xcut), h->GetNbinsX() + 1) / totalEvts * 100; // in %
414 alarmState = getAlarmState(fract, m_injectionBGAlarmLevels);
415 m_text4->AddText(Form("Events w/ Injection BG: %.2f %%", fract));
416 }
417 }
418
419 setEpicsPV("injectionBGAlarmLevels", fract);
420 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
421
422 auto* canvas = findCanvas("TOP/c_goodHitsPerEventAll");
423 if (canvas) {
424 canvas->cd();
425 if (not m_injBGCutLine) {
426 m_injBGCutLine = new TLine(xcut, 0, xcut, ymax);
427 m_injBGCutLine->SetLineWidth(2);
428 m_injBGCutLine->SetLineColor(kRed);
429 m_injBGCutLine->Draw("same");
430 } else {
431 m_injBGCutLine->SetX1(xcut);
432 m_injBGCutLine->SetX2(xcut);
433 m_injBGCutLine->SetY2(ymax);
434 }
435 m_text4->Draw();
436 canvas->Pad()->SetFrameFillColor(10);
437 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
438 canvas->Modified();
439 }
440}
TLine * m_injBGCutLine
a line denoting the cut on the number of hits for injection BG counting

◆ updateTimingCanvas()

void updateTimingCanvas ( )
private

Updates canvas of timing plot w/ alarming.

Definition at line 495 of file DQMHistAnalysisTOP.cc.

496{
497 int alarmState = c_Gray;
498
499 auto* h = static_cast<TH1F*>(findHist("TOP/goodHitTimes"));
500 auto* href = static_cast<TH1F*>(findRefHist("TOP/goodHitTimes"));
501 if (h and href) {
502 double n = h->Integral();
503 double nref = href->Integral();
504 if (n > 0 and nref > 0 and sameHistDefinition(h, href)) {
505 auto* h_clone = static_cast<TH1F*>(h->Clone("tmp"));
506 auto* href_clone = static_cast<TH1F*>(href->Clone("tmpref"));
507 h_clone->Scale(1 / n);
508 href_clone->Scale(1 / nref);
509 h_clone->Add(h_clone, href_clone, 1, -1);
510 double sumDiff = 0;
511 double errDiff = 0;
512 for (int i = 1; i <= h_clone->GetNbinsX(); i++) {
513 sumDiff += fabs(h_clone->GetBinContent(i));
514 errDiff += pow(h_clone->GetBinError(i), 2);
515 }
516 errDiff = sqrt(errDiff);
517 if (sumDiff < 5 * errDiff) sumDiff = 0; // difference not significant
518 alarmState = getAlarmState(sumDiff, m_timingAlarmLevels);
519 delete h_clone;
520 delete href_clone;
521 }
522 }
523
524 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
525
526 auto* canvas = findCanvas("TOP/c_goodHitTimes");
527 if (canvas) {
528 canvas->cd();
529 canvas->Pad()->SetFrameFillColor(10);
530 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
531 canvas->Modified();
532 }
533}
static bool sameHistDefinition(TH1 *h1, TH1 *h2)
Checks if histograms are defined in the same way (nbins, xmin, xmax)

◆ updateWindowVsSlotCanvas()

void updateWindowVsSlotCanvas ( )
private

Updates canvas of window_vs_slot w/ alarming.

Definition at line 330 of file DQMHistAnalysisTOP.cc.

331{
332 int alarmState = c_Gray;
333 m_text1->Clear();
334
335 auto* hraw = static_cast<TH2F*>(findHist("TOP/window_vs_slot"));
336 if (hraw) {
337 auto* px = hraw->ProjectionX("tmp_px");
338 auto* band = hraw->ProjectionX("TOP/windowFractions", m_asicWindowsBand[0], m_asicWindowsBand[1]);
339 band->Add(px, band, 1, -1);
340 double total = px->Integral();
341 double totalWindowFraction = (total != 0) ? band->Integral() / total : 0;
342 band->Divide(band, px);
343 setMiraBelleVariables("RateBadRaw_slot", band);
344 m_mirabelleVariables["RateBadRaw_all"] = totalWindowFraction;
345 if (total > 0) {
346 alarmState = getAlarmState(totalWindowFraction, m_asicWindowsAlarmLevels);
347 m_text1->AddText(Form("Fraction outside red lines: %.2f %%", totalWindowFraction * 100.0));
348 }
349 delete px;
350 delete band;
351 }
352
353 m_alarmStateOverall = std::max(m_alarmStateOverall, alarmState);
354
355 auto* canvas = findCanvas("TOP/c_window_vs_slot");
356 if (canvas) {
357 canvas->Clear();
358 canvas->cd();
359 if (hraw) hraw->Draw();
360 m_text1->Draw();
361 for (auto* line : m_asicWindowsBandLines) line->Draw();
362 canvas->Pad()->SetFrameFillColor(10);
363 canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
364 canvas->Modified();
365 }
366}

Member Data Documentation

◆ m_activeFraction

TH1F* m_activeFraction = nullptr
private

fraction of active channels per slot

Definition at line 288 of file DQMHistAnalysisTOP.h.

◆ m_alarmColors

std::vector<int> m_alarmColors = {c_ColorTooFew, c_ColorGood, c_ColorWarning, c_ColorError}
private

alarm colors (see base class)

Definition at line 267 of file DQMHistAnalysisTOP.h.

267{c_ColorTooFew, c_ColorGood, c_ColorWarning, c_ColorError};

◆ m_alarmStateOverall

int m_alarmStateOverall = 0
private

overall alarm state of histograms to be sent by EpicsPV

Definition at line 271 of file DQMHistAnalysisTOP.h.

◆ m_asicWindowsAlarmLevels

std::vector<double> m_asicWindowsAlarmLevels = {0.002, 0.02}
private

alarm levels for fraction of windows outside the band

Definition at line 249 of file DQMHistAnalysisTOP.h.

249{0.002, 0.02};

◆ m_asicWindowsBand

std::vector<int> m_asicWindowsBand = {215, 235}
private

lower and upper bin of a band denoting good windows

Definition at line 248 of file DQMHistAnalysisTOP.h.

248{215, 235};

◆ m_asicWindowsBandLines

std::vector<TLine*> m_asicWindowsBandLines
private

lines denoting a band of good windows

Definition at line 311 of file DQMHistAnalysisTOP.h.

◆ m_averageRate

double m_averageRate = 0
private

average BG rate (to pass to EpicsPV)

Definition at line 272 of file DQMHistAnalysisTOP.h.

◆ m_backgroundAlarmLevels

std::vector<double> m_backgroundAlarmLevels = {5.0, 10.0}
private

alarm levels for background rates [MHz/PMT]

Definition at line 253 of file DQMHistAnalysisTOP.h.

253{5.0, 10.0};

◆ m_backgroundAlarmLines

std::vector<TLine*> m_backgroundAlarmLines
private

lines representing alarm levels

Definition at line 315 of file DQMHistAnalysisTOP.h.

◆ m_backgroundRates

TH1D* m_backgroundRates = nullptr
private

background rates per slot

Definition at line 281 of file DQMHistAnalysisTOP.h.

◆ m_bsmap

std::map<std::string, int> m_bsmap
private

a map of boardstack names to ID's

Definition at line 270 of file DQMHistAnalysisTOP.h.

◆ m_c_backgroundRates

TCanvas* m_c_backgroundRates = nullptr
private

Canvas: background rates per slot.

Definition at line 283 of file DQMHistAnalysisTOP.h.

◆ m_c_deadAndHot

TCanvas* m_c_deadAndHot = nullptr
private

Canvas: fractin of dead and hot channels.

Definition at line 291 of file DQMHistAnalysisTOP.h.

◆ m_c_injBGs

std::map<std::string, TCanvas*> m_c_injBGs
private

Canvases for projections of injection BG histograms.

Definition at line 300 of file DQMHistAnalysisTOP.h.

◆ m_c_injVetoFlagFract

TCanvas* m_c_injVetoFlagFract = nullptr
private

Canvas: fraction of events w/ injection veto flag set vs.

boardstack

Definition at line 307 of file DQMHistAnalysisTOP.h.

◆ m_c_junkFraction

TCanvas* m_c_junkFraction = nullptr
private

Canvas: fraction of junk hits per boardstack.

Definition at line 295 of file DQMHistAnalysisTOP.h.

◆ m_c_photonYields

TCanvas* m_c_photonYields = nullptr
private

Canvas: photon yields per slot.

Definition at line 282 of file DQMHistAnalysisTOP.h.

◆ m_c_pmtHitRates

std::vector<TCanvas*> m_c_pmtHitRates
private

Canvases of PMT hits per event (index = slot - 1)

Definition at line 298 of file DQMHistAnalysisTOP.h.

◆ m_c_skipProcFlagFract

TCanvas* m_c_skipProcFlagFract = nullptr
private

Canvas: fraction of events w/ skip processing flag set vs.

boardstack

Definition at line 306 of file DQMHistAnalysisTOP.h.

◆ m_conditions

std::vector<ModuleCondition> m_conditions
privateinherited

Module condition, only non-null if set.

Definition at line 520 of file Module.h.

◆ m_deadChannelsAlarmLevels

std::vector<double> m_deadChannelsAlarmLevels = {0.1, 0.35}
private

alarm levels for the fraction of dead + hot channels

Definition at line 252 of file DQMHistAnalysisTOP.h.

252{0.1, 0.35};

◆ m_deadChannelsAlarmLines

std::vector<TLine*> m_deadChannelsAlarmLines
private

lines representing alarm levels

Definition at line 314 of file DQMHistAnalysisTOP.h.

◆ m_deadFraction

TH1F* m_deadFraction = nullptr
private

fraction of dead channels per slot (included boardstacks only)

Definition at line 286 of file DQMHistAnalysisTOP.h.

◆ m_description

std::string m_description
privateinherited

The description of the module.

Definition at line 510 of file Module.h.

◆ m_epicsReadOnly

bool m_epicsReadOnly
staticprivateinherited
Initial value:
=
false

Flag if to use EPICS in ReadOnly mode (for reading limits) do not set by yourself, use EpicsEnable module to set.

Definition at line 155 of file DQMHistAnalysis.h.

◆ m_eventMonitorAlarmLevels

std::vector<double> m_eventMonitorAlarmLevels = {1e-4, 2e-3}
private

alarm levels for fraction of desynchronized digits

Definition at line 250 of file DQMHistAnalysisTOP.h.

250{1e-4, 2e-3};

◆ m_eventT0MeanAlarmLevels

std::vector<double> m_eventT0MeanAlarmLevels = {8, 20}
private

alarm levels for mean of event T0 [ns]

Definition at line 260 of file DQMHistAnalysisTOP.h.

260{8, 20};

◆ m_eventT0RmsAlarmLevels

std::vector<double> m_eventT0RmsAlarmLevels = {10, 20}
private

alarm levels for r.m.s.

of event T0 [ ns]

Definition at line 261 of file DQMHistAnalysisTOP.h.

261{10, 20};

◆ m_excludedBoardstacks

std::vector<std::string> m_excludedBoardstacks
private

list of boarstacks to be excluded from alarming

Definition at line 255 of file DQMHistAnalysisTOP.h.

◆ m_excludedBSHisto

TH1F* m_excludedBSHisto = nullptr
private

histogram to show excluded boardstacks on junk fraction plot

Definition at line 294 of file DQMHistAnalysisTOP.h.

◆ m_excludedFraction

TH1F* m_excludedFraction = nullptr
private

fraction of dead and hot channels per slot in excluded boardstacks only

Definition at line 287 of file DQMHistAnalysisTOP.h.

◆ m_hasReturnValue

bool m_hasReturnValue
privateinherited

True, if the return value is set.

Definition at line 517 of file Module.h.

◆ m_hotFraction

TH1F* m_hotFraction = nullptr
private

fraction of hot channels per slot (included boardstacks only)

Definition at line 285 of file DQMHistAnalysisTOP.h.

◆ m_includedBoardstacks

std::vector<bool> m_includedBoardstacks
private

boardstacks included in alarming

Definition at line 269 of file DQMHistAnalysisTOP.h.

◆ m_injBGCutLine

TLine* m_injBGCutLine = nullptr
private

a line denoting the cut on the number of hits for injection BG counting

Definition at line 317 of file DQMHistAnalysisTOP.h.

◆ m_injectionBGAlarmLevels

std::vector<double> m_injectionBGAlarmLevels = {5, 10}
private

alarm levels for injection background (in % of events)

Definition at line 258 of file DQMHistAnalysisTOP.h.

258{5, 10};

◆ m_injVetoFlagFract

TH1D* m_injVetoFlagFract = nullptr
private

fraction of events w/ injection veto flag set vs.

boardstack

Definition at line 305 of file DQMHistAnalysisTOP.h.

◆ m_IsNullRun

bool m_IsNullRun = false
private

Run type flag for null runs.

Definition at line 274 of file DQMHistAnalysisTOP.h.

◆ m_junkFraction

TH1F* m_junkFraction = nullptr
private

fraction of junk hits per boardstack

Definition at line 293 of file DQMHistAnalysisTOP.h.

◆ m_junkHitsAlarmLevels

std::vector<double> m_junkHitsAlarmLevels = {0.05, 0.25}
private

alarm levels for the fraction of junk hits

Definition at line 251 of file DQMHistAnalysisTOP.h.

251{0.05, 0.25};

◆ m_junkHitsAlarmLines

std::vector<TLine*> m_junkHitsAlarmLines
private

lines representing alarm levels

Definition at line 313 of file DQMHistAnalysisTOP.h.

◆ m_legend

TLegend* m_legend = nullptr
private

legend for dead and hot channels

Definition at line 290 of file DQMHistAnalysisTOP.h.

◆ m_logConfig

LogConfig m_logConfig
privateinherited

The log system configuration of the module.

Definition at line 513 of file Module.h.

◆ m_mirabelleVariables

std::map<std::string, double> m_mirabelleVariables
private

variables for MiraBelle

Definition at line 326 of file DQMHistAnalysisTOP.h.

◆ m_moduleParamList

ModuleParamList m_moduleParamList
privateinherited

List storing and managing all parameter of the module.

Definition at line 515 of file Module.h.

◆ m_monObj

MonitoringObject* m_monObj = nullptr
private

MiraBelle monitoring object.

Definition at line 327 of file DQMHistAnalysisTOP.h.

◆ m_name

std::string m_name
privateinherited

The name of the module, saved as a string (user-modifiable)

Definition at line 507 of file Module.h.

◆ m_numEvents

double m_numEvents = 0
private

number of events processed with TOPDQM module

Definition at line 276 of file DQMHistAnalysisTOP.h.

◆ m_officialStates

std::vector<int> m_officialStates = {c_StatusTooFew, c_StatusGood, c_StatusWarning, c_StatusError}
private

official alarm states

Definition at line 268 of file DQMHistAnalysisTOP.h.

268{c_StatusTooFew, c_StatusGood, c_StatusWarning, c_StatusError};

◆ m_offsetMeanAlarmLevels

std::vector<double> m_offsetMeanAlarmLevels = {0.2, 0.5}
private

alarm levels for mean of bunch offset [ns]

Definition at line 262 of file DQMHistAnalysisTOP.h.

262{0.2, 0.5};

◆ m_offsetRmsAlarmLevels

std::vector<double> m_offsetRmsAlarmLevels = {0.25, 0.50}
private

alarm levels for r.m.s.

of bunch offset [ns]

Definition at line 263 of file DQMHistAnalysisTOP.h.

263{0.25, 0.50};

◆ m_package

std::string m_package
privateinherited

Package this module is found in (may be empty).

Definition at line 509 of file Module.h.

◆ m_photonYields

TH1D* m_photonYields = nullptr
private

photon yields per slot

Definition at line 280 of file DQMHistAnalysisTOP.h.

◆ m_photonYieldsAlarmLevels

std::vector<double> m_photonYieldsAlarmLevels = {15.0, 25.0}
private

alarm levels for the number of photons per track

Definition at line 254 of file DQMHistAnalysisTOP.h.

254{15.0, 25.0};

◆ m_photonYieldsAlarmLines

std::vector<TLine*> m_photonYieldsAlarmLines
private

lines representing alarm levels

Definition at line 316 of file DQMHistAnalysisTOP.h.

◆ m_pmtHitRates

std::vector<TH1F*> m_pmtHitRates
private

histograms of PMT hits per event (index = slot - 1)

Definition at line 297 of file DQMHistAnalysisTOP.h.

◆ m_profiles

std::map<std::string, TProfile*> m_profiles
private

profiles of injection BG

Definition at line 301 of file DQMHistAnalysisTOP.h.

◆ m_projections

std::map<std::string, TH1D*> m_projections
private

projections of injection BG

Definition at line 302 of file DQMHistAnalysisTOP.h.

◆ m_propertyFlags

unsigned int m_propertyFlags
privateinherited

The properties of the module as bitwise or (with |) of EModulePropFlags.

Definition at line 511 of file Module.h.

◆ m_PVPrefix

std::string m_PVPrefix = "TEST:"
staticprivateinherited

The Prefix for EPICS PVs.

Definition at line 160 of file DQMHistAnalysis.h.

◆ m_pvPrefix

std::string m_pvPrefix
private

Epics PV prefix.

Definition at line 256 of file DQMHistAnalysisTOP.h.

◆ m_returnValue

int m_returnValue
privateinherited

The return value.

Definition at line 518 of file Module.h.

◆ m_runType

std::string m_runType
private

Run type.

Definition at line 275 of file DQMHistAnalysisTOP.h.

◆ m_skipProcFlagFract

TH1D* m_skipProcFlagFract = nullptr
private

fraction of events w/ skip processing flag set vs.

boardstack

Definition at line 304 of file DQMHistAnalysisTOP.h.

◆ m_stack

THStack* m_stack = nullptr
private

stack for drawing dead, hot and active channel fractions

Definition at line 289 of file DQMHistAnalysisTOP.h.

◆ m_text1

TPaveText* m_text1 = nullptr
private

text to be written to window_vs_slot

Definition at line 319 of file DQMHistAnalysisTOP.h.

◆ m_text2

TPaveText* m_text2 = nullptr
private

text to be written to event desynchonization monitor

Definition at line 320 of file DQMHistAnalysisTOP.h.

◆ m_text3

TPaveText* m_text3 = nullptr
private

text to be written to background rates

Definition at line 321 of file DQMHistAnalysisTOP.h.

◆ m_text4

TPaveText* m_text4 = nullptr
private

text to be written to number of good hits per event

Definition at line 322 of file DQMHistAnalysisTOP.h.

◆ m_timingAlarmLevels

std::vector<double> m_timingAlarmLevels = {0.15, 0.30}
private

alarm levels for time distribution (fraction of area difference)

Definition at line 259 of file DQMHistAnalysisTOP.h.

259{0.15, 0.30};

◆ m_type

std::string m_type
privateinherited

The type of the module, saved as a string.

Definition at line 508 of file Module.h.

◆ m_useEpics

bool m_useEpics = false
staticprivateinherited

Flag if to use EPICS do not set by yourself, use EpicsEnable module to set.

Definition at line 149 of file DQMHistAnalysis.h.

◆ m_verticalLines

std::vector<TLine*> m_verticalLines
private

vertical lines splitting slots

Definition at line 312 of file DQMHistAnalysisTOP.h.

◆ s_canvasUpdatedList

DQMHistAnalysisModule::CanvasUpdatedList s_canvasUpdatedList
staticprivateinherited

The list of canvas updated status.

Definition at line 124 of file DQMHistAnalysis.h.

◆ s_deltaList

DQMHistAnalysisModule::DeltaList s_deltaList
staticinherited

The list of Delta Histograms and settings.

Definition at line 118 of file DQMHistAnalysis.h.

◆ s_eventProcessed

int s_eventProcessed = 0
inlinestaticprivateinherited

Number of Events processed to fill histograms.

Attention: histograms are updates asynchronously Thus the number for a specific histogram may be lower or higher. If you need precise number, you must fill it in the histogram itself (e.g. underflow bin)

Definition at line 138 of file DQMHistAnalysis.h.

◆ s_histList

DQMHistAnalysisModule::HistList s_histList
staticprivateinherited

The list of Histograms.

Definition at line 108 of file DQMHistAnalysis.h.

◆ s_monObjList

DQMHistAnalysisModule::MonObjList s_monObjList
staticprivateinherited

The list of MonitoringObjects.

Definition at line 112 of file DQMHistAnalysis.h.

◆ s_refList

DQMHistAnalysisModule::RefList s_refList
staticprivateinherited

The list of references.

Definition at line 129 of file DQMHistAnalysis.h.

◆ s_runType

std::string s_runType = ""
inlinestaticprivateinherited

The Run type.

Definition at line 143 of file DQMHistAnalysis.h.


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