CMS 3D CMS Logo

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