CMS 3D CMS Logo

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