CMS 3D CMS Logo

RawRunSummary.cc
Go to the documentation of this file.
2 
3 namespace hcaldqm {
4  using namespace constants;
6  : DQClient(name, taskname, ps), _booked(false) {}
7 
8  /* virtual */ void RawRunSummary::beginRun(edm::Run const& r, edm::EventSetup const& es) {
9  DQClient::beginRun(r, es);
10 
11  if (_ptype != fOffline)
12  return;
13 
14  // INITIALIZE WHAT NEEDS TO BE INITIALIZE ONLY ONCE!
16  _vhashVME.push_back(
20  _vhashVME); // filter out VME
22  _vhashuTCA); // filter out uTCA
23 
24  // INTIALIZE CONTAINERS ACTING AS HOLDERS OF RUN INFORAMTION
26  "EvnMsm",
31  0);
33  "BcnMsm",
38  0);
40  "EvnMsm",
45  0);
47  "BcnMsm",
52  0);
54  "BadQuality",
59  0);
60 
64  // BOOK CONTAINERSXXX
65  _xEvn.book(_emap);
66  _xBcn.book(_emap);
67  _xBadQ.book(_emap);
68  }
69 
70  /*
71  * END OF LUMINOSITY HARVESTING
72  * RAW FORMAT HAS ONLY LUMI BASED FLAGS!
73  * THEREFORE STEPS ARE:
74  * 1) LOAD CONTAINERS YOU NEED (MUST BE LUMI BASED)
75  * 2) ANALYZE
76  * 3) GENERATE SUMMARY FLAGS AND PUSH THEM
77  */
80  edm::LuminosityBlock const& lb,
81  edm::EventSetup const& es) {
82  DQClient::endLuminosityBlock(ib, ig, lb, es);
83 
84  if (_ptype != fOffline)
85  return;
86 
87  // INITIALIZE WHAT YOU NEED
88  LSSummary lssum; // summary for this LS
89  lssum._LS = _currentLS; // set the LS
90 
91  // RESET CONTAINERS USED FOR ANALYSIS OF THIS LS
92  _xEvn.reset();
93  _xBcn.reset();
94  _xBadQ.reset();
95 
96  // INITIALIZE LUMI BASED HISTOGRAMS
97  Container2D cEvnMsm_ElectronicsVME, cEvnMsm_ElectronicsuTCA;
98  Container2D cBcnMsm_ElectronicsVME, cBcnMsm_ElectronicsuTCA;
99  Container2D cBadQuality_depth;
100  cEvnMsm_ElectronicsVME.initialize(_taskname,
101  "EvnMsm",
106  0);
107  cBcnMsm_ElectronicsVME.initialize(_taskname,
108  "BcnMsm",
113  0);
114  cEvnMsm_ElectronicsuTCA.initialize(_taskname,
115  "EvnMsm",
120  0);
121  cBcnMsm_ElectronicsuTCA.initialize(_taskname,
122  "BcnMsm",
127  0);
128  cBadQuality_depth.initialize(_taskname,
129  "BadQuality",
134  0);
135 
136  // LOAD LUMI BASED HISTOGRAMS
137  cEvnMsm_ElectronicsVME.load(ig, _emap, _filter_uTCA, _subsystem);
138  cBcnMsm_ElectronicsVME.load(ig, _emap, _filter_uTCA, _subsystem);
139  cEvnMsm_ElectronicsuTCA.load(ig, _emap, _filter_VME, _subsystem);
140  cBcnMsm_ElectronicsuTCA.load(ig, _emap, _filter_VME, _subsystem);
141  cBadQuality_depth.load(ig, _emap, _subsystem);
142  MonitorElement* meNumEvents = ig.get(_subsystem + "/RunInfo/NumberOfEvents");
143  int numEvents = meNumEvents->getBinContent(1);
144 
145  // BOOK for the very first time
146  if (!_booked) {
152  _booked = true;
153  }
154 
155  // ANALYZE THIS LS
156  // iterate over all channels
157  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
158  for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
159  if (!it->isHcalDetId())
160  continue;
161  HcalDetId did = HcalDetId(it->rawId());
163 
164  _xBadQ.get(eid) += cBadQuality_depth.getBinContent(did);
165  _cBadQuality_depth.fill(did, cBadQuality_depth.getBinContent(did));
166  if (eid.isVMEid()) {
167  _xEvn.get(eid) += cEvnMsm_ElectronicsVME.getBinContent(eid);
168  _xBcn.get(eid) += cBcnMsm_ElectronicsVME.getBinContent(eid);
169 
170  _cEvnMsm_ElectronicsVME.fill(eid, cEvnMsm_ElectronicsVME.getBinContent(eid));
171  _cBcnMsm_ElectronicsVME.fill(eid, cBcnMsm_ElectronicsVME.getBinContent(eid));
172  } else {
173  _xEvn.get(eid) += cEvnMsm_ElectronicsuTCA.getBinContent(eid);
174  _xBcn.get(eid) += cBcnMsm_ElectronicsuTCA.getBinContent(eid);
175 
176  _cEvnMsm_ElectronicsuTCA.fill(eid, cEvnMsm_ElectronicsuTCA.getBinContent(eid));
177  _cBcnMsm_ElectronicsuTCA.fill(eid, cBcnMsm_ElectronicsuTCA.getBinContent(eid));
178  }
179  }
180 
181  // GENERATE THE SUMMARY FOR THIS LS AND STORE IT
182  std::vector<flag::Flag> vtmpflags; // tmp summary flags vector
183  vtmpflags.resize(nRawFlag);
184  vtmpflags[fEvnMsm] = flag::Flag("EvnMsm");
185  vtmpflags[fBcnMsm] = flag::Flag("BcnMsm");
186  vtmpflags[fBadQ] = flag::Flag("BadQ");
187  for (std::vector<uint32_t>::const_iterator it = _vhashFEDs.begin(); it != _vhashFEDs.end(); ++it) {
188  HcalElectronicsId eid(*it);
189 
190  // reset all the tmp flags to fNA
191  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
192  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
193  ft->reset();
194 
195  // check if this FED was @cDAQ
196  std::vector<uint32_t>::const_iterator cit = std::find(_vcdaqEids.begin(), _vcdaqEids.end(), *it);
197  if (cit == _vcdaqEids.end()) {
198  // was not @cDAQ, set all the flags for this FED as fNCDAQ
199  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
200  ft->_state = flag::fNCDAQ;
201 
202  // push all the flags for this FED
203  // IMPORTANT!!!
204  lssum._vflags.push_back(vtmpflags);
205  continue;
206  }
207 
208  // here only if was registered at cDAQ
210  if (_xEvn.get(eid) > 0)
211  vtmpflags[fEvnMsm]._state = flag::fBAD;
212  else
213  vtmpflags[fEvnMsm]._state = flag::fGOOD;
214  if (_xBcn.get(eid) > 0)
215  vtmpflags[fBcnMsm]._state = flag::fBAD;
216  else
217  vtmpflags[fBcnMsm]._state = flag::fGOOD;
218  if (double(_xBadQ.get(eid)) > double(12 * numEvents))
219  vtmpflags[fBadQ]._state = flag::fBAD;
220  else if (_xBadQ.get(eid) > 0)
221  vtmpflags[fBadQ]._state = flag::fPROBLEMATIC;
222  else
223  vtmpflags[fBadQ]._state = flag::fGOOD;
224  }
225 
226  // push all the flags for this FED
227  lssum._vflags.push_back(vtmpflags);
228  }
229 
230  // push all flags for all FEDs for this LS
231  _vflagsLS.push_back(lssum);
232  }
233 
234  /*
235  * END JOB
236  * BOOK THE SUMMARY CONTAINERS, SET THE FLAGS
237  * RETURN THE LIST OF FLAGS FOR THIS DATATIER
238  */
239  /* virtual */ std::vector<flag::Flag> RawRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
240  if (_ptype != fOffline)
241  return std::vector<flag::Flag>();
242 
243  // PREPARE LS BASED FLAGS to use it for booking
244  std::vector<flag::Flag> vflagsLS;
245  vflagsLS.resize(nRawFlag);
246  vflagsLS[fEvnMsm] = flag::Flag("EvnMsm");
247  vflagsLS[fBcnMsm] = flag::Flag("BcnMsm");
248  vflagsLS[fBadQ] = flag::Flag("BadQ");
249 
250  // INITIALIZE AND BOOK SUMMARY CONTAINERS
251  ContainerSingle2D cSummaryvsLS; // summary per FED: flag vs LS
252  Container2D cSummaryvsLS_FED; // LS based flags vs LS for each FED
253  cSummaryvsLS.initialize(_name,
254  "SummaryvsLS",
258  0);
259  cSummaryvsLS_FED.initialize(_name,
260  "SummaryvsLS",
263  new quantity::FlagQuantity(vflagsLS),
265  0);
266  cSummaryvsLS_FED.book(ib, _emap, _subsystem);
267  cSummaryvsLS.book(ib, _subsystem);
268 
269  /*
270  * Iterate over each FED
271  * Iterate over each LS SUmmary
272  * Iterate over all flags
273  * set...
274  */
275 
276  std::vector<flag::Flag> sumflags; // flag per FED
277  int ifed = 0;
278  for (std::vector<uint32_t>::const_iterator it = _vhashFEDs.begin(); it != _vhashFEDs.end(); ++it) {
279  flag::Flag fSumRun("RAW"); // summary flag for this FED
280  HcalElectronicsId eid(*it);
281 
282  // ITERATE OVER EACH LS
283  for (std::vector<LSSummary>::const_iterator itls = _vflagsLS.begin(); itls != _vflagsLS.end(); ++itls) {
284  // fill histograms per LS
285  int iflag = 0;
286  flag::Flag fSumLS("RAW");
287  for (std::vector<flag::Flag>::const_iterator ft = itls->_vflags[ifed].begin(); ft != itls->_vflags[ifed].end();
288  ++ft) {
289  // Flag vs LS per FEd
290  cSummaryvsLS_FED.setBinContent(eid, itls->_LS, int(iflag), ft->_state);
291  fSumLS += (*ft);
292  iflag++;
293  }
294  // FED vs LS
295  cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
296  fSumRun += fSumLS;
297  }
298 
299  // push the summary flag for this FED for the whole RUN
300  sumflags.push_back(fSumRun);
301 
302  // increment the fed counter
303  ifed++;
304  }
305 
306  return sumflags;
307  }
308 } // namespace hcaldqm
std::vector< uint32_t > _vcdaqEids
Definition: DQClient.h:67
Container2D _cEvnMsm_ElectronicsVME
Definition: RawRunSummary.h:32
int const CRATE_VME_MIN
Definition: Constants.h:91
filter::HashFilter _filter_VME
Definition: RawRunSummary.h:29
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
std::vector< uint32_t > _vhashFEDs
Definition: DQClient.h:61
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQClient.cc:13
State _state
Definition: Flag.h:62
Container2D _cBadQuality_depth
Definition: RawRunSummary.h:34
std::string _taskname
Definition: DQClient.h:46
ContainerXXX< uint32_t > _xBadQ
Definition: RawRunSummary.h:39
Container2D _cEvnMsm_ElectronicsuTCA
Definition: RawRunSummary.h:32
virtual void initialize(std::string const &folder, quantity::Quantity *, quantity::Quantity *, quantity::Quantity *qz=new quantity::ValueQuantity(quantity::fN), int debug=0)
int const SPIGOT_MIN
Definition: Constants.h:116
Container2D _cBcnMsm_ElectronicsuTCA
Definition: RawRunSummary.h:33
HcalElectronicsMap const * _emap
Definition: DQClient.h:53
virtual void reset()
Definition: ContainerXXX.h:292
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int const FIBER_VME_MIN
Definition: Constants.h:121
std::vector< int > _vFEDsuTCA
Definition: RawRunSummary.h:28
int const FIBERCH_MIN
Definition: Constants.h:130
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: RawRunSummary.cc:8
ProcessingType _ptype
Definition: DQModule.h:43
virtual void setBinContent(int, int, int)
virtual void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQClient.cc:98
electronicsmap::ElectronicsMap _ehashmap
Definition: RawRunSummary.h:24
int const FIBER_uTCA_MIN1
Definition: Constants.h:124
std::vector< HcalGenericDetId > allPrecisionId() const
filter::HashFilter _filter_uTCA
Definition: RawRunSummary.h:29
RawRunSummary(std::string const &, std::string const &, edm::ParameterSet const &)
Definition: RawRunSummary.cc:5
ContainerXXX< uint32_t > _xEvn
Definition: RawRunSummary.h:39
std::string _name
Definition: DQModule.h:41
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
int const CRATE_uTCA_MIN
Definition: Constants.h:96
std::vector< uint32_t > _vhashuTCA
Definition: RawRunSummary.h:27
Container2D _cBcnMsm_ElectronicsVME
Definition: RawRunSummary.h:33
double getBinContent(HcalDetId const &) override
Definition: Container2D.cc:132
bool isFEDHBHE(HcalElectronicsId const &)
Definition: Utilities.cc:142
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:87
std::vector< int > _vFEDs
Definition: DQClient.h:60
virtual void initialize(std::string const &folder, hashfunctions::HashType, quantity::Quantity *, quantity::Quantity *, quantity::Quantity *qz=new quantity::ValueQuantity(quantity::fN), int debug=0)
Definition: Container2D.cc:25
ContainerXXX< uint32_t > _xBcn
Definition: RawRunSummary.h:39
std::vector< flag::Flag > endJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setBinContent(HcalDetId const &, int) override
Definition: Container2D.cc:163
double getBinContent(int binx) const
get content of bin (1-D)
virtual STDTYPE & get(HcalDetId const &)
Definition: ContainerXXX.h:197
void fill(HcalDetId const &) override
Definition: Container2D.cc:52
virtual void initialize(FilterType ftype, hashfunctions::HashType htype, std::vector< uint32_t > const &)
Definition: HashFilter.cc:17
std::string _subsystem
Definition: DQModule.h:48
bool isFEDHO(HcalElectronicsId const &)
Definition: Utilities.cc:180
std::vector< LSSummary > _vflagsLS
Definition: RawRunSummary.h:22
virtual void load(DQMStore::IGetter &, HcalElectronicsMap const *, std::string const &subsystem="Hcal", std::string const &aux="")
Definition: Container1D.cc:450
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:81
void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="") override
Definition: Container2D.cc:558
std::vector< int > _vFEDsVME
Definition: RawRunSummary.h:28
std::vector< uint32_t > _vhashVME
Definition: RawRunSummary.h:27
Readout chain identification for Hcal.
bool isFEDHF(HcalElectronicsId const &)
Definition: Utilities.cc:156
int const SLOT_uTCA_MIN
Definition: Constants.h:103
Definition: Run.h:45
void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
ib
Definition: cuy.py:662