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) {
154 
155  // skip monitoring for ZDC crate for now (Oct. 1 2023), the Hcal DQM group need to discuss with the ZDC group on the monitoring flags settings.
156  if (HcalGenericDetId(_emap->lookup(eid)).isHcalZDCDetId()) {
157  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
158  ft->reset();
159  lssum._vflags.push_back(vtmpflags);
160  continue;
161  }
162 
164 
165  // reset all the tmp flags to fNA
166  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
167  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
168  ft->reset();
169 
170  if (_xDigiSize.get(eid) > 0)
171  vtmpflags[fDigiSize]._state = flag::fBAD;
172  else
173  vtmpflags[fDigiSize]._state = flag::fGOOD;
174 
175  if (did.subdet() == HcalForward) {
176  if (_xNChs.get(eid) != _xNChsNominal.get(eid))
177  vtmpflags[fNChsHF]._state = flag::fBAD;
178  else
179  vtmpflags[fNChsHF]._state = flag::fGOOD;
180  } else {
181  vtmpflags[fNChsHF]._state = flag::fNA;
182  }
183  if (unknownIdsPresent)
184  vtmpflags[fUnknownIds]._state = flag::fBAD;
185  else
186  vtmpflags[fUnknownIds]._state = flag::fGOOD;
187 
188  if ((did.subdet() == HcalBarrel) || (did.subdet() == HcalBarrel) || (did.subdet() == HcalBarrel) ||
189  (did.subdet() == HcalBarrel)) {
190  std::string ledHistName = _subsystem + "/" + _taskname + "/LED_CUCountvsLS/Subdet/";
191  if (did.subdet() == HcalBarrel) {
192  ledHistName += "HB";
193  } else if (did.subdet() == HcalEndcap) {
194  ledHistName += "HE";
195  } else if (did.subdet() == HcalOuter) {
196  ledHistName += "HO";
197  } else if (did.subdet() == HcalForward) {
198  ledHistName += "HF";
199  }
200  MonitorElement* ledHist = ig.get(ledHistName);
201  if (ledHist) {
202  bool ledSignalPresent = (ledHist->getEntries() > 0);
203  if (ledSignalPresent)
204  vtmpflags[fLED]._state = flag::fBAD;
205  else
206  vtmpflags[fLED]._state = flag::fGOOD;
207  } else {
208  vtmpflags[fLED]._state = flag::fNA;
209  }
210  } else {
211  vtmpflags[fLED]._state = flag::fNA;
212  }
213 
214  // push all the flags for this crate
215  lssum._vflags.push_back(vtmpflags);
216  }
217 
218  // push all the flags for all FEDs for this LS
219  _vflagsLS.push_back(lssum);
220  cDigiSize_Crate.reset();
221  cOccupancy_depth.reset();
222  }
223 
224  /*
225  * End Job
226  */
227  /* virtual */ std::vector<flag::Flag> DigiRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
228  if (_ptype != fOffline)
229  return std::vector<flag::Flag>();
230 
231  _xDead.reset();
232  _xUniHF.reset();
233  _xUni.reset();
234 
235  // PREPARE LS AND RUN BASED FLAGS TO USE IT FOR BOOKING
236  std::vector<flag::Flag> vflagsPerLS;
237  std::vector<flag::Flag> vflagsPerRun;
238  vflagsPerLS.resize(nLSFlags);
239  vflagsPerRun.resize(nDigiFlag - nLSFlags + 1);
240  vflagsPerLS[fDigiSize] = flag::Flag("DigiSize");
241  vflagsPerLS[fNChsHF] = flag::Flag("NChsHF");
242  vflagsPerLS[fUnknownIds] = flag::Flag("UnknownIds");
243  vflagsPerLS[fLED] = flag::Flag("LEDMisfire");
244  vflagsPerRun[fDigiSize] = flag::Flag("DigiSize");
245  vflagsPerRun[fNChsHF] = flag::Flag("NChsHF");
246  vflagsPerRun[fUniHF - nLSFlags + 1] = flag::Flag("UniSlotHF");
247  vflagsPerRun[fDead - nLSFlags + 1] = flag::Flag("Dead");
248 
249  // INITIALIZE SUMMARY CONTAINERS
250  ContainerSingle2D cSummaryvsLS;
251  Container2D cSummaryvsLS_Crate;
252  cSummaryvsLS.initialize(_name,
253  "SummaryvsLS",
257  0);
258  cSummaryvsLS.book(ib, _subsystem);
259  cSummaryvsLS_Crate.initialize(_name,
260  "SummaryvsLS",
263  new quantity::FlagQuantity(vflagsPerLS),
265  0);
266  cSummaryvsLS_Crate.book(ib, _emap, _subsystem);
267 
268  // INITIALIZE CONTAINERS WE NEED TO LOAD or BOOK
269  Container2D cOccupancyCut_depth;
270  Container2D cDead_depth, cDead_Crate;
271  cOccupancyCut_depth.initialize(_taskname,
272  "OccupancyCut",
277  0);
278  cDead_depth.initialize(_name,
279  "Dead",
284  0);
285  cDead_Crate.initialize(_name,
286  "Dead",
291  0);
292 
293  // LOAD
294  cOccupancyCut_depth.load(ig, _emap, _subsystem);
295  cDead_depth.book(ib, _emap, _subsystem);
296  cDead_Crate.book(ib, _emap, _subsystem);
297 
298  // ANALYZE RUN BASED QUANTITIES
299  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
300  for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
301  if (!it->isHcalDetId())
302  continue;
303 
304  HcalDetId did = HcalDetId(it->rawId());
306 
307  if (_cOccupancy_depth.getBinContent(did) < 1) {
308  _xDead.get(eid)++;
309  cDead_depth.fill(did);
310  cDead_Crate.fill(eid);
311  }
312  if (did.subdet() == HcalForward)
313  _xUniHF.get(eid) += cOccupancyCut_depth.getBinContent(did);
314  }
315  // ANALYZE FOR HF SLOT UNIFORMITY
316  for (uintCompactMap::const_iterator it = _xUniHF.begin(); it != _xUniHF.end(); ++it) {
317  uint32_t hash1 = it->first;
318  HcalElectronicsId eid1(hash1);
319  double x1 = it->second;
320 
321  for (uintCompactMap::const_iterator jt = _xUniHF.begin(); jt != _xUniHF.end(); ++jt) {
322  if (jt == it)
323  continue;
324 
325  double x2 = jt->second;
326  if (x2 == 0)
327  continue;
328  if (x1 / x2 < _thresh_unihf)
329  _xUni.get(eid1)++;
330  }
331  }
332 
333  /*
334  * Iterate over each crate
335  * Iterate over each LS Summary
336  * Iterate over all flags
337  * set...
338  */
339  // iterate over all crates
340  std::vector<flag::Flag> sumflags;
341  int icrate = 0;
342  for (auto& it_crate : _vhashCrates) {
343  flag::Flag fSumRun("DIGI"); // summary flag for this FED
344  flag::Flag ffDead("Dead");
345  flag::Flag ffUniSlotHF("UniSlotHF");
346  HcalElectronicsId eid(it_crate);
347 
348  // skip monitoring for ZDC crate for now (Oct. 1 2023), the Hcal DQM group need to discuss with the ZDC group on the monitoring flags settings.
349  if (HcalGenericDetId(_emap->lookup(eid)).isHcalZDCDetId()) {
350  sumflags.push_back(fSumRun);
351  continue;
352  }
353 
355 
356  // ITERATE OVER EACH LS
357  for (std::vector<LSSummary>::const_iterator itls = _vflagsLS.begin(); itls != _vflagsLS.end(); ++itls) {
358  int iflag = 0;
359  flag::Flag fSumLS("DIGI");
360  for (std::vector<flag::Flag>::const_iterator ft = itls->_vflags[icrate].begin();
361  ft != itls->_vflags[icrate].end();
362  ++ft) {
363  cSummaryvsLS_Crate.setBinContent(eid, itls->_LS, int(iflag), ft->_state);
364  fSumLS += (*ft);
365  iflag++;
366  }
367  cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
368  fSumRun += fSumLS;
369  }
370 
371  // EVALUATE RUN BASED FLAGS
372  if (_xDead.get(eid) > 0)
373  ffDead._state = flag::fBAD;
374  else
375  ffDead._state = flag::fGOOD;
376  if (did.subdet() == HcalForward) {
377  if (_xUni.get(eid) > 0)
378  ffUniSlotHF._state = flag::fBAD;
379  else
380  ffUniSlotHF._state = flag::fGOOD;
381  }
382  fSumRun += ffDead + ffUniSlotHF;
383 
384  // push the summary flag for this FED for the Whole Run
385  sumflags.push_back(fSumRun);
386 
387  // increment fed
388  icrate++;
389  }
390 
391  return sumflags;
392  }
393 } // namespace hcaldqm
std::vector< LSSummary > _vflagsLS
MonitorElement * _meNumEvents
ContainerXXX< uint32_t > _xDigiSize
int const CRATE_VME_MIN
Definition: Constants.h:99
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:70
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:124
HcalElectronicsMap const * _emap
Definition: DQClient.h:60
virtual void reset()
Definition: ContainerXXX.h:293
filter::HashFilter _filter_FEDHF
int const FIBER_VME_MIN
Definition: Constants.h:129
std::vector< uint32_t > _vhashCrates
Definition: DQClient.h:64
int const FIBERCH_MIN
Definition: Constants.h:138
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:71
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:132
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:104
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:88
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:198
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:82
void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="") override
Definition: Container2D.cc:567
filter::HashFilter _filter_VME
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
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:111
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)