CMS 3D CMS Logo

DQTask.cc
Go to the documentation of this file.
2 
5 
6 namespace hcaldqm {
7  using namespace constants;
9  : DQModule(ps),
10  _cEvsTotal(_name, "EventsTotal"),
11  _cEvsPerLS(_name, "EventsPerLS"),
12  _cRunKeyVal(_name, "RunKeyValue"),
13  _cRunKeyName(_name, "RunKeyName"),
14  _cProcessingTypeName(_name, "ProcessingType"),
15  _procLSs(0),
16  hcalDbServiceToken_(esConsumes<HcalDbService, HcalDbRecord, edm::Transition::BeginRun>()),
17  runInfoToken_(esConsumes<RunInfo, RunInfoRcd, edm::Transition::BeginRun>()),
18  hcalChannelQualityToken_(
19  esConsumes<HcalChannelQuality, HcalChannelQualityRcd, edm::Transition::BeginLuminosityBlock>(
20  edm::ESInputTag("", "withTopo"))) {
21  // tags and Tokens
22  _tagRaw = ps.getUntrackedParameter<edm::InputTag>("tagRaw", edm::InputTag("rawDataCollector"));
23  _tokRaw = consumes<FEDRawDataCollection>(_tagRaw);
24  }
25 
26  /*
27  * By design, all the sources will ahve this function inherited and will
28  * never override.
29  */
30  void DQTask::analyze(edm::Event const &e, edm::EventSetup const &es) {
31  this->_resetMonitors(fEvent);
32  _logger.debug(_name + " processing");
33  if (!this->_isApplicable(e))
34  return;
35 
36  _evsTotal++;
38 
39  auto lumiCache = luminosityBlockCache(e.getLuminosityBlock().index());
40  lumiCache->EvtCntLS++;
41  _evsPerLS = lumiCache->EvtCntLS;
43 
44  this->_process(e, es);
45  }
46 
47  void DQTask::bookHistograms(DQMStore::IBooker &ib, edm::Run const &r, edm::EventSetup const &es) {
48  // initialize some containers to be used by all modules
50 
51  // get the run info FEDs - FEDs registered at cDAQ
52  // and determine if there are any HCAL FEDs in.
53  // push them as ElectronicsIds into the vector
54  if (auto runInfoRec = es.tryToGet<RunInfoRcd>()) {
55  const RunInfo &runInfo = es.getData(runInfoToken_);
56  std::vector<int> vfeds = runInfo.m_fed_in;
57  for (std::vector<int>::const_iterator it = vfeds.begin(); it != vfeds.end(); ++it) {
58  if (*it >= constants::FED_VME_MIN && *it <= FED_VME_MAX)
59  _vcdaqEids.push_back(
61  .rawId());
62  else if (*it >= constants::FED_uTCA_MIN && *it <= FEDNumbering::MAXHCALuTCAFEDID) {
63  std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(*it);
64  _vcdaqEids.push_back(
65  HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
66  }
67  }
68  }
69 
70  // book some base guys
76 
77  // fill what you can now
81 
82  // Load conditions and emap
85  }
86 
87  void DQTask::dqmBeginRun(edm::Run const &, edm::EventSetup const &) {
88  this->_resetMonitors(fEvent);
89  this->_resetMonitors(f1LS);
90  this->_resetMonitors(f10LS);
91  this->_resetMonitors(f50LS);
92  this->_resetMonitors(f100LS);
93  }
94 
95  std::shared_ptr<hcaldqm::Cache> DQTask::globalBeginLuminosityBlock(edm::LuminosityBlock const &lb,
96  edm::EventSetup const &es) const {
97  auto d = std::make_shared<hcaldqm::Cache>();
98  d->currentLS = lb.luminosityBlock();
99  d->EvtCntLS = 0;
100 
101  /* //// these resets were not useful anymore
102  this->_resetMonitors(f1LS);
103  if (_procLSs % 10 == 0)
104  this->_resetMonitors(f10LS);
105  if (_procLSs % 50 == 0)
106  this->_resetMonitors(f50LS);
107  if (_procLSs % 100 == 0)
108  this->_resetMonitors(f100LS);
109 */
110 
111  // get the Channel Quality Status for all the channels
112  d->xQuality.initialize(hashfunctions::fDChannel);
113  d->xQuality.reset();
115  std::vector<DetId> detids = cq.getAllChannels();
116  for (std::vector<DetId>::const_iterator it = detids.begin(); it != detids.end(); ++it) {
117  // if unknown skip
119  continue;
120 
121  if (HcalGenericDetId(*it).isHcalDetId()) {
122  HcalDetId did(*it);
123  uint32_t mask = (cq.getValues(did))->getValue();
124  if (mask != 0) {
125  d->xQuality.push(did, mask);
126  }
127  }
128  }
129  return d;
130  }
131 
133 
135  // reset per event
136  switch (uf) {
137  case fEvent:
138  break;
139  case f1LS:
140  _evsPerLS = 0;
141  break;
142  case f10LS:
143  break;
144  case f50LS:
145  break;
146  case f100LS:
147  break;
148  default:
149  break;
150  }
151  }
152 
154  int calibType = 0;
155 
157  if (!e.getByToken(_tokRaw, craw))
158  _logger.dqmthrow("Collection FEDRawDataCollection isn't available " + _tagRaw.label() + " " + _tagRaw.instance());
159 
160  int badFEDs = 0;
161  std::vector<int> types(8, 0);
162  for (int i = FED_VME_MIN; i <= FED_VME_MAX; i++) {
163  FEDRawData const &fd = craw->FEDData(i);
164  if (fd.size() < 24) {
165  badFEDs++;
166  continue;
167  }
168  int cval = (int)((HcalDCCHeader const *)(fd.data()))->getCalibType();
169  if (cval > 7)
170  _logger.warn("Unexpected Calib Type in FED " + std::to_string(i));
171  types[cval]++;
172  }
173  for (int i = FED_uTCA_MIN; i <= FED_uTCA_MAX; i++) {
174  FEDRawData const &fd = craw->FEDData(i);
175  if (fd.size() < 24) {
176  badFEDs++;
177  continue;
178  }
179  int cval = (int)((HcalDCCHeader const *)(fd.data()))->getCalibType();
180  if (cval > 7)
181  _logger.warn("Unexpected Calib Type in FED " + std::to_string(i));
182  types[cval]++;
183  }
184 
185  int max = 0;
186  for (unsigned int ic = 0; ic < 8; ic++) {
187  if (types[ic] > max) {
188  max = types[ic];
189  calibType = ic;
190  }
191  }
192  if (max != (FED_VME_NUM + (FED_uTCA_MAX - FED_uTCA_MIN + 1) - badFEDs))
193  _logger.warn("Conflicting Calibration Types found. Assigning " + std::to_string(calibType));
194 
195  return calibType;
196  }
197 } // namespace hcaldqm
hcaldqm::constants::FED_VME_MIN
const int FED_VME_MIN
Definition: Constants.h:80
hcaldqm::ContainerXXX::initialize
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:81
hcaldqm::DQTask::globalEndLuminosityBlock
void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DQTask.cc:132
hcaldqm::DQTask::_tokRaw
edm::EDGetTokenT< FEDRawDataCollection > _tokRaw
Definition: DQTask.h:72
mps_fire.i
i
Definition: mps_fire.py:355
hcaldqm::UpdateFreq
UpdateFreq
Definition: DQTask.h:32
hcaldqm::DQModule
Definition: DQModule.h:30
hcaldqm::DQTask::_cRunKeyName
ContainerS _cRunKeyName
Definition: DQTask.h:58
hcaldqm::DQTask::_tagRaw
edm::InputTag _tagRaw
Definition: DQTask.h:71
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
HcalGenericDetId
Definition: HcalGenericDetId.h:15
ESInputTag
hcaldqm::DQTask::globalBeginLuminosityBlock
std::shared_ptr< hcaldqm::Cache > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const override
Definition: DQTask.cc:95
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
HcalChannelQualityRcd
Definition: HcalChannelQualityRcd.h:8
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
hcaldqm
Definition: Constants.h:8
hcaldqm::constants::SPIGOT_MIN
const int SPIGOT_MIN
Definition: Constants.h:118
hcaldqm::DQTask::_procLSs
int _procLSs
Definition: DQTask.h:62
hcaldqm::DQModule::_evsTotal
int _evsTotal
Definition: DQModule.h:50
hcaldqm::ContainerI::fill
virtual void fill(int x)
Definition: ContainerI.h:19
hcaldqm::constants::FIBER_uTCA_MIN1
const int FIBER_uTCA_MIN1
Definition: Constants.h:126
RunInfo::m_fed_in
std::vector< int > m_fed_in
Definition: RunInfo.h:25
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HcalChannelQuality
Definition: HcalChannelQuality.h:17
constants
hcaldqm::DQModule::_runkeyVal
int _runkeyVal
Definition: DQModule.h:46
hcaldqm::DQModule::_ptype
ProcessingType _ptype
Definition: DQModule.h:43
hcaldqm::DQTask::hcalDbServiceToken_
edm::ESGetToken< HcalDbService, HcalDbRecord > hcalDbServiceToken_
Definition: DQTask.h:75
edm::Handle
Definition: AssociativeIterator.h:50
hcaldqm::DQTask::_cEvsPerLS
ContainerI _cEvsPerLS
Definition: DQTask.h:56
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
HcalDbService::getHcalMapping
const HcalElectronicsMap * getHcalMapping() const
Definition: HcalDbService.cc:343
FEDRawData
Definition: FEDRawData.h:19
hcaldqm::DQTask::_xQuality
ContainerXXX< uint32_t > _xQuality
Definition: DQTask.h:65
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
hcaldqm::DQTask::dqmBeginRun
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: DQTask.cc:87
ztee.fd
fd
Definition: ztee.py:136
RunInfo
Definition: RunInfo.h:18
hcaldqm::DQTask::runInfoToken_
edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
Definition: DQTask.h:76
edm::EventSetup::tryToGet
std::optional< T > tryToGet() const
Definition: EventSetup.h:94
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
HcalGenericDetId::HcalGenUnknown
Definition: HcalGenericDetId.h:27
hcaldqm::constants::FIBER_VME_MIN
const int FIBER_VME_MIN
Definition: Constants.h:123
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
hcaldqm::DQModule::_name
std::string _name
Definition: DQModule.h:41
Logger::warn
void warn(std::string const &msg) const
Definition: Logger.h:13
hcaldqm::constants::FIBERCH_MIN
const int FIBERCH_MIN
Definition: Constants.h:132
Transition.h
hcaldqm::constants::FED_VME_NUM
const int FED_VME_NUM
Definition: Constants.h:83
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
RunInfoRcd
Definition: RunSummaryRcd.h:26
hcaldqm::ContainerS::fill
virtual void fill(std::string const &x)
Definition: ContainerS.h:20
hcaldqm::DQTask::_isApplicable
virtual bool _isApplicable(edm::Event const &)
Definition: DQTask.h:51
Logger::dqmthrow
void dqmthrow(std::string const &msg) const
Definition: Logger.h:12
hcaldqm::DQModule::_runkeyName
std::string _runkeyName
Definition: DQModule.h:47
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
edm::Transition
Transition
Definition: Transition.h:12
hcaldqm::pTypeNames
const std::string pTypeNames[nProcessingType]
Definition: DQModule.h:28
hcaldqm::hashfunctions::fDChannel
Definition: HashFunctions.h:134
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
hcaldqm::constants::FED_uTCA_MIN
const int FED_uTCA_MIN
Definition: Constants.h:85
hcaldqm::DQTask::_process
virtual void _process(edm::Event const &, edm::EventSetup const &)=0
HcalCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: HcalCondObjectContainer.h:312
hcaldqm::DQModule::_logger
Logger _logger
Definition: DQModule.h:54
reco::JetExtendedAssociation::getValue
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
Definition: JetExtendedAssociation.cc:50
hcaldqm::constants::FED_VME_MAX
const int FED_VME_MAX
Definition: Constants.h:81
FEDNumbering::MAXHCALuTCAFEDID
Definition: FEDNumbering.h:104
HcalDetId
Definition: HcalDetId.h:12
createfilelist.int
int
Definition: createfilelist.py:10
hcaldqm::ContainerI::book
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerI.h:21
hcaldqm::DQTask::_dbService
edm::ESHandle< HcalDbService > _dbService
Definition: DQTask.h:79
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:141
cuy.ib
ib
Definition: cuy.py:662
edm::EventSetup
Definition: EventSetup.h:57
hcaldqm::f1LS
Definition: DQTask.h:32
hcaldqm::DQTask::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DQTask.cc:47
hcaldqm::f100LS
Definition: DQTask.h:32
hcaldqm::DQTask::_vcdaqEids
std::vector< uint32_t > _vcdaqEids
Definition: DQTask.h:68
hcaldqm::DQModule::_subsystem
std::string _subsystem
Definition: DQModule.h:48
HcalDCCHeader
Definition: HcalDCCHeader.h:17
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:113
alignCSCRings.r
r
Definition: alignCSCRings.py:93
types
types
Definition: AlignPCLThresholds_PayloadInspector.cc:30
hcaldqm::fEvent
Definition: DQTask.h:32
DQTask.h
HcalDbService
Definition: HcalDbService.h:26
ESInputTag.h
hcaldqm::DQTask::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: DQTask.cc:30
HcalGenericDetId::isHcalDetId
bool isHcalDetId() const
Definition: HcalGenericDetId.cc:64
HcalGenericDetId::genericSubdet
HcalGenericSubdetector genericSubdet() const
Definition: HcalGenericDetId.cc:21
HcalElectronicsId::rawId
constexpr uint32_t rawId() const
Definition: HcalElectronicsId.h:59
hcaldqm::ContainerS::book
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerS.h:22
hcaldqm::DQTask::_emap
const HcalElectronicsMap * _emap
Definition: DQTask.h:80
hcaldqm::f10LS
Definition: DQTask.h:32
hcaldqm::utilities::fed2crate
std::pair< uint16_t, uint16_t > fed2crate(int fed)
Definition: Utilities.cc:10
hcaldqm::DQTask::hcalChannelQualityToken_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > hcalChannelQualityToken_
Definition: DQTask.h:77
ztail.d
d
Definition: ztail.py:151
hcaldqm::DQTask::_getCalibType
virtual int _getCalibType(edm::Event const &)
Definition: DQTask.cc:153
HcalDbRecord
Definition: HcalDbRecord.h:30
hcaldqm::DQTask::_cProcessingTypeName
ContainerS _cProcessingTypeName
Definition: DQTask.h:59
hcaldqm::DQTask::_cEvsTotal
ContainerI _cEvsTotal
Definition: DQTask.h:55
Logger::debug
void debug(STDTYPE const &msg) const
Definition: Logger.h:20
hcaldqm::DQTask::_resetMonitors
virtual void _resetMonitors(UpdateFreq)
Definition: DQTask.cc:134
hcaldqm::DQTask::DQTask
DQTask(edm::ParameterSet const &)
Definition: DQTask.cc:8
edm::Event
Definition: Event.h:73
hcaldqm::f50LS
Definition: DQTask.h:32
edm::InputTag
Definition: InputTag.h:15
hcaldqm::DQTask::_cRunKeyVal
ContainerI _cRunKeyVal
Definition: DQTask.h:57
hcaldqm::constants::FED_uTCA_MAX
const int FED_uTCA_MAX
Definition: Constants.h:87
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
hcaldqm::DQModule::_evsPerLS
int _evsPerLS
Definition: DQModule.h:51