CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 
21 namespace cscdqm {
22 
30  collection(p_config), processor(p_config), processorFract(p_config) {
31 
33  config = p_config;
34  provider = p_provider;
35 
37  config->fnGetCacheEMUHisto = boost::bind(&Cache::getEMU, &cache, _1, _2);
38  config->fnGetCacheFEDHisto = boost::bind(&Cache::getFED, &cache, _1, _2, _3);
39  config->fnGetCacheDDUHisto = boost::bind(&Cache::getDDU, &cache, _1, _2, _3);
40  config->fnGetCacheCSCHisto = boost::bind(&Cache::getCSC, &cache, _1, _2, _3, _4, _5);
41  config->fnGetCacheParHisto = boost::bind(&Cache::getPar, &cache, _1, _2);
42  config->fnPutHisto = boost::bind(&Cache::put, &cache, _1, _2);
43  config->fnNextBookedCSC = boost::bind(&Cache::nextBookedCSC, &cache, _1, _2, _3);
44  config->fnIsBookedCSC = boost::bind(&Cache::isBookedCSC, &cache, _1, _2);
45  config->fnIsBookedDDU = boost::bind(&Cache::isBookedDDU, &cache, _1);
46  config->fnIsBookedFED = boost::bind(&Cache::isBookedFED, &cache, _1);
47 
49  config->fnGetHisto = boost::bind(&Dispatcher::getHisto, this, _1, _2);
50 
53 
56 
57  }
58 
64  collection.load();
66  processor.init();
67  }
68 
74  unsigned int Dispatcher::maskHWElements(std::vector<std::string>& tokens) {
75  return processorFract.maskHWElements(tokens);
76  }
77 
84  const bool Dispatcher::getHisto(const HistoDef& histoD, MonitorObject*& me) {
85 
87  if (typeid(histoD) == FEDHistoDefT && !cache.isBookedFED(histoD.getFEDId())) {
89  if (cache.get(histoD, me)) return true;
90  }
91 
93  if (typeid(histoD) == DDUHistoDefT && !cache.isBookedDDU(histoD.getDDUId())) {
95  if (cache.get(histoD, me)) return true;
96  }
97 
99  if (typeid(histoD) == CSCHistoDefT) {
100  if (!cache.isBookedCSC(histoD.getCrateId(), histoD.getDMBId())) {
101  collection.bookCSCHistos(histoD.getCrateId(), histoD.getDMBId());
103  }
104  if (collection.isOnDemand(histoD.getHistoName())) {
105  collection.bookCSCHistos(histoD.getId(), histoD.getCrateId(), histoD.getDMBId(), histoD.getAddId());
106  }
107  if (cache.get(histoD, me)) return true;
108  }
109 
111  if (typeid(histoD) == ParHistoDefT) {
112  HistoBookRequest req(histoD, config->getFOLDER_PAR(), -1.0f);
113  me = provider->bookMonitorObject(req);
114  cache.put(histoD, me);
115  return true;
116  }
117 
119  cache.put(histoD, NULL);
120 
121  return false;
122  }
123 
129  if ( config->getFRAEFF_AUTO_UPDATE() &&
130  (config->getNEventsCSC() >= config->getFRAEFF_AUTO_UPDATE_START()) &&
131  (config->getNEventsCSC() % config->getFRAEFF_AUTO_UPDATE_FREQ()) == 0) {
133  }
134  }
135 
142  if (config->getFRAEFF_SEPARATE_THREAD()) {
143  boost::function<void ()> fnUpdate = boost::bind(&EventProcessorMutex::updateFractionAndEfficiencyHistos, &processorFract);
144 #ifdef DQMMT
145  threads.create_thread(boost::ref(fnUpdate));
146 #else
147  fnUpdate();
148 #endif
149  } else {
151  }
152  }
153 
160  if (config->getFRAEFF_SEPARATE_THREAD()) {
161  boost::function<void (HWStandbyType&)> fnUpdate = boost::bind(&EventProcessorMutex::processStandby, &processorFract, _1);
162 #ifdef DQMMT
163  threads.create_thread(boost::ref(fnUpdate));
164 #else
165  fnUpdate(standby);
166 #endif
167  } else {
169  }
170  }
171 
172 #ifdef DQMLOCAL
173 
182  void Dispatcher::processEvent(const char* data, const int32_t dataSize, const uint32_t errorStat, const int32_t nodeNumber) {
183  config->eventProcessTimer(true);
184  processor.processEvent(data, dataSize, errorStat, nodeNumber);
185  config->eventProcessTimer(false);
187  }
188 
189 #endif
190 
191 #ifdef DQMGLOBAL
192 
199  void Dispatcher::processEvent(const edm::Event& e, const edm::InputTag& inputTag, HWStandbyType& standby) {
200  config->eventProcessTimer(true);
201 
202  // Consider standby information
203  if (standby.process) {
204 
205  // Set in full standby once at the start. Afterwards - no!
206  // i.e. if we ever in the run have gone off standby - this value is false
207  config->setIN_FULL_STANDBY(config->getIN_FULL_STANDBY() && standby.fullStandby());
208 
209  //std::cout << "standby.MeP = " << standby.MeP << "\n";
210  //std::cout << "standby.MeM = " << standby.MeM << "\n";
211  //std::cout << "standby.fullStandby() = " << standby.fullStandby() << "\n";
212  //std::cout << "config->getIN_FULL_STANDBY = " << config->getIN_FULL_STANDBY() << "\n";
213 
214  processStandby(standby);
215 
216  // We do not fill histograms in full standby!
217  if (standby.fullStandby()) {
218  return;
219  }
220 
221  }
222 
223  processor.processEvent(e, inputTag);
224 
225  config->eventProcessTimer(false);
226 
228 
229  }
230 
231 #endif
232 
233 }
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.
boost::function< bool(unsigned int &, unsigned int &) > fnIsBookedCSC
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.
boost::function< bool(const HistoId id, MonitorObject *&mo) > fnGetCacheParHisto
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 ...
Abstract Base Histogram Definition.
void eventProcessTimer(const bool start)
Switch on/off event processing timer.
EventProcessorMutex processorFract
#define NULL
Definition: scimark2.h:8
const bool isOnDemand(const HistoName &name) const
Check if the histogram is on demand (by histogram name)
boost::function< bool(const HistoId id, const HwId &id1, const HwId &id2, const HwId &id3, MonitorObject *&mo) > fnGetCacheCSCHisto
virtual const HwId getDDUId() const
Get DDU ID.
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.
const unsigned long getNEventsCSC() const
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.
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.
boost::function< bool(unsigned int &, unsigned int &, unsigned int &) > fnNextBookedCSC
unsigned int maskHWElements(std::vector< std::string > &tokens)
Mask HW elements from the efficiency calculations. Can be applied on runtime!
boost::function< bool(const HistoDef &histoT, MonitorObject *&) > fnGetHisto
virtual bool getCSCDetId(const unsigned int crateId, const unsigned int dmbId, CSCDetId &detId) const =0
boost::function< bool(const unsigned int, const unsigned int, CSCDetId &) > fnGetCSCDetId
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
boost::function< MonitorObject *(const HistoBookRequest &) > fnBook
Configuration * config
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.
boost::function< bool(unsigned int &) > fnIsBookedDDU
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
boost::function< bool(unsigned int &) > fnIsBookedFED
boost::function< bool(const HistoId id, const HwId &id1, MonitorObject *&mo) > fnGetCacheFEDHisto
boost::function< void(const HistoDef &histoT, MonitorObject *&) > fnPutHisto
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
boost::function< bool(const HistoId id, const HwId &id1, MonitorObject *&mo) > fnGetCacheDDUHisto
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.
boost::function< bool(const HistoId id, MonitorObject *&mo) > fnGetCacheEMUHisto