CMS 3D CMS Logo

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