CMS 3D CMS Logo

DQTask.cc
Go to the documentation of this file.
2 
3 namespace hcaldqm {
4  using namespace constants;
6  : DQModule(ps),
7  _cEvsTotal(_name, "EventsTotal"),
8  _cEvsPerLS(_name, "EventsPerLS"),
9  _cRunKeyVal(_name, "RunKeyValue"),
10  _cRunKeyName(_name, "RunKeyName"),
11  _cProcessingTypeName(_name, "ProcessingType"),
12  _procLSs(0) {
13  // tags and Tokens
14  _tagRaw = ps.getUntrackedParameter<edm::InputTag>("tagRaw", edm::InputTag("rawDataCollector"));
15  _tokRaw = consumes<FEDRawDataCollection>(_tagRaw);
16  }
17 
18  /*
19  * By design, all the sources will ahve this function inherited and will
20  * never override.
21  */
22  void DQTask::analyze(edm::Event const &e, edm::EventSetup const &es) {
23  this->_resetMonitors(fEvent);
24  _logger.debug(_name + " processing");
25  if (!this->_isApplicable(e))
26  return;
27 
28  _evsTotal++;
30  _evsPerLS++;
32  this->_process(e, es);
33  }
34 
36  // initialize some containers to be used by all modules
38 
39  // get the run info FEDs - FEDs registered at cDAQ
40  // and determine if there are any HCAL FEDs in.
41  // push them as ElectronicsIds into the vector
42  if (auto runInfoRec = es.tryToGet<RunInfoRcd>()) {
44  runInfoRec->get(ri);
45  std::vector<int> vfeds = ri->m_fed_in;
46  for (std::vector<int>::const_iterator it = vfeds.begin(); it != vfeds.end(); ++it) {
47  if (*it >= constants::FED_VME_MIN && *it <= FED_VME_MAX)
48  _vcdaqEids.push_back(
50  .rawId());
51  else if (*it >= constants::FED_uTCA_MIN && *it <= FEDNumbering::MAXHCALuTCAFEDID) {
52  std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(*it);
53  _vcdaqEids.push_back(
54  HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
55  }
56  }
57  }
58 
59  // book some base guys
65 
66  // fill what you can now
70 
71  // Load conditions and emap
72  es.get<HcalDbRecord>().get(_dbService);
74  }
75 
76  void DQTask::dqmBeginRun(edm::Run const &r, edm::EventSetup const &es) {
77  this->_resetMonitors(fEvent);
78  this->_resetMonitors(f1LS);
79  this->_resetMonitors(f10LS);
80  this->_resetMonitors(f50LS);
81  this->_resetMonitors(f100LS);
82  }
83 
86  this->_resetMonitors(f1LS);
87 
88  if (_procLSs % 10 == 0)
89  this->_resetMonitors(f10LS);
90  if (_procLSs % 50 == 0)
91  this->_resetMonitors(f50LS);
92  if (_procLSs % 100 == 0)
93  this->_resetMonitors(f100LS);
94 
95  // get the Channel Quality Status for all the channels
96  _xQuality.reset();
98  es.get<HcalChannelQualityRcd>().get("withTopo", hcq);
99  const HcalChannelQuality *cq = hcq.product();
100  std::vector<DetId> detids = cq->getAllChannels();
101  for (std::vector<DetId>::const_iterator it = detids.begin(); it != detids.end(); ++it) {
102  // if unknown skip
104  continue;
105 
106  if (HcalGenericDetId(*it).isHcalDetId()) {
107  HcalDetId did(*it);
108  uint32_t mask = (cq->getValues(did))->getValue();
109  if (mask != 0) {
110  _xQuality.push(did, mask);
111  }
112  }
113  }
114  }
115 
117 
119  // reset per event
120  switch (uf) {
121  case fEvent:
122  break;
123  case f1LS:
124  _evsPerLS = 0;
125  break;
126  case f10LS:
127  break;
128  case f50LS:
129  break;
130  case f100LS:
131  break;
132  default:
133  break;
134  }
135  }
136 
138  int calibType = 0;
139 
141  if (!e.getByToken(_tokRaw, craw))
142  _logger.dqmthrow("Collection FEDRawDataCollection isn't available " + _tagRaw.label() + " " + _tagRaw.instance());
143 
144  int badFEDs = 0;
145  std::vector<int> types(8, 0);
146  for (int i = FED_VME_MIN; i <= FED_VME_MAX; i++) {
147  FEDRawData const &fd = craw->FEDData(i);
148  if (fd.size() < 24) {
149  badFEDs++;
150  continue;
151  }
152  int cval = (int)((HcalDCCHeader const *)(fd.data()))->getCalibType();
153  if (cval > 7)
154  _logger.warn("Unexpected Calib Type in FED " + std::to_string(i));
155  types[cval]++;
156  }
157  for (int i = FED_uTCA_MIN; i <= FED_uTCA_MAX; i++) {
158  FEDRawData const &fd = craw->FEDData(i);
159  if (fd.size() < 24) {
160  badFEDs++;
161  continue;
162  }
163  int cval = (int)((HcalDCCHeader const *)(fd.data()))->getCalibType();
164  if (cval > 7)
165  _logger.warn("Unexpected Calib Type in FED " + std::to_string(i));
166  types[cval]++;
167  }
168 
169  int max = 0;
170  for (unsigned int ic = 0; ic < 8; ic++) {
171  if (types[ic] > max) {
172  max = types[ic];
173  calibType = ic;
174  }
175  }
176  if (max != (FED_VME_NUM + (FED_uTCA_MAX - FED_uTCA_MIN + 1) - badFEDs))
177  _logger.warn("Conflicting Calibration Types found. Assigning " + std::to_string(calibType));
178 
179  return calibType;
180  }
181 } // namespace hcaldqm
constexpr uint32_t rawId() const
virtual int _getCalibType(edm::Event const &)
Definition: DQTask.cc:137
T getUntrackedParameter(std::string const &, T const &) const
ContainerI _cEvsTotal
Definition: DQTask.h:38
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DQTask.cc:84
std::optional< T > tryToGet() const
Definition: EventSetup.h:92
DQTask(edm::ParameterSet const &)
Definition: DQTask.cc:5
void warn(std::string const &msg) const
Definition: Logger.h:13
std::pair< uint16_t, uint16_t > fed2crate(int fed)
Definition: Utilities.cc:10
ContainerS _cRunKeyName
Definition: DQTask.h:41
edm::InputTag _tagRaw
Definition: DQTask.h:54
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void debug(STDTYPE const &msg) const
Definition: Logger.h:20
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: DQTask.cc:76
edm::EDGetTokenT< FEDRawDataCollection > _tokRaw
Definition: DQTask.h:55
UpdateFreq
Definition: DQTask.h:16
ContainerI _cEvsPerLS
Definition: DQTask.h:39
int const SPIGOT_MIN
Definition: Constants.h:116
virtual void push(HcalDetId const &, STDTYPE)
Definition: ContainerXXX.h:227
int _procLSs
Definition: DQTask.h:45
const Item * getValues(DetId fId, bool throwOnFail=true) const
virtual void reset()
Definition: ContainerXXX.h:292
int const FIBER_VME_MIN
Definition: Constants.h:121
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int const FED_uTCA_MIN
Definition: Constants.h:83
int const FIBERCH_MIN
Definition: Constants.h:130
virtual bool _isApplicable(edm::Event const &)
Definition: DQTask.h:34
LuminosityBlockNumber_t luminosityBlock() const
int const FED_uTCA_MAX
Definition: Constants.h:85
ProcessingType _ptype
Definition: DQModule.h:43
virtual void _process(edm::Event const &, edm::EventSetup const &)=0
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
virtual void fill(std::string const &x)
Definition: ContainerS.h:20
void dqmthrow(std::string const &msg) const
Definition: Logger.h:12
ContainerXXX< uint32_t > _xQuality
Definition: DQTask.h:48
int const FED_VME_MIN
Definition: Constants.h:78
std::vector< DetId > getAllChannels() const
std::vector< int > m_fed_in
Definition: RunInfo.h:26
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerI.h:21
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DQTask.cc:116
int const FIBER_uTCA_MIN1
Definition: Constants.h:124
virtual void fill(int x)
Definition: ContainerI.h:19
Logger _logger
Definition: DQModule.h:54
std::string _name
Definition: DQModule.h:41
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerS.h:22
HcalElectronicsMap const * _emap
Definition: DQTask.h:59
bool isHcalDetId() const
int const FED_VME_NUM
Definition: Constants.h:81
std::string const & label() const
Definition: InputTag.h:36
virtual void _resetMonitors(UpdateFreq)
Definition: DQTask.cc:118
edm::ESHandle< HcalDbService > _dbService
Definition: DQTask.h:58
T get() const
Definition: EventSetup.h:71
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
const HcalElectronicsMap * getHcalMapping() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: DQTask.cc:35
std::string _subsystem
Definition: DQModule.h:48
std::string _runkeyName
Definition: DQModule.h:47
ContainerS _cProcessingTypeName
Definition: DQTask.h:42
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:51
std::string const pTypeNames[nProcessingType]
Definition: DQModule.h:28
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:81
HcalGenericSubdetector genericSubdet() const
int const FED_VME_MAX
Definition: Constants.h:79
ContainerI _cRunKeyVal
Definition: DQTask.h:40
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: DQTask.cc:22
T const * product() const
Definition: ESHandle.h:86
Readout chain identification for Hcal.
std::string const & instance() const
Definition: InputTag.h:37
Definition: Run.h:45
ib
Definition: cuy.py:662