File indexing completed on 2024-04-06 12:06:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include "CSCDQM_Dispatcher.h"
0020
0021 namespace cscdqm {
0022
0023
0024
0025
0026
0027
0028
0029 Dispatcher::Dispatcher(Configuration* const p_config, MonitorObjectProvider* p_provider)
0030 : collection(p_config), processor(p_config), processorFract(p_config) {
0031 commonConstruct(p_config, p_provider);
0032 }
0033
0034 #ifdef DQMGLOBAL
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 Dispatcher::Dispatcher(Configuration* const p_config,
0045 MonitorObjectProvider* p_provider,
0046 const edm::InputTag& itag,
0047 edm::ConsumesCollector&& coco)
0048 : collection(p_config), processor(p_config, itag, coco), processorFract(p_config) {
0049 commonConstruct(p_config, p_provider);
0050 }
0051
0052 #endif
0053
0054 void Dispatcher::commonConstruct(Configuration* const p_config, MonitorObjectProvider* p_provider) {
0055
0056 config = p_config;
0057 provider = p_provider;
0058
0059
0060 config->fnGetCacheEMUHisto = std::bind(&Cache::getEMU, &cache, std::placeholders::_1, std::placeholders::_2);
0061 config->fnGetCacheFEDHisto =
0062 std::bind(&Cache::getFED, &cache, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
0063 config->fnGetCacheDDUHisto =
0064 std::bind(&Cache::getDDU, &cache, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
0065 config->fnGetCacheCSCHisto = std::bind(&Cache::getCSC,
0066 &cache,
0067 std::placeholders::_1,
0068 std::placeholders::_2,
0069 std::placeholders::_3,
0070 std::placeholders::_4,
0071 std::placeholders::_5);
0072 config->fnGetCacheParHisto = std::bind(&Cache::getPar, &cache, std::placeholders::_1, std::placeholders::_2);
0073 config->fnPutHisto = std::bind(&Cache::put, &cache, std::placeholders::_1, std::placeholders::_2);
0074 config->fnNextBookedCSC =
0075 std::bind(&Cache::nextBookedCSC, &cache, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
0076 config->fnIsBookedCSC = std::bind(&Cache::isBookedCSC, &cache, std::placeholders::_1, std::placeholders::_2);
0077 config->fnIsBookedDDU = std::bind(&Cache::isBookedDDU, &cache, std::placeholders::_1);
0078 config->fnIsBookedFED = std::bind(&Cache::isBookedFED, &cache, std::placeholders::_1);
0079
0080
0081 config->fnGetHisto = std::bind(&Dispatcher::getHisto, this, std::placeholders::_1, std::placeholders::_2);
0082
0083
0084 config->fnGetCSCDetId = std::bind(&MonitorObjectProvider::getCSCDetId,
0085 provider,
0086 std::placeholders::_1,
0087 std::placeholders::_2,
0088 std::placeholders::_3);
0089
0090
0091 config->fnBook = std::bind(&MonitorObjectProvider::bookMonitorObject, provider, std::placeholders::_1);
0092 }
0093
0094
0095
0096
0097
0098 void Dispatcher::init() {
0099 collection.load();
0100
0101
0102 }
0103
0104 void Dispatcher::book() {
0105 collection.bookEMUHistos();
0106
0107
0108 if (config->getPREBOOK_ALL_HISTOS()) {
0109
0110 for (HwId FEDId = 750; FEDId < 758; FEDId++) {
0111 if (!cache.isBookedFED(FEDId)) {
0112 collection.bookFEDHistos(FEDId);
0113 }
0114 }
0115
0116 if (config->getPROCESS_DDU()) {
0117
0118 for (HwId DDUId = 1; DDUId <= 36; DDUId++) {
0119 if (!cache.isBookedDDU(DDUId)) {
0120 collection.bookDDUHistos(DDUId);
0121 }
0122 }
0123 }
0124
0125 if (config->getPROCESS_CSC()) {
0126
0127 for (HwId CrateId = 1; CrateId <= 60; CrateId++) {
0128 for (HwId DMBId = 1; DMBId <= 10; DMBId++) {
0129 if (DMBId == 6)
0130 continue;
0131 if (!cache.isBookedCSC(CrateId, DMBId)) {
0132 collection.bookCSCHistos(CrateId, DMBId);
0133 }
0134 }
0135 }
0136 }
0137
0138 if (config->getPROCESS_EFF_PARAMETERS()) {
0139
0140
0141 std::vector<HistoId> parameters;
0142 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING01);
0143 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING02);
0144 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING03);
0145 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01);
0146 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02_RING01);
0147 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02_RING02);
0148 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02);
0149 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03_RING01);
0150 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03_RING02);
0151 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03);
0152 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04_RING01);
0153 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04_RING02);
0154 parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04);
0155 parameters.push_back(h::PAR_CSC_SIDEPLUS);
0156 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING01);
0157 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING02);
0158 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING03);
0159 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01);
0160 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02_RING01);
0161 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02_RING02);
0162 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02);
0163 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03_RING01);
0164 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03_RING02);
0165 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03);
0166 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04_RING01);
0167 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04_RING02);
0168 parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04);
0169 parameters.push_back(h::PAR_CSC_SIDEMINUS);
0170 parameters.push_back(h::PAR_REPORT_SUMMARY);
0171
0172 for (size_t i = 0; i < parameters.size(); i++) {
0173 ParHistoDef histoD(parameters[i]);
0174 auto histodef = HistoDef(parameters[i]);
0175 HistoBookRequest req(histodef, config->getFOLDER_PAR(), -1.0f);
0176 MonitorObject* me = provider->bookMonitorObject(req);
0177 cache.put(histoD, me);
0178 }
0179 }
0180 }
0181
0182 processor.init();
0183 }
0184
0185
0186
0187
0188
0189
0190 unsigned int Dispatcher::maskHWElements(std::vector<std::string>& tokens) {
0191 return processorFract.maskHWElements(tokens);
0192 }
0193
0194
0195
0196
0197
0198
0199
0200 const bool Dispatcher::getHisto(const HistoDef& histoD, MonitorObject*& me) {
0201
0202 if (typeid(histoD) == FEDHistoDefT && !cache.isBookedFED(histoD.getFEDId())) {
0203 collection.bookFEDHistos(histoD.getFEDId());
0204 if (cache.get(histoD, me))
0205 return true;
0206 }
0207
0208
0209 if (typeid(histoD) == DDUHistoDefT && !cache.isBookedDDU(histoD.getDDUId())) {
0210 collection.bookDDUHistos(histoD.getDDUId());
0211 if (cache.get(histoD, me))
0212 return true;
0213 }
0214
0215
0216 if (typeid(histoD) == CSCHistoDefT) {
0217 if (!cache.isBookedCSC(histoD.getCrateId(), histoD.getDMBId())) {
0218 collection.bookCSCHistos(histoD.getCrateId(), histoD.getDMBId());
0219
0220 }
0221 if (collection.isOnDemand(histoD.getHistoName())) {
0222 collection.bookCSCHistos(histoD.getId(), histoD.getCrateId(), histoD.getDMBId(), histoD.getAddId());
0223 }
0224 if (cache.get(histoD, me))
0225 return true;
0226 }
0227
0228
0229 if (typeid(histoD) == ParHistoDefT) {
0230 HistoBookRequest req(histoD, config->getFOLDER_PAR(), -1.0f);
0231 me = provider->bookMonitorObject(req);
0232 cache.put(histoD, me);
0233 return true;
0234 }
0235
0236
0237 cache.put(histoD, nullptr);
0238
0239 return false;
0240 }
0241
0242
0243
0244
0245
0246 void Dispatcher::updateFractionAndEfficiencyHistosAuto() {
0247 if (config->getFRAEFF_AUTO_UPDATE() && (config->getNEventsCSC() >= config->getFRAEFF_AUTO_UPDATE_START()) &&
0248 (config->getNEventsCSC() % config->getFRAEFF_AUTO_UPDATE_FREQ()) == 0) {
0249 updateFractionAndEfficiencyHistos();
0250 }
0251 }
0252
0253
0254
0255
0256
0257 void Dispatcher::updateFractionAndEfficiencyHistos() {
0258 LockType lock(processorFract.mutex);
0259 if (config->getFRAEFF_SEPARATE_THREAD()) {
0260 std::function<void()> fnUpdate =
0261 std::bind(&EventProcessorMutex::updateFractionAndEfficiencyHistos, &processorFract);
0262 #ifdef DQMMT
0263 threads.create_thread(std::ref(fnUpdate));
0264 #else
0265 fnUpdate();
0266 #endif
0267 } else {
0268 processorFract.updateFractionAndEfficiencyHistos();
0269 }
0270 }
0271
0272
0273
0274
0275
0276 void Dispatcher::processStandby(HWStandbyType& standby) {
0277 LockType lock(processorFract.mutex);
0278 if (config->getFRAEFF_SEPARATE_THREAD()) {
0279 std::function<void(HWStandbyType&)> fnUpdate =
0280 std::bind(&EventProcessorMutex::processStandby, &processorFract, std::placeholders::_1);
0281 #ifdef DQMMT
0282 threads.create_thread(std::ref(fnUpdate));
0283 #else
0284 fnUpdate(standby);
0285 #endif
0286 } else {
0287 processorFract.processStandby(standby);
0288 }
0289 }
0290
0291 #ifdef DQMLOCAL
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301 void Dispatcher::processEvent(const char* data,
0302 const int32_t dataSize,
0303 const uint32_t errorStat,
0304 const int32_t nodeNumber) {
0305 config->eventProcessTimer(true);
0306 processor.processEvent(data, dataSize, errorStat, nodeNumber);
0307 config->eventProcessTimer(false);
0308 updateFractionAndEfficiencyHistosAuto();
0309 }
0310
0311 #endif
0312
0313 #ifdef DQMGLOBAL
0314
0315
0316
0317
0318
0319
0320
0321 void Dispatcher::processEvent(const edm::Event& e, const edm::InputTag& inputTag, HWStandbyType& standby) {
0322 config->eventProcessTimer(true);
0323
0324
0325 if (standby.process) {
0326
0327
0328 config->setIN_FULL_STANDBY(config->getIN_FULL_STANDBY() && standby.fullStandby());
0329
0330
0331
0332
0333
0334
0335 processStandby(standby);
0336
0337
0338 if (standby.fullStandby()) {
0339 return;
0340 }
0341 }
0342
0343 processor.processEvent(e, inputTag);
0344
0345 config->eventProcessTimer(false);
0346
0347 updateFractionAndEfficiencyHistosAuto();
0348 }
0349
0350 #endif
0351
0352 }