CMS 3D CMS Logo

DQTask.cc
Go to the documentation of this file.
1 
3 
4 namespace hcaldqm
5 {
6  using namespace constants;
8  DQModule(ps),
9  _cEvsTotal(_name, "EventsTotal"),
10  _cEvsPerLS(_name, "EventsPerLS"),
11  _cRunKeyVal(_name, "RunKeyValue"),
12  _cRunKeyName(_name, "RunKeyName"),
13  _cProcessingTypeName(_name, "ProcessingType"),
14  _procLSs(0)
15  {
16  // tags and Tokens
18  edm::InputTag("rawDataCollector"));
19  _tokRaw = consumes<FEDRawDataCollection>(_tagRaw);
20  }
21 
22  /*
23  * By design, all the sources will ahve this function inherited and will
24  * never override.
25  */
26  /* virtual */ void DQTask::analyze(edm::Event const& e,
27  edm::EventSetup const& es)
28  {
29  this->_resetMonitors(fEvent);
30  _logger.debug(_name+" processing");
31  if (!this->_isApplicable(e))
32  return;
33 
36  this->_process(e, es);
37  }
38 
40  edm::Run const& r,
41  edm::EventSetup const& es)
42  {
43  // initialize some containers to be used by all modules
45 
46  // get the run info FEDs - FEDs registered at cDAQ
47  // and determine if there are any HCAL FEDs in.
48  // push them as ElectronicsIds into the vector
51  "RunInfoRcd"));
52  if (es.find(recordKey))
53  {
55  es.get<RunInfoRcd>().get(ri);
56  std::vector<int> vfeds= ri->m_fed_in;
57  for (std::vector<int>::const_iterator it=vfeds.begin();
58  it!=vfeds.end(); ++it)
59  {
60  if (*it>=constants::FED_VME_MIN && *it<=FED_VME_MAX)
61  _vcdaqEids.push_back(HcalElectronicsId(
64  (*it)-FED_VME_MIN).rawId());
65  else if (*it>=constants::FED_uTCA_MIN &&
67  {
68  std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(*it);
69  _vcdaqEids.push_back(HcalElectronicsId(
70  cspair.first, cspair.second,
71  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
72  }
73  }
74  }
75 
76  // get the Channel Quality Status for all the channels
78  es.get<HcalChannelQualityRcd>().get("withTopo", hcq);
79  const HcalChannelQuality *cq = hcq.product();
80  std::vector<DetId> detids = cq->getAllChannels();
81  for (std::vector<DetId>::const_iterator it=detids.begin();
82  it!=detids.end(); ++it)
83  {
84  // if unknown skip
85  if (HcalGenericDetId(*it).genericSubdet()==
87  continue;
88 
89  if (HcalGenericDetId(*it).isHcalDetId())
90  {
91  HcalDetId did(*it);
92  uint32_t mask = (cq->getValues(did))->getValue();
93  if (mask!=0)
94  {
95  _xQuality.push(did, mask);
96  }
97  }
98  }
99 
100  // book some base guys
106 
107  // fill what you can now
111 
112  // Load conditions and emap
113  es.get<HcalDbRecord>().get(_dbService);
115  }
116 
117  /* virtual */ void DQTask::dqmBeginRun(edm::Run const& r,
118  edm::EventSetup const& es)
119  {
120  this->_resetMonitors(fEvent);
121  this->_resetMonitors(f1LS);
122  this->_resetMonitors(f10LS);
123  this->_resetMonitors(f50LS);
124  this->_resetMonitors(f100LS);
125  }
126 
127  /* virtual */ void DQTask::beginLuminosityBlock(
128  edm::LuminosityBlock const& lb,
129  edm::EventSetup const& es)
130  {
132  this->_resetMonitors(f1LS);
133 
134  if (_procLSs%10==0)
135  this->_resetMonitors(f10LS);
136  if (_procLSs%50==0)
137  this->_resetMonitors(f50LS);
138  if (_procLSs%100==0)
139  this->_resetMonitors(f100LS);
140 
141  }
142 
143  /* virtual */ void DQTask::endLuminosityBlock(
144  edm::LuminosityBlock const& lb,
145  edm::EventSetup const& es)
146  {
147  _procLSs++;
148  }
149 
150  /* virtual */ void DQTask::_resetMonitors(UpdateFreq uf)
151  {
152  // reset per event
153  switch (uf)
154  {
155  case fEvent:
156  break;
157  case f1LS:
158  _evsPerLS = 0;
159  break;
160  case f10LS:
161  break;
162  case f50LS:
163  break;
164  case f100LS:
165  break;
166  default:
167  break;
168  }
169  }
170 
171  /* virtual */ int DQTask::_getCalibType(edm::Event const&e)
172  {
173  int calibType = 0;
174 
176  if (!e.getByToken(_tokRaw, craw))
178  "Collection FEDRawDataCollection isn't available "
179  + _tagRaw.label() + " " + _tagRaw.instance());
180 
181  int badFEDs=0;
182  std::vector<int> types(8,0);
183  for (int i=FED_VME_MIN; i<=FED_VME_MAX; i++)
184  {
185  FEDRawData const& fd = craw->FEDData(i);
186  if (fd.size()<24)
187  {
188  badFEDs++;
189  continue;
190  }
191  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
192  if (cval>7)
193  _logger.warn("Unexpected Calib Type in FED " +
194  std::to_string(i));
195  types[cval]++;
196  }
197  for (int i=FED_uTCA_MIN; i<=FED_uTCA_MAX; i++)
198  {
199  FEDRawData const& fd = craw->FEDData(i);
200  if (fd.size()<24)
201  {
202  badFEDs++;
203  continue;
204  }
205  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
206  if (cval>7)
207  _logger.warn("Unexpected Calib Type in FED " +
208  std::to_string(i));
209  types[cval]++;
210  }
211 
212  int max = 0;
213  for (unsigned int ic=0; ic<8; ic++)
214  {
215  if (types[ic]>max)
216  {
217  max = types[ic];
218  calibType = ic;
219  }
220  }
221  if (max!=(FED_VME_NUM+(FED_uTCA_MAX-FED_uTCA_MIN+1)-badFEDs))
222  _logger.warn("Conflicting Calibration Types found. Assigning " +
223  std::to_string(calibType));
224 
225  return calibType;
226  }
227 }
228 
229 
230 
231 
232 
233 
virtual int _getCalibType(edm::Event const &)
Definition: DQTask.cc:171
T getUntrackedParameter(std::string const &, T const &) const
ContainerI _cEvsTotal
Definition: DQTask.h:52
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DQTask.cc:127
DQTask(edm::ParameterSet const &)
Definition: DQTask.cc:7
void warn(std::string const &msg) const
Definition: Logger.h:20
std::pair< uint16_t, uint16_t > fed2crate(int fed)
Definition: Utilities.cc:12
ContainerS _cRunKeyName
Definition: DQTask.h:55
uint32_t rawId() const
edm::InputTag _tagRaw
Definition: DQTask.h:68
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
void debug(STDTYPE const &msg) const
Definition: Logger.h:31
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: DQTask.cc:117
edm::EDGetTokenT< FEDRawDataCollection > _tokRaw
Definition: DQTask.h:69
UpdateFreq
Definition: DQTask.h:17
ContainerI _cEvsPerLS
Definition: DQTask.h:53
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
int const SPIGOT_MIN
Definition: Constants.h:136
virtual void push(HcalDetId const &, STDTYPE)
Definition: ContainerXXX.h:285
int _procLSs
Definition: DQTask.h:59
const Item * getValues(DetId fId, bool throwOnFail=true) const
int const FIBER_VME_MIN
Definition: Constants.h:141
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int const FED_uTCA_MIN
Definition: Constants.h:103
int const FIBERCH_MIN
Definition: Constants.h:151
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:91
virtual bool _isApplicable(edm::Event const &)
Definition: DQTask.h:48
LuminosityBlockNumber_t luminosityBlock() const
int const FED_uTCA_MAX
Definition: Constants.h:105
ProcessingType _ptype
Definition: DQModule.h:59
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:29
void dqmthrow(std::string const &msg) const
Definition: Logger.h:15
ContainerXXX< uint32_t > _xQuality
Definition: DQTask.h:62
int const FED_VME_MIN
Definition: Constants.h:98
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:33
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DQTask.cc:143
int const FIBER_uTCA_MIN1
Definition: Constants.h:144
virtual void fill(int x)
Definition: ContainerI.h:28
Logger _logger
Definition: DQModule.h:70
std::string _name
Definition: DQModule.h:57
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerS.h:34
HcalElectronicsMap const * _emap
Definition: DQTask.h:73
bool isHcalDetId() const
const T & get() const
Definition: EventSetup.h:55
int const FED_VME_NUM
Definition: Constants.h:101
std::string const & label() const
Definition: InputTag.h:36
virtual void _resetMonitors(UpdateFreq)
Definition: DQTask.cc:150
edm::ESHandle< HcalDbService > _dbService
Definition: DQTask.h:72
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:39
std::string _subsystem
Definition: DQModule.h:64
std::string _runkeyName
Definition: DQModule.h:63
ContainerS _cProcessingTypeName
Definition: DQTask.h:56
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:65
std::string const pTypeNames[nProcessingType]
Definition: DQModule.h:41
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:91
HcalGenericSubdetector genericSubdet() const
int const FED_VME_MAX
Definition: Constants.h:99
ContainerI _cRunKeyVal
Definition: DQTask.h:54
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: DQTask.cc:26
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:43
ib
Definition: cuy.py:660