File indexing completed on 2023-03-17 11:00:26
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef FASTMONITOR_H_
0009 #define FASTMONITOR_H_
0010
0011 #include "EventFilter/Utilities/interface/JsonMonitorable.h"
0012 #include "EventFilter/Utilities/interface/DataPointDefinition.h"
0013 #include "EventFilter/Utilities/interface/DataPoint.h"
0014
0015 #include <unordered_set>
0016
0017 namespace jsoncollector {
0018
0019 class FastMonitor {
0020 public:
0021 FastMonitor(std::string const& defPath,
0022 std::string const defGroup,
0023 bool strictChecking,
0024 bool useSource = true,
0025 bool useDefinition = true);
0026 FastMonitor(DataPointDefinition const* dpd, bool strictChecking, bool useSource = true, bool useDefinition = true);
0027
0028 virtual ~FastMonitor();
0029
0030 void addFastPathDefinition(std::string const& defPathFast, std::string const defGroupFast, bool strict);
0031
0032 void setDefPath(std::string const& dpath) {
0033 defPath_ = dpath;
0034 for (auto dp : dataPoints_)
0035 dp->updateDefinition(dpath);
0036 }
0037
0038 void setNStreams(unsigned int nStreams) { nStreams_ = nStreams; }
0039
0040
0041 void registerGlobalMonitorable(JsonMonitorable* newMonitorable,
0042 bool NAifZeroUpdates,
0043 unsigned int* nBins = nullptr);
0044
0045
0046 void registerFastGlobalMonitorable(JsonMonitorable* newMonitorable);
0047
0048
0049 void registerStreamMonitorableUIntVec(std::string const& name,
0050 std::vector<unsigned int>* inputs,
0051 bool NAifZeroUpdates,
0052 unsigned int* nBins = nullptr);
0053
0054
0055
0056
0057
0058
0059 void registerStreamMonitorableUIntVecAtomic(std::string const& name,
0060 std::vector<AtomicMonUInt*>* inputs,
0061 bool NAifZeroUpdates,
0062 unsigned int* nBins = nullptr);
0063
0064
0065 void commit(std::vector<unsigned int>* streamLumisPtr);
0066
0067
0068 void snap(unsigned int ls);
0069
0070
0071 void snapGlobal(unsigned int ls);
0072
0073
0074 void snapStreamAtomic(unsigned int ls, unsigned int streamID);
0075
0076
0077 std::string getCSVString(int sid = -1);
0078
0079
0080 void outputCSV(std::string const& path, std::string const& csvString);
0081
0082
0083 JsonMonitorable* getMergedIntJForLumi(std::string const& name, unsigned int forLumi);
0084
0085
0086 bool outputFullJSONs(std::string const& pathstem, std::string const& ext, unsigned int lumi, bool output = true);
0087 bool outputFullJSON(std::string const& path, unsigned int lumi, bool output = true);
0088
0089
0090 void discardCollected(unsigned int forLumi);
0091
0092
0093 void getHostAndPID(std::string& sHPid);
0094
0095 private:
0096 std::string defPath_;
0097 std::string defPathFast_;
0098 bool strictChecking_;
0099 bool fastPathStrictChecking_;
0100 bool useSource_;
0101 bool useDefinition_;
0102 bool haveFastPath_ = false;
0103
0104 unsigned int nStreams_;
0105
0106 std::string sourceInfo_;
0107 DataPointDefinition const* dpd_;
0108 DataPointDefinition const* dpdFast_;
0109 bool deleteDef_ = false;
0110 bool deleteDefFast_ = false;
0111
0112 std::vector<DataPoint*> dataPoints_;
0113 std::vector<DataPoint*> dataPointsFastOnly_;
0114 std::vector<unsigned int> jsonDpIndex_;
0115 std::vector<DataPoint*> jsonDpIndexFast_;
0116 std::vector<DataPoint*> orphanedDps_;
0117 std::map<std::string, unsigned int> dpNameMap_;
0118
0119 unsigned int recentSnaps_ = 0;
0120 unsigned int recentSnapsTimer_ = 0;
0121 unsigned int regDpCount_ = 0;
0122 unsigned int fregDpCount_ = 0;
0123
0124 std::unordered_set<std::string> uids_;
0125 };
0126
0127 }
0128
0129 #endif