CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DigiRunSummary.cc
Go to the documentation of this file.
2 
3 namespace hcaldqm
4 {
6  std::string const& taskname, edm::ParameterSet const& ps) :
7  DQClient(name, taskname, ps), _booked(false)
8  {
9  _thresh_unihf = ps.getUntrackedParameter<double>("thresh_unihf",
10  0.2);
11  }
12 
13  /* virtual */ void DigiRunSummary::beginRun(edm::Run const& r,
14  edm::EventSetup const& es)
15  {
16  DQClient::beginRun(r,es);
17 
18  if (_ptype!=fOffline)
19  return;
20 
21  // INITIALIZE WHAT NEEDS TO BE INITIALIZE ONLY ONCE!
26  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
28  _vhashVME); // filter out VME
30  _vhashuTCA); // filter out uTCA
32  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
34  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
36  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
38  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
40  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
42  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
44  _vhashFEDHF); // preserve only HF FEDs
45 
50 
56 
57  _cOccupancy_depth.initialize(_name, "Occupancy",
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();
66  it!=gids.end(); ++it)
67  {
68  if (!it->isHcalDetId())
69  continue;
70  HcalDetId did(it->rawId());
72  _xNChsNominal.get(eid)++;
73  }
74  }
75 
76  /*
77  * END LUMI. EVALUATE LUMI BASED FLAGS
78  */
81  edm::EventSetup const& es)
82  {
83  DQClient::endLuminosityBlock(ib, ig, lb, es);
84 
85  if (_ptype!=fOffline)
86  return;
87 
88  LSSummary lssum;
89  lssum._LS=_currentLS;
90 
92 
93  // INITIALIZE LUMI BASED HISTOGRAMS
94  Container2D cDigiSize_FED, cOccupancy_depth;
95  cDigiSize_FED.initialize(_taskname, "DigiSize",
99  cOccupancy_depth.initialize(_taskname, "Occupancy",
104 
105  // LOAD LUMI BASED HISTOGRAMS
106  cOccupancy_depth.load(ig, _emap, _subsystem);
107  cDigiSize_FED.load(ig, _emap, _subsystem);
108  MonitorElement *meNumEvents = ig.get(_subsystem+
109  "/RunInfo/NumberOfEvents");
110  int numEvents = meNumEvents->getBinContent(1);
111  bool unknownIdsPresent = ig.get(_subsystem+"/"
112  +_taskname+"/UnknownIds")->getBinContent(1)>0;
113 
114  // book the Numer of Events - set axis extendable
115  if (!_booked)
116  {
118  _meNumEvents = ib.book1D("NumberOfEvents", "NumberOfEvents",
119  1000, 1, 1001); // 1000 to start with
120  _meNumEvents->getTH1()->SetCanExtend(TH1::kXaxis);
121 
123  _booked=true;
124  }
126 
127  // ANALYZE THIS LS for LS BASED FLAGS
128  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
129  for (std::vector<HcalGenericDetId>::const_iterator it=gids.begin();
130  it!=gids.end(); ++it)
131  {
132  if (!it->isHcalDetId())
133  continue;
134 
135  HcalDetId did = HcalDetId(it->rawId());
137 
138  cOccupancy_depth.getBinContent(did)>0?_xNChs.get(eid)++:
139  _xNChs.get(eid)+=0;
140  _cOccupancy_depth.fill(did, cOccupancy_depth.getBinContent(did));
141  // digi size
142  cDigiSize_FED.getMean(eid)!=
143  constants::DIGISIZE[did.subdet()-1]?
144  _xDigiSize.get(eid)++:_xDigiSize.get(eid)+=0;
145  cDigiSize_FED.getRMS(eid)!=0?
146  _xDigiSize.get(eid)++:_xDigiSize.get(eid)+=0;
147  }
148 
149  // GENERATE SUMMARY AND STORE IT
150  std::vector<flag::Flag> vtmpflags;
151  vtmpflags.resize(nLSFlags);
152  vtmpflags[fDigiSize]=flag::Flag("DigiSize");
153  vtmpflags[fNChsHF]=flag::Flag("NChsHF");
154  vtmpflags[fUnknownIds]=flag::Flag("UnknownIds");
155  for (std::vector<uint32_t>::const_iterator it=_vhashFEDs.begin();
156  it!=_vhashFEDs.end(); ++it)
157  {
158  HcalElectronicsId eid(*it);
159 
160  // reset all the tmp flags to fNA
161  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
162  for (std::vector<flag::Flag>::iterator ft=vtmpflags.begin();
163  ft!=vtmpflags.end(); ++ft)
164  ft->reset();
165 
166  std::vector<uint32_t>::const_iterator cit=std::find(
167  _vcdaqEids.begin(), _vcdaqEids.end(), *it);
168  if (cit==_vcdaqEids.end())
169  {
170  // was not @cDAQ, set all the flags for this FED as fNCDAQ
171  for (std::vector<flag::Flag>::iterator ft=vtmpflags.begin();
172  ft!=vtmpflags.end(); ++ft)
173  ft->_state = flag::fNCDAQ;
174 
175  // push all the flags for this FED
176  // IMPORTANT!!!
177  lssum._vflags.push_back(vtmpflags);
178  continue;
179  }
180 
181  if (utilities::isFEDHBHE(eid) || utilities::isFEDHF(eid) ||
182  utilities::isFEDHO(eid))
183  {
184  if (_xDigiSize.get(eid)>0)
185  vtmpflags[fDigiSize]._state = flag::fBAD;
186  else
187  vtmpflags[fDigiSize]._state = flag::fGOOD;
188  if (utilities::isFEDHF(eid))
189  {
190  if (_xNChs.get(eid)!=_xNChsNominal.get(eid))
191  vtmpflags[fNChsHF]._state = flag::fBAD;
192  else
193  vtmpflags[fNChsHF]._state = flag::fGOOD;
194  }
195  }
196  if (unknownIdsPresent)
197  vtmpflags[fUnknownIds]._state = flag::fBAD;
198  else
199  vtmpflags[fUnknownIds]._state = flag::fGOOD;
200 
201  // push all the flags for this FED
202  lssum._vflags.push_back(vtmpflags);
203  }
204 
205  // push all the flags for all FEDs for this LS
206  _vflagsLS.push_back(lssum);
207  }
208 
209  /*
210  * End Job
211  */
212  /* virtual */ std::vector<flag::Flag> DigiRunSummary::endJob(
214  {
215  if (_ptype!=fOffline)
216  return std::vector<flag::Flag>();
217 
219 
220  // PREPARE LS AND RUN BASED FLAGS TO USE IT FOR BOOKING
221  std::vector<flag::Flag> vflagsPerLS;
222  std::vector<flag::Flag> vflagsPerRun;
223  vflagsPerLS.resize(nLSFlags);
224  vflagsPerRun.resize(nDigiFlag-nLSFlags+1);
225  vflagsPerLS[fDigiSize]=flag::Flag("DigiSize");
226  vflagsPerLS[fNChsHF]=flag::Flag("NChsHF");
227  vflagsPerRun[fDigiSize]=flag::Flag("DigiSize");
228  vflagsPerRun[fNChsHF]=flag::Flag("NChsHF");
229  vflagsPerRun[fUniHF-nLSFlags+1]=flag::Flag("UniSlotHF");
230  vflagsPerRun[fDead-nLSFlags+1]=flag::Flag("Dead");
231 
232  // INITIALIZE SUMMARY CONTAINERS
233  ContainerSingle2D cSummaryvsLS;
234  Container2D cSummaryvsLS_FED;
235  cSummaryvsLS.initialize(_name, "SummaryvsLS",
239  cSummaryvsLS_FED.initialize(_name, "SummaryvsLS",
242  new quantity::FlagQuantity(vflagsPerLS),
244  cSummaryvsLS_FED.book(ib, _emap, _subsystem);
245  cSummaryvsLS.book(ib, _subsystem);
246 
247  // INITIALIZE CONTAINERS WE NEED TO LOAD or BOOK
248  Container2D cOccupancyCut_depth;
249  Container2D cDead_depth, cDead_FEDVME, cDead_FEDuTCA;
250  cOccupancyCut_depth.initialize(_taskname, "OccupancyCut",
255  cDead_depth.initialize(_name, "Dead",
260  cDead_FEDVME.initialize(_name, "Dead",
265  cDead_FEDuTCA.initialize(_name, "Dead",
270 
271  // LOAD
272  cOccupancyCut_depth.load(ig, _emap, _subsystem);
273  cDead_depth.book(ib, _emap, _subsystem);
274  cDead_FEDVME.book(ib, _emap, _filter_uTCA, _subsystem);
275  cDead_FEDuTCA.book(ib, _emap, _filter_VME, _subsystem);
276 
277  // ANALYZE RUN BASED QUANTITIES
278  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
279  for (std::vector<HcalGenericDetId>::const_iterator it=gids.begin();
280  it!=gids.end(); ++it)
281  {
282  if (!it->isHcalDetId())
283  continue;
284 
285  HcalDetId did = HcalDetId(it->rawId());
287 
288  if (_cOccupancy_depth.getBinContent(did)<1)
289  {
290  _xDead.get(eid)++;
291  cDead_depth.fill(did);
292  eid.isVMEid()?cDead_FEDVME.fill(eid):cDead_FEDuTCA.fill(eid);
293  }
294  if (did.subdet()==HcalForward)
295  _xUniHF.get(eid)+=cOccupancyCut_depth.getBinContent(did);
296  }
297  // ANALYZE FOR HF SLOT UNIFORMITY
298  for (uintCompactMap::const_iterator it=_xUniHF.begin();
299  it!=_xUniHF.end(); ++it)
300  {
301  uint32_t hash1 = it->first;
302  HcalElectronicsId eid1(hash1);
303  double x1 = it->second;
304 
305  for (uintCompactMap::const_iterator jt=_xUniHF.begin();
306  jt!=_xUniHF.end(); ++jt)
307  {
308  if (jt==it)
309  continue;
310 
311  double x2 = jt->second;
312  if (x2==0)
313  continue;
314  if (x1/x2<_thresh_unihf)
315  _xUni.get(eid1)++;
316  }
317  }
318 
319  /*
320  * Iterate over each FED
321  * Iterate over each LS Summary
322  * Iterate over all flags
323  * set...
324  */
325  // iterate over all FEDs
326  std::vector<flag::Flag> sumflags;
327  int ifed=0;
328  for (std::vector<uint32_t>::const_iterator it=_vhashFEDs.begin();
329  it!=_vhashFEDs.end(); ++it)
330  {
331  flag::Flag fSumRun("DIGI"); // summary flag for this FED
332  flag::Flag ffDead("Dead");
333  flag::Flag ffUniSlotHF("UniSlotHF");
334  HcalElectronicsId eid(*it);
335 
336  // ITERATE OVER EACH LS
337  for (std::vector<LSSummary>::const_iterator itls=_vflagsLS.begin();
338  itls!=_vflagsLS.end(); ++itls)
339  {
340  int iflag=0;
341  flag::Flag fSumLS("DIGI");
342  for (std::vector<flag::Flag>::const_iterator ft=
343  itls->_vflags[ifed].begin(); ft!=itls->_vflags[ifed].end();
344  ++ft)
345  {
346  cSummaryvsLS_FED.setBinContent(eid, itls->_LS, int(iflag),
347  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  // NOTE, THAT IF THE FED IS NOT @cDAQ fSumRun state will be fNCDAQ
357  if (utilities::isFEDHBHE(eid) || utilities::isFEDHF(eid) ||
358  utilities::isFEDHO(eid))
359  {
360  if (_xDead.get(eid)>0)
361  ffDead._state = flag::fBAD;
362  else
363  ffDead._state = flag::fGOOD;
364  if (utilities::isFEDHF(eid))
365  {
366  if (_xUni.get(eid)>0)
367  ffUniSlotHF._state = flag::fBAD;
368  else
369  ffUniSlotHF._state = flag::fGOOD;
370  }
371  }
372  fSumRun+=ffDead+ffUniSlotHF;
373 
374  // push the summary flag for this FED for the Whole Run
375  sumflags.push_back(fSumRun);
376 
377  // increment fed
378  ifed++;
379  }
380 
381  return sumflags;
382  }
383 }
std::vector< uint32_t > _vcdaqEids
Definition: DQClient.h:64
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:60
int ib
Definition: cuy.py:660
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
ContainerXXX< uint32_t > _xUni
virtual double getRMS(HcalDetId const &, int axix=1)
Definition: Container1D.cc:237
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
std::vector< uint32_t > _vhashFEDs
Definition: DQClient.h:58
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQClient.cc:15
virtual CompactMap::const_iterator begin()
Definition: ContainerXXX.h:75
State _state
Definition: Flag.h:79
std::string _taskname
Definition: DQClient.h:47
int const SPIGOT_MIN
Definition: Constants.h:85
HcalElectronicsMap const * _emap
Definition: DQClient.h:54
virtual void reset()
Definition: ContainerXXX.h:366
filter::HashFilter _filter_FEDHF
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int const FIBER_VME_MIN
Definition: Constants.h:90
int const FIBERCH_MIN
Definition: Constants.h:100
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
virtual CompactMap::const_iterator end()
Definition: ContainerXXX.h:77
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:105
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
virtual void initialize(std::string const &folder, hashfunctions::HashType, Quantity *, Quantity *, Quantity *qz=new ValueQuantity(quantity::fN), int debug=0)
Definition: Container2D.cc:32
int const FIBER_uTCA_MIN1
Definition: Constants.h:93
ContainerXXX< uint32_t > _xNChsNominal
TH1 * getTH1(void) const
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
virtual void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< HcalGenericDetId > allPrecisionId() const
std::string _name
Definition: DQModule.h:57
std::vector< uint32_t > _vhashFEDHF
std::vector< std::vector< flag::Flag > > _vflags
Definition: DQClient.h:43
virtual double getMean(HcalDetId const &, int axis=1)
Definition: Container1D.cc:232
int const CRATE_uTCA_MIN
Definition: Constants.h:65
std::vector< uint32_t > _vhashVME
DigiRunSummary(std::string const &, std::string const &, edm::ParameterSet const &)
virtual std::vector< flag::Flag > endJob(DQMStore::IBooker &, DQMStore::IGetter &)
virtual double getBinContent(HcalDetId const &) override
Definition: Container2D.cc:184
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
bool isFEDHBHE(HcalElectronicsId const &)
Definition: Utilities.cc:131
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:99
virtual void initialize(std::string const &folder, Quantity *, Quantity *, Quantity *qz=new ValueQuantity(quantity::fN), int debug=0)
std::vector< int > _vFEDs
Definition: DQClient.h:57
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:596
int const DIGISIZE[SUBDET_NUM]
Definition: Constants.h:132
ContainerXXX< uint32_t > _xNChs
virtual 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:249
if(dp >Float(M_PI)) dp-
electronicsmap::ElectronicsMap _ehashmap
virtual void fill(HcalDetId const &) override
Definition: Container2D.cc:59
std::string _subsystem
Definition: DQModule.h:64
bool isFEDHO(HcalElectronicsId const &)
Definition: Utilities.cc:178
volatile std::atomic< bool > shutdown_flag false
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:91
virtual void initialize(FilterType ftype, HashType htype, std::vector< uint32_t > const &)
Definition: HashFilter.cc:26
virtual 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.
bool isFEDHF(HcalElectronicsId const &)
Definition: Utilities.cc:153
ContainerXXX< uint32_t > _xUniHF
int const SLOT_uTCA_MIN
Definition: Constants.h:72
Definition: Run.h:42
ContainerXXX< uint32_t > _xDead