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, "EventssPerLS"),
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 
37  this->_process(e, es);
38  }
39 
41  edm::Run const& r,
42  edm::EventSetup const& es)
43  {
44  _cEvsTotal.book(ib);
45  _cEvsPerLS.book(ib);
46  _cRunKeyVal.book(ib);
47  _cRunKeyName.book(ib);
49 
50  // fill what you can now
54  }
55 
56  /* virtual */ void DQTask::dqmBeginRun(edm::Run const& r,
57  edm::EventSetup const& es)
58  {
59  this->_resetMonitors(fEvent);
60  this->_resetMonitors(fLS);
61  this->_resetMonitors(f10LS);
62  this->_resetMonitors(f50LS);
63  this->_resetMonitors(f100LS);
64  }
65 
66  /* virtual */ void DQTask::beginLuminosityBlock(
67  edm::LuminosityBlock const& lb,
68  edm::EventSetup const& es)
69  {
70  this->_resetMonitors(fLS);
71  if (_procLSs%10==0)
72  this->_resetMonitors(f10LS);
73  if (_procLSs%50==0)
74  this->_resetMonitors(f50LS);
75  if (_procLSs%100==0)
76  this->_resetMonitors(f100LS);
77  }
78 
79  /* virtual */ void DQTask::endLuminosityBlock(
80  edm::LuminosityBlock const& lb,
81  edm::EventSetup const& es)
82  {
83  _procLSs++;
84  }
85 
86  /* virtual */ void DQTask::_resetMonitors(UpdateFreq uf)
87  {
88  // reset per event
89  switch (uf)
90  {
91  case fEvent:
92  break;
93  case fLS:
94  _evsPerLS = 0;
95  break;
96  case f10LS:
97  break;
98  case f50LS:
99  break;
100  case f100LS:
101  break;
102  default:
103  break;
104  }
105  }
106 
107  /* virtual */ int DQTask::_getCalibType(edm::Event const&e)
108  {
109  int calibType = 0;
110 
112  if (!e.getByToken(_tokRaw, craw))
114  "Collection FEDRawDataCollection isn't available "
115  + _tagRaw.label() + " " + _tagRaw.instance());
116 
117  int badFEDs=0;
118  std::vector<int> types(8,0);
119  for (int i=FED_VME_MIN; i<=FED_VME_MAX; i++)
120  {
121  FEDRawData const& fd = craw->FEDData(i);
122  if (fd.size()<24)
123  {
124  badFEDs++;
125  continue;
126  }
127  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
128  if (cval>7)
129  _logger.warn("Unexpected Calib Type in FED " +
130  boost::lexical_cast<std::string>(i));
131  types[cval]++;
132  }
133  for (int i=FED_uTCA_MIN; i<=FED_uTCA_MAX; i++)
134  {
135  FEDRawData const& fd = craw->FEDData(i);
136  if (fd.size()<24)
137  {
138  badFEDs++;
139  continue;
140  }
141  int cval = (int)((HcalDCCHeader const*)(fd.data()))->getCalibType();
142  if (cval>7)
143  _logger.warn("Unexpected Calib Type in FED " +
144  boost::lexical_cast<std::string>(i));
145  types[cval]++;
146  }
147 
148  int max = 0;
149  for (unsigned int ic=0; ic<8; ic++)
150  {
151  if (types[ic]>max)
152  {
153  max = types[ic];
154  calibType = ic;
155  }
156  }
157  if (max!=(FED_VME_NUM+(FED_uTCA_MAX-FED_uTCA_MIN+1)-badFEDs))
158  _logger.warn("Conflicting Calibration Types found. Assigning " +
159  boost::lexical_cast<std::string>(calibType));
160 
161  return calibType;
162  }
163 }
164 
165 
166 
167 
168 
169 
virtual int _getCalibType(edm::Event const &)
Definition: DQTask.cc:107
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
ContainerI _cEvsTotal
Definition: DQTask.h:51
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:79
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
ContainerS _cRunKeyName
Definition: DQTask.h:54
edm::InputTag _tagRaw
Definition: DQTask.h:61
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:62
UpdateFreq
Definition: DQTask.h:16
tuple calibType
Definition: diJetCalib.py:20
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:62
ContainerI _cEvsPerLS
Definition: DQTask.h:52
int _procLSs
Definition: DQTask.h:58
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int const FED_uTCA_MIN
Definition: Constants.h:31
virtual bool _isApplicable(edm::Event const &)
Definition: DQTask.h:47
int const FED_uTCA_MAX
Definition: Constants.h:32
ProcessingType _ptype
Definition: DQModule.h:52
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
int const FED_VME_MIN
Definition: Constants.h:26
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerI.h:33
tuple fd
Definition: ztee.py:136
virtual void fill(int x)
Definition: ContainerI.h:28
Logger _logger
Definition: DQModule.h:62
std::string _name
Definition: DQModule.h:50
virtual void book(DQMStore::IBooker &ib, std::string subsystem="Hcal", std::string aux="")
Definition: ContainerS.h:34
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQTask.cc:66
int const FED_VME_NUM
Definition: Constants.h:29
std::string const & label() const
Definition: InputTag.h:36
virtual void _resetMonitors(UpdateFreq)
Definition: DQTask.cc:86
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
std::string _runkeyName
Definition: DQModule.h:56
ContainerS _cProcessingTypeName
Definition: DQTask.h:55
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
Definition: DQTask.cc:40
std::string const pTypeNames[nProcessingType]
Definition: DQModule.h:34
int const FED_VME_MAX
Definition: Constants.h:27
ContainerI _cRunKeyVal
Definition: DQTask.h:53
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQTask.cc:56
std::string const & instance() const
Definition: InputTag.h:37
Definition: Run.h:43