File indexing completed on 2024-04-06 12:11:05
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef DATAPOINT_H_
0009 #define DATAPOINT_H_
0010
0011 #include "EventFilter/Utilities/interface/JsonMonitorable.h"
0012 #include "EventFilter/Utilities/interface/JsonSerializable.h"
0013
0014 #include <string>
0015 #include <vector>
0016 #include <memory>
0017 #include <atomic>
0018 #include <cstdint>
0019 #include <cassert>
0020
0021
0022
0023
0024 #define ATOMIC_LEVEL 0
0025
0026 namespace jsoncollector {
0027
0028 #if ATOMIC_LEVEL > 0
0029 typedef std::atomic<unsigned int> AtomicMonUInt;
0030 #else
0031 typedef unsigned int AtomicMonUInt;
0032 #endif
0033
0034 typedef std::map<unsigned int, JsonMonPtr> MonPtrMap;
0035
0036 class DataPoint : public JsonSerializable {
0037 public:
0038 DataPoint() {}
0039
0040 DataPoint(std::string const& source, std::string const& definition, bool fast = false)
0041 : source_(source), definition_(definition), isFastOnly_(fast) {}
0042
0043 ~DataPoint() override;
0044
0045
0046
0047
0048
0049 void serialize(Json::Value& root) const override;
0050
0051
0052
0053
0054 void deserialize(Json::Value& root) override;
0055
0056 std::vector<std::string>& getData() { return data_; }
0057 std::string& getDefinition() { return definition_; }
0058
0059
0060
0061
0062
0063 void serialize(Json::Value& root, bool rootInit, std::string const& input) const;
0064
0065
0066 void snap(unsigned int lumi);
0067 void snapGlobal(unsigned int lumi);
0068 void snapStreamAtomic(unsigned int lumi, unsigned int streamID);
0069
0070
0071 void trackMonitorable(JsonMonitorable const* monitorable, bool NAifZeroUpdates);
0072
0073
0074 void trackVectorUInt(std::string const& name, std::vector<unsigned int> const* monvec, bool NAifZeroUpdates);
0075
0076
0077 void trackVectorUIntAtomic(std::string const& name,
0078 std::vector<AtomicMonUInt*> const* monvec,
0079 bool NAifZeroUpdates);
0080
0081
0082 void trackDummy(std::string const& name, bool setNAifZeroUpdates) {
0083 name_ = name;
0084 isDummy_ = true;
0085 NAifZeroUpdates_ = true;
0086 }
0087
0088 void makeStreamLumiMap(unsigned int size);
0089
0090
0091 void setOperation(OperationType op) { opType_ = op; }
0092
0093
0094 void setStreamLumiPtr(std::vector<unsigned int>* streamLumiPtr) { streamLumisPtr_ = streamLumiPtr; }
0095
0096
0097 std::string fastOutCSV(int sid = -1);
0098
0099
0100 JsonMonitorable* mergeAndRetrieveValue(unsigned int forLumi);
0101
0102
0103 void mergeAndSerialize(Json::Value& jsonRoot, unsigned int lumi, bool initJsonValue, int sid);
0104
0105
0106 void discardCollected(unsigned int forLumi);
0107
0108
0109 void setNBins(unsigned int* nBins) { nBinsPtr_ = nBins; }
0110
0111 std::string const& getName() const { return name_; }
0112
0113 void updateDefinition(std::string const& definition) { definition_ = definition; }
0114
0115
0116 static const std::string SOURCE;
0117 static const std::string DEFINITION;
0118 static const std::string DATA;
0119
0120 protected:
0121
0122 std::string source_;
0123 std::string definition_;
0124 std::vector<std::string> data_;
0125
0126 std::vector<MonPtrMap> streamDataMaps_;
0127 MonPtrMap globalDataMap_;
0128 void const* tracked_ = nullptr;
0129
0130
0131 std::vector<unsigned int>* streamLumisPtr_ = nullptr;
0132
0133 bool isStream_ = false;
0134 bool isAtomic_ = false;
0135 bool isDummy_ = false;
0136 bool NAifZeroUpdates_ = false;
0137 bool isFastOnly_;
0138
0139 MonType monType_;
0140 OperationType opType_;
0141 std::string name_;
0142
0143
0144 uint32_t* buf_ = nullptr;
0145 unsigned int bufLen_ = 0;
0146
0147 unsigned int* nBinsPtr_ = nullptr;
0148 int cacheI_;
0149 bool isCached_ = false;
0150
0151 unsigned int fastIndex_ = 0;
0152 };
0153 }
0154
0155 #endif