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 
113  /* virtual */ void DQTask::dqmBeginRun(edm::Run const& r,
114  edm::EventSetup const& es)
115  {
116  this->_resetMonitors(fEvent);
117  this->_resetMonitors(f1LS);
118  this->_resetMonitors(f10LS);
119  this->_resetMonitors(f50LS);
120  this->_resetMonitors(f100LS);
121  }
122 
123  /* virtual */ void DQTask::beginLuminosityBlock(
124  edm::LuminosityBlock const& lb,
125  edm::EventSetup const& es)
126  {
128  this->_resetMonitors(f1LS);
129 
130  if (_procLSs%10==0)
131  this->_resetMonitors(f10LS);
132  if (_procLSs%50==0)
133  this->_resetMonitors(f50LS);
134  if (_procLSs%100==0)
135  this->_resetMonitors(f100LS);
136 
137  }
138 
139  /* virtual */ void DQTask::endLuminosityBlock(
140  edm::LuminosityBlock const& lb,
141  edm::EventSetup const& es)
142  {
143  _procLSs++;
144  }
145 
146  /* virtual */ void DQTask::_resetMonitors(UpdateFreq uf)
147  {
148  // reset per event
149  switch (uf)
150  {
151  case fEvent:
152  break;
153  case f1LS:
154  _evsPerLS = 0;
155  break;
156  case f10LS:
157  break;
158  case f50LS:
159  break;
160  case f100LS:
161  break;
162  default:
163  break;
164  }
165  }
166 
167  /* virtual */ int DQTask::_getCalibType(edm::Event const&e)
168  {
169  int calibType = 0;
170 
172  if (!e.getByToken(_tokRaw, craw))
174  "Collection FEDRawDataCollection isn't available "
175  + _tagRaw.label() + " " + _tagRaw.instance());
176 
177  int badFEDs=0;
178  std::vector<int> types(8,0);
179  for (int i=FED_VME_MIN; i<=FED_VME_MAX; i++)
180  {
181  FEDRawData const& fd = craw->FEDData(i);
182  if (fd.size()<24)
183  {
184  badFEDs++;
185  continue;
186  }
187  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
188  if (cval>7)
189  _logger.warn("Unexpected Calib Type in FED " +
190  boost::lexical_cast<std::string>(i));
191  types[cval]++;
192  }
193  for (int i=FED_uTCA_MIN; i<=FED_uTCA_MAX; i++)
194  {
195  FEDRawData const& fd = craw->FEDData(i);
196  if (fd.size()<24)
197  {
198  badFEDs++;
199  continue;
200  }
201  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
202  if (cval>7)
203  _logger.warn("Unexpected Calib Type in FED " +
204  boost::lexical_cast<std::string>(i));
205  types[cval]++;
206  }
207 
208  int max = 0;
209  for (unsigned int ic=0; ic<8; ic++)
210  {
211  if (types[ic]>max)
212  {
213  max = types[ic];
214  calibType = ic;
215  }
216  }
217  if (max!=(FED_VME_NUM+(FED_uTCA_MAX-FED_uTCA_MIN+1)-badFEDs))
218  _logger.warn("Conflicting Calibration Types found. Assigning " +
219  boost::lexical_cast<std::string>(calibType));
220 
221  return calibType;
222  }
223 }
224 
225 
226 
227 
228 
229 
virtual int _getCalibType(edm::Event const &)
Definition: DQTask.cc:167
T getUntrackedParameter(std::string const &, T const &) const
ContainerI _cEvsTotal
Definition: DQTask.h:52
virtual void analyze(edm::Event const &, edm::EventSetup const &)
Definition: DQTask.cc:26
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQTask.cc:139
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:13
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:457
void debug(STDTYPE const &msg) const
Definition: Logger.h:31
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:93
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:98
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int const FED_uTCA_MIN
Definition: Constants.h:60
int const FIBERCH_MIN
Definition: Constants.h:108
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:62
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:55
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
int const FIBER_uTCA_MIN1
Definition: Constants.h:101
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
bool isHcalDetId() const
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQTask.cc:123
const T & get() const
Definition: EventSetup.h:56
int const FED_VME_NUM
Definition: Constants.h:58
std::string const & label() const
Definition: InputTag.h:36
virtual void _resetMonitors(UpdateFreq)
Definition: DQTask.cc:146
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
std::string _subsystem
Definition: DQModule.h:64
std::string _runkeyName
Definition: DQModule.h:63
ContainerS _cProcessingTypeName
Definition: DQTask.h:56
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: DQTask.cc:39
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:56
ContainerI _cRunKeyVal
Definition: DQTask.h:54
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQTask.cc:113
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:42
ib
Definition: cuy.py:660