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 
45  const edm::InputTag& itag, edm::ConsumesCollector&& coco) :
46  collection(p_config), processor(p_config, itag, coco), processorFract(p_config) {
47  commonConstruct( p_config, p_provider );
48 }
49 
50 #endif
51 
52 void Dispatcher::commonConstruct( Configuration* const p_config, MonitorObjectProvider* p_provider ) {
53 
55  config = p_config;
56  provider = p_provider;
57 
59  config->fnGetCacheEMUHisto = boost::bind(&Cache::getEMU, &cache, _1, _2);
60  config->fnGetCacheFEDHisto = boost::bind(&Cache::getFED, &cache, _1, _2, _3);
61  config->fnGetCacheDDUHisto = boost::bind(&Cache::getDDU, &cache, _1, _2, _3);
62  config->fnGetCacheCSCHisto = boost::bind(&Cache::getCSC, &cache, _1, _2, _3, _4, _5);
63  config->fnGetCacheParHisto = boost::bind(&Cache::getPar, &cache, _1, _2);
64  config->fnPutHisto = boost::bind(&Cache::put, &cache, _1, _2);
65  config->fnNextBookedCSC = boost::bind(&Cache::nextBookedCSC, &cache, _1, _2, _3);
66  config->fnIsBookedCSC = boost::bind(&Cache::isBookedCSC, &cache, _1, _2);
67  config->fnIsBookedDDU = boost::bind(&Cache::isBookedDDU, &cache, _1);
68  config->fnIsBookedFED = boost::bind(&Cache::isBookedFED, &cache, _1);
69 
71  config->fnGetHisto = boost::bind(&Dispatcher::getHisto, this, _1, _2);
72 
74  config->fnGetCSCDetId = boost::bind(&MonitorObjectProvider::getCSCDetId, provider, _1, _2, _3);
75 
77  config->fnBook = boost::bind(&MonitorObjectProvider::bookMonitorObject, provider, _1);
78 
79 }
80 
86  collection.load();
87  // collection.bookEMUHistos();
88  // processor.init();
89 }
90 
92 
94 
95  /*** FOr multi-threading pre-book all FED, DDU, CSC histograms ***/
96  if ( config->getPREBOOK_ALL_HISTOS()) {
97 
99  for (HwId FEDId = 750; FEDId < 758; FEDId++) {
100  if (!cache.isBookedFED(FEDId)) {
101  collection.bookFEDHistos(FEDId);
102  }
103  }
104 
105  if (config->getPROCESS_DDU()) {
107  for (HwId DDUId = 1; DDUId <= 36; DDUId++) {
108  if (!cache.isBookedDDU(DDUId)) {
109  collection.bookDDUHistos(DDUId);
110  }
111  }
112  }
113 
114  if (config->getPROCESS_CSC()) {
116  for (HwId CrateId = 1; CrateId <= 60; CrateId++) {
117  for (HwId DMBId = 1; DMBId <=10; DMBId++) {
118  if (DMBId == 6) continue;
119  if (!cache.isBookedCSC(CrateId, DMBId)) {
120  collection.bookCSCHistos(CrateId, DMBId);
121  }
122  }
123  }
124  }
125 
126  if (config->getPROCESS_EFF_PARAMETERS()) {
129  std::vector<HistoId> parameters;
130  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING01);
131  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING02);
132  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01_RING03);
133  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION01);
134  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02_RING01);
135  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02_RING02);
136  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION02);
137  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03_RING01);
138  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03_RING02);
139  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION03);
140  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04_RING01);
141  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04_RING02);
142  parameters.push_back(h::PAR_CSC_SIDEPLUS_STATION04);
143  parameters.push_back(h::PAR_CSC_SIDEPLUS);
144  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING01);
145  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING02);
146  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01_RING03);
147  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION01);
148  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02_RING01);
149  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02_RING02);
150  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION02);
151  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03_RING01);
152  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03_RING02);
153  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION03);
154  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04_RING01);
155  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04_RING02);
156  parameters.push_back(h::PAR_CSC_SIDEMINUS_STATION04);
157  parameters.push_back(h::PAR_CSC_SIDEMINUS);
158  parameters.push_back(h::PAR_REPORT_SUMMARY);
159 
160 
161  for (size_t i = 0; i < parameters.size(); i++) {
162  ParHistoDef histoD(parameters[i]);
163  auto histodef = HistoDef(parameters[i]);
164  HistoBookRequest req(histodef, config->getFOLDER_PAR(), -1.0f);
166  cache.put(histoD, me);
167  }
168  }
169 
170  }
171 
172  processor.init();
173 
174 }
175 
181 unsigned int Dispatcher::maskHWElements(std::vector<std::string>& tokens) {
182  return processorFract.maskHWElements(tokens);
183 }
184 
191 const bool Dispatcher::getHisto(const HistoDef& histoD, MonitorObject*& me) {
192 
194  if (typeid(histoD) == FEDHistoDefT && !cache.isBookedFED(histoD.getFEDId())) {
196  if (cache.get(histoD, me)) return true;
197  }
198 
200  if (typeid(histoD) == DDUHistoDefT && !cache.isBookedDDU(histoD.getDDUId())) {
202  if (cache.get(histoD, me)) return true;
203  }
204 
206  if (typeid(histoD) == CSCHistoDefT) {
207  if (!cache.isBookedCSC(histoD.getCrateId(), histoD.getDMBId())) {
208  collection.bookCSCHistos(histoD.getCrateId(), histoD.getDMBId());
210  }
211  if (collection.isOnDemand(histoD.getHistoName())) {
212  collection.bookCSCHistos(histoD.getId(), histoD.getCrateId(), histoD.getDMBId(), histoD.getAddId());
213  }
214  if (cache.get(histoD, me)) return true;
215  }
216 
218  if (typeid(histoD) == ParHistoDefT) {
219  HistoBookRequest req(histoD, config->getFOLDER_PAR(), -1.0f);
220  me = provider->bookMonitorObject(req);
221  cache.put(histoD, me);
222  return true;
223  }
224 
226  cache.put(histoD, nullptr);
227 
228  return false;
229 }
230 
236  if ( config->getFRAEFF_AUTO_UPDATE() &&
237  (config->getNEventsCSC() >= config->getFRAEFF_AUTO_UPDATE_START()) &&
238  (config->getNEventsCSC() % config->getFRAEFF_AUTO_UPDATE_FREQ()) == 0) {
240  }
241 }
242 
249  if (config->getFRAEFF_SEPARATE_THREAD()) {
250  boost::function<void ()> fnUpdate = boost::bind(&EventProcessorMutex::updateFractionAndEfficiencyHistos, &processorFract);
251 #ifdef DQMMT
252  threads.create_thread(boost::ref(fnUpdate));
253 #else
254  fnUpdate();
255 #endif
256  } else {
258  }
259 }
260 
267  if (config->getFRAEFF_SEPARATE_THREAD()) {
268  boost::function<void (HWStandbyType&)> fnUpdate = boost::bind(&EventProcessorMutex::processStandby, &processorFract, _1);
269 #ifdef DQMMT
270  threads.create_thread(boost::ref(fnUpdate));
271 #else
272  fnUpdate(standby);
273 #endif
274  } else {
276  }
277 }
278 
279 #ifdef DQMLOCAL
280 
289 void Dispatcher::processEvent(const char* data, const int32_t dataSize, const uint32_t errorStat, const int32_t nodeNumber) {
290  config->eventProcessTimer(true);
291  processor.processEvent(data, dataSize, errorStat, nodeNumber);
292  config->eventProcessTimer(false);
294 }
295 
296 #endif
297 
298 #ifdef DQMGLOBAL
299 
307  config->eventProcessTimer(true);
308 
309  // Consider standby information
310  if (standby.process) {
311 
312  // Set in full standby once at the start. Afterwards - no!
313  // i.e. if we ever in the run have gone off standby - this value is false
314  config->setIN_FULL_STANDBY(config->getIN_FULL_STANDBY() && standby.fullStandby());
315 
316  //std::cout << "standby.MeP = " << standby.MeP << "\n";
317  //std::cout << "standby.MeM = " << standby.MeM << "\n";
318  //std::cout << "standby.fullStandby() = " << standby.fullStandby() << "\n";
319  //std::cout << "config->getIN_FULL_STANDBY = " << config->getIN_FULL_STANDBY() << "\n";
320 
321  processStandby(standby);
322 
323  // We do not fill histograms in full standby!
324  if (standby.fullStandby()) {
325  return;
326  }
327 
328  }
329 
330  processor.processEvent(e, inputTag);
331 
332  config->eventProcessTimer(false);
333 
335 
336 }
337 
338 #endif
339 
340 }
const bool getFED(const HistoId &id, const HwId &fedId, MonitorObject *&mo)
Get FED MO on Histogram Id and FED Id.
Definition: CSCDQM_Cache.cc:71
void init()
Initialize Dispatcher: book histograms, init processor, etc.
unsigned int HwId
static const std::type_info & FEDHistoDefT
const bool isBookedDDU(const HwId &dduId) const
Check if DDU was booked on given identifier.
const HistoName & getHistoName() const
Get raw histogram name.
virtual const HwId getCrateId() const
Get CSC Crate ID.
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:56
void bookEMUHistos() const
Book EMU histograms.
void updateFractionAndEfficiencyHistos()
On demand update fraction and efficiency MOs.
const bool nextBookedCSC(unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
Iterator to get booked CSC identifiers on enumerator.
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
dispatcher processEvent(e, inputTag, standby)
Abstract Base Histogram Definition.
Parameter Histogram Definition.
EventProcessorMutex processorFract
const bool isOnDemand(const HistoName &name) const
Check if the histogram is on demand (by histogram name)
virtual const HwId getDDUId() const
Get DDU ID.
Definition: config.py:1
void init()
Initialize EventProcessor: reading out config information.
void updateFractionAndEfficiencyHistosAuto()
Automatically called fraction and efficiency MOs update function.
void processStandby(HWStandbyType &standby)
Set HW Standby modes.
unsigned int maskHWElements(std::vector< std::string > &tokens)
Mask HW elements from the efficiency calculations. Can be applied on runtime!
virtual MonitorObject * bookMonitorObject(const HistoBookRequest &p_req)=0
Dispatcher(Configuration *const p_config, MonitorObjectProvider *const p_provider)
Constructor.
virtual bool getCSCDetId(const unsigned int crateId, const unsigned int dmbId, CSCDetId &detId) const =0
CSCDQM Framework Global Configuration.
const HistoId getId() const
Get Histogram ID.
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
unsigned int maskHWElements(std::vector< std::string > &tokens)
Mask HW elements from the efficiency calculations. Can be applied on runtime!
static const std::type_info & CSCHistoDefT
void processStandby(HWStandbyType &standby)
Process standby information.
void load()
Load XML file and fill definition map(s)
EventProcessor processor
static const std::type_info & ParHistoDefT
void bookFEDHistos(const HwId fedId) const
Book FED histograms.
virtual const HwId getDMBId() const
Get CSC DMB ID.
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! ...
const bool getDDU(const HistoId &id, const HwId &dduId, MonitorObject *&mo)
Get DDU MO on Histogram Id and DDU Id.
static const std::type_info & DDUHistoDefT
void bookDDUHistos(const HwId dduId) const
Book DDU histograms.
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
void bookCSCHistos(const HwId crateId, const HwId dmbId) const
Book Chamber Histograms.
const bool get(const HistoDef &histo, MonitorObject *&mo)
Get Monitoring Object on Histogram Definition.
Definition: CSCDQM_Cache.cc:29
MonitorObjectProvider * provider
Interface for Histogram providing objects. Used by Event Processor to retrieve MonitorObject &#39;s and b...
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.
void updateFractionAndEfficiencyHistos()
Update Fraction and Efficiency histograms.
virtual const HwId getAddId() const
Get CSC Additional ID (used to store Layer, CLCT, ALCT and other identifiers.
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
virtual const HwId getFEDId() const
Get FED ID.
void commonConstruct(Configuration *const p_config, MonitorObjectProvider *const p_provider)