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  bool ledSignalPresent = ig.get(_subsystem+"/"
122  +_taskname+"/LED/LEDEventCount")->getBinContent(1)>0;
123 
124  // book the Numer of Events - set axis extendable
125  if (!_booked)
126  {
128  _meNumEvents = ib.book1D("NumberOfEvents", "NumberOfEvents",
129  1000, 1, 1001); // 1000 to start with
130  _meNumEvents->getTH1()->SetCanExtend(TH1::kXaxis);
131 
133  _booked=true;
134  }
136 
137  // ANALYZE THIS LS for LS BASED FLAGS
138  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
139  for (std::vector<HcalGenericDetId>::const_iterator it=gids.begin();
140  it!=gids.end(); ++it)
141  {
142  if (!it->isHcalDetId())
143  continue;
144 
145  HcalDetId did = HcalDetId(it->rawId());
147 
148  cOccupancy_depth.getBinContent(did)>0?_xNChs.get(eid)++:
149  _xNChs.get(eid)+=0;
150  _cOccupancy_depth.fill(did, cOccupancy_depth.getBinContent(did));
151  // digi size
152  cDigiSize_Crate.getMean(eid)!=
153  _refDigiSize[did.subdet()]?
154  _xDigiSize.get(eid)++:_xDigiSize.get(eid)+=0;
155  cDigiSize_Crate.getRMS(eid)!=0?
156  _xDigiSize.get(eid)++:_xDigiSize.get(eid)+=0;
157  }
158 
159  // GENERATE SUMMARY AND STORE IT
160  std::vector<flag::Flag> vtmpflags;
161  vtmpflags.resize(nLSFlags);
162  vtmpflags[fDigiSize]=flag::Flag("DigiSize");
163  vtmpflags[fNChsHF]=flag::Flag("NChsHF");
164  vtmpflags[fUnknownIds]=flag::Flag("UnknownIds");
165  vtmpflags[fLED]=flag::Flag("LEDMisfire");
166  for (std::vector<uint32_t>::const_iterator it=_vhashCrates.begin();
167  it!=_vhashCrates.end(); ++it)
168  {
169  HcalElectronicsId eid(*it);
170  HcalDetId did = HcalDetId(_emap->lookup(eid));
171 
172  // reset all the tmp flags to fNA
173  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
174  for (std::vector<flag::Flag>::iterator ft=vtmpflags.begin();
175  ft!=vtmpflags.end(); ++ft)
176  ft->reset();
177 
178  if (_xDigiSize.get(eid)>0)
179  vtmpflags[fDigiSize]._state = flag::fBAD;
180  else
181  vtmpflags[fDigiSize]._state = flag::fGOOD;
182 
183  if (did.subdet() == HcalForward)
184  {
185  if (_xNChs.get(eid)!=_xNChsNominal.get(eid))
186  vtmpflags[fNChsHF]._state = flag::fBAD;
187  else
188  vtmpflags[fNChsHF]._state = flag::fGOOD;
189  } else {
190  vtmpflags[fNChsHF]._state = flag::fNA;
191  }
192  if (unknownIdsPresent)
193  vtmpflags[fUnknownIds]._state = flag::fBAD;
194  else
195  vtmpflags[fUnknownIds]._state = flag::fGOOD;
196 
197  if (ledSignalPresent)
198  vtmpflags[fLED]._state = flag::fBAD;
199  else
200  vtmpflags[fLED]._state = flag::fGOOD;
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  }
209 
210  /*
211  * End Job
212  */
213  /* virtual */ std::vector<flag::Flag> DigiRunSummary::endJob(
215  {
216  if (_ptype!=fOffline)
217  return std::vector<flag::Flag>();
218 
220 
221  // PREPARE LS AND RUN BASED FLAGS TO USE IT FOR BOOKING
222  std::vector<flag::Flag> vflagsPerLS;
223  std::vector<flag::Flag> vflagsPerRun;
224  vflagsPerLS.resize(nLSFlags);
225  vflagsPerRun.resize(nDigiFlag-nLSFlags+1);
226  vflagsPerLS[fDigiSize]=flag::Flag("DigiSize");
227  vflagsPerLS[fNChsHF]=flag::Flag("NChsHF");
228  vflagsPerLS[fUnknownIds]=flag::Flag("UnknownIds");
229  vflagsPerLS[fLED]=flag::Flag("LEDMisfire");
230  vflagsPerRun[fDigiSize]=flag::Flag("DigiSize");
231  vflagsPerRun[fNChsHF]=flag::Flag("NChsHF");
232  vflagsPerRun[fUniHF-nLSFlags+1]=flag::Flag("UniSlotHF");
233  vflagsPerRun[fDead-nLSFlags+1]=flag::Flag("Dead");
234 
235  // INITIALIZE SUMMARY CONTAINERS
236  ContainerSingle2D cSummaryvsLS;
237  Container2D cSummaryvsLS_Crate;
238  cSummaryvsLS.initialize(_name, "SummaryvsLS",
242  cSummaryvsLS.book(ib, _subsystem);
243  cSummaryvsLS_Crate.initialize(_name, "SummaryvsLS",
246  new quantity::FlagQuantity(vflagsPerLS),
248  cSummaryvsLS_Crate.book(ib, _emap, _subsystem);
249 
250  // INITIALIZE CONTAINERS WE NEED TO LOAD or BOOK
251  Container2D cOccupancyCut_depth;
252  Container2D cDead_depth, cDead_Crate;
253  cOccupancyCut_depth.initialize(_taskname, "OccupancyCut",
258  cDead_depth.initialize(_name, "Dead",
263  cDead_Crate.initialize(_name, "Dead",
268 
269  // LOAD
270  cOccupancyCut_depth.load(ig, _emap, _subsystem);
271  cDead_depth.book(ib, _emap, _subsystem);
272  cDead_Crate.book(ib, _emap, _subsystem);
273 
274  // ANALYZE RUN BASED QUANTITIES
275  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
276  for (std::vector<HcalGenericDetId>::const_iterator it=gids.begin();
277  it!=gids.end(); ++it)
278  {
279  if (!it->isHcalDetId())
280  continue;
281 
282  HcalDetId did = HcalDetId(it->rawId());
284 
285  if (_cOccupancy_depth.getBinContent(did)<1)
286  {
287  _xDead.get(eid)++;
288  cDead_depth.fill(did);
289  cDead_Crate.fill(eid);
290  }
291  if (did.subdet()==HcalForward)
292  _xUniHF.get(eid)+=cOccupancyCut_depth.getBinContent(did);
293  }
294  // ANALYZE FOR HF SLOT UNIFORMITY
295  for (uintCompactMap::const_iterator it=_xUniHF.begin();
296  it!=_xUniHF.end(); ++it)
297  {
298  uint32_t hash1 = it->first;
299  HcalElectronicsId eid1(hash1);
300  double x1 = it->second;
301 
302  for (uintCompactMap::const_iterator jt=_xUniHF.begin();
303  jt!=_xUniHF.end(); ++jt)
304  {
305  if (jt==it)
306  continue;
307 
308  double x2 = jt->second;
309  if (x2==0)
310  continue;
311  if (x1/x2<_thresh_unihf)
312  _xUni.get(eid1)++;
313  }
314  }
315 
316  /*
317  * Iterate over each crate
318  * Iterate over each LS Summary
319  * Iterate over all flags
320  * set...
321  */
322  // iterate over all crates
323  std::vector<flag::Flag> sumflags;
324  int icrate=0;
325  for (auto& it_crate : _vhashCrates) {
326  flag::Flag fSumRun("DIGI"); // summary flag for this FED
327  flag::Flag ffDead("Dead");
328  flag::Flag ffUniSlotHF("UniSlotHF");
329  HcalElectronicsId eid(it_crate);
330  HcalDetId did = HcalDetId(_emap->lookup(eid));
331 
332  // ITERATE OVER EACH LS
333  for (std::vector<LSSummary>::const_iterator itls=_vflagsLS.begin();
334  itls!=_vflagsLS.end(); ++itls)
335  {
336  int iflag=0;
337  flag::Flag fSumLS("DIGI");
338  for (std::vector<flag::Flag>::const_iterator ft=
339  itls->_vflags[icrate].begin(); ft!=itls->_vflags[icrate].end();
340  ++ft)
341  {
342  cSummaryvsLS_Crate.setBinContent(eid, itls->_LS, int(iflag), ft->_state);
343  fSumLS+=(*ft);
344  iflag++;
345  }
346  cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
347  fSumRun+=fSumLS;
348  }
349 
350  // EVALUATE RUN BASED FLAGS
351  if (_xDead.get(eid)>0)
352  ffDead._state = flag::fBAD;
353  else
354  ffDead._state = flag::fGOOD;
355  if (did.subdet() == HcalForward)
356  {
357  if (_xUni.get(eid)>0)
358  ffUniSlotHF._state = flag::fBAD;
359  else
360  ffUniSlotHF._state = flag::fGOOD;
361  }
362  fSumRun+=ffDead+ffUniSlotHF;
363 
364  // push the summary flag for this FED for the Whole Run
365  sumflags.push_back(fSumRun);
366 
367  // increment fed
368  icrate++;
369  }
370 
371  return sumflags;
372  }
373 }
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:142
ContainerXXX< uint32_t > _xUni
virtual double getRMS(HcalDetId const &, int axix=1)
Definition: Container1D.cc:238
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:302
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:47
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:54
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:58
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
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:115
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
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:233
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:184
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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:32
virtual void load(DQMStore *, HcalElectronicsMap const *, std::string const &subsystem="Hcal", std::string const &aux="", std::string const &prepend="", DQMStore::OpenRunDirs mode=DQMStore::StripRunDirs)
Definition: Container1D.cc:597
ContainerXXX< uint32_t > _xNChs
void setBinContent(HcalDetId const &, int) override
Definition: Container2D.cc:235
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:59
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 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:895
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:661