CMS 3D CMS Logo

RawRunSummary.cc
Go to the documentation of this file.
2 
3 namespace hcaldqm
4 {
5  using namespace constants;
7  std::string const& taskname, edm::ParameterSet const& ps) :
8  DQClient(name, taskname, ps), _booked(false)
9  {}
10 
11  /* virtual */ void RawRunSummary::beginRun(edm::Run const& r,
12  edm::EventSetup const& es)
13  {
14  DQClient::beginRun(r,es);
15 
16  if (_ptype!=fOffline)
17  return;
18 
19  // INITIALIZE WHAT NEEDS TO BE INITIALIZE ONLY ONCE!
24  FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
26  _vhashVME); // filter out VME
28  _vhashuTCA); // filter out uTCA
29 
30  // INTIALIZE CONTAINERS ACTING AS HOLDERS OF RUN INFORAMTION
51  _cBadQuality_depth.initialize(_name, "BadQuality",
56 
60  // BOOK CONTAINERSXXX
62  }
63 
64  /*
65  * END OF LUMINOSITY HARVESTING
66  * RAW FORMAT HAS ONLY LUMI BASED FLAGS!
67  * THEREFORE STEPS ARE:
68  * 1) LOAD CONTAINERS YOU NEED (MUST BE LUMI BASED)
69  * 2) ANALYZE
70  * 3) GENERATE SUMMARY FLAGS AND PUSH THEM
71  */
74  edm::EventSetup const& es)
75  {
76  DQClient::endLuminosityBlock(ib, ig, lb, es);
77 
78  if (_ptype!=fOffline)
79  return;
80 
81  // INITIALIZE WHAT YOU NEED
82  LSSummary lssum; // summary for this LS
83  lssum._LS = _currentLS; // set the LS
84 
85  // RESET CONTAINERS USED FOR ANALYSIS OF THIS LS
87 
88  // INITIALIZE LUMI BASED HISTOGRAMS
89  Container2D cEvnMsm_ElectronicsVME,cEvnMsm_ElectronicsuTCA;
90  Container2D cBcnMsm_ElectronicsVME,cBcnMsm_ElectronicsuTCA;
91  Container2D cBadQuality_depth;
92  cEvnMsm_ElectronicsVME.initialize(_taskname, "EvnMsm",
97  cBcnMsm_ElectronicsVME.initialize(_taskname, "BcnMsm",
102  cEvnMsm_ElectronicsuTCA.initialize(_taskname, "EvnMsm",
107  cBcnMsm_ElectronicsuTCA.initialize(_taskname, "BcnMsm",
112  cBadQuality_depth.initialize(_taskname, "BadQuality",
117 
118  // LOAD LUMI BASED HISTOGRAMS
119  cEvnMsm_ElectronicsVME.load(ig, _emap, _filter_uTCA, _subsystem);
120  cBcnMsm_ElectronicsVME.load(ig, _emap, _filter_uTCA, _subsystem);
121  cEvnMsm_ElectronicsuTCA.load(ig, _emap, _filter_VME, _subsystem);
122  cBcnMsm_ElectronicsuTCA.load(ig, _emap, _filter_VME, _subsystem);
123  cBadQuality_depth.load(ig, _emap, _subsystem);
124  MonitorElement *meNumEvents = ig.get(_subsystem+
125  "/RunInfo/NumberOfEvents");
126  int numEvents = meNumEvents->getBinContent(1);
127 
128  // BOOK for the very first time
129  if (!_booked)
130  {
136  _booked=true;
137  }
138 
139  // ANALYZE THIS LS
140  // iterate over all channels
141  std::vector<HcalGenericDetId> gids = _emap->allPrecisionId();
142  for (std::vector<HcalGenericDetId>::const_iterator it=gids.begin();
143  it!=gids.end(); ++it)
144  {
145  if (!it->isHcalDetId())
146  continue;
147  HcalDetId did = HcalDetId(it->rawId());
149 
150  _xBadQ.get(eid)+=cBadQuality_depth.getBinContent(did);
151  _cBadQuality_depth.fill(did, cBadQuality_depth.getBinContent(did));
152  if (eid.isVMEid())
153  {
154  _xEvn.get(eid)+=cEvnMsm_ElectronicsVME.getBinContent(eid);
155  _xBcn.get(eid)+=cBcnMsm_ElectronicsVME.getBinContent(eid);
156 
158  cEvnMsm_ElectronicsVME.getBinContent(eid));
160  cBcnMsm_ElectronicsVME.getBinContent(eid));
161  }
162  else
163  {
164  _xEvn.get(eid)+=cEvnMsm_ElectronicsuTCA.getBinContent(eid);
165  _xBcn.get(eid)+=cBcnMsm_ElectronicsuTCA.getBinContent(eid);
166 
168  cEvnMsm_ElectronicsuTCA.getBinContent(eid));
170  cBcnMsm_ElectronicsuTCA.getBinContent(eid));
171  }
172  }
173 
174 
175  // GENERATE THE SUMMARY FOR THIS LS AND STORE IT
176  std::vector<flag::Flag> vtmpflags; // tmp summary flags vector
177  vtmpflags.resize(nRawFlag);
178  vtmpflags[fEvnMsm]=flag::Flag("EvnMsm");
179  vtmpflags[fBcnMsm]=flag::Flag("BcnMsm");
180  vtmpflags[fBadQ]=flag::Flag("BadQ");
181  for (std::vector<uint32_t>::const_iterator it=_vhashFEDs.begin();
182  it!=_vhashFEDs.end(); ++it)
183  {
184  HcalElectronicsId eid(*it);
185 
186  // reset all the tmp flags to fNA
187  // MUST DO IT NOW! AS NCDAQ MIGHT OVERWRITE IT!
188  for (std::vector<flag::Flag>::iterator ft=vtmpflags.begin();
189  ft!=vtmpflags.end(); ++ft)
190  ft->reset();
191 
192  // check if this FED was @cDAQ
193  std::vector<uint32_t>::const_iterator cit=std::find(
194  _vcdaqEids.begin(), _vcdaqEids.end(), *it);
195  if (cit==_vcdaqEids.end())
196  {
197  // was not @cDAQ, set all the flags for this FED as fNCDAQ
198  for (std::vector<flag::Flag>::iterator ft=vtmpflags.begin();
199  ft!=vtmpflags.end(); ++ft)
200  ft->_state = flag::fNCDAQ;
201 
202  // push all the flags for this FED
203  // IMPORTANT!!!
204  lssum._vflags.push_back(vtmpflags);
205  continue;
206  }
207 
208  // here only if was registered at cDAQ
209  if (utilities::isFEDHBHE(eid) || utilities::isFEDHF(eid) ||
210  utilities::isFEDHO(eid))
211  {
212  if (_xEvn.get(eid)>0)
213  vtmpflags[fEvnMsm]._state = flag::fBAD;
214  else
215  vtmpflags[fEvnMsm]._state = flag::fGOOD;
216  if (_xBcn.get(eid)>0)
217  vtmpflags[fBcnMsm]._state = flag::fBAD;
218  else
219  vtmpflags[fBcnMsm]._state = flag::fGOOD;
220  if (double(_xBadQ.get(eid))>double(12*numEvents))
221  vtmpflags[fBadQ]._state = flag::fBAD;
222  else if (_xBadQ.get(eid)>0)
223  vtmpflags[fBadQ]._state = flag::fPROBLEMATIC;
224  else
225  vtmpflags[fBadQ]._state = flag::fGOOD;
226  }
227 
228  // push all the flags for this FED
229  lssum._vflags.push_back(vtmpflags);
230  }
231 
232  // push all flags for all FEDs for this LS
233  _vflagsLS.push_back(lssum);
234  }
235 
236  /*
237  * END JOB
238  * BOOK THE SUMMARY CONTAINERS, SET THE FLAGS
239  * RETURN THE LIST OF FLAGS FOR THIS DATATIER
240  */
241  /* virtual */ std::vector<flag::Flag> RawRunSummary::endJob(
243  {
244 
245  if (_ptype!=fOffline)
246  return std::vector<flag::Flag>();
247 
248 
249  // PREPARE LS BASED FLAGS to use it for booking
250  std::vector<flag::Flag> vflagsLS;
251  vflagsLS.resize(nRawFlag);
252  vflagsLS[fEvnMsm]=flag::Flag("EvnMsm");
253  vflagsLS[fBcnMsm]=flag::Flag("BcnMsm");
254  vflagsLS[fBadQ]=flag::Flag("BadQ");
255 
256 
257  // INITIALIZE AND BOOK SUMMARY CONTAINERS
258  ContainerSingle2D cSummaryvsLS; // summary per FED: flag vs LS
259  Container2D cSummaryvsLS_FED; // LS based flags vs LS for each FED
260  cSummaryvsLS.initialize(_name, "SummaryvsLS",
264  cSummaryvsLS_FED.initialize(_name, "SummaryvsLS",
267  new quantity::FlagQuantity(vflagsLS),
269  cSummaryvsLS_FED.book(ib, _emap, _subsystem);
270  cSummaryvsLS.book(ib, _subsystem);
271 
272  /*
273  * Iterate over each FED
274  * Iterate over each LS SUmmary
275  * Iterate over all flags
276  * set...
277  */
278 
279  std::vector<flag::Flag> sumflags; // flag per FED
280  int ifed=0;
281  for (std::vector<uint32_t>::const_iterator it=_vhashFEDs.begin();
282  it!=_vhashFEDs.end(); ++it)
283  {
284  flag::Flag fSumRun("RAW"); // summary flag for this FED
285  HcalElectronicsId eid(*it);
286 
287  // ITERATE OVER EACH LS
288  for (std::vector<LSSummary>::const_iterator itls=_vflagsLS.begin();
289  itls!=_vflagsLS.end(); ++itls)
290  {
291  // fill histograms per LS
292  int iflag=0;
293  flag::Flag fSumLS("RAW");
294  for (std::vector<flag::Flag>::const_iterator ft=
295  itls->_vflags[ifed].begin(); ft!=itls->_vflags[ifed].end();
296  ++ft)
297  {
298  // Flag vs LS per FEd
299  cSummaryvsLS_FED.setBinContent(eid, itls->_LS, int(iflag),
300  ft->_state);
301  fSumLS+=(*ft);
302  iflag++;
303  }
304  // FED vs LS
305  cSummaryvsLS.setBinContent(eid, itls->_LS, fSumLS._state);
306  fSumRun+=fSumLS;
307  }
308 
309  // push the summary flag for this FED for the whole RUN
310  sumflags.push_back(fSumRun);
311 
312  // increment the fed counter
313  ifed++;
314  }
315 
316  return sumflags;
317  }
318 }
std::vector< uint32_t > _vcdaqEids
Definition: DQClient.h:67
Container2D _cEvnMsm_ElectronicsVME
Definition: RawRunSummary.h:35
int const CRATE_VME_MIN
Definition: Constants.h:83
filter::HashFilter _filter_VME
Definition: RawRunSummary.h:32
void initialize(HcalElectronicsMap const *, ElectronicsMapType etype=fHcalElectronicsMap)
std::vector< uint32_t > _vhashFEDs
Definition: DQClient.h:61
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQClient.cc:13
State _state
Definition: Flag.h:62
Container2D _cBadQuality_depth
Definition: RawRunSummary.h:37
std::string _taskname
Definition: DQClient.h:46
ContainerXXX< uint32_t > _xBadQ
Definition: RawRunSummary.h:42
Container2D _cEvnMsm_ElectronicsuTCA
Definition: RawRunSummary.h:35
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:108
Container2D _cBcnMsm_ElectronicsuTCA
Definition: RawRunSummary.h:36
HcalElectronicsMap const * _emap
Definition: DQClient.h:53
virtual void reset()
Definition: ContainerXXX.h:292
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int const FIBER_VME_MIN
Definition: Constants.h:113
std::vector< int > _vFEDsuTCA
Definition: RawRunSummary.h:31
int const FIBERCH_MIN
Definition: Constants.h:122
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:43
virtual void setBinContent(int, int, int)
virtual void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQClient.cc:98
electronicsmap::ElectronicsMap _ehashmap
Definition: RawRunSummary.h:27
int const FIBER_uTCA_MIN1
Definition: Constants.h:116
std::vector< HcalGenericDetId > allPrecisionId() const
filter::HashFilter _filter_uTCA
Definition: RawRunSummary.h:32
RawRunSummary(std::string const &, std::string const &, edm::ParameterSet const &)
Definition: RawRunSummary.cc:6
ContainerXXX< uint32_t > _xEvn
Definition: RawRunSummary.h:42
std::string _name
Definition: DQModule.h:41
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
int const CRATE_uTCA_MIN
Definition: Constants.h:88
std::vector< uint32_t > _vhashuTCA
Definition: RawRunSummary.h:30
Container2D _cBcnMsm_ElectronicsVME
Definition: RawRunSummary.h:36
double getBinContent(HcalDetId const &) override
Definition: Container2D.cc:132
bool isFEDHBHE(HcalElectronicsId const &)
Definition: Utilities.cc:142
virtual void book(HcalElectronicsMap const *)
Definition: ContainerXXX.h:87
std::vector< int > _vFEDs
Definition: DQClient.h:60
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:42
std::vector< flag::Flag > endJob(DQMStore::IBooker &, DQMStore::IGetter &) override
void setBinContent(HcalDetId const &, int) override
Definition: Container2D.cc:163
double getBinContent(int binx) const
get content of bin (1-D)
virtual STDTYPE & get(HcalDetId const &)
Definition: ContainerXXX.h:197
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:48
bool isFEDHO(HcalElectronicsId const &)
Definition: Utilities.cc:180
std::vector< LSSummary > _vflagsLS
Definition: RawRunSummary.h:25
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:558
std::vector< int > _vFEDsVME
Definition: RawRunSummary.h:31
std::vector< uint32_t > _vhashVME
Definition: RawRunSummary.h:30
Readout chain identification for Hcal.
bool isFEDHF(HcalElectronicsId const &)
Definition: Utilities.cc:156
int const SLOT_uTCA_MIN
Definition: Constants.h:95
Definition: Run.h:45
void endLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
ib
Definition: cuy.py:662