CMS 3D CMS Logo

CSCDQM_Dispatcher.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Dispatcher.cc
5  *
6  * Description: CSCDQM Dispatcher implementation
7  *
8  * Version: 1.0
9  * Created: 12/01/2008 10:32:38 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #include "CSCDQM_Dispatcher.h"
20 
21 namespace cscdqm {
22 
30  : collection(p_config), processor(p_config), processorFract(p_config) {
31  commonConstruct(p_config, p_provider);
32  }
33 
34 #ifdef DQMGLOBAL
35 
44  Dispatcher::Dispatcher(Configuration* const p_config,
45  MonitorObjectProvider* p_provider,
46  const edm::InputTag& itag,
48  : collection(p_config), processor(p_config, itag, coco), processorFract(p_config) {
49  commonConstruct(p_config, p_provider);
50  }
51 
52 #endif
53 
56  config = p_config;
57  provider = p_provider;
58 
60  config->fnGetCacheEMUHisto = std::bind(&Cache::getEMU, &cache, std::placeholders::_1, std::placeholders::_2);
61  config->fnGetCacheFEDHisto =
62  std::bind(&Cache::getFED, &cache, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
63  config->fnGetCacheDDUHisto =
64  std::bind(&Cache::getDDU, &cache, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
65  config->fnGetCacheCSCHisto = std::bind(&Cache::getCSC,
66  &cache,
67  std::placeholders::_1,
68  std::placeholders::_2,
69  std::placeholders::_3,
70  std::placeholders::_4,
71  std::placeholders::_5);
72  config->fnGetCacheParHisto = std::bind(&Cache::getPar, &cache, std::placeholders::_1, std::placeholders::_2);
73  config->fnPutHisto = std::bind(&Cache::put, &cache, std::placeholders::_1, std::placeholders::_2);
74  config->fnNextBookedCSC =
75  std::bind(&Cache::nextBookedCSC, &cache, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
76  config->fnIsBookedCSC = std::bind(&Cache::isBookedCSC, &cache, std::placeholders::_1, std::placeholders::_2);
77  config->fnIsBookedDDU = std::bind(&Cache::isBookedDDU, &cache, std::placeholders::_1);
78  config->fnIsBookedFED = std::bind(&Cache::isBookedFED, &cache, std::placeholders::_1);
79 
81  config->fnGetHisto = std::bind(&Dispatcher::getHisto, this, std::placeholders::_1, std::placeholders::_2);
82 
84  config->fnGetCSCDetId = std::bind(&MonitorObjectProvider::getCSCDetId,
85  provider,
86  std::placeholders::_1,
87  std::placeholders::_2,
88  std::placeholders::_3);
89 
91  config->fnBook = std::bind(&MonitorObjectProvider::bookMonitorObject, provider, std::placeholders::_1);
92  }
93 
99  collection.load();
100  // collection.bookEMUHistos();
101  // processor.init();
102  }
103 
106 
107  /*** FOr multi-threading pre-book all FED, DDU, CSC histograms ***/
108  if (config->getPREBOOK_ALL_HISTOS()) {
110  for (HwId FEDId = 750; FEDId < 758; FEDId++) {
111  if (!cache.isBookedFED(FEDId)) {
112  collection.bookFEDHistos(FEDId);
113  }
114  }
115 
116  if (config->getPROCESS_DDU()) {
118  for (HwId DDUId = 1; DDUId <= 36; DDUId++) {
119  if (!cache.isBookedDDU(DDUId)) {
120  collection.bookDDUHistos(DDUId);
121  }
122  }
123  }
124 
125  if (config->getPROCESS_CSC()) {
127  for (HwId CrateId = 1; CrateId <= 60; CrateId++) {
128  for (HwId DMBId = 1; DMBId <= 10; DMBId++) {
129  if (DMBId == 6)
130  continue;
131  if (!cache.isBookedCSC(CrateId, DMBId)) {
132  collection.bookCSCHistos(CrateId, DMBId);
133  }
134  }
135  }
136  }
137 
138  if (config->getPROCESS_EFF_PARAMETERS()) {
141  std::vector<HistoId> parameters;
142  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING01);
143  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING02);
144  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING03);
145  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01);
146  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02_RING01);
147  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02_RING02);
148  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02);
149  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03_RING01);
150  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03_RING02);
151  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03);
152  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04_RING01);
153  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04_RING02);
154  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04);
155  parameters.push_back(h::PAR_CSC_SIDEPLUS);
156  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING01);
157  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING02);
158  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING03);
159  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01);
160  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02_RING01);
161  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02_RING02);
162  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02);
163  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03_RING01);
164  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03_RING02);
165  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03);
166  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04_RING01);
167  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04_RING02);
168  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04);
169  parameters.push_back(h::PAR_CSC_SIDEMINUS);
170  parameters.push_back(h::PAR_REPORT_SUMMARY);
171 
172  for (size_t i = 0; i < parameters.size(); i++) {
173  ParHistoDef histoD(parameters[i]);
174  auto histodef = HistoDef(parameters[i]);
175  HistoBookRequest req(histodef, config->getFOLDER_PAR(), -1.0f);
177  cache.put(histoD, me);
178  }
179  }
180  }
181 
182  processor.init();
183  }
184 
190  unsigned int Dispatcher::maskHWElements(std::vector<std::string>& tokens) {
191  return processorFract.maskHWElements(tokens);
192  }
193 
200  const bool Dispatcher::getHisto(const HistoDef& histoD, MonitorObject*& me) {
202  if (typeid(histoD) == FEDHistoDefT && !cache.isBookedFED(histoD.getFEDId())) {
204  if (cache.get(histoD, me))
205  return true;
206  }
207 
209  if (typeid(histoD) == DDUHistoDefT && !cache.isBookedDDU(histoD.getDDUId())) {
211  if (cache.get(histoD, me))
212  return true;
213  }
214 
216  if (typeid(histoD) == CSCHistoDefT) {
217  if (!cache.isBookedCSC(histoD.getCrateId(), histoD.getDMBId())) {
218  collection.bookCSCHistos(histoD.getCrateId(), histoD.getDMBId());
220  }
221  if (collection.isOnDemand(histoD.getHistoName())) {
222  collection.bookCSCHistos(histoD.getId(), histoD.getCrateId(), histoD.getDMBId(), histoD.getAddId());
223  }
224  if (cache.get(histoD, me))
225  return true;
226  }
227 
229  if (typeid(histoD) == ParHistoDefT) {
230  HistoBookRequest req(histoD, config->getFOLDER_PAR(), -1.0f);
231  me = provider->bookMonitorObject(req);
232  cache.put(histoD, me);
233  return true;
234  }
235 
237  cache.put(histoD, nullptr);
238 
239  return false;
240  }
241 
247  if (config->getFRAEFF_AUTO_UPDATE() && (config->getNEventsCSC() >= config->getFRAEFF_AUTO_UPDATE_START()) &&
248  (config->getNEventsCSC() % config->getFRAEFF_AUTO_UPDATE_FREQ()) == 0) {
250  }
251  }
252 
259  if (config->getFRAEFF_SEPARATE_THREAD()) {
260  std::function<void()> fnUpdate =
262 #ifdef DQMMT
263  threads.create_thread(std::ref(fnUpdate));
264 #else
265  fnUpdate();
266 #endif
267  } else {
269  }
270  }
271 
278  if (config->getFRAEFF_SEPARATE_THREAD()) {
279  std::function<void(HWStandbyType&)> fnUpdate =
280  std::bind(&EventProcessorMutex::processStandby, &processorFract, std::placeholders::_1);
281 #ifdef DQMMT
282  threads.create_thread(std::ref(fnUpdate));
283 #else
284  fnUpdate(standby);
285 #endif
286  } else {
288  }
289  }
290 
291 #ifdef DQMLOCAL
292 
301  void Dispatcher::processEvent(const char* data,
302  const int32_t dataSize,
303  const uint32_t errorStat,
304  const int32_t nodeNumber) {
305  config->eventProcessTimer(true);
306  processor.processEvent(data, dataSize, errorStat, nodeNumber);
307  config->eventProcessTimer(false);
309  }
310 
311 #endif
312 
313 #ifdef DQMGLOBAL
314 
321  void Dispatcher::processEvent(const edm::Event& e, const edm::InputTag& inputTag, HWStandbyType& standby) {
322  config->eventProcessTimer(true);
323 
324  // Consider standby information
325  if (standby.process) {
326  // Set in full standby once at the start. Afterwards - no!
327  // i.e. if we ever in the run have gone off standby - this value is false
328  config->setIN_FULL_STANDBY(config->getIN_FULL_STANDBY() && standby.fullStandby());
329 
330  //std::cout << "standby.MeP = " << standby.MeP << "\n";
331  //std::cout << "standby.MeM = " << standby.MeM << "\n";
332  //std::cout << "standby.fullStandby() = " << standby.fullStandby() << "\n";
333  //std::cout << "config->getIN_FULL_STANDBY = " << config->getIN_FULL_STANDBY() << "\n";
334 
335  processStandby(standby);
336 
337  // We do not fill histograms in full standby!
338  if (standby.fullStandby()) {
339  return;
340  }
341  }
342 
343  processor.processEvent(e, inputTag);
344 
345  config->eventProcessTimer(false);
346 
348  }
349 
350 #endif
351 
352 } // namespace cscdqm
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
mps_fire.i
i
Definition: mps_fire.py:428
cscdqm::HistoDef
Abstract Base Histogram Definition.
Definition: CSCDQM_HistoDef.h:62
cscdqm::HWStandbyType
Definition: CSCDQM_EventProcessor.h:59
cscdqm::Dispatcher::cache
Cache cache
Definition: CSCDQM_Dispatcher.h:161
CSCDQM_Dispatcher.h
cscdqm::Cache::getFED
const bool getFED(const HistoId &id, const HwId &fedId, MonitorObject *&mo)
Get FED MO on Histogram Id and FED Id.
Definition: CSCDQM_Cache.cc:66
cscdqm::Collection::bookCSCHistos
void bookCSCHistos(const HwId crateId, const HwId dmbId) const
Book Chamber Histograms.
Definition: CSCDQM_Collection.cc:372
cscdqm::Dispatcher::Dispatcher
Dispatcher(Configuration *const p_config, MonitorObjectProvider *const p_provider)
Constructor.
Definition: CSCDQM_Dispatcher.cc:29
cscdqm::Dispatcher::updateFractionAndEfficiencyHistos
void updateFractionAndEfficiencyHistos()
On demand update fraction and efficiency MOs.
Definition: CSCDQM_Dispatcher.cc:257
cscdqm::Cache::nextBookedCSC
const bool nextBookedCSC(unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
Iterator to get booked CSC identifiers on enumerator.
Definition: CSCDQM_Cache.cc:244
cscdqm::Cache::isBookedDDU
const bool isBookedDDU(const HwId &dduId) const
Check if DDU was booked on given identifier.
Definition: CSCDQM_Cache.cc:322
cscdqm::CSCHistoDefT
static const std::type_info & CSCHistoDefT
Definition: CSCDQM_HistoDef.h:453
cscdqm::ParHistoDef
Parameter Histogram Definition.
Definition: CSCDQM_HistoDef.h:425
cscdqm::Dispatcher::processorFract
EventProcessorMutex processorFract
Definition: CSCDQM_Dispatcher.h:164
cscdqm::HistoDef::getAddId
virtual const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
Definition: CSCDQM_HistoDef.h:196
cscdqm::Cache::isBookedCSC
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
Definition: CSCDQM_Cache.cc:299
config
Definition: config.py:1
cscdqm::EventProcessor::init
void init()
Initialize EventProcessor: reading out config information.
Definition: CSCDQM_EventProcessor.cc:58
cscdqm::Cache::get
const bool get(const HistoDef &histo, MonitorObject *&mo)
Get Monitoring Object on Histogram Definition.
Definition: CSCDQM_Cache.cc:29
cscdqm::HwId
unsigned int HwId
Definition: CSCDQM_HistoDef.h:38
cscdqm::DDUHistoDefT
static const std::type_info & DDUHistoDefT
Definition: CSCDQM_HistoDef.h:452
cscdqm::Dispatcher::updateFractionAndEfficiencyHistosAuto
void updateFractionAndEfficiencyHistosAuto()
Automatically called fraction and efficiency MOs update function.
Definition: CSCDQM_Dispatcher.cc:246
processEvent
dispatcher processEvent(e, inputTag, standby)
cscdqm::HistoDef::getCrateId
virtual const HwId getCrateId() const
Get CSC Crate ID.
Definition: CSCDQM_HistoDef.h:183
cscdqm::EventProcessorMutex::processStandby
void processStandby(HWStandbyType &standby)
Process standby information.
Definition: CSCDQM_Dispatcher.h:95
cscdqm::HistoBookRequest
Definition: CSCDQM_MonitorObjectProvider.h:31
cscdqm::HistoDef::getDDUId
virtual const HwId getDDUId() const
Get DDU ID.
Definition: CSCDQM_HistoDef.h:208
cscdqm::Cache::getPar
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
Definition: CSCDQM_Cache.cc:143
cscdqm::Collection::bookDDUHistos
void bookDDUHistos(const HwId dduId) const
Book DDU histograms.
Definition: CSCDQM_Collection.cc:349
CommonMethods.lock
def lock()
Definition: CommonMethods.py:82
cscdqm
Definition: CSCDQM_DCSBase.h:29
cscdqm::Cache::getDDU
const bool getDDU(const HistoId &id, const HwId &dduId, MonitorObject *&mo)
Get DDU MO on Histogram Id and DDU Id.
Definition: CSCDQM_Cache.cc:92
cscdqm::Dispatcher::maskHWElements
unsigned int maskHWElements(std::vector< std::string > &tokens)
Mask HW elements from the efficiency calculations. Can be applied on runtime!
Definition: CSCDQM_Dispatcher.cc:190
cscdqm::Dispatcher::commonConstruct
void commonConstruct(Configuration *const p_config, MonitorObjectProvider *const p_provider)
Definition: CSCDQM_Dispatcher.cc:54
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
cscdqm::HistoDef::getId
const HistoId getId() const
Get Histogram ID.
Definition: CSCDQM_HistoDef.h:84
cscdqm::Dispatcher::collection
Collection collection
Definition: CSCDQM_Dispatcher.h:155
cscdqm::EventProcessorMutex::maskHWElements
unsigned int maskHWElements(std::vector< std::string > &tokens)
Mask HW elements from the efficiency calculations. Can be applied on runtime!
Definition: CSCDQM_Dispatcher.h:89
cscdqm::Collection::bookFEDHistos
void bookFEDHistos(const HwId fedId) const
Book FED histograms.
Definition: CSCDQM_Collection.cc:327
cscdqm::Collection::load
void load()
Load XML file and fill definition map(s)
Definition: CSCDQM_Collection.cc:37
ecalMultiFitUncalibRecHit_gpu_new_cfi.threads
threads
Definition: ecalMultiFitUncalibRecHit_gpu_new_cfi.py:80
cscdqm::Dispatcher::processor
EventProcessor processor
Definition: CSCDQM_Dispatcher.h:158
cscdqm::ParHistoDefT
static const std::type_info & ParHistoDefT
Definition: CSCDQM_HistoDef.h:454
cscdqm::Dispatcher::processStandby
void processStandby(HWStandbyType &standby)
Set HW Standby modes.
Definition: CSCDQM_Dispatcher.cc:276
cscdqm::FEDHistoDefT
static const std::type_info & FEDHistoDefT
Definition: CSCDQM_HistoDef.h:451
cscdqm::Configuration
CSCDQM Framework Global Configuration.
Definition: CSCDQM_Configuration.h:231
cscdqm::Collection::isOnDemand
const bool isOnDemand(const HistoName &name) const
Check if the histogram is on demand (by histogram name)
Definition: CSCDQM_Collection.cc:625
cscdqm::HistoDef::getHistoName
const HistoName & getHistoName() const
Get raw histogram name.
Definition: CSCDQM_HistoDef.h:90
cscdqm::Dispatcher::provider
MonitorObjectProvider * provider
Definition: CSCDQM_Dispatcher.h:152
cscdqm::Cache::isBookedFED
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
Definition: CSCDQM_Cache.cc:312
cscdqm::LockType
Definition: CSCDQM_Lock.h:31
cscdqm::Cache::put
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
Definition: CSCDQM_Cache.cc:157
cscdqm::Dispatcher::init
void init()
Initialize Dispatcher: book histograms, init processor, etc.
Definition: CSCDQM_Dispatcher.cc:98
cscdqm::Dispatcher::getHisto
const bool getHisto(const HistoDef &histoD, MonitorObject *&me)
Global get MO function. If request has reached this function it means that histo is not in cache!
Definition: CSCDQM_Dispatcher.cc:200
cscdqm::Collection::bookEMUHistos
void bookEMUHistos() const
Book EMU histograms.
Definition: CSCDQM_Collection.cc:305
cscdqm::Cache::getEMU
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:51
HiBiasedCentrality_cfi.function
function
Definition: HiBiasedCentrality_cfi.py:4
cscdqm::MonitorObject
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
Definition: CSCDQM_MonitorObject.h:35
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
funct::void
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
cscdqm::HistoDef::getFEDId
virtual const HwId getFEDId() const
Get FED ID.
Definition: CSCDQM_HistoDef.h:202
cscdqm::Lock::mutex
bool mutex
Definition: CSCDQM_Lock.h:48
cscdqm::MonitorObjectProvider::bookMonitorObject
virtual MonitorObject * bookMonitorObject(const HistoBookRequest &p_req)=0
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
cscdqm::Dispatcher::book
void book()
Definition: CSCDQM_Dispatcher.cc:104
edm::Event
Definition: Event.h:73
cscdqm::EventProcessorMutex::updateFractionAndEfficiencyHistos
void updateFractionAndEfficiencyHistos()
Update Fraction and Efficiency histograms.
Definition: CSCDQM_Dispatcher.h:72
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
cscdqm::HistoDef::getDMBId
virtual const HwId getDMBId() const
Get CSC DMB ID.
Definition: CSCDQM_HistoDef.h:189
cscdqm::Cache::getCSC
const bool getCSC(const HistoId &id, const HwId &crateId, const HwId &dmbId, const HwId &addId, MonitorObject *&mo)
Get CSC MO on Histogram Id and CSC Crate and DMB Ids.
Definition: CSCDQM_Cache.cc:119
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
cscdqm::MonitorObjectProvider
Interface for Histogram providing objects. Used by Event Processor to retrieve MonitorObject 's and b...
Definition: CSCDQM_MonitorObjectProvider.h:124
cscdqm::MonitorObjectProvider::getCSCDetId
virtual bool getCSCDetId(const unsigned int crateId, const unsigned int dmbId, CSCDetId &detId) const =0