JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwAlarmHandler.h
Go to the documentation of this file.
1/*!
2 * \file QwAlarmHandler.h
3 * \brief Alarm handling data handler for monitoring system alerts
4 * \author wdconinc, cameronc
5 * \date 2010-10-22
6 */
7
8#pragma once
9
10// Parent Class
11#include "VQwDataHandler.h"
12
13/**
14 * \class QwAlarmHandler
15 * \ingroup QwAnalysis
16 * \brief Data handler that evaluates alarm conditions and writes status outputs
17 *
18 * Connects to configured variables and checks them against user-defined alarm
19 * thresholds or patterns. Can periodically write a CSV status file for online
20 * monitoring and provides simple state tracking to avoid flapping.
21 */
22class QwAlarmHandler:public VQwDataHandler, public MQwDataHandlerCloneable<QwAlarmHandler>
23{
24 public:
25 typedef std::vector< VQwHardwareChannel* >::iterator Iterator_HdwChan;
26 typedef std::vector< VQwHardwareChannel* >::const_iterator ConstIterator_HdwChan;
27
28 public:
29 /// \brief Constructor with name
30 QwAlarmHandler(const TString& name);
31
32 /// \brief Copy constructor
33 QwAlarmHandler(const QwAlarmHandler &source);
34 /// Virtual destructor
35 ~QwAlarmHandler() override {};
36
37 /// \brief Load the channels and sensitivities
38 Int_t LoadChannelMap(const std::string& mapfile) override;
39
40 /// \brief Connect to Channels (event only)
41 //Int_t ConnectChannels(QwSubsystemArrayParity& event);
42 /**
43 * \brief Connect to channels across subsystem arrays
44 *
45 * Establish pointers to input variables (yield/asym/diff) and prepare
46 * output channels for alarm evaluation.
47 *
48 * \param yield Subsystem array containing per-MPS yields
49 * \param asym Subsystem array containing asymmetries
50 * \param diff Subsystem array containing differences
51 * \return 0 on success, non-zero on failure
52 */
53 Int_t ConnectChannels(
56 QwSubsystemArrayParity& diff) override;
57
58
59 /**
60 * \brief Process a single event: update alarm states and outputs.
61 *
62 * Checks all configured alarm conditions against current inputs and updates
63 * any associated status channels. May periodically write an overview CSV
64 * if enabled by configuration.
65 */
66 void ProcessData() override;
67 void CheckAlarms();
68 void UpdateAlarmFile();
69 void ParseConfigFile(QwParameterFile&) override;
70
71
72
73 protected:
74
75 /// Default constructor (Protected for child class access)
77
78 std::string fAlarmOutputFile = "adaqfs/home/apar/bin/onlineAlarms.csv"; // The location of outpur file: alarm-output-file=/location/on/disk....
79 UInt_t fCounter = 0;
80 int fAlarmNupdate = 350;
81 int fAlarmActive = 0; // Default to not actually doing the alarm loop unless specified by the user
82 std::pair<std::string,std::string> ParseAlarmMapVariable(const string&, char);
83
84 // List of parameters to use in the alarm handler
85 // Cameron's Alarm Stuff
86 struct alarmObject {
87 // To get contents of map do map.at("key");
88 // To see if contents in map check map.count("key")!=0
89 std::map <std::string,std::string> alarmParameterMapStr;
90 std::map <std::string,double> alarmParameterMap;
92 // List of resultant objects for data handler to update
94 const UInt_t* eventcutErrorFlag;
95 std::string alarmStatus;
96 int Nviolated; // Vector of 0's for history tracking
97 int NsinceLastViolation; // Vector of 0's for history tracking
98 /*
99 std::string type;
100 std::string channel;
101 std::string ana;
102 std::string tree;
103 std::string analysisName;
104 std::string highHigh;
105 std::string high;
106 std::string low;
107 std::string lowLow;
108 std::string ringLength;
109 std::string tolerance; */
110 };
111
112 std::vector<alarmObject> fAlarmObjectList; // Vector pointer of objects
113
114}; // class QwAlarmHandler
115
116inline std::ostream& operator<< (std::ostream& stream, const QwAlarmHandler::EQwHandleType& i) {
117 switch (i){
118 case QwAlarmHandler::kHandleTypeMps: stream << "mps"; break;
119 case QwAlarmHandler::kHandleTypeAsym: stream << "asym"; break;
120 case QwAlarmHandler::kHandleTypeYield: stream << "yield"; break;
121 case QwAlarmHandler::kHandleTypeDiff: stream << "diff"; break;
122 default: stream << "Unknown";
123 }
124 return stream;
125}
std::ostream & operator<<(std::ostream &stream, const QwAlarmHandler::EQwHandleType &i)
Virtual base class for data handlers accessing multiple subsystems.
Configuration file parser with flexible tokenization and search capabilities.
Abstract base for concrete hardware channels implementing dual-operator pattern.
std::string fAlarmOutputFile
~QwAlarmHandler() override
Virtual destructor.
void ParseConfigFile(QwParameterFile &) override
std::vector< alarmObject > fAlarmObjectList
QwAlarmHandler()
Default constructor (Protected for child class access)
QwAlarmHandler(const TString &name)
Constructor with name.
std::pair< std::string, std::string > ParseAlarmMapVariable(const string &, char)
std::vector< VQwHardwareChannel * >::iterator Iterator_HdwChan
void ProcessData() override
Process a single event: update alarm states and outputs.
Int_t ConnectChannels(QwSubsystemArrayParity &yield, QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff) override
Connect to Channels (event only)
std::vector< VQwHardwareChannel * >::const_iterator ConstIterator_HdwChan
const VQwHardwareChannel * value
VQwDataHandler::EQwHandleType analysisType
std::map< std::string, double > alarmParameterMap
std::map< std::string, std::string > alarmParameterMapStr
Subsystem array container specialized for parity analysis with asymmetry calculations.
VQwDataHandler(const TString &name)