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