CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RawTask.cc
Go to the documentation of this file.
2 
4  DQTask(ps)
5 {
7  edm::InputTag("rawDataCollector"));
9  edm::InputTag("hcalDigis"));
10 
11  _tokFEDs = consumes<FEDRawDataCollection>(_tagFEDs);
12  _tokReport = consumes<HcalUnpackerReport>(_tagReport);
13 
14  _vflags.resize(nRawFlag);
15  _vflags[fEvnMsm]=flag::Flag("EvnMsm");
16  _vflags[fBcnMsm]=flag::Flag("BcnMsm");
17  _vflags[fBadQ]=flag::Flag("BadQ");
18 }
19 
21  edm::Run const& r, edm::EventSetup const& es)
22 {
23  DQTask::bookHistograms(ib,r,es);
24 
25  // GET WHAT YOU NEED
27  es.get<HcalDbRecord>().get(dbs);
28  _emap = dbs->getHcalMapping();
29  std::vector<int> vFEDs = utilities::getFEDList(_emap);
30  std::vector<int> vFEDsVME = utilities::getFEDVMEList(_emap);
31  std::vector<int> vFEDsuTCA = utilities::getFEDuTCAList(_emap);
32  std::vector<uint32_t> vVME;
33  std::vector<uint32_t> vuTCA;
34  std::vector<uint32_t> vhashFEDsVME;
35  std::vector<uint32_t> vhashFEDsuTCA;
39  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
41  vVME);
43  vuTCA);
44 
45  for (std::vector<int>::const_iterator it=vFEDsVME.begin();
46  it!=vFEDsVME.end(); ++it)
47  {
48  vhashFEDsVME.push_back(HcalElectronicsId(constants::FIBERCH_MIN,
50  (*it)-constants::FED_VME_MIN).rawId());
53  (*it)-constants::FED_VME_MIN).rawId());
54  }
55  for (std::vector<int>::const_iterator it=vFEDsuTCA.begin();
56  it!=vFEDsuTCA.end(); ++it)
57  {
58  vhashFEDsuTCA.push_back(HcalElectronicsId(
60  FIBERCH_MIN, false).rawId());
61  _vhashFEDs.push_back(HcalElectronicsId(
63  FIBERCH_MIN, false).rawId());
64  }
66  hashfunctions::fFED, vhashFEDsVME);
68  hashfunctions::fFED, vhashFEDsuTCA);
69 
70  // INITIALIZE FIRST
73  new quantity::FEDQuantity(vFEDsVME),
78  new quantity::FEDQuantity(vFEDsVME),
83  new quantity::FEDQuantity(vFEDsVME),
88  new quantity::FEDQuantity(vFEDsuTCA),
93  new quantity::FEDQuantity(vFEDsuTCA),
98  new quantity::FEDQuantity(vFEDsuTCA),
101 
102  // Bad Quality
103  _cBadQuality_FEDVME.initialize(_name, "BadQuality",
108  _cBadQuality_FEDuTCA.initialize(_name, "BadQuality",
113  _cBadQualityvsLS.initialize(_name, "BadQualityvsLS",
116  _cBadQualityvsBX.initialize(_name, "BadQualityvsBX",
119  _cBadQuality_depth.initialize(_name, "BadQuality",
124 
125  // INITIALIZE HISTOGRAMS to be used in Online Only
126  if (_ptype==fOnline)
127  {
131  _cSummaryvsLS_FED.initialize(_name, "SummaryvsLS",
136  _cSummaryvsLS.initialize(_name, "SummaryvsLS",
138  new quantity::FEDQuantity(vFEDs),
140  }
141 
142  // BOOK HISTOGRAMS
149 
150 
156 
157  // BOOK HISTOGRAMS to be used in ONLINE ONLY!
158  if (_ptype==fOnline)
159  {
165  }
166 
167  // FOR OFFLINE PROCESSING MARK THESE HISTOGRAMS AS LUMI BASED
168  if (_ptype==fOffline)
169  {
175  }
176 
177  // initialize hash map
179 }
180 
181 /* virtual */ void RawTask::_resetMonitors(UpdateFreq uf)
182 {
183  // base reset
184  DQTask::_resetMonitors(uf);
185 }
186 
187 /* virtual */ void RawTask::_process(edm::Event const& e,
188  edm::EventSetup const&)
189 {
192  if (!e.getByToken(_tokFEDs, craw))
193  _logger.dqmthrow("Collection FEDRawDataCollection isn't available"+
194  _tagFEDs.label()+" " +_tagFEDs.instance());
195  if (!e.getByToken(_tokReport, creport))
196  _logger.dqmthrow("Collection HcalUnpackerReport isn't available"+
198 
199  // extract some info
200  int bx = e.bunchCrossing();
201 
202 
203  int nn = 0;
204  // loop thru and fill the detIds with bad quality
205  // NOTE: Calibration Channels are skipped!
206  // TODO: Include for Online Calibration Channels marked as bad
207  // a comment below is left on purpose!
208  //_cBadQualityvsBX.fill(bx, creport->badQualityDigis());
209  for (std::vector<DetId>::const_iterator it=creport->bad_quality_begin();
210  it!=creport->bad_quality_end(); ++it)
211  {
212  if (!HcalGenericDetId(*it).isHcalDetId())
213  continue;
214 
215  nn++;
218  // ONLINE ONLY!
219  if (_ptype==fOnline)
220  _xBadQLS.get(eid)++;
221  if (eid.isVMEid())
222  {
223  if (_filter_FEDsVME.filter(eid))
224  continue;
226  }
227  else
228  {
229  if (_filter_FEDsuTCA.filter(eid))
230  continue;
232  }
233  }
235  _cBadQualityvsBX.fill(bx, nn);
236 
237  for (int fed=FEDNumbering::MINHCALFEDID;
238  fed<=FEDNumbering::MAXHCALuTCAFEDID; fed++)
239  {
240  // skip nonHCAL FEDs
241  if ((fed>FEDNumbering::MAXHCALFEDID &&
244  continue;
245  FEDRawData const& raw = craw->FEDData(fed);
246  if (raw.size()<constants::RAW_EMPTY)
247  continue;
248 
249  if (fed<=FEDNumbering::MAXHCALFEDID) // VME
250  {
251  HcalDCCHeader const* hdcc = (HcalDCCHeader const*)(raw.data());
252  if (!hdcc)
253  continue;
254 
255  uint32_t bcn = hdcc->getBunchId();
256  uint32_t orn = hdcc->getOrbitNumber();
257  uint32_t evn = hdcc->getDCCEventNumber();
259 
260  // iterate over spigots
261  HcalHTRData htr;
262  for (int is=0; is<HcalDCCHeader::SPIGOT_COUNT; is++)
263  {
264  int r = hdcc->getSpigotData(is, htr, raw.size());
265  if (r!=0)
266  continue;
269  is, dccId);
270  if (_filter_FEDsVME.filter(eid))
271  continue;
272 
273  uint32_t htr_evn = htr.getL1ANumber();
274  uint32_t htr_orn = htr.getOrbitNumber();
275  uint32_t htr_bcn = htr.getBunchNumber();
276  bool qevn = (htr_evn!=evn);
277  bool qbcn = (htr_bcn!=bcn);
278  bool qorn = (htr_orn!=orn);
279  if (qevn)
280  {
282 
284  _xEvnMsmLS.get(eid)++;
285  }
286  if (qorn)
288  if (qbcn)
289  {
291 
293  _xBcnMsmLS.get(eid)++;
294  }
295  }
296  }
297  else // uTCA
298  {
299  hcal::AMC13Header const* hamc13 = (hcal::AMC13Header const*)
300  raw.data();
301  if (!hamc13)
302  continue;
303 
304  uint32_t bcn = hamc13->bunchId();
305  uint32_t orn = hamc13->orbitNumber();
306  uint32_t evn = hamc13->l1aNumber();
307  int namc = hamc13->NAMC();
308 
309  for (int iamc=0; iamc<namc; iamc++)
310  {
311  int slot = hamc13->AMCSlot(iamc);
312  int crate = hamc13->AMCId(iamc)&0xFF;
313  HcalElectronicsId eid(crate, slot, FIBER_uTCA_MIN1,
314  FIBERCH_MIN, false);
315  if (_filter_FEDsuTCA.filter(eid))
316  continue;
317  HcalUHTRData uhtr(hamc13->AMCPayload(iamc),
318  hamc13->AMCSize(iamc));
319 
320  uint32_t uhtr_evn = uhtr.l1ANumber();
321  uint32_t uhtr_bcn = uhtr.bunchNumber();
322  uint32_t uhtr_orn = uhtr.orbitNumber();
323  bool qevn = (uhtr_evn!=evn);
324  bool qbcn = (uhtr_bcn!=bcn);
325  bool qorn = (uhtr_orn!=orn);
326  if (qevn)
327  {
329 
330  if (_ptype==fOnline)
331  _xEvnMsmLS.get(eid)++;
332  }
333  if (qorn)
335  if (qbcn)
336  {
338 
339  if (_ptype==fOnline)
340  _xBcnMsmLS.get(eid)++;
341  }
342  }
343  }
344  }
345 }
346 
348  edm::EventSetup const& es)
349 {
350  DQTask::beginLuminosityBlock(lb, es);
351 
352 // _cBadQualityvsLS.extendAxisRange(_currentLS);
353 
354  // ONLINE ONLY!
355  if (_ptype!=fOnline)
356  return;
357 // _cSummaryvsLS_FED.extendAxisRange(_currentLS);
358 // _cSummaryvsLS.extendAxisRange(_currentLS);
359 
360 }
361 
363  edm::EventSetup const& es)
364 {
365  if (_ptype!=fOnline)
366  return;
367 
368  //
369  // GENERATE STATUS ONLY FOR ONLINE!
370  //
371  for (std::vector<uint32_t>::const_iterator it=_vhashFEDs.begin();
372  it!=_vhashFEDs.end(); ++it)
373  {
374  flag::Flag fSum("RAW");
376 
377  std::vector<uint32_t>::const_iterator cit=std::find(
378  _vcdaqEids.begin(), _vcdaqEids.end(), *it);
379  if (cit==_vcdaqEids.end())
380  {
381  // not @cDAQ
382  for (uint32_t iflag=0; iflag<_vflags.size(); iflag++)
383  _cSummaryvsLS_FED.setBinContent(eid, _currentLS, int(iflag),
384  int(flag::fNCDAQ));
386  continue;
387  }
388 
389  // FED is @cDAQ
390  if (utilities::isFEDHBHE(eid) || utilities::isFEDHF(eid) ||
391  utilities::isFEDHO(eid))
392  {
393  if (_xEvnMsmLS.get(eid)>0)
394  _vflags[fEvnMsm]._state = flag::fBAD;
395  else
396  _vflags[fEvnMsm]._state = flag::fGOOD;
397  if (_xBcnMsmLS.get(eid)>0)
398  _vflags[fBcnMsm]._state = flag::fBAD;
399  else
400  _vflags[fBcnMsm]._state = flag::fGOOD;
401  if (_xBadQLS.get(eid)>0)
402  _vflags[fBadQ]._state = flag::fBAD;
403  else
404  _vflags[fBadQ]._state = flag::fGOOD;
405  }
406 
407  int iflag=0;
408  // iterate over all flags:
409  // - sum them all up in summary flag for this FED
410  // - reset each flag right after using it
411  for (std::vector<flag::Flag>::iterator ft=_vflags.begin();
412  ft!=_vflags.end(); ++ft)
413  {
414  _cSummaryvsLS_FED.setBinContent(eid, _currentLS, int(iflag),
415  ft->_state);
416  fSum+=(*ft);
417  iflag++;
418 
419  // this is the MUST! We don't keep flags per FED, reset
420  // each one of them after using
421  ft->reset();
422  }
424  }
425 
426  // reset...
428 
429  // in the end always do the DQTask::endLumi
430  DQTask::endLuminosityBlock(lb, es);
431 }
432 
434 
ContainerXXX< uint32_t > _xEvnMsmLS
Definition: RawTask.h:86
T getUntrackedParameter(std::string const &, T const &) const
int const RAW_EMPTY
Definition: Constants.h:215
virtual void initialize(std::string const &folder, Quantity *, Quantity *qy=new ValueQuantity(quantity::fN), int debug=0)
Container2D _cBadQuality_FEDuTCA
Definition: RawTask.h:73
virtual void setBinContent(HcalDetId const &, int)
Definition: Container2D.cc:235
int const CRATE_VME_MIN
Definition: Constants.h:60
int ib
Definition: cuy.py:660
uint16_t fed2crate(int fed)
Definition: Utilities.cc:12
electronicsmap::ElectronicsMap _ehashmap
Definition: RawTask.h:60
ContainerXXX< uint32_t > _xBcnMsmLS
Definition: RawTask.h:86
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: RawTask.cc:20
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ContainerSingleProf1D _cBadQualityvsLS
Definition: RawTask.h:76
UpdateFreq
Definition: DQTask.h:17
State _state
Definition: Flag.h:79
Container2D _cBcnMsm_ElectronicsuTCA
Definition: RawTask.h:84
int bunchCrossing() const
Definition: EventBase.h:65
Container2D _cOrnMsm_ElectronicsuTCA
Definition: RawTask.h:85
int const SPIGOT_MIN
Definition: Constants.h:85
ContainerSingleProf1D _cBadQualityvsBX
Definition: RawTask.h:77
ContainerXXX< uint32_t > _xBadQLS
Definition: RawTask.h:86
virtual void _process(edm::Event const &, edm::EventSetup const &)
Definition: RawTask.cc:187
virtual void reset()
Definition: ContainerXXX.h:342
int l1aNumber() const
Definition: AMC13Header.h:19
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
int const FIBER_VME_MIN
Definition: Constants.h:90
HashFilter _filter_FEDsuTCA
Definition: RawTask.h:69
unsigned int getOrbitNumber() const
Get the HTR orbit number.
Definition: HcalHTRData.cc:324
Container2D _cBadQuality_FEDVME
Definition: RawTask.h:72
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void bookHistograms(fwlite::EventContainer &eventCont)
int const FIBERCH_MIN
Definition: Constants.h:100
int AMCSize(int i) const
Definition: AMC13Header.h:37
Container2D _cBadQuality_depth
Definition: RawTask.h:74
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
std::vector< int > getFEDVMEList(HcalElectronicsMap const *)
Definition: Utilities.cc:71
int const SPIGOT_MAX
Definition: Constants.h:86
virtual void fill(HcalDetId const &)
Definition: Container2D.cc:59
unsigned int getOrbitNumber() const
Definition: HcalDCCHeader.h:46
int getBunchId() const
Definition: HcalDCCHeader.h:34
Container2D _cOrnMsm_ElectronicsVME
Definition: RawTask.h:82
ProcessingType _ptype
Definition: DQModule.h:59
int bunchId() const
Definition: AMC13Header.h:17
void reset()
Definition: Flag.h:76
HashFilter _filter_uTCA
Definition: RawTask.h:67
HashFilter _filter_FEDsVME
Definition: RawTask.h:68
virtual void setBinContent(int, int, int)
void dqmthrow(std::string const &msg) const
Definition: Logger.h:15
std::vector< uint32_t > _vhashFEDs
Definition: RawTask.h:63
int const FED_VME_MIN
Definition: Constants.h:47
virtual void _resetMonitors(UpdateFreq)
Definition: RawTask.cc:181
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
RawTask(edm::ParameterSet const &)
Definition: RawTask.cc:3
ContainerSingle2D _cSummaryvsLS
Definition: RawTask.h:89
Container2D _cEvnMsm_ElectronicsVME
Definition: RawTask.h:80
Logger _logger
Definition: DQModule.h:70
edm::EDGetTokenT< HcalUnpackerReport > _tokReport
Definition: RawTask.h:46
std::string _name
Definition: DQModule.h:57
edm::EDGetTokenT< FEDRawDataCollection > _tokFEDs
Definition: RawTask.h:45
bool isHcalDetId() const
int const CRATE_uTCA_MIN
Definition: Constants.h:65
Container2D _cSummaryvsLS_FED
Definition: RawTask.h:88
int getSourceId() const
Definition: HcalDCCHeader.h:32
unsigned int orbitNumber() const
Definition: AMC13Header.h:23
HashFilter _filter_VME
Definition: RawTask.h:66
bool isVMEid() const
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: RawTask.cc:362
bool isFEDHBHE(HcalElectronicsId const &)
Definition: Utilities.cc:124
virtual void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="")
Definition: Container2D.cc:895
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:93
virtual void initialize(std::string const &folder, Quantity *, Quantity *, Quantity *qz=new ValueQuantity(quantity::fN), int debug=0)
const T & get() const
Definition: EventSetup.h:56
uint32_t l1ANumber() const
Get the HTR event number.
Definition: HcalUHTRData.h:104
Container2D _cBcnMsm_ElectronicsVME
Definition: RawTask.h:81
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag _tagFEDs
Definition: RawTask.h:43
std::vector< flag::Flag > _vflags
Definition: RawTask.h:49
int NAMC() const
Definition: AMC13Header.h:25
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
virtual STDTYPE & get(HcalDetId const &)
Definition: ContainerXXX.h:243
int AMCSlot(int i) const
Definition: AMC13Header.h:33
const uint64_t * AMCPayload(int i) const
Definition: AMC13Header.cc:4
virtual void setLumiFlag()
unsigned int getBunchNumber() const
Get the HTR bunch number.
Definition: HcalHTRData.h:115
std::vector< int > getFEDList(HcalElectronicsMap const *)
Definition: Utilities.cc:47
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
std::vector< int > getFEDuTCAList(HcalElectronicsMap const *)
Definition: Utilities.cc:97
virtual bool filter(HcalDetId const &) const
Definition: HashFilter.cc:36
Container2D _cEvnMsm_ElectronicsuTCA
Definition: RawTask.h:83
std::string _subsystem
Definition: DQModule.h:64
edm::InputTag _tagReport
Definition: RawTask.h:44
bool isFEDHO(HcalElectronicsId const &)
Definition: Utilities.cc:171
std::vector< uint32_t > _vcdaqEids
Definition: DQTask.h:65
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:85
virtual void initialize(FilterType ftype, HashType htype, std::vector< uint32_t > const &)
Definition: HashFilter.cc:26
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: RawTask.cc:347
uint16_t AMCId(int i) const
Definition: AMC13Header.h:31
unsigned int getL1ANumber() const
Get the HTR event number.
Definition: HcalHTRData.h:111
unsigned dccId(DetId const &)
unsigned long getDCCEventNumber() const
Definition: HcalDCCHeader.h:36
Readout chain identification for Hcal.
std::string const & instance() const
Definition: InputTag.h:37
bool isFEDHF(HcalElectronicsId const &)
Definition: Utilities.cc:146
int const SLOT_uTCA_MIN
Definition: Constants.h:72
Definition: Run.h:43
HcalElectronicsMap const * _emap
Definition: RawTask.h:59