CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  _vcdaqEids.push_back(HcalElectronicsId(
69  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
70  }
71  }
72 
73  // get the Channel Quality Status for all the channels
75  es.get<HcalChannelQualityRcd>().get("withTopo", hcq);
76  const HcalChannelQuality *cq = hcq.product();
77  std::vector<DetId> detids = cq->getAllChannels();
78  for (std::vector<DetId>::const_iterator it=detids.begin();
79  it!=detids.end(); ++it)
80  {
81  // if unknown skip
82  if (HcalGenericDetId(*it).genericSubdet()==
84  continue;
85 
86  if (HcalGenericDetId(*it).isHcalDetId())
87  {
88  HcalDetId did(*it);
89  uint32_t mask = (cq->getValues(did))->getValue();
90  if (mask!=0)
91  {
92  _xQuality.push(did, mask);
93  }
94  }
95 
96  /*
97  * TODO: use Channel Quality Information
98  if (HcalGenericDetId(*it).isHcalTrigTowerDetId())
99  {
100  HcalTrigTowerDetId tid(*it);
101  uint32_t mask = (cq->getValues(tid))->getValue();
102  std::cout << tid << " " << mask << std::endl;
103  }
104  */
105  }
106 
107  // book some base guys
113 
114  // fill what you can now
118  }
119 
120  /* virtual */ void DQTask::dqmBeginRun(edm::Run const& r,
121  edm::EventSetup const& es)
122  {
123  this->_resetMonitors(fEvent);
124  this->_resetMonitors(f1LS);
125  this->_resetMonitors(f10LS);
126  this->_resetMonitors(f50LS);
127  this->_resetMonitors(f100LS);
128  }
129 
130  /* virtual */ void DQTask::beginLuminosityBlock(
131  edm::LuminosityBlock const& lb,
132  edm::EventSetup const& es)
133  {
135  this->_resetMonitors(f1LS);
136 
137  if (_procLSs%10==0)
138  this->_resetMonitors(f10LS);
139  if (_procLSs%50==0)
140  this->_resetMonitors(f50LS);
141  if (_procLSs%100==0)
142  this->_resetMonitors(f100LS);
143 
144  }
145 
146  /* virtual */ void DQTask::endLuminosityBlock(
147  edm::LuminosityBlock const& lb,
148  edm::EventSetup const& es)
149  {
150  _procLSs++;
151  }
152 
153  /* virtual */ void DQTask::_resetMonitors(UpdateFreq uf)
154  {
155  // reset per event
156  switch (uf)
157  {
158  case fEvent:
159  break;
160  case f1LS:
161  _evsPerLS = 0;
162  break;
163  case f10LS:
164  break;
165  case f50LS:
166  break;
167  case f100LS:
168  break;
169  default:
170  break;
171  }
172  }
173 
174  /* virtual */ int DQTask::_getCalibType(edm::Event const&e)
175  {
176  int calibType = 0;
177 
179  if (!e.getByToken(_tokRaw, craw))
181  "Collection FEDRawDataCollection isn't available "
182  + _tagRaw.label() + " " + _tagRaw.instance());
183 
184  int badFEDs=0;
185  std::vector<int> types(8,0);
186  for (int i=FED_VME_MIN; i<=FED_VME_MAX; i++)
187  {
188  FEDRawData const& fd = craw->FEDData(i);
189  if (fd.size()<24)
190  {
191  badFEDs++;
192  continue;
193  }
194  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
195  if (cval>7)
196  _logger.warn("Unexpected Calib Type in FED " +
197  boost::lexical_cast<std::string>(i));
198  types[cval]++;
199  }
200  for (int i=FED_uTCA_MIN; i<=FED_uTCA_MAX; i++)
201  {
202  FEDRawData const& fd = craw->FEDData(i);
203  if (fd.size()<24)
204  {
205  badFEDs++;
206  continue;
207  }
208  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
209  if (cval>7)
210  _logger.warn("Unexpected Calib Type in FED " +
211  boost::lexical_cast<std::string>(i));
212  types[cval]++;
213  }
214 
215  int max = 0;
216  for (unsigned int ic=0; ic<8; ic++)
217  {
218  if (types[ic]>max)
219  {
220  max = types[ic];
221  calibType = ic;
222  }
223  }
224  if (max!=(FED_VME_NUM+(FED_uTCA_MAX-FED_uTCA_MIN+1)-badFEDs))
225  _logger.warn("Conflicting Calibration Types found. Assigning " +
226  boost::lexical_cast<std::string>(calibType));
227 
228  return calibType;
229  }
230 }
231 
232 
233 
234 
235 
236 
virtual int _getCalibType(edm::Event const &)
Definition: DQTask.cc:174
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
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:146
int ib
Definition: cuy.py:660
DQTask(edm::ParameterSet const &)
Definition: DQTask.cc:7
void warn(std::string const &msg) const
Definition: Logger.h:20
uint16_t fed2crate(int fed)
Definition: Utilities.cc:12
ContainerS _cRunKeyName
Definition: DQTask.h:55
edm::InputTag _tagRaw
Definition: DQTask.h:68
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void debug(STDTYPE const &msg) const
Definition: Logger.h:31
edm::EDGetTokenT< FEDRawDataCollection > _tokRaw
Definition: DQTask.h:69
UpdateFreq
Definition: DQTask.h:17
tuple calibType
Definition: diJetCalib.py:20
ContainerI _cEvsPerLS
Definition: DQTask.h:53
int const SPIGOT_MIN
Definition: Constants.h:85
virtual void push(HcalDetId const &, STDTYPE)
Definition: ContainerXXX.h:261
int _procLSs
Definition: DQTask.h:59
const Item * getValues(DetId fId, bool throwOnFail=true) const
int const FIBER_VME_MIN
Definition: Constants.h:90
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int const FED_uTCA_MIN
Definition: Constants.h:52
int const FIBERCH_MIN
Definition: Constants.h:100
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:54
ProcessingType _ptype
Definition: DQModule.h:59
virtual void _process(edm::Event const &, edm::EventSetup const &)=0
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:47
std::vector< DetId > getAllChannels() const
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:93
tuple fd
Definition: ztee.py:136
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:130
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
int const FED_VME_NUM
Definition: Constants.h:50
std::string const & label() const
Definition: InputTag.h:36
virtual void _resetMonitors(UpdateFreq)
Definition: DQTask.cc:153
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:85
HcalGenericSubdetector genericSubdet() const
int const FED_VME_MAX
Definition: Constants.h:48
ContainerI _cRunKeyVal
Definition: DQTask.h:54
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQTask.cc:120
Readout chain identification for Hcal.
std::string const & instance() const
Definition: InputTag.h:37
int const SLOT_uTCA_MIN
Definition: Constants.h:72
Definition: Run.h:43
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125