CMS 3D CMS Logo

DigiRunSummary.cc
Go to the documentation of this file.
2 
3 namespace hcaldqm {
4  using namespace constants;
5 
7  std::string const& taskname,
8  edm::ParameterSet const& ps,
10  : DQClient(name, taskname, ps, iC), _booked(false) {
11  _thresh_unihf = ps.getUntrackedParameter<double>("thresh_unihf", 0.2);
12 
13  std::vector<uint32_t> vrefDigiSize = ps.getUntrackedParameter<std::vector<uint32_t>>("refDigiSize");
14  _refDigiSize[HcalBarrel] = vrefDigiSize[0];
15  _refDigiSize[HcalEndcap] = vrefDigiSize[1];
16  _refDigiSize[HcalOuter] = vrefDigiSize[2];
17  _refDigiSize[HcalForward] = vrefDigiSize[3];
18  }
19 
20  /* virtual */ void DigiRunSummary::beginRun(edm::Run const& r, edm::EventSetup const& es) {
21  DQClient::beginRun(r, es);
22 
23  if (_ptype != fOffline)
24  return;
25 
26  // INITIALIZE WHAT NEEDS TO BE INITIALIZE ONLY ONCE!
28  _vhashVME.push_back(
32  _vhashVME); // filter out VME
34  _vhashuTCA); // filter out uTCA
42  _vhashFEDHF); // preserve only HF FEDs
43 
48 
49  _xDead.book(_emap);
55  _xNChs.book(_emap);
57 
59  "Occupancy",
64  0);
65 
66  // GET THE NOMINAL NUMBER OF CHANNELS PER FED
67  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
68  for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
69  if (!it->isHcalDetId())
70  continue;
71  HcalDetId did(it->rawId());
74  }
75  }
76 
77  /*
78  * END LUMI. EVALUATE LUMI BASED FLAGS
79  */
82  edm::LuminosityBlock const& lb,
83  edm::EventSetup const& es) {
84  DQClient::endLuminosityBlock(ib, ig, lb, es);
85 
86  if (_ptype != fOffline)
87  return;
88 
89  LSSummary lssum;
90  lssum._LS = _currentLS;
91 
92  _xDigiSize.reset();
93  _xNChs.reset();
94 
95  // INITIALIZE LUMI BASED HISTOGRAMS
96  Container2D cDigiSize_Crate, cOccupancy_depth;
97  cDigiSize_Crate.initialize(_taskname,
98  "DigiSize",
102  0);
103  cOccupancy_depth.initialize(_taskname,
104  "Occupancy",
109  0);
110 
111  // LOAD LUMI BASED HISTOGRAMS
112  cOccupancy_depth.load(ig, _emap, _subsystem);
113  cDigiSize_Crate.load(ig, _emap, _subsystem);
114  MonitorElement* meNumEvents = ig.get(_subsystem + "/RunInfo/NumberOfEvents");
115  int numEvents = meNumEvents->getBinContent(1);
116  bool unknownIdsPresent = ig.get(_subsystem + "/" + _taskname + "/UnknownIds")->getBinContent(1) > 0;
117 
118  // book the Numer of Events - set axis extendable
119  if (!_booked) {
120  ib.setCurrentFolder(_subsystem + "/" + _taskname);
121  _meNumEvents = ib.book1DD("NumberOfEvents", "NumberOfEvents", 1000, 1, 1001); // 1000 to start with
122  _meNumEvents->getTH1()->SetCanExtend(TH1::kXaxis);
123 
125  _booked = true;
126  }
128 
129  // ANALYZE THIS LS for LS BASED FLAGS
130  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
131  for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
132  if (!it->isHcalDetId())
133  continue;
134 
135  HcalDetId did = HcalDetId(it->rawId());
137 
138  cOccupancy_depth.getBinContent(did) > 0 ? _xNChs.get(eid)++ : _xNChs.get(eid) += 0;
139  _cOccupancy_depth.fill(did, cOccupancy_depth.getBinContent(did));
140  // digi size
141  cDigiSize_Crate.getMean(eid) != _refDigiSize[did.subdet()] ? _xDigiSize.get(eid)++ : _xDigiSize.get(eid) += 0;
142  cDigiSize_Crate.getRMS(eid) != 0 ? _xDigiSize.get(eid)++ : _xDigiSize.get(eid) += 0;
143  }
144 
145  // GENERATE SUMMARY AND STORE IT
146  std::vector<flag::Flag> vtmpflags;
147  vtmpflags.resize(nLSFlags);
148  vtmpflags[fDigiSize] = flag::Flag("DigiSize");
149  vtmpflags[fNChsHF] = flag::Flag("NChsHF");
150  vtmpflags[fUnknownIds] = flag::Flag("UnknownIds");
151  vtmpflags[fLED] = flag::Flag("LEDMisfire");
152  for (std::vector<uint32_t>::const_iterator it = _vhashCrates.begin(); it != _vhashCrates.end(); ++it) {
153  HcalElectronicsId eid(*it);
155 
156  // reset all the tmp flags to fNA
157  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
158  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
159  ft->reset();
160 
161  if (_xDigiSize.get(eid) > 0)
162  vtmpflags[fDigiSize]._state = flag::fBAD;
163  else
164  vtmpflags[fDigiSize]._state = flag::fGOOD;
165 
166  if (did.subdet() == HcalForward) {
167  if (_xNChs.get(eid) != _xNChsNominal.get(eid))
168  vtmpflags[fNChsHF]._state = flag::fBAD;
169  else
170  vtmpflags[fNChsHF]._state = flag::fGOOD;
171  } else {
172  vtmpflags[fNChsHF]._state = flag::fNA;
173  }
174  if (unknownIdsPresent)
175  vtmpflags[fUnknownIds]._state = flag::fBAD;
176  else
177  vtmpflags[fUnknownIds]._state = flag::fGOOD;
178 
179  if ((did.subdet() == HcalBarrel) || (did.subdet() == HcalBarrel) || (did.subdet() == HcalBarrel) ||
180  (did.subdet() == HcalBarrel)) {
181  std::string ledHistName = _subsystem + "/" + _taskname + "/LED_CUCountvsLS/Subdet/";
182  if (did.subdet() == HcalBarrel) {
183  ledHistName += "HB";
184  } else if (did.subdet() == HcalEndcap) {
185  ledHistName += "HE";
186  } else if (did.subdet() == HcalOuter) {
187  ledHistName += "HO";
188  } else if (did.subdet() == HcalForward) {
189  ledHistName += "HF";
190  }
191  MonitorElement* ledHist = ig.get(ledHistName);
192  if (ledHist) {
193  bool ledSignalPresent = (ledHist->getEntries() > 0);
194  if (ledSignalPresent)
195  vtmpflags[fLED]._state = flag::fBAD;
196  else
197  vtmpflags[fLED]._state = flag::fGOOD;
198  } else {
199  vtmpflags[fLED]._state = flag::fNA;
200  }
201  } else {
202  vtmpflags[fLED]._state = flag::fNA;
203  }
204 
205  // push all the flags for this crate
206  lssum._vflags.push_back(vtmpflags);
207  }
208 
209  // push all the flags for all FEDs for this LS
210  _vflagsLS.push_back(lssum);
211  cDigiSize_Crate.reset();
212  cOccupancy_depth.reset();
213  }
214 
215  /*
216  * End Job
217  */
218  /* virtual */ std::vector<flag::Flag> DigiRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
219  if (_ptype != fOffline)
220  return std::vector<flag::Flag>();
221 
222  _xDead.reset();
223  _xUniHF.reset();
224  _xUni.reset();
225 
226  // PREPARE LS AND RUN BASED FLAGS TO USE IT FOR BOOKING
227  std::vector<flag::Flag> vflagsPerLS;
228  std::vector<flag::Flag> vflagsPerRun;
229  vflagsPerLS.resize(nLSFlags);
230  vflagsPerRun.resize(nDigiFlag - nLSFlags + 1);
231  vflagsPerLS[fDigiSize] = flag::Flag("DigiSize");
232  vflagsPerLS[fNChsHF] = flag::Flag("NChsHF");
233  vflagsPerLS[fUnknownIds] = flag::Flag("UnknownIds");
234  vflagsPerLS[fLED] = flag::Flag("LEDMisfire");
235  vflagsPerRun[fDigiSize] = flag::Flag("DigiSize");
236  vflagsPerRun[fNChsHF] = flag::Flag("NChsHF");
237  vflagsPerRun[fUniHF - nLSFlags + 1] = flag::Flag("UniSlotHF");
238  vflagsPerRun[fDead - nLSFlags + 1] = flag::Flag("Dead");
239 
240  // INITIALIZE SUMMARY CONTAINERS
241  ContainerSingle2D cSummaryvsLS;
242  Container2D cSummaryvsLS_Crate;
243  cSummaryvsLS.initialize(_name,
244  "SummaryvsLS",
248  0);
249  cSummaryvsLS.book(ib, _subsystem);
250  cSummaryvsLS_Crate.initialize(_name,
251  "SummaryvsLS",
254  new quantity::FlagQuantity(vflagsPerLS),
256  0);
257  cSummaryvsLS_Crate.book(ib, _emap, _subsystem);
258 
259  // INITIALIZE CONTAINERS WE NEED TO LOAD or BOOK
260  Container2D cOccupancyCut_depth;
261  Container2D cDead_depth, cDead_Crate;
262  cOccupancyCut_depth.initialize(_taskname,
263  "OccupancyCut",
268  0);
269  cDead_depth.initialize(_name,
270  "Dead",
275  0);
276  cDead_Crate.initialize(_name,
277  "Dead",
282  0);
283 
284  // LOAD
285  cOccupancyCut_depth.load(ig, _emap, _subsystem);
286  cDead_depth.book(ib, _emap, _subsystem);
287  cDead_Crate.book(ib, _emap, _subsystem);
288 
289  // ANALYZE RUN BASED QUANTITIES
290  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
291  for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
292  if (!it->isHcalDetId())
293  continue;
294 
295  HcalDetId did = HcalDetId(it->rawId());
297 
298  if (_cOccupancy_depth.getBinContent(did) < 1) {
299  _xDead.get(eid)++;
300  cDead_depth.fill(did);
301  cDead_Crate.fill(eid);
302  }
303  if (did.subdet() == HcalForward)
304  _xUniHF.get(eid) += cOccupancyCut_depth.getBinContent(did);
305  }
306  // ANALYZE FOR HF SLOT UNIFORMITY
307  for (uintCompactMap::const_iterator it = _xUniHF.begin(); it != _xUniHF.end(); ++it) {
308  uint32_t hash1 = it->first;
309  HcalElectronicsId eid1(hash1);
310  double x1 = it->second;
311 
312  for (uintCompactMap::const_iterator jt = _xUniHF.begin(); jt != _xUniHF.end(); ++jt) {
313  if (jt == it)
314  continue;
315 
316  double x2 = jt->second;
317  if (x2 == 0)
318  continue;
319  if (x1 / x2 < _thresh_unihf)
320  _xUni.get(eid1)++;
321  }
322  }
323 
324  /*
325  * Iterate over each crate
326  * Iterate over each LS Summary
327  * Iterate over all flags
328  * set...
329  */
330  // iterate over all crates
331  std::vector<flag::Flag> sumflags;
332  int icrate = 0;
333  for (auto& it_crate : _vhashCrates) {
334  flag::Flag fSumRun("DIGI"); // summary flag for this FED
335  flag::Flag ffDead("Dead");
336  flag::Flag ffUniSlotHF("UniSlotHF");
337  HcalElectronicsId eid(it_crate);
339 
340  // ITERATE OVER EACH LS
341  for (std::vector<LSSummary>::const_iterator itls = _vflagsLS.begin(); itls != _vflagsLS.end(); ++itls) {
342  int iflag = 0;
343  flag::Flag fSumLS("DIGI");
344  for (std::vector<flag::Flag>::const_iterator ft = itls->_vflags[icrate].begin();
345  ft != itls->_vflags[icrate].end();
346  ++ft) {
347  cSummaryvsLS_Crate.setBinContent(eid, itls->_LS, int(iflag), ft->_state);
348  fSumLS += (*ft);
349  iflag++;
350  }
351  cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
352  fSumRun += fSumLS;
353  }
354 
355  // EVALUATE RUN BASED FLAGS
356  if (_xDead.get(eid) > 0)
357  ffDead._state = flag::fBAD;
358  else
359  ffDead._state = flag::fGOOD;
360  if (did.subdet() == HcalForward) {
361  if (_xUni.get(eid) > 0)
362  ffUniSlotHF._state = flag::fBAD;
363  else
364  ffUniSlotHF._state = flag::fGOOD;
365  }
366  fSumRun += ffDead + ffUniSlotHF;
367 
368  // push the summary flag for this FED for the Whole Run
369  sumflags.push_back(fSumRun);
370 
371  // increment fed
372  icrate++;
373  }
374 
375  return sumflags;
376  }
377 } // namespace hcaldqm
std::vector< LSSummary > _vflagsLS
MonitorElement * _meNumEvents
ContainerXXX< uint32_t > _xDigiSize
int const CRATE_VME_MIN
Definition: Constants.h:95
ContainerXXX< uint32_t > _xUni
virtual double getRMS(HcalDetId const &, int axix=1)
Definition: Container1D.cc:193
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQClient.cc:24
virtual CompactMap::const_iterator begin()
Definition: ContainerXXX.h:69
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
State _state
Definition: Flag.h:62
std::string _taskname
Definition: DQClient.h:50
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:120
HcalElectronicsMap const * _emap
Definition: DQClient.h:60
virtual void reset()
Definition: ContainerXXX.h:292
filter::HashFilter _filter_FEDHF
int const FIBER_VME_MIN
Definition: Constants.h:125
std::vector< uint32_t > _vhashCrates
Definition: DQClient.h:64
int const FIBERCH_MIN
Definition: Constants.h:134
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
T getUntrackedParameter(std::string const &, T const &) const
std::vector< flag::Flag > endJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual CompactMap::const_iterator end()
Definition: ContainerXXX.h:70
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
ProcessingType _ptype
Definition: DQModule.h:44
virtual void reset()
Definition: Container1D.cc:60
std::vector< uint32_t > _vhashuTCA
filter::HashFilter _filter_uTCA
virtual void setBinContent(int, int, int)
Container2D _cOccupancy_depth
virtual void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQClient.cc:105
int const FIBER_uTCA_MIN1
Definition: Constants.h:128
ContainerXXX< uint32_t > _xNChsNominal
virtual double getEntries() const
get # of entries
void beginRun(edm::Run const &, edm::EventSetup const &) override
void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
std::string _name
Definition: DQModule.h:42
std::vector< uint32_t > _vhashFEDHF
virtual double getMean(HcalDetId const &, int axis=1)
Definition: Container1D.cc:189
int const CRATE_uTCA_MIN
Definition: Constants.h:100
std::map< HcalSubdetector, uint32_t > _refDigiSize
std::vector< uint32_t > _vhashVME
double getBinContent(HcalDetId const &) override
Definition: Container2D.cc:132
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:87
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
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 > _xNChs
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
void setBinContent(HcalDetId const &, int) override
Definition: Container2D.cc:163
virtual TH1 * getTH1() const
virtual STDTYPE & get(HcalDetId const &)
Definition: ContainerXXX.h:197
std::vector< HcalGenericDetId > allPrecisionId() const
electronicsmap::ElectronicsMap _ehashmap
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:49
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:567
filter::HashFilter _filter_VME
Readout chain identification for Hcal.
DigiRunSummary(std::string const &, std::string const &, edm::ParameterSet const &, edm::ConsumesCollector &iC)
ContainerXXX< uint32_t > _xUniHF
int const SLOT_uTCA_MIN
Definition: Constants.h:107
Definition: Run.h:45
ContainerXXX< uint32_t > _xDead
ib
Definition: cuy.py:661
virtual double getBinContent(int binx) const
get content of bin (1-D)