1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* FastMonitor.h
*
* Created on: Nov 27, 2012
* Author: aspataru
*/
#ifndef FASTMONITOR_H_
#define FASTMONITOR_H_
#include "EventFilter/Utilities/interface/JsonMonitorable.h"
#include "EventFilter/Utilities/interface/DataPointDefinition.h"
#include "EventFilter/Utilities/interface/DataPoint.h"
#include <unordered_set>
namespace jsoncollector {
class FastMonitor {
public:
FastMonitor(std::string const& defPath,
std::string const defGroup,
bool strictChecking,
bool useSource = true,
bool useDefinition = true);
FastMonitor(DataPointDefinition const* dpd, bool strictChecking, bool useSource = true, bool useDefinition = true);
virtual ~FastMonitor();
void addFastPathDefinition(std::string const& defPathFast, std::string const defGroupFast, bool strict);
void setDefPath(std::string const& dpath) {
defPath_ = dpath;
for (auto dp : dataPoints_)
dp->updateDefinition(dpath);
}
void setNStreams(unsigned int nStreams) { nStreams_ = nStreams; }
//register global monitorable
void registerGlobalMonitorable(JsonMonitorable* newMonitorable,
bool NAifZeroUpdates,
unsigned int* nBins = nullptr);
//register fastPath global monitorable
void registerFastGlobalMonitorable(JsonMonitorable* newMonitorable);
//register per-stream monitores vector (unsigned int)
void registerStreamMonitorableUIntVec(std::string const& name,
std::vector<unsigned int>* inputs,
bool NAifZeroUpdates,
unsigned int* nBins = nullptr);
//NOT implemented yet
//void registerStreamMonitorableIntVec(std::string &name, std::vector<unsigned int>,true,0);
//void registerStreamMonitorableDoubleVec(std::string &name, std::vector<unsigned int>,true,0);
//void registerStreamMonitorableStringVec(std::string &name, std::vector<std::string>,true,0);
void registerStreamMonitorableUIntVecAtomic(std::string const& name,
std::vector<AtomicMonUInt*>* inputs,
bool NAifZeroUpdates,
unsigned int* nBins = nullptr);
//take vector used to track stream lumis and finish initialization
void commit(std::vector<unsigned int>* streamLumisPtr);
// fetches new snapshot and outputs one-line CSV if set (timer based)
void snap(unsigned int ls);
//only update global variables (invoked at global EOL)
void snapGlobal(unsigned int ls);
//only updates atomic vectors (for certain stream - at stream EOL)
void snapStreamAtomic(unsigned int ls, unsigned int streamID);
//fastpath CSV string
std::string getCSVString(int sid = -1);
//fastpath file output
void outputCSV(std::string const& path, std::vector<std::string> const& csvString);
//provide merged variable back to user
JsonMonitorable* getMergedIntJForLumi(std::string const& name, unsigned int forLumi);
// merges and outputs everything collected for the given stream to JSON file
bool outputFullJSON(std::string const& path, unsigned int lumi, bool output = true);
//discard what was collected for a lumisection
void discardCollected(unsigned int forLumi);
//this is added to the JSON file
void getHostAndPID(std::string& sHPid);
private:
std::string defPath_;
std::string defPathFast_;
bool strictChecking_;
bool fastPathStrictChecking_;
bool useSource_;
bool useDefinition_;
bool haveFastPath_ = false;
unsigned int nStreams_;
std::string sourceInfo_;
DataPointDefinition const* dpd_;
DataPointDefinition const* dpdFast_;
bool deleteDef_ = false;
bool deleteDefFast_ = false;
std::vector<DataPoint*> dataPoints_;
std::vector<DataPoint*> dataPointsFastOnly_;
std::vector<unsigned int> jsonDpIndex_;
std::vector<DataPoint*> jsonDpIndexFast_;
std::vector<DataPoint*> orphanedDps_;
std::map<std::string, unsigned int> dpNameMap_;
unsigned int recentSnaps_ = 0;
unsigned int recentSnapsTimer_ = 0;
unsigned int regDpCount_ = 0;
unsigned int fregDpCount_ = 0;
std::unordered_set<std::string> uids_;
};
} // namespace jsoncollector
#endif /* FASTMONITOR_H_ */
|