CMS 3D CMS Logo

LEDTask.cc
Go to the documentation of this file.
1 
3 
4 using namespace hcaldqm;
5 using namespace hcaldqm::constants;
6 using namespace hcaldqm::filter;
8  DQTask(ps)
9 {
10  // tags
12  edm::InputTag("hcalDigis"));
14  edm::InputTag("hcalDigis"));
16  edm::InputTag("hcalDigis"));
18  edm::InputTag("hcalDigis"));
20  edm::InputTag("tbunpacker"));
21  _tokHBHE = consumes<HBHEDigiCollection>(_tagHBHE);
22  _tokHEP17 = consumes<QIE11DigiCollection>(_tagHEP17);
23  _tokHO = consumes<HODigiCollection>(_tagHO);
24  _tokHF = consumes<QIE10DigiCollection>(_tagHF);
25  _tokTrigger = consumes<HcalTBTriggerData>(_tagTrigger);
26 
27  // constants
28  _lowHBHE = ps.getUntrackedParameter<double>("lowHBHE",
29  20);
30  _lowHEP17 = ps.getUntrackedParameter<double>("lowHEP17",
31  20);
32  _lowHO = ps.getUntrackedParameter<double>("lowHO",
33  20);
34  _lowHF = ps.getUntrackedParameter<double>("lowHF",
35  20);
36 }
37 
39  edm::Run const& r, edm::EventSetup const& es)
40 {
41  if (_ptype==fLocal)
42  if (r.runAuxiliary().run()==1)
43  return;
44 
45  DQTask::bookHistograms(ib, r, es);
46 
48  es.get<HcalDbRecord>().get(dbService);
49  _emap = dbService->getHcalMapping();
50 
51  std::vector<uint32_t> vhashVME;
52  std::vector<uint32_t> vhashuTCA;
53  std::vector<uint32_t> vhashC36;
54  vhashVME.push_back(HcalElectronicsId(constants::FIBERCH_MIN,
56  vhashuTCA.push_back(HcalElectronicsId(CRATE_uTCA_MIN, SLOT_uTCA_MIN,
57  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
59  vhashVME);
61  vhashuTCA);
62 
63  // INITIALIZE
64  _cSignalMean_Subdet.initialize(_name, "SignalMean",
68  _cSignalRMS_Subdet.initialize(_name, "SignalRMS",
72  _cTimingMean_Subdet.initialize(_name, "TimingMean",
76  _cTimingRMS_Subdet.initialize(_name, "TimingRMS",
80 
81  if (_ptype != fOffline) { // hidefed2crate
82  _cSignalMean_FEDVME.initialize(_name, "SignalMean",
92  _cSignalRMS_FEDVME.initialize(_name, "SignalRMS",
102  _cTimingMean_FEDVME.initialize(_name, "TimingMean",
107  _cTimingMean_FEDuTCA.initialize(_name, "TimingMean",
112  _cTimingRMS_FEDVME.initialize(_name, "TimingRMS",
117  _cTimingRMS_FEDuTCA.initialize(_name, "TimingRMS",
122 
127  }
128 
129  _cSignalMean_depth.initialize(_name, "SignalMean",
134  _cSignalRMS_depth.initialize(_name, "SignalRMS",
139  _cTimingMean_depth.initialize(_name, "TimingMean",
144  _cTimingRMS_depth.initialize(_name, "TimingRMS",
149 
150  _cMissing_depth.initialize(_name, "Missing",
155  if (_ptype != fOffline) { // hidefed2crate
156  _cMissing_FEDVME.initialize(_name, "Missing",
166  }
167 
168  // initialize compact containers
174 
175  // BOOK
180 
185 
187  if (_ptype != fOffline) { // hidefed2crate
199  }
200 
206 
208 }
209 
211 {
212  DQTask::_resetMonitors(uf);
213 }
214 
215 /* virtual */ void LEDTask::_dump()
216 {
225 
226  if (_ptype != fOffline) { // hidefed2crate
235  }
236 
237  std::vector<HcalGenericDetId> dids = _emap->allPrecisionId();
238  for (std::vector<HcalGenericDetId>::const_iterator it=dids.begin();
239  it!=dids.end(); ++it)
240  {
241  if (!it->isHcalDetId())
242  continue;
243  HcalDetId did = HcalDetId(it->rawId());
245  int n = _xEntries.get(did);
246  double msig = _xSignalSum.get(did)/n;
247  double mtim = _xTimingSum.get(did)/n;
248  double rsig = sqrt(_xSignalSum2.get(did)/n-msig*msig);
249  double rtim = sqrt(_xTimingSum2.get(did)/n-mtim*mtim);
250 
251  // channels missing or low signal
252  if (n==0)
253  {
254  _cMissing_depth.fill(did);
255  if (_ptype != fOffline) { // hidefed2crate
256  if (eid.isVMEid())
258  else
260  }
261  continue;
262  }
263  _cSignalMean_Subdet.fill(did, msig);
264  _cSignalMean_depth.fill(did, msig);
265  _cSignalRMS_Subdet.fill(did, rsig);
266  _cSignalRMS_depth.fill(did, rsig);
267  _cTimingMean_Subdet.fill(did, mtim);
268  _cTimingMean_depth.fill(did, mtim);
269  _cTimingRMS_Subdet.fill(did, rtim);
270  _cTimingRMS_depth.fill(did, rtim);
271  if (_ptype != fOffline) { // hidefed2crate
272  if (eid.isVMEid())
273  {
275  _cSignalRMS_FEDVME.fill(eid, rsig);
277  _cTimingRMS_FEDVME.fill(eid, rtim);
278  }
279  else
280  {
285  }
286  }
287  }
288 }
289 
290 /* virtual */ void LEDTask::_process(edm::Event const& e,
291  edm::EventSetup const& es)
292 {
297 
298  if (!e.getByToken(_tokHBHE, chbhe))
299  _logger.dqmthrow("Collection HBHEDigiCollection isn't available "
300  + _tagHBHE.label() + " " + _tagHBHE.instance());
301  if (!e.getByToken(_tokHO, cho))
302  _logger.dqmthrow("Collection HODigiCollection isn't available "
303  + _tagHO.label() + " " + _tagHO.instance());
304  if (!e.getByToken(_tokHF, chf))
305  _logger.dqmthrow("Collection QIE10DigiCollection isn't available "
306  + _tagHF.label() + " " + _tagHF.instance());
307  if (!e.getByToken(_tokHEP17, chep17))
308  _logger.dqmthrow("Collection QIE11DigiCollection isn't available "
309  + _tagHEP17.label() + " " + _tagHEP17.instance());
310 
311 // int currentEvent = e.eventAuxiliary().id().event();
312 
313  for (HBHEDigiCollection::const_iterator it=chbhe->begin();
314  it!=chbhe->end(); ++it)
315  {
316  const HBHEDataFrame digi = (const HBHEDataFrame)(*it);
317  HcalDetId did = digi.id();
318  HcalElectronicsId eid = digi.elecId();
319 
320  // Get total charge and apply charge cut
321  CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<HBHEDataFrame>(_dbService, did, digi);
322  //double sumQ = hcaldqm::utilities::sumQ<HBHEDataFrame>(digi, 2.5, 0, digi.size()-1);
323  double sumQ = hcaldqm::utilities::sumQDB<HBHEDataFrame>(_dbService, digi_fC, did, digi, 0, digi.size()-1);
324  if (sumQ<_lowHBHE)
325  continue;
326 
327  //double aveTS = hcaldqm::utilities::aveTS<HBHEDataFrame>(digi, 2.5, 0,digi.size()-1);
328  double aveTS = hcaldqm::utilities::aveTSDB<HBHEDataFrame>(_dbService, digi_fC, did, digi, 0, digi.size()-1);
329 
330  _xSignalSum.get(did)+=sumQ;
331  _xSignalSum2.get(did)+=sumQ*sumQ;
332  _xTimingSum.get(did)+=aveTS;
333  _xTimingSum2.get(did)+=aveTS*aveTS;
334  _xEntries.get(did)++;
335 
336  if (_ptype != fOffline) { // hidefed2crate
337  for (int i=0; i<digi.size(); i++) {
338  //_cShapeCut_FEDSlot.fill(eid, i, digi.sample(i).nominal_fC()-2.5);
339  _cShapeCut_FEDSlot.fill(eid, i, hcaldqm::utilities::adc2fCDBMinusPedestal<HBHEDataFrame>(_dbService, digi_fC, did, digi, i));
340  }
341  }
342  }
343 
344  for (QIE11DigiCollection::const_iterator it=chep17->begin(); it!=chep17->end();
345  ++it)
346  {
347  const QIE11DataFrame digi = static_cast<const QIE11DataFrame>(*it);
348  HcalDetId const& did = digi.detid();
349  if (did.subdet() != HcalEndcap) {
350  continue;
351  }
352  uint32_t rawid = _ehashmap.lookup(did);
353  if (!rawid) {
354  std::string unknown_id_string="Detid "+std::to_string(int(did))+", ieta "+std::to_string(did.ieta());
355  unknown_id_string+=", iphi "+std::to_string(did.iphi())+", depth "+std::to_string(did.depth());
356  unknown_id_string+=", is not in emap. Skipping.";
357  _logger.warn(unknown_id_string);
358  continue;
359  }
360  HcalElectronicsId const& eid(rawid);
361 
362  CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<QIE11DataFrame>(_dbService, did, digi);
363  //double sumQ = hcaldqm::utilities::sumQ_v10<QIE11DataFrame>(digi, 2.5, 0, digi.samples()-1);
364  double sumQ = hcaldqm::utilities::sumQDB<QIE11DataFrame>(_dbService, digi_fC, did, digi, 0, digi.samples()-1);
365  if (sumQ<_lowHEP17)
366  continue;
367 
368  //double aveTS = hcaldqm::utilities::aveTS_v10<QIE11DataFrame>(digi, 2.5, 0,digi.samples()-1);
369  double aveTS = hcaldqm::utilities::aveTSDB<QIE11DataFrame>(_dbService, digi_fC, did, digi, 0, digi.size()-1);
370 
371  _xSignalSum.get(did)+=sumQ;
372  _xSignalSum2.get(did)+=sumQ*sumQ;
373  _xTimingSum.get(did)+=aveTS;
374  _xTimingSum2.get(did)+=aveTS*aveTS;
375  _xEntries.get(did)++;
376 
377  if (_ptype != fOffline) { // hidefed2crate
378  for (int i=0; i<digi.samples(); i++) {
379  //_cShapeCut_FEDSlot.fill(eid, i, digi.sample(i).nominal_fC()-2.5);
380  _cShapeCut_FEDSlot.fill(eid, i, hcaldqm::utilities::adc2fCDBMinusPedestal<QIE11DataFrame>(_dbService, digi_fC, did, digi, i));
381  }
382  }
383  }
385  it!=cho->end(); ++it)
386  {
387  const HODataFrame digi = (const HODataFrame)(*it);
388  HcalDetId did = digi.id();
389  HcalElectronicsId eid = digi.elecId();
390  //double sumQ = hcaldqm::utilities::sumQ<HODataFrame>(digi, 8.5, 0, digi.size()-1);
391  CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<HODataFrame>(_dbService, did, digi);
392  double sumQ = hcaldqm::utilities::sumQDB<HODataFrame>(_dbService, digi_fC, did, digi, 0, digi.size()-1);
393  if (sumQ<_lowHO)
394  continue;
395 
396  //double aveTS = hcaldqm::utilities::aveTS<HODataFrame>(digi, 8.5, 0, digi.size()-1);
397  double aveTS = hcaldqm::utilities::aveTSDB<HODataFrame>(_dbService, digi_fC, did, digi, 0, digi.size()-1);
398 
399  _xSignalSum.get(did)+=sumQ;
400  _xSignalSum2.get(did)+=sumQ*sumQ;
401  _xTimingSum.get(did)+=aveTS;
402  _xTimingSum2.get(did)+=aveTS*aveTS;
403  _xEntries.get(did)++;
404 
405  if (_ptype != fOffline) { // hidefed2crate
406  for (int i=0; i<digi.size(); i++) {
407  //_cShapeCut_FEDSlot.fill(eid, i, digi.sample(i).nominal_fC()-8.5);
408  _cShapeCut_FEDSlot.fill(eid, i, hcaldqm::utilities::adc2fCDBMinusPedestal<HODataFrame>(_dbService, digi_fC, did, digi, i));
409  }
410  }
411  }
413  it!=chf->end(); ++it)
414  {
415  const QIE10DataFrame digi = static_cast<const QIE10DataFrame>(*it);
416  HcalDetId did = digi.detid();
417  if (did.subdet() != HcalForward) {
418  continue;
419  }
421  //double sumQ = hcaldqm::utilities::sumQ_v10<QIE10DataFrame>(digi, 2.5, 0, digi.samples()-1);
422  CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<QIE10DataFrame>(_dbService, did, digi);
423  double sumQ = hcaldqm::utilities::sumQDB<QIE10DataFrame>(_dbService, digi_fC, did, digi, 0, digi.samples()-1);
424  if (sumQ<_lowHF)
425  continue;
426 
427  //double aveTS = hcaldqm::utilities::aveTS_v10<QIE10DataFrame>(digi, 2.5, 0, digi.samples()-1);
428  double aveTS = hcaldqm::utilities::aveTSDB<QIE10DataFrame>(_dbService, digi_fC, did, digi, 0, digi.size()-1);
429 
430  _xSignalSum.get(did)+=sumQ;
431  _xSignalSum2.get(did)+=sumQ*sumQ;
432  _xTimingSum.get(did)+=aveTS;
433  _xTimingSum2.get(did)+=aveTS*aveTS;
434  _xEntries.get(did)++;
435 
436  if (_ptype != fOffline) { // hidefed2crate
437  for (int i = 0; i < digi.samples(); ++i) {
438  // Note: this used to be digi.sample(i).nominal_fC() - 2.5, but this branch doesn't exist in QIE10DataFrame.
439  // Instead, use lookup table.
440  //_cShapeCut_FEDSlot.fill(eid, i, constants::adc2fC[digi[i].adc()]);
441  _cShapeCut_FEDSlot.fill(eid, i, hcaldqm::utilities::adc2fCDBMinusPedestal<QIE10DataFrame>(_dbService, digi_fC, did, digi, i));
442  }
443  }
444  }
445 
446  if (_ptype==fOnline && _evsTotal>0 &&
448  this->_dump();
449 }
450 
451 /* virtual */ bool LEDTask::_isApplicable(edm::Event const& e)
452 {
453  if (_ptype!=fOnline)
454  {
455  // local
457  if (!e.getByToken(_tokTrigger, ctrigger))
458  _logger.dqmthrow("Collection HcalTBTriggerData isn't available "
459  + _tagTrigger.label() + " " + _tagTrigger.instance());
460  return ctrigger->wasLEDTrigger();
461  }
462 
463  return false;
464 }
465 
467 
468 
int samples() const
total number of samples in the digi
DetId detid() const
Get the detector id.
T getUntrackedParameter(std::string const &, T const &) const
double aveTS(DIGI const &digi, double ped=0, int i=0, int j=3)
Definition: Utilities.h:108
hcaldqm::Container2D _cMissing_FEDuTCA
Definition: LEDTask.h:102
hcaldqm::Container2D _cMissing_FEDVME
Definition: LEDTask.h:101
LEDTask(edm::ParameterSet const &)
Definition: LEDTask.cc:7
hcaldqm::ContainerProf2D _cSignalMean_depth
Definition: LEDTask.h:85
hcaldqm::ContainerProf2D _cTimingMean_FEDuTCA
Definition: LEDTask.h:93
virtual void initialize(std::string const &folder, hashfunctions::HashType, Quantity *, Quantity *qy=new ValueQuantity(quantity::fN), int debug=0)
Definition: Container1D.cc:40
int const CRATE_VME_MIN
Definition: Constants.h:111
double _lowHBHE
Definition: LEDTask.h:63
void warn(std::string const &msg) const
Definition: Logger.h:20
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
hcaldqm::ContainerProf2D _cTimingMean_depth
Definition: LEDTask.h:87
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
hcaldqm::ContainerProf2D _cSignalMean_FEDVME
Definition: LEDTask.h:90
hcaldqm::Container2D _cMissing_depth
Definition: LEDTask.h:100
bool wasLEDTrigger() const
returns true if this was a LED trigger
edm::EDGetTokenT< HcalTBTriggerData > _tokTrigger
Definition: LEDTask.h:55
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
double _lowHF
Definition: LEDTask.h:66
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< HBHEDigiCollection > _tokHBHE
Definition: LEDTask.h:51
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
hcaldqm::ContainerProf2D _cTimingMean_FEDVME
Definition: LEDTask.h:92
UpdateFreq
Definition: DQTask.h:17
std::vector< HBHEDataFrame >::const_iterator const_iterator
int const SPIGOT_MIN
Definition: Constants.h:136
void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="") override
edm::InputTag _tagHO
Definition: LEDTask.h:48
const_iterator begin() const
hcaldqm::ContainerProf2D _cSignalRMS_FEDVME
Definition: LEDTask.h:94
edm::InputTag _tagHF
Definition: LEDTask.h:49
int const FIBER_VME_MIN
Definition: Constants.h:141
hcaldqm::filter::HashFilter _filter_uTCA
Definition: LEDTask.h:59
hcaldqm::ContainerXXX< int > _xEntries
Definition: LEDTask.h:71
const HcalElectronicsId & elecId() const
Definition: HODataFrame.h:24
void bookHistograms(fwlite::EventContainer &eventCont)
const HcalDetId & id() const
Definition: HODataFrame.h:23
int const FIBERCH_MIN
Definition: Constants.h:151
hcaldqm::ContainerXXX< double > _xTimingSum
Definition: LEDTask.h:72
hcaldqm::ContainerProf2D _cSignalRMS_FEDuTCA
Definition: LEDTask.h:95
int depth() const
get the tower depth
Definition: HcalDetId.cc:129
ProcessingType _ptype
Definition: DQModule.h:59
virtual void fill(uint32_t)
Definition: Container1D.cc:82
virtual void reset()
Definition: Container1D.cc:65
double _lowHO
Definition: LEDTask.h:65
void dqmthrow(std::string const &msg) const
Definition: Logger.h:15
T sqrt(T t)
Definition: SSEVec.h:18
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
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:144
DetId detid() const
Get the detector id.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: LEDTask.cc:38
std::vector< HcalGenericDetId > allPrecisionId() const
Logger _logger
Definition: DQModule.h:70
RunAuxiliary const & runAuxiliary() const override
Definition: Run.h:62
edm::InputTag _tagTrigger
Definition: LEDTask.h:50
std::string _name
Definition: DQModule.h:57
HcalElectronicsMap const * _emap
Definition: DQTask.h:73
hcaldqm::ContainerProf2D _cSignalMean_FEDuTCA
Definition: LEDTask.h:91
hcaldqm::ContainerProf2D _cTimingRMS_depth
Definition: LEDTask.h:88
edm::InputTag _tagHEP17
Definition: LEDTask.h:47
edm::EDGetTokenT< QIE10DigiCollection > _tokHF
Definition: LEDTask.h:54
edm::EDGetTokenT< QIE11DigiCollection > _tokHEP17
Definition: LEDTask.h:52
hcaldqm::Container1D _cSignalRMS_Subdet
Definition: LEDTask.h:77
void initialize(std::string const &folder, hashfunctions::HashType, Quantity *, Quantity *, Quantity *qz=new ValueQuantity(quantity::fEnergy), int debug=0) override
edm::InputTag _tagHBHE
Definition: LEDTask.h:46
hcaldqm::filter::HashFilter _filter_VME
Definition: LEDTask.h:60
int const CRATE_uTCA_MIN
Definition: Constants.h:116
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:124
int const CALIBEVENTS_MIN
Definition: Constants.h:265
hcaldqm::ContainerXXX< double > _xTimingSum2
Definition: LEDTask.h:73
hcaldqm::ContainerProf2D _cTimingRMS_FEDVME
Definition: LEDTask.h:96
hcaldqm::ContainerProf2D _cTimingRMS_FEDuTCA
Definition: LEDTask.h:97
edm::EDGetTokenT< HODigiCollection > _tokHO
Definition: LEDTask.h:53
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:99
hcaldqm::ContainerXXX< double > _xSignalSum
Definition: LEDTask.h:69
virtual void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="")
Definition: Container1D.cc:957
const T & get() const
Definition: EventSetup.h:55
double _lowHEP17
Definition: LEDTask.h:64
void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="") override
void initialize(std::string const &folder, hashfunctions::HashType, Quantity *, Quantity *, int debug=0) override
void _process(edm::Event const &, edm::EventSetup const &) override
Definition: LEDTask.cc:290
hcaldqm::Container1D _cTimingMean_Subdet
Definition: LEDTask.h:78
const HcalElectronicsId & elecId() const
Definition: HBHEDataFrame.h:23
void _resetMonitors(hcaldqm::UpdateFreq) override
Definition: LEDTask.cc:210
std::string const & label() const
Definition: InputTag.h:36
const_iterator end() const
hcaldqm::ContainerProf2D _cSignalRMS_depth
Definition: LEDTask.h:86
bool _isApplicable(edm::Event const &) override
Definition: LEDTask.cc:451
virtual STDTYPE & get(HcalDetId const &)
Definition: ContainerXXX.h:249
edm::ESHandle< HcalDbService > _dbService
Definition: DQTask.h:72
hcaldqm::Container1D _cTimingRMS_Subdet
Definition: LEDTask.h:79
void fill(HcalDetId const &) override
Definition: Container2D.cc:59
virtual void _dump()
Definition: LEDTask.cc:215
const HcalElectronicsMap * getHcalMapping() const
std::string _subsystem
Definition: DQModule.h:64
hcaldqm::ContainerXXX< double > _xSignalSum2
Definition: LEDTask.h:70
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
hcaldqm::electronicsmap::ElectronicsMap _ehashmap
Definition: LEDTask.h:58
hcaldqm::ContainerProf1D _cShapeCut_FEDSlot
Definition: LEDTask.h:82
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
void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="") override
Definition: Container2D.cc:895
int samples() const
total number of samples in the digi
Readout chain identification for Hcal.
std::string const & instance() const
Definition: InputTag.h:37
RunNumber_t run() const
Definition: RunAuxiliary.h:41
int const SLOT_uTCA_MIN
Definition: Constants.h:123
const_iterator begin() const
Definition: Run.h:43
ib
Definition: cuy.py:660
double sumQ(DIGI const &digi, double ped, int i=0, int j=3)
Definition: Utilities.h:122
hcaldqm::Container1D _cSignalMean_Subdet
Definition: LEDTask.h:76