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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
/*
* =====================================================================================
*
* Filename: CSCDQM_Dispatcher.h
*
* Description: CSCDQM Framework frontend and Histogram Cache controller
*
* Version: 1.0
* Created: 10/03/2008 10:26:04 AM
* Revision: none
* Compiler: gcc
*
* Author: Valdas Rapsevicius, valdas.rapsevicius@cern.ch
* Company: CERN, CH
*
* =====================================================================================
*/
#ifndef CSCDQM_Dispatcher_H
#define CSCDQM_Dispatcher_H
#include <typeinfo>
#ifdef DQMMT
#include <boost/thread.hpp>
#endif
#include "CSCDQM_Configuration.h"
#include "CSCDQM_EventProcessor.h"
#include "CSCDQM_Collection.h"
#include "CSCDQM_HistoDef.h"
#include "CSCDQM_Cache.h"
#include "CSCDQM_Logger.h"
#include "CSCDQM_Lock.h"
namespace cscdqm {
/**
* @class EventProcessorMutex
* @brief Locking object (wrapper) that holds a separate EventProcessor. This
* object can be used (theoretically) in separate thread.
*/
class EventProcessorMutex : public Lock {
private:
/** Local (wrapped) event processor */
EventProcessor processor;
/** Global Configuration */
Configuration* config;
/** If full standby was already processed? */
bool fullStandbyProcessed;
/** Last standby value. To be checked for HV changes */
HWStandbyType lastStandby;
public:
/**
* @brief Constructor.
* @param p_config Pointer to Global Configuration
*/
EventProcessorMutex(Configuration* const p_config) : processor(p_config) {
config = p_config;
fullStandbyProcessed = false;
}
/**
* @brief Update Fraction and Efficiency histograms
* @return
*/
void updateFractionAndEfficiencyHistos() {
LockType lock(mutex);
config->updateFraTimer(true);
processor.updateFractionHistos();
config->updateFraTimer(false);
if (config->getPROCESS_EFF_HISTOS()) {
config->updateEffTimer(true);
processor.updateEfficiencyHistos();
config->updateEffTimer(false);
}
}
/**
* @brief Mask HW elements from the efficiency calculations. Can be applied on runtime!
* @param tokens String tokens of the HW elements
* @return elements masked
*/
unsigned int maskHWElements(std::vector<std::string>& tokens) { return processor.maskHWElements(tokens); }
/**
* @brief Process standby information
* @param standby Standby information
*/
void processStandby(HWStandbyType& standby) {
if (lastStandby != standby) {
processor.standbyEfficiencyHistos(standby);
if (config->getIN_FULL_STANDBY()) {
// Lets mark CSCs as BAD - have not ever ever been in !STANDBY
if (!fullStandbyProcessed) {
processor.standbyEfficiencyHistos(standby);
processor.writeShifterHistograms();
fullStandbyProcessed = true;
}
}
lastStandby = standby;
}
}
};
/**
* @class Dispatcher
* @brief CSCDQM Framework frontend and Histogram Cache controller
*/
class Dispatcher {
public:
Dispatcher(Configuration* const p_config, MonitorObjectProvider* const p_provider);
#ifdef DQMGLOBAL
Dispatcher(Configuration* const p_config,
MonitorObjectProvider* const p_provider,
const edm::InputTag& itag,
edm::ConsumesCollector&& coco);
#endif
/**
* @brief Destructor. Joins and waits to complete all threads.
*/
~Dispatcher() {
#ifdef DQMMT
threads.join_all();
#endif
}
void init();
void book();
void updateFractionAndEfficiencyHistos();
const bool getHisto(const HistoDef& histoD, MonitorObject*& me);
unsigned int maskHWElements(std::vector<std::string>& tokens);
void processStandby(HWStandbyType& standby);
private:
// Old content of ctor into separate function so it can be called by both ctors
void commonConstruct(Configuration* const p_config, MonitorObjectProvider* const p_provider);
void updateFractionAndEfficiencyHistosAuto();
/** Pointer to Global Configuration */
Configuration* config;
/** Pointer to MO provider */
MonitorObjectProvider* provider;
/** MO Collection object */
Collection collection;
/** Event Processor object */
EventProcessor processor;
/** MO Cache object */
Cache cache;
/** Lockable Fractional and Efficiency MO update object */
EventProcessorMutex processorFract;
#ifdef DQMMT
/** Thread group to store all threads created by Dispatcher */
boost::thread_group threads;
#endif
#ifdef DQMLOCAL
public:
void processEvent(const char* data, const int32_t dataSize, const uint32_t errorStat, const int32_t nodeNumber);
#endif
#ifdef DQMGLOBAL
public:
void processEvent(const edm::Event& e, const edm::InputTag& inputTag, HWStandbyType& standby);
#endif
};
} // namespace cscdqm
#endif
|