CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripSpyMonitorModule.cc
Go to the documentation of this file.
1 // Original Author: Anne-Marie Magnan
2 // Created: 2010/01/11
3 //
4 
5 #include <sstream>
6 #include <memory>
7 #include <list>
8 #include <algorithm>
9 #include <cassert>
10 
22 
30 
35 
37 
38 // For plotting.
41 
45 
46 //
47 // Class declaration
48 //
49 
51 {
52  public:
53 
54 
57 
58  private:
59 
60  virtual void beginJob() override;
61  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
62  virtual void endJob() override;
63 
64 
65  //check if contains pedsubtr data = 0
67  uint16_t aPair);
68 
70  const uint16_t threshold);
71 
74  const uint16_t threshold,
75  uint16_t & aCounter);
76 
77  //tag of spydata collection
80 
83 
84 
85  //tag of l1A and apveAddress counters
89 
93 
94 
95  uint32_t minDigiRange_;
96  uint32_t maxDigiRange_;
97  uint32_t minDigitalLow_;
98  uint32_t maxDigitalLow_;
99  uint32_t minDigitalHigh_;
100  uint32_t maxDigitalHigh_;
101 
102  unsigned int evt_;
103 
105  //folder name for histograms in DQMStore
107  //book detailed histograms even if they will be empty (for merging)
109  //do histos vs time with time=event number. Default time = orbit number (s)
112  //write the DQMStore to a root file at the end of the job
115 
117  uint16_t firstHeaderBit_;
119 
122 
123  std::ofstream outfile_[20];
124  std::vector<std::string> outfileNames_;
125  std::map<std::string,unsigned int> outfileMap_;
126 
128 
129 };
130 
131 
132 
133 using edm::LogError;
134 using edm::LogWarning;
135 using edm::LogInfo;
136 //
137 // Constructors and destructor
138 //
139 
141  : spyScopeRawDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyScopeRawDigisTag",edm::InputTag("SiStripSpyUnpacker","ScopeRawDigis"))),
142  spyPedSubtrDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyPedSubtrDigisTag",edm::InputTag("SiStripFEDEmulator",""))),
143  spyL1Tag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyL1Tag",edm::InputTag("SiStripSpyDigiConverter","L1ACount"))),
144  spyTotCountTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyTotalEventCountTag",edm::InputTag("SiStripSpyDigiConverter","TotalEventCount"))),
145  spyAPVeTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyAPVeTag",edm::InputTag("SiStripSpyDigiConverter","APVAddress"))),
146  dqm_(0),
147  folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/SpyMonitoringSummary")),
148  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)),
149  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)),
150  fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithLocalEventNumber",false)),
151  writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)),
152  dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>("DQMStoreFileName","DQMStore.root")),
153  firstHeaderBit_(0),
154  firstTrailerBit_(0),
155  outfileNames_(iConfig.getUntrackedParameter<std::vector<std::string> >("OutputErrors")),
156  writeCabling_(iConfig.getUntrackedParameter<bool>("WriteCabling",false))
157 {
158 
159  spyScopeRawDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyScopeRawDigisTag_);
160  spyPedSubtrDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyPedSubtrDigisTag_);
161 
162  spyL1Token_ = consumes<std::vector<uint32_t> >(spyL1Tag_);
163  spyTotCountToken_ = consumes<std::vector<uint32_t> >(spyTotCountTag_);
164  spyAPVeToken_ = consumes<std::vector<uint32_t> >(spyAPVeTag_);
165 
166  evt_ = 0;
167  std::ostringstream pDebugStream;
168  histManager_.initialise(iConfig,&pDebugStream);
169  const unsigned int nFiles = outfileNames_.size();
170 
171  for (unsigned int i(0); i<nFiles; i++){
172  std::ostringstream lName;
173  lName << outfileNames_.at(i) << ".out";
174  if (i<20) outfile_[i].open(lName.str().c_str(),std::ios::out);
175  outfileMap_[outfileNames_.at(i)] = i;
176  }
177 
178  frameQuality_.minDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinDigiRange",100));
179  frameQuality_.maxDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxDigiRange",1024));
180  frameQuality_.minZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinZeroLight",0));
181  frameQuality_.maxZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxZeroLight",1024));
182  frameQuality_.minTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinTickHeight",0));
183  frameQuality_.maxTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxTickHeight",1024));
184 
185 }
186 
188 {
189  const unsigned int nFiles = outfileNames_.size();
190  for (unsigned int i(0); i<nFiles; i++){
191  outfile_[i].close();
192  }
193 
194  outfileMap_.clear();
195  outfileNames_.clear();
196 
197 }
198 
199 
200 // ------------ method called once each job just before starting event loop ------------
201 void
203 {
204 
205  //get DQM store
208 
209  LogInfo("SiStripSpyMonitorModule") << " Histograms will be written in "
210  << folderName_
211  << ". Current folder is : "
212  << dqm_->pwd()
213  << std::endl;
214 
215  //this propagates dqm_ to the histoclass, must be called !
217 
219 
220  evt_ = 0;
221  firstHeaderBit_ = 0;
222  firstTrailerBit_ = 0;
223 }
224 
225 
226 
227 // ------------ method called to for each event ------------
228 void
230  const edm::EventSetup& iSetup)
231 {
232 
233  static bool firstEvent = true;
234  //update cabling and pedestals
235  const SiStripFedCabling* lCabling = utility_.getCabling( iSetup );
236  if (firstEvent && writeCabling_){
237  std::ofstream lOutCabling;
238  lOutCabling.open("trackerDetId_FEDIdChNum_list.txt",std::ios::out);
239  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) {//loop on feds
240  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++){//loop on channels
241  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
242  if (!lConnection.isConnected()) continue;
243  uint32_t lDetId = lConnection.detId();
244  lOutCabling << "FED ID = " << lFedId
245  << ", Channel = " << lFedChannel
246  << ",fedkey = " << sistrip::FEDCH_PER_FED*lFedId + lFedChannel
247  << ", detId = " << lDetId
248  << std::endl;
249  }
250  }
251  lOutCabling.close();
252  }
253 
254  //For spy data
255  //get map of TotalEventCount and L1ID, indexed by fedId, and APVaddress indexed by fedIndex.
256  edm::Handle<std::vector<uint32_t> > lSpyL1IDHandle,lSpyTotCountHandle,lSpyAPVeHandle;
257  try {
258  /*
259  iEvent.getByLabel(spyL1Tag_,lSpyL1IDHandle);
260  iEvent.getByLabel(spyTotCountTag_,lSpyTotCountHandle);
261  iEvent.getByLabel(spyAPVeTag_,lSpyAPVeHandle);
262  */
263  iEvent.getByToken(spyL1Token_,lSpyL1IDHandle);
264  iEvent.getByToken(spyTotCountToken_,lSpyTotCountHandle);
265  iEvent.getByToken(spyAPVeToken_,lSpyAPVeHandle);
266  }
267  catch (const cms::Exception& e) {
268  LogError("SiStripSpyMonitorModule") << e.what() ;
269  return;
270  }
271  //const std::map<uint32_t,uint32_t> & lSpyMaxCountMap = *lSpyL1IDHandle;
272  //const std::map<uint32_t,uint32_t> & lSpyMinCountMap = *lSpyTotCountHandle;
273  const std::vector<uint32_t> & lSpyAPVeVec = *lSpyAPVeHandle;
274 
275  //retrieve the scope digis
277  try {
278  // iEvent.getByLabel(spyScopeRawDigisTag_, digisHandle);
279  iEvent.getByToken(spyScopeRawDigisToken_, digisHandle);
280  }
281  catch (const cms::Exception& e) {
282  LogError("SiStripSpyMonitorModule") << e.what() ;
283  return;
284  }
285  const edm::DetSetVector<SiStripRawDigi> * lInputDigis = digisHandle.product();
286 
287  //retrieve the reordered payload digis
289  try {
290  // iEvent.getByLabel(spyPedSubtrDigisTag_, payloadHandle);
291  iEvent.getByToken(spyPedSubtrDigisToken_, payloadHandle);
292  }
293  catch (const cms::Exception& e) {
294  LogError("SiStripSpyMonitorModule") << e.what() ;
295  return;
296  }
297  const edm::DetSetVector<SiStripRawDigi> * lPayloadDigis = payloadHandle.product();
298 
299 
300  //for first event only
301  //loop first on channels to calculate majority value of when the first header bit is found.
302  //output info message to give the value found
303  //should currently be 6 but may vary in the futur
304  //then we can check firstTrailerBit is +256+24 after
305 
306  if (firstEvent){
309  }
310 
311  //initialise some counters, filled in histos eventually
313  lCounters.nNoData = 0;
314  lCounters.nLowRange = 0;
315  lCounters.nHighRange = 0;
316  lCounters.nMinZero = 0;
317  lCounters.nMaxSat = 0;
318  lCounters.nLowPb = 0;
319  lCounters.nHighPb = 0;
320  lCounters.nOOS = 0;
321  lCounters.nOtherPbs = 0;
322  lCounters.nAPVError = 0;
323  lCounters.nAPVAddressError = 0;
324  lCounters.nNegPeds = 0;
325 
326 
327 
328  //fill event number for output text files
329  const unsigned int nFiles = outfileNames_.size();
330  for (unsigned int i(0); i<nFiles; i++){
331  outfile_[i] << "**** evt "<< iEvent.id().event() << " ****" << std::endl ;
332  }
333 
334 
335  //loop over all FEDs and channels
336 
337  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) {//loop on feds
338 
339  SPYHistograms::Errors lFEDErrors;
340  lFEDErrors.hasNoData = false;
341  lFEDErrors.hasLowRange = false;
342  lFEDErrors.hasHighRange = false;
343  lFEDErrors.hasMinZero = false;
344  lFEDErrors.hasMaxSat = false;
345  lFEDErrors.hasLowPb = false;
346  lFEDErrors.hasHighPb = false;
347  lFEDErrors.hasOOS = false;
348  lFEDErrors.hasOtherPbs = false;
349  lFEDErrors.hasErrorBit0 = false;
350  lFEDErrors.hasErrorBit1 = false;
351  lFEDErrors.hasAPVAddressError0 = false;
352  lFEDErrors.hasAPVAddressError1 = false;
353  lFEDErrors.hasNegPeds = false;
354 
355  uint32_t lAPVAddrRef = lSpyAPVeVec.at(lFedId);
356 
357  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++){//loop on channels
358 
359  uint32_t lFedIndex = sistrip::FEDCH_PER_FED*lFedId + lFedChannel;
360 
361  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
362 
363  if (!lConnection.isConnected()) continue;
364 
365  uint32_t lDetId = lConnection.detId();
366  //uint16_t lNPairs = lConnection.nApvPairs();
367  uint16_t lPair = lConnection.apvPairNumber();
368 
369  edm::DetSetVector<SiStripRawDigi>::const_iterator lDigis = lInputDigis->find(lFedIndex);
370 
371  //pedsubtr digis
372  edm::DetSetVector<SiStripRawDigi>::const_iterator lPayload = lPayloadDigis->find(lDetId);
373 
374  //no digis found, continue.
375  if (lDigis == lInputDigis->end()) {
376  LogDebug("SiStripSpyMonitorModule") << " -- digis not found in ScopeRawDigis map for FEDID "
377  << lFedId << " and FED channel " << lFedChannel << std::endl;
378  continue;
379  }
380 
382 
383  SPYHistograms::Errors lErrors;
384  lErrors.hasNoData = false;
385  lErrors.hasLowRange = false;
386  lErrors.hasHighRange = false;
387  lErrors.hasMinZero = false;
388  lErrors.hasMaxSat = false;
389  lErrors.hasLowPb = false;
390  lErrors.hasHighPb = false;
391  lErrors.hasOOS = false;
392  lErrors.hasOtherPbs = false;
393  lErrors.hasErrorBit0 = false;
394  lErrors.hasErrorBit1 = false;
395  lErrors.hasAPVAddressError0 = false;
396  lErrors.hasAPVAddressError1 = false;
397  lErrors.hasNegPeds = false;
398 
399  uint16_t lRange = sistrip::SpyUtilities::range(lFrame);
400  uint16_t lThreshold = sistrip::SpyUtilities::threshold(lFrame);
401 
402  if (lRange == 0) {
403  lCounters.nNoData++;
404  lErrors.hasNoData = true;
405  lFEDErrors.hasNoData = true;
406  if (outfileMap_.find("NoData") != outfileMap_.end()) outfile_[outfileMap_["NoData"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
407  }
408  else if (lFrame.digitalLow == 0 && lRange > 0) {
409  lCounters.nMinZero++;
410  lErrors.hasMinZero = true;
411  lFEDErrors.hasMinZero = true;
412  if (outfileMap_.find("MinZero") != outfileMap_.end()) outfile_[outfileMap_["MinZero"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
413  }
414  else if (lFrame.digitalHigh >= 1023){
415  lCounters.nMaxSat++;
416  lErrors.hasMaxSat = true;
417  lFEDErrors.hasMaxSat = true;
418  if (outfileMap_.find("MaxSat") != outfileMap_.end()) outfile_[outfileMap_["MaxSat"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
419  }
420  else if (lRange > 0 && lRange < frameQuality_.minDigiRange) {
421  lCounters.nLowRange++;
422  lErrors.hasLowRange = true;
423  lFEDErrors.hasLowRange = true;
424  if (outfileMap_.find("LowRange") != outfileMap_.end()) outfile_[outfileMap_["LowRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
425  }
426  else if (lRange > frameQuality_.maxDigiRange) {
427  lCounters.nHighRange++;
428  lErrors.hasHighRange = true;
429  lFEDErrors.hasHighRange = true;
430  if (outfileMap_.find("HighRange") != outfileMap_.end()) outfile_[outfileMap_["HighRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
431  }
433  lCounters.nLowPb++;
434  lErrors.hasLowPb = true;
435  lFEDErrors.hasLowPb = true;
436  if (outfileMap_.find("LowPb") != outfileMap_.end()) outfile_[outfileMap_["LowPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
437  }
439  lCounters.nHighPb++;
440  lErrors.hasHighPb = true;
441  lFEDErrors.hasHighPb = true;
442  if (outfileMap_.find("HighPb") != outfileMap_.end()) outfile_[outfileMap_["HighPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
443  }
444  else if ( lFrame.firstHeaderBit != firstHeaderBit_ && //header in wrong position
445  ( (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //header and
446  lFrame.firstTrailerBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //trailer found
447  lFrame.firstTrailerBit-lFrame.firstHeaderBit == 280) || //+ right distance between them
448  (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && // or header found
449  lFrame.firstTrailerBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // and trailer not found
450  lFrame.firstHeaderBit > 16 ) || // corresponding to back-to-back frame late enough
451  (lFrame.firstHeaderBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // or header not found
452  identifyTickmarks(*lDigis,lThreshold) ) // but such that tickmark compatible with OOS frame
453  )
454  ){
455  lCounters.nOOS++;
456  lErrors.hasOOS = true;
457  lFEDErrors.hasOOS = true;
458  if (outfileMap_.find("OOS") != outfileMap_.end()) outfile_[outfileMap_["OOS"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
459  }
460  else if ( !(lFrame.firstHeaderBit == firstHeaderBit_ && lFrame.firstTrailerBit == firstTrailerBit_) ){
461  lCounters.nOtherPbs++;
462  lErrors.hasOtherPbs = true;
463  lFEDErrors.hasOtherPbs = true;
464  if (outfileMap_.find("OtherPbs") != outfileMap_.end()) outfile_[outfileMap_["OtherPbs"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
465  }
466  else if (lFrame.apvErrorBit.first || lFrame.apvErrorBit.second) {
467  if (lFrame.apvErrorBit.first) {
468  lCounters.nAPVError++;
469  lErrors.hasErrorBit0 = true;
470  lFEDErrors.hasErrorBit0 = true;
471  }
472  if (lFrame.apvErrorBit.second) {
473  lCounters.nAPVError++;
474  lErrors.hasErrorBit1 = true;
475  lFEDErrors.hasErrorBit1 = true;
476  }
477  if (outfileMap_.find("APVError") != outfileMap_.end()) {
478  outfile_[outfileMap_["APVError"]] << lFedId << " " << lFedChannel << " " << lDetId ;
479  if (lFrame.apvErrorBit.first) outfile_[outfileMap_["APVError"]] << " APV0" << std::endl;
480  if (lFrame.apvErrorBit.second) outfile_[outfileMap_["APVError"]] << " APV1" << std::endl;
481  }
482  }
483  else if ( lFrame.apvAddress.first != lAPVAddrRef ||
484  lFrame.apvAddress.second != lAPVAddrRef ) {
485  if (lFrame.apvAddress.first != lAPVAddrRef){
486  lCounters.nAPVAddressError++;
487  lErrors.hasAPVAddressError0 = true;
488  lFEDErrors.hasAPVAddressError0 = true;
489  }
490  if (lFrame.apvAddress.second != lAPVAddrRef){
491  lCounters.nAPVAddressError++;
492  lErrors.hasAPVAddressError1 = true;
493  lFEDErrors.hasAPVAddressError1 = true;
494  }
495  if (outfileMap_.find("APVAddressError") != outfileMap_.end()){
496  outfile_[outfileMap_["APVAddressError"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
497  if (lFrame.apvAddress.first != lAPVAddrRef) outfile_[outfileMap_["APVAddressError"]] << " APV0" << std::endl;
498  if (lFrame.apvAddress.second != lAPVAddrRef) outfile_[outfileMap_["APVAddressError"]] << " APV1" << std::endl;
499  }
500  }
501  else if (lPayload != lPayloadDigis->end() && hasNegativePedSubtr(*lPayload,lPair)){
502  lCounters.nNegPeds++;
503  lErrors.hasNegPeds = true;
504  lFEDErrors.hasNegPeds = true;
505  if (outfileMap_.find("NegPeds") != outfileMap_.end()) outfile_[outfileMap_["NegPeds"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
506  }
507 
508  histManager_.fillDetailedHistograms(lErrors,lFrame,lFedId,lFedChannel);
509 
510  }//loop on channels
511 
512 
513  histManager_.fillFEDHistograms(lFEDErrors,lFedId);
514 
515  }//loop on feds
516 
517  double lTime;
518  //if (fillWithEvtNum_)
519  //lTime = iEvent.id().event();
520  //else if (fillWithLocalEvtNum_) lTime = evt_;
521  //no orbit number for spy data !!
522  //else lTime = iEvent.orbitNumber()/11223.;
523  lTime = iEvent.id().event();
524  if (fillWithLocalEvtNum_) lTime = evt_;
525 
526  histManager_.fillCountersHistograms(lCounters,lTime);
527 
528 
529  //used to fill histo vs time with local event number....
530  evt_++;
531  firstEvent = false;
532 
533 }//analyze method
534 
535 
536 
537 // ------------ method called once each job just after ending the event loop ------------
538 void
540 {
541 
542  LogInfo("SiStripSpyMonitorModule") << "WriteDQMStore ? " << writeDQMStore_
543  << " file name = " << dqmStoreFileName_
544  << std::endl;
546 
547  const unsigned int nFiles = outfileNames_.size();
548  for (unsigned int i(0); i<nFiles; i++){
549  outfile_[i].close();
550  }
551 
552  outfileMap_.clear();
553  outfileNames_.clear();
554 
555 }
556 
557 
558 
560  uint16_t aPair)
561 {
563  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
564 
565  uint32_t count = 0;
566  for (; iDigi != endChannelDigis; ++iDigi) {
567  const uint16_t val = iDigi->adc();
568  uint16_t lPair = static_cast<uint16_t>(count/sistrip::STRIPS_PER_FEDCH);
569  if (val == 0 && lPair == aPair) return true;
570  count++;
571  }
572 
573  return false;
574 
575 }
576 
578  const uint16_t threshold)
579 {
580 
581  //start from the end
583  uint16_t lastPos = sistrip::SPY_SAMPLES_PER_CHANNEL;
584  uint16_t nTrailers = 0;
586 
587  for ( ; count == 0; count--){
588  iDigi = findTwoConsecutive(channelDigis,threshold,count);
589  //if found, in different position = 70 before than previous value, go and look 70 before
590  if (iDigi != channelDigis.end() &&
591  (lastPos == sistrip::SPY_SAMPLES_PER_CHANNEL || count == lastPos+1-70)) {
592  nTrailers++;
593  lastPos = count-1;
594  count -= 70;
595  }
596  //else keep looking
597  else count--;
598  }
599 
600  if (nTrailers > 1) LogDebug("SiStripSpyMonitorModule") << " -- Found "
601  << nTrailers << " trailers every 70 clock cycles for channel "
602  << channelDigis.detId()
603  << ", evt " << evt_
604  << std::endl;
605  //if only one found, should be < 280 otherwise header should have been found and this method would not be called
606  return (nTrailers > 1) || (nTrailers == 1 && lastPos < 280);
607 
608 }
609 
612  const uint16_t threshold,
613  uint16_t & aCounter)
614 {
615  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
616  edm::DetSetVector<SiStripRawDigi>::detset::const_iterator lStart = channelDigis.begin()+aCounter;
617 
618  bool foundTrailer = false;
619  // Loop over digis looking for last two above threshold
620  uint8_t aboveThreshold = 0;
621 
622  for (; lStart != endChannelDigis; ++lStart) {
623  if ( lStart->adc() > threshold) {
624  aboveThreshold++;
625  }
626  else {
627  aboveThreshold = 0;
628  }
629  if (aboveThreshold == 2) {foundTrailer = true; break; }
630  aCounter++;
631  }//end of loop over digis
632 
633  if (foundTrailer) return lStart;
634  else {
636  return endChannelDigis;
637  }
638 }
639 
640 //
641 // Define as a plug-in
642 //
643 
646 
#define LogDebug(id)
iterator end()
Definition: DetSet.h:60
virtual char const * what() const
Definition: Exception.cc:141
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static const uint16_t FED_ID_MIN
iterator find(det_id_type id)
Definition: DetSetVector.h:285
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator findTwoConsecutive(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
det_id_type detId() const
Definition: DetSet.h:72
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
uint16_t apvPairNumber() const
SiStripSpyMonitorModule(const edm::ParameterSet &)
bool identifyTickmarks(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
static const uint16_t SPY_SAMPLES_PER_CHANNEL
std::pair< uint8_t, uint8_t > apvAddress
void initialise(const edm::ParameterSet &iConfig, std::ostringstream *pDebugStream)
bool hasNegativePedSubtr(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, uint16_t aPair)
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
void fillCountersHistograms(const ErrorCounters &aCounter, const double aTime)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
int iEvent
Definition: GenABIO.cc:243
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
const uint32_t & detId() const
std::map< std::string, unsigned int > outfileMap_
Class containning control, module, detector and connection information, at the level of a FED channel...
void bookAllFEDHistograms()
virtual void endJob() override
sistrip::SpyUtilities::FrameQuality frameQuality_
static const uint16_t range(const Frame &aFrame)
std::vector< std::string > outfileNames_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
virtual void beginJob() override
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
static const uint16_t threshold(const Frame &aFrame)
iterator begin()
Definition: DetSet.h:59
tuple out
Definition: dbtoconf.py:99
static const uint16_t STRIPS_PER_FEDCH
Constants and enumerated types for FED/FEC systems.
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
void fillFEDHistograms(const Errors &aErr, const unsigned int aFedId)
std::pair< bool, bool > apvErrorBit
T const * product() const
Definition: Handle.h:81
void bookTopLevelHistograms(DQMStore *dqm)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
edm::EventID id() const
Definition: EventBase.h:56
static const uint16_t FEDCH_PER_FED
void fillDetailedHistograms(const Errors &aErr, const sistrip::SpyUtilities::Frame &aFrame, const unsigned int aFedId, const unsigned int aFedChannel)
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
static const uint16_t FED_ID_MAX
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
volatile std::atomic< bool > shutdown_flag false
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
sistrip::SpyUtilities utility_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
const std::string & pwd(void) const
Definition: DQMStore.cc:556