CMS 3D CMS Logo

RawRunSummary.cc
Go to the documentation of this file.
2 
3 namespace hcaldqm {
4  using namespace constants;
6  std::string const& taskname,
7  edm::ParameterSet const& ps,
9  : DQClient(name, taskname, ps, iC), _booked(false) {}
10 
11  /* virtual */ void RawRunSummary::beginRun(edm::Run const& r, edm::EventSetup const& es) {
12  DQClient::beginRun(r, es);
13 
14  if (_ptype != fOffline)
15  return;
16 
17  // INITIALIZE WHAT NEEDS TO BE INITIALIZE ONLY ONCE!
19  _vhashVME.push_back(
23  _vhashVME); // filter out VME
25  _vhashuTCA); // filter out uTCA
26 
27  // INTIALIZE CONTAINERS ACTING AS HOLDERS OF RUN INFORAMTION
29  "EvnMsm",
34  0);
36  "BcnMsm",
41  0);
43  "BadQuality",
48  0);
49 
53  // BOOK CONTAINERSXXX
54  _xEvn.book(_emap);
55  _xBcn.book(_emap);
56  _xBadQ.book(_emap);
57  }
58 
59  /*
60  * END OF LUMINOSITY HARVESTING
61  * RAW FORMAT HAS ONLY LUMI BASED FLAGS!
62  * THEREFORE STEPS ARE:
63  * 1) LOAD CONTAINERS YOU NEED (MUST BE LUMI BASED)
64  * 2) ANALYZE
65  * 3) GENERATE SUMMARY FLAGS AND PUSH THEM
66  */
69  edm::LuminosityBlock const& lb,
70  edm::EventSetup const& es) {
71  DQClient::endLuminosityBlock(ib, ig, lb, es);
72 
73  if (_ptype != fOffline)
74  return;
75 
76  // INITIALIZE WHAT YOU NEED
77  LSSummary lssum; // summary for this LS
78  lssum._LS = _currentLS; // set the LS
79 
80  // RESET CONTAINERS USED FOR ANALYSIS OF THIS LS
81  _xEvn.reset();
82  _xBcn.reset();
83  _xBadQ.reset();
84 
85  // INITIALIZE LUMI BASED HISTOGRAMS
86  Container2D cEvnMsm_ElectronicsuTCA;
87  Container2D cBcnMsm_ElectronicsuTCA;
88  Container2D cBadQuality_depth;
89  cEvnMsm_ElectronicsuTCA.initialize(_taskname,
90  "EvnMsm",
95  0);
96  cBcnMsm_ElectronicsuTCA.initialize(_taskname,
97  "BcnMsm",
102  0);
103  cBadQuality_depth.initialize(_taskname,
104  "BadQuality",
109  0);
110 
111  // LOAD LUMI BASED HISTOGRAMS
112  cEvnMsm_ElectronicsuTCA.load(ig, _emap, _filter_VME, _subsystem);
113  cBcnMsm_ElectronicsuTCA.load(ig, _emap, _filter_VME, _subsystem);
114  cBadQuality_depth.load(ig, _emap, _subsystem);
115  MonitorElement* meNumEvents = ig.get(_subsystem + "/RunInfo/NumberOfEvents");
116  int numEvents = meNumEvents->getBinContent(1);
117 
118  // BOOK for the very first time
119  if (!_booked) {
123  _booked = true;
124  }
125 
126  // ANALYZE THIS LS
127  // iterate over all channels
128  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
129  for (std::vector<HcalGenericDetId>::const_iterator it = gids.begin(); it != gids.end(); ++it) {
130  if (!it->isHcalDetId())
131  continue;
132  HcalDetId did = HcalDetId(it->rawId());
134 
135  _xBadQ.get(eid) += cBadQuality_depth.getBinContent(did);
136  _cBadQuality_depth.fill(did, cBadQuality_depth.getBinContent(did));
137  if (!eid.isVMEid()) {
138  _xEvn.get(eid) += cEvnMsm_ElectronicsuTCA.getBinContent(eid);
139  _xBcn.get(eid) += cBcnMsm_ElectronicsuTCA.getBinContent(eid);
140 
141  _cEvnMsm_ElectronicsuTCA.fill(eid, cEvnMsm_ElectronicsuTCA.getBinContent(eid));
142  _cBcnMsm_ElectronicsuTCA.fill(eid, cBcnMsm_ElectronicsuTCA.getBinContent(eid));
143  }
144  }
145 
146  // GENERATE THE SUMMARY FOR THIS LS AND STORE IT
147  std::vector<flag::Flag> vtmpflags; // tmp summary flags vector
148  vtmpflags.resize(nRawFlag);
149  vtmpflags[fEvnMsm] = flag::Flag("EvnMsm");
150  vtmpflags[fBcnMsm] = flag::Flag("BcnMsm");
151  vtmpflags[fBadQ] = flag::Flag("BadQ");
152  for (std::vector<uint32_t>::const_iterator it = _vhashFEDs.begin(); it != _vhashFEDs.end(); ++it) {
153  HcalElectronicsId eid(*it);
154 
155  // reset all the tmp flags to fNA
156  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
157  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
158  ft->reset();
159 
160  // check if this FED was @cDAQ
161  std::vector<uint32_t>::const_iterator cit = std::find(_vcdaqEids.begin(), _vcdaqEids.end(), *it);
162  if (cit == _vcdaqEids.end()) {
163  // was not @cDAQ, set all the flags for this FED as fNCDAQ
164  for (std::vector<flag::Flag>::iterator ft = vtmpflags.begin(); ft != vtmpflags.end(); ++ft)
165  ft->_state = flag::fNCDAQ;
166 
167  // push all the flags for this FED
168  // IMPORTANT!!!
169  lssum._vflags.push_back(vtmpflags);
170  continue;
171  }
172 
173  // here only if was registered at cDAQ
175  if (_xEvn.get(eid) > 0)
176  vtmpflags[fEvnMsm]._state = flag::fBAD;
177  else
178  vtmpflags[fEvnMsm]._state = flag::fGOOD;
179  if (_xBcn.get(eid) > 0)
180  vtmpflags[fBcnMsm]._state = flag::fBAD;
181  else
182  vtmpflags[fBcnMsm]._state = flag::fGOOD;
183  if (double(_xBadQ.get(eid)) > double(12 * numEvents))
184  vtmpflags[fBadQ]._state = flag::fBAD;
185  else if (_xBadQ.get(eid) > 0)
186  vtmpflags[fBadQ]._state = flag::fPROBLEMATIC;
187  else
188  vtmpflags[fBadQ]._state = flag::fGOOD;
189  }
190 
191  // push all the flags for this FED
192  lssum._vflags.push_back(vtmpflags);
193  }
194 
195  // push all flags for all FEDs for this LS
196  _vflagsLS.push_back(lssum);
197  }
198 
199  /*
200  * END JOB
201  * BOOK THE SUMMARY CONTAINERS, SET THE FLAGS
202  * RETURN THE LIST OF FLAGS FOR THIS DATATIER
203  */
204  /* virtual */ std::vector<flag::Flag> RawRunSummary::endJob(DQMStore::IBooker& ib, DQMStore::IGetter& ig) {
205  if (_ptype != fOffline)
206  return std::vector<flag::Flag>();
207 
208  // PREPARE LS BASED FLAGS to use it for booking
209  std::vector<flag::Flag> vflagsLS;
210  vflagsLS.resize(nRawFlag);
211  vflagsLS[fEvnMsm] = flag::Flag("EvnMsm");
212  vflagsLS[fBcnMsm] = flag::Flag("BcnMsm");
213  vflagsLS[fBadQ] = flag::Flag("BadQ");
214 
215  // INITIALIZE AND BOOK SUMMARY CONTAINERS
216  ContainerSingle2D cSummaryvsLS; // summary per FED: flag vs LS
217  Container2D cSummaryvsLS_FED; // LS based flags vs LS for each FED
218  cSummaryvsLS.initialize(_name,
219  "SummaryvsLS",
223  0);
224  cSummaryvsLS_FED.initialize(_name,
225  "SummaryvsLS",
228  new quantity::FlagQuantity(vflagsLS),
230  0);
231  cSummaryvsLS_FED.book(ib, _emap, _subsystem);
232  cSummaryvsLS.book(ib, _subsystem);
233 
234  /*
235  * Iterate over each FED
236  * Iterate over each LS SUmmary
237  * Iterate over all flags
238  * set...
239  */
240 
241  std::vector<flag::Flag> sumflags; // flag per FED
242  int ifed = 0;
243  for (std::vector<uint32_t>::const_iterator it = _vhashFEDs.begin(); it != _vhashFEDs.end(); ++it) {
244  flag::Flag fSumRun("RAW"); // summary flag for this FED
245  HcalElectronicsId eid(*it);
246 
247  // ITERATE OVER EACH LS
248  for (std::vector<LSSummary>::const_iterator itls = _vflagsLS.begin(); itls != _vflagsLS.end(); ++itls) {
249  // fill histograms per LS
250  int iflag = 0;
251  flag::Flag fSumLS("RAW");
252  for (std::vector<flag::Flag>::const_iterator ft = itls->_vflags[ifed].begin(); ft != itls->_vflags[ifed].end();
253  ++ft) {
254  // Flag vs LS per FEd
255  cSummaryvsLS_FED.setBinContent(eid, itls->_LS, int(iflag), ft->_state);
256  fSumLS += (*ft);
257  iflag++;
258  }
259  // FED vs LS
260  cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
261  fSumRun += fSumLS;
262  }
263 
264  // push the summary flag for this FED for the whole RUN
265  sumflags.push_back(fSumRun);
266 
267  // increment the fed counter
268  ifed++;
269  }
270 
271  return sumflags;
272  }
273 } // namespace hcaldqm
std::vector< uint32_t > _vcdaqEids
Definition: DQClient.h:74
int const CRATE_VME_MIN
Definition: Constants.h:95
filter::HashFilter _filter_VME
Definition: RawRunSummary.h:29
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
std::vector< uint32_t > _vhashFEDs
Definition: DQClient.h:68
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQClient.cc:24
State _state
Definition: Flag.h:62
Container2D _cBadQuality_depth
Definition: RawRunSummary.h:34
std::string _taskname
Definition: DQClient.h:50
ContainerXXX< uint32_t > _xBadQ
Definition: RawRunSummary.h:39
Container2D _cEvnMsm_ElectronicsuTCA
Definition: RawRunSummary.h:32
virtual void initialize(std::string const &folder, quantity::Quantity *, quantity::Quantity *, quantity::Quantity *qz=new quantity::ValueQuantity(quantity::fN), int debug=0)
int const SPIGOT_MIN
Definition: Constants.h:120
Container2D _cBcnMsm_ElectronicsuTCA
Definition: RawRunSummary.h:33
HcalElectronicsMap const * _emap
Definition: DQClient.h:60
virtual void reset()
Definition: ContainerXXX.h:292
RawRunSummary(std::string const &, std::string const &, edm::ParameterSet const &, edm::ConsumesCollector &iC)
Definition: RawRunSummary.cc:5
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int const FIBER_VME_MIN
Definition: Constants.h:125
std::vector< int > _vFEDsuTCA
Definition: RawRunSummary.h:28
int const FIBERCH_MIN
Definition: Constants.h:134
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
void beginRun(edm::Run const &, edm::EventSetup const &) override
ProcessingType _ptype
Definition: DQModule.h:44
virtual void setBinContent(int, int, int)
virtual void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQClient.cc:105
electronicsmap::ElectronicsMap _ehashmap
Definition: RawRunSummary.h:24
int const FIBER_uTCA_MIN1
Definition: Constants.h:128
filter::HashFilter _filter_uTCA
Definition: RawRunSummary.h:29
ContainerXXX< uint32_t > _xEvn
Definition: RawRunSummary.h:39
std::string _name
Definition: DQModule.h:42
int const CRATE_uTCA_MIN
Definition: Constants.h:100
std::vector< uint32_t > _vhashuTCA
Definition: RawRunSummary.h:27
double getBinContent(HcalDetId const &) override
Definition: Container2D.cc:132
bool isFEDHBHE(HcalElectronicsId const &)
Definition: Utilities.cc:156
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:87
std::vector< int > _vFEDs
Definition: DQClient.h:67
virtual void initialize(std::string const &folder, hashfunctions::HashType, quantity::Quantity *, quantity::Quantity *, quantity::Quantity *qz=new quantity::ValueQuantity(quantity::fN), int debug=0)
Definition: Container2D.cc:25
ContainerXXX< uint32_t > _xBcn
Definition: RawRunSummary.h:39
std::vector< flag::Flag > endJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:697
void setBinContent(HcalDetId const &, int) override
Definition: Container2D.cc:163
virtual STDTYPE & get(HcalDetId const &)
Definition: ContainerXXX.h:197
std::vector< HcalGenericDetId > allPrecisionId() const
void fill(HcalDetId const &) override
Definition: Container2D.cc:52
virtual void initialize(FilterType ftype, hashfunctions::HashType htype, std::vector< uint32_t > const &)
Definition: HashFilter.cc:17
std::string _subsystem
Definition: DQModule.h:49
bool isFEDHO(HcalElectronicsId const &)
Definition: Utilities.cc:182
std::vector< LSSummary > _vflagsLS
Definition: RawRunSummary.h:22
virtual void load(DQMStore::IGetter &, HcalElectronicsMap const *, std::string const &subsystem="Hcal", std::string const &aux="")
Definition: Container1D.cc:450
virtual void initialize(hashfunctions::HashType, int debug=0)
Definition: ContainerXXX.h:81
void book(DQMStore::IBooker &, HcalElectronicsMap const *, std::string subsystem="Hcal", std::string aux="") override
Definition: Container2D.cc:567
std::vector< uint32_t > _vhashVME
Definition: RawRunSummary.h:27
Readout chain identification for Hcal.
bool isFEDHF(HcalElectronicsId const &)
Definition: Utilities.cc:170
int const SLOT_uTCA_MIN
Definition: Constants.h:107
Definition: Run.h:45
void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
ib
Definition: cuy.py:661
virtual double getBinContent(int binx) const
get content of bin (1-D)