CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelRawDataErrorModule.cc
Go to the documentation of this file.
4 // Framework
6 // STL
7 #include <vector>
8 #include <memory>
9 #include <string>
10 #include <iostream>
11 #include <stdlib.h>
12 #include <sstream>
13 
14 // Data Formats
19 
20 using namespace std;
21 
28 
35 const int SiPixelRawDataErrorModule::DB1_shift = DB0_shift + DataBit_bits;
36 const int SiPixelRawDataErrorModule::DB2_shift = DB1_shift + DataBit_bits;
37 const int SiPixelRawDataErrorModule::DB3_shift = DB2_shift + DataBit_bits;
38 const int SiPixelRawDataErrorModule::DB4_shift = DB3_shift + DataBit_bits;
39 const int SiPixelRawDataErrorModule::DB5_shift = DB4_shift + DataBit_bits;
40 const int SiPixelRawDataErrorModule::DB6_shift = DB5_shift + DataBit_bits;
41 const int SiPixelRawDataErrorModule::DB7_shift = DB6_shift + DataBit_bits;
42 
43 const uint32_t SiPixelRawDataErrorModule::LINK_mask = ~(~uint32_t(0) << LINK_bits);
44 const uint32_t SiPixelRawDataErrorModule::ROC_mask = ~(~uint32_t(0) << ROC_bits);
45 const uint32_t SiPixelRawDataErrorModule::DCOL_mask = ~(~uint32_t(0) << DCOL_bits);
46 const uint32_t SiPixelRawDataErrorModule::PXID_mask = ~(~uint32_t(0) << PXID_bits);
47 const uint32_t SiPixelRawDataErrorModule::ADC_mask = ~(~uint32_t(0) << ADC_bits);
48 const uint32_t SiPixelRawDataErrorModule::DataBit_mask = ~(~uint32_t(0) << DataBit_bits);
49 
53 
55 const int SiPixelRawDataErrorModule::EVTLGT_shift = TRLRBGN_shift + TRLRBGN_bits;
56 const int SiPixelRawDataErrorModule::TRLREND_shift = EVTLGT_shift + EVTLGT_bits;
57 
58 const long long SiPixelRawDataErrorModule::TRLREND_mask = ~(~(long long)(0) << TRLREND_bits);
59 const long long SiPixelRawDataErrorModule::EVTLGT_mask = ~(~(long long)(0) << EVTLGT_bits);
60 const long long SiPixelRawDataErrorModule::TRLRBGN_mask = ~(~(long long)(0) << TRLRBGN_bits);
61 //
62 // Constructors
63 //
65  id_(0),
66  ncols_(416),
67  nrows_(160)
68 {
69  _debug_ = false;
70 }
71 //
73  id_(id),
74  ncols_(416),
75  nrows_(160)
76 {
77  _debug_ = false;
78 }
79 //
80 SiPixelRawDataErrorModule::SiPixelRawDataErrorModule(const uint32_t& id, const int& ncols, const int& nrows) :
81  id_(id),
82  ncols_(ncols),
83  nrows_(nrows)
84 {
85  _debug_ = false;
86 }
87 //
88 // Destructor
89 //
91 //
92 // Book histograms for errors with detId
93 //
95 }
96 //
97 // Book histograms for errors within a FED
98 //
100 //std::cout<<"Entering SiPixelRawDataErrorModule::bookFED: "<<std::endl;
101  std::string hid;
102  // Get collection name and instantiate Histo Id builder
103  edm::InputTag src = iConfig.getParameter<edm::InputTag>( "src" );
104  SiPixelHistogramId* theHistogramId = new SiPixelHistogramId( src.label() );
105  // Get DQM interface
106  DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
107  // Types of errors
108  hid = theHistogramId->setHistoId("errorType",id_);
109  meErrorType_ = theDMBE->book1D(hid,"Type of errors",15,24.5,39.5);
110  meErrorType_->setAxisTitle("Type of errors",1);
111  // Number of errors
112  hid = theHistogramId->setHistoId("NErrors",id_);
113  meNErrors_ = theDMBE->book1D(hid,"Number of errors",36,0.,36.);
114  meNErrors_->setAxisTitle("Number of errors",1);
115  // Type of FIFO full (errorType = 28). FIFO 1 is 1-5 (where fullType = channel of FIFO 1),
116  // fullType = 6 signifies FIFO 2 nearly full, 7 signifies trigger FIFO nearly full, 8
117  // indicates an unexpected result
118  hid = theHistogramId->setHistoId("fullType",id_);
119  meFullType_ = theDMBE->book1D(hid,"Type of FIFO full",7,0.5,7.5);
120  meFullType_->setAxisTitle("FIFO type",1);
121  // For error type 30, the type of problem encoded in the TBM trailer
122  // 0 = stack full, 1 = Pre-cal issued, 2 = clear trigger counter, 3 = sync trigger,
123  // 4 = sync trigger error, 5 = reset ROC, 6 = reset TBM, 7 = no token bit pass
124  hid = theHistogramId->setHistoId("TBMMessage",id_);
125  meTBMMessage_ = theDMBE->book1D(hid,"TBM trailer message",8,-0.5,7.5);
126  meTBMMessage_->setAxisTitle("TBM message",1);
127  // For error type 30, the type of problem encoded in the TBM error trailer 0 = none
128  // 1 = data stream too long, 2 = FSM errors, 3 = invalid # of ROCs, 4 = multiple
129  hid = theHistogramId->setHistoId("TBMType",id_);
130  meTBMType_ = theDMBE->book1D(hid,"Type of TBM trailer",5,-0.5,4.5);
131  meTBMType_->setAxisTitle("TBM Type",1);
132  // For error type 31, the event number of the TBM header with the error
133  hid = theHistogramId->setHistoId("EvtNbr",id_);
134  meEvtNbr_ = theDMBE->bookInt(hid);
135  // For errorType = 34, datastream size according to error word
136  hid = theHistogramId->setHistoId("evtSize",id_);
137  meEvtSize_ = theDMBE->bookInt(hid);
138 
139  for(int j=0; j!=37; j++){
140  std::stringstream temp; temp << j;
141  hid = "FedChNErrArray_" + temp.str();
142  meFedChNErrArray_[j] = theDMBE->bookInt(hid);
143  hid = "FedChLErrArray_" + temp.str();
144  meFedChLErrArray_[j] = theDMBE->bookInt(hid);
145  hid = "FedETypeNErrArray_" + temp.str();
146  if(j<21) meFedETypeNErrArray_[j] = theDMBE->bookInt(hid);
147  }
148  delete theHistogramId;
149 //std::cout<<"...leaving SiPixelRawDataErrorModule::bookFED. "<<std::endl;
150 }
151 //
152 // Fill histograms
153 //
154 int SiPixelRawDataErrorModule::fill(const edm::DetSetVector<SiPixelRawDataError>& input, bool modon, bool ladon, bool bladeon) {
155 //std::cout<<"Entering SiPixelRawDataErrorModule::fill: "<<std::endl;
156  bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
157  bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
158 
159  // Get DQM interface
160  DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
161 
162  unsigned int numberOfSeriousErrors = 0;
163 
164  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(id_); // search errors of detid
165 
166  if( isearch != input.end() ) { // Not at empty iterator
167  // Look at errors now
169  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
170  int FedId = di->getFedId(); // FED the error came from
171  int chanNmbr = 0;
172  int errorType = di->getType(); // type of error
173  int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int evtNbr=-1; int fullType=-1;
174  //bool notReset = true;
175  const int LINK_bits = 6;
176  const int LINK_shift = 26;
177  const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
178 
179  if(modon){
180  if(errorType == 32 || errorType == 33 || errorType == 34) {
181  long long errorWord = di->getWord64(); // for 64-bit error words
182  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
183  if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
184  } else {
185  uint32_t errorWord = di->getWord32(); // for 32-bit error words
186  chanNmbr = (errorWord >> LINK_shift) & LINK_mask; // default way to get channel number. Only different for case 29 below.
187  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
188  case(28) : {
189  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
190  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
191  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
192  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
193  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
194  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
195  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
196  if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
197  if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
198  if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
199  if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
200  if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
201  if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
202  if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
203  chanNmbr = 0; // signifies channel not known
204  break; }
205  case(29) : {
206  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
207  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
208  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
209  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
210  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
211  int BLOCK_bits = 3;
212  int BLOCK_shift = 8;
213  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
214  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
215  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
216  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
217  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
218  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
219  break; }
220  case(30) : {
221  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
222  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
223  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
224  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
225  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
226  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
227  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
228  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
229  if (T0==1) TBMMessage=0;
230  if (T1==1) TBMMessage=1;
231  if (T2==1) TBMMessage=2;
232  if (T3==1) TBMMessage=3;
233  if (T4==1) TBMMessage=4;
234  if (T5==1) TBMMessage=5;
235  if (T6==1) TBMMessage=6;
236  if (T7==1) TBMMessage=7;
237  //if(TBMMessage==5 || TBMMessage==6) notReset=false;
238  int StateMach_bits = 4;
239  int StateMach_shift = 8;
240  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
241  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
242  switch(StateMach) {
243  case(0) : {
244  TBMType = 0;
245  break; }
246  case(1) : case(9) : {
247  TBMType = 1;
248  break; }
249  case(2) : case(4) : case(6) : {
250  TBMType = 2;
251  break; }
252  case(8) : {
253  TBMType = 3;
254  break; }
255  default : TBMType = 4;
256  };
257  break; }
258  case(31) : {
259  evtNbr = (errorWord >> ADC_shift) & ADC_mask;
260  break; }
261  case(36) : {
262  //ROCId = (errorWord >> ROC_shift) & ROC_mask;
263  break; }
264  case(37) : {
265  //DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
266  //PXId = (errorWord >> PXID_shift) & PXID_mask;
267  break; }
268  case(38) : {
269  //ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
270  break; }
271  default : break;
272  };
273  }//end if not double precision
274  }//end if modon
275 
276  if(ladon && barrel){
277  if(errorType == 32 || errorType == 33 || errorType == 34){
278  long long errorWord = di->getWord64(); // for 64-bit error words
279  if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
280  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
281  } else {
282  uint32_t errorWord = di->getWord32(); // for 32-bit error words
283  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
284  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
285  case(28) : {
286  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
287  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
288  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
289  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
290  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
291  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
292  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
293  if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
294  if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
295  if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
296  if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
297  if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
298  if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
299  if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
300  chanNmbr = 0;
301  break; }
302  case(29) : {
303  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
304  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
305  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
306  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
307  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
308  int BLOCK_bits = 3;
309  int BLOCK_shift = 8;
310  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
311  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
312  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
313  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
314  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
315  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
316  break; }
317  case(30) : {
318  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
319  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
320  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
321  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
322  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
323  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
324  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
325  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
326  if (T0==1) TBMMessage=0;
327  if (T1==1) TBMMessage=1;
328  if (T2==1) TBMMessage=2;
329  if (T3==1) TBMMessage=3;
330  if (T4==1) TBMMessage=4;
331  if (T5==1) TBMMessage=5;
332  if (T6==1) TBMMessage=6;
333  if (T7==1) TBMMessage=7;
334  int StateMach_bits = 4;
335  int StateMach_shift = 8;
336  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
337  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
338  switch(StateMach) {
339  case(0) : {
340  TBMType = 0;
341  break; }
342  case(1) : case(9) : {
343  TBMType = 1;
344  break; }
345  case(2) : case(4) : case(6) : {
346  TBMType = 2;
347  break; }
348  case(8) : {
349  TBMType = 3;
350  break; }
351  default : TBMType = 4;
352  };
353  break; }
354  case(31) : {
355  evtNbr = (errorWord >> ADC_shift) & ADC_mask;
356  break; }
357  case(36) : {
358  //int ROCId = (errorWord >> ROC_shift) & ROC_mask;
359  break; }
360  case(37) : {
361  //int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
362  //int PXId = (errorWord >> PXID_shift) & PXID_mask;
363  break; }
364  case(38) : {
365  //int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
366  break; }
367  default : break;
368  };
369  }
370  }//end if ladderon
371 
372  if(bladeon && endcap){
373  if(errorType == 32 || errorType == 33 || errorType == 34){
374  long long errorWord = di->getWord64(); // for 64-bit error words
375  if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
376  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
377  } else {
378  uint32_t errorWord = di->getWord32(); // for 32-bit error words
379  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
380  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
381  case(28) : {
382  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
383  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
384  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
385  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
386  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
387  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
388  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
389  if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
390  if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
391  if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
392  if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
393  if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
394  if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
395  if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
396  chanNmbr = 0;
397  break; }
398  case(29) : {
399  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
400  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
401  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
402  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
403  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
404  int BLOCK_bits = 3;
405  int BLOCK_shift = 8;
406  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
407  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
408  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
409  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
410  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
411  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
412  break; }
413  case(30) : {
414  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
415  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
416  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
417  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
418  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
419  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
420  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
421  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
422  if (T0==1) TBMMessage=0;
423  if (T1==1) TBMMessage=1;
424  if (T2==1) TBMMessage=2;
425  if (T3==1) TBMMessage=3;
426  if (T4==1) TBMMessage=4;
427  if (T5==1) TBMMessage=5;
428  if (T6==1) TBMMessage=6;
429  if (T7==1) TBMMessage=7;
430  int StateMach_bits = 4;
431  int StateMach_shift = 8;
432  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
433  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
434  switch(StateMach) {
435  case(0) : {
436  TBMType = 0;
437  break; }
438  case(1) : case(9) : {
439  TBMType = 1;
440  break; }
441  case(2) : case(4) : case(6) : {
442  TBMType = 2;
443  break; }
444  case(8) : {
445  TBMType = 3;
446  break; }
447  default : TBMType = 4;
448  };
449  break; }
450  case(31) : {
451  evtNbr = (errorWord >> ADC_shift) & ADC_mask;
452  break; }
453  case(36) : {
454  //int ROCId = (errorWord >> ROC_shift) & ROC_mask;
455  break; }
456  case(37) : {
457  //int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
458  //int PXId = (errorWord >> PXID_shift) & PXID_mask;
459  break; }
460  case(38) : {
461  //int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
462  break; }
463  default : break;
464  };
465  }
466  }//end if bladeon
467 
468  if(!(FedId==38&&chanNmbr==7)){ // mask slow channel that spits out lots of EventNumber errors even when in STDBY!
469  if(errorType==29 || (errorType==30 && TBMType==1)){ // consider only TIMEOUT and OVERFLOW as serious errors right now
470  //if(!(errorType==30) || notReset){
471  //cout<<"ERROR: "<<errorType<<" "<<TBMType<<endl;
472  std::string hid;
473  static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
474  char chNbuf[sizeof(chNfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
475  sprintf(chNbuf, chNfmt, FedId, chanNmbr);
476  hid = chNbuf;
477  meFedChNErrArray_[chanNmbr] = theDMBE->get(hid);
478  if(meFedChNErrArray_[chanNmbr]) meFedChNErrArray_[chanNmbr]->Fill(meFedChNErrArray_[chanNmbr]->getIntValue()+1);
479 
480  static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErrArray_%d";
481  char chLbuf[sizeof(chLfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
482  sprintf(chLbuf, chLfmt, FedId, chanNmbr);
483  hid = chLbuf;
484  meFedChLErrArray_[chanNmbr] = theDMBE->get(hid);
485  if(meFedChLErrArray_[chanNmbr]) meFedChLErrArray_[chanNmbr]->Fill(errorType);
486 
487  numberOfSeriousErrors++;
488  int messageType = 99;
489  if(errorType<30) messageType = errorType-25;
490  else if(errorType>30) messageType = errorType-19;
491  else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
492  else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
493  else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
494  else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
495  else if(errorType==30 && TBMType==1) messageType = errorType-21;
496  else if(errorType==30 && TBMType==2) messageType = errorType-20;
497  else if(errorType==30 && TBMType==3) messageType = errorType-19;
498  if(messageType<=20){
499  static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErrArray_%d";
500  char buf[sizeof(fmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
501  sprintf(buf, fmt, FedId, messageType);
502  hid = buf;
503  meFedETypeNErrArray_[messageType] = theDMBE->get(hid);
504  if(meFedETypeNErrArray_[messageType]) meFedETypeNErrArray_[messageType]->Fill(meFedETypeNErrArray_[messageType]->getIntValue()+1);
505  }
506  }
507 
508  std::string currDir = theDMBE->pwd();
509  static const char buf[] = "Pixel/AdditionalPixelErrors/FED_%d";
510  char feddir[sizeof(buf)+2];
511  sprintf(feddir,buf,FedId);
512  theDMBE->cd(feddir);
513  MonitorElement* me;
514  static const char buf1[] = "Pixel/AdditionalPixelErrors/FED_%d/NErrors_siPixelDigis_%d";
515  char hname1[sizeof(buf1)+4];
516  sprintf(hname1,buf1,FedId,FedId);
517  me = theDMBE->get(hname1);
518  if(me) me->Fill((int)numberOfSeriousErrors);
519  static const char buf2[] = "Pixel/AdditionalPixelErrors/FED_%d/TBMMessage_siPixelDigis_%d";
520  char hname2[sizeof(buf2)+4];
521  sprintf(hname2,buf2,FedId,FedId);
522  me = theDMBE->get(hname2);
523  if(me) me->Fill((int)TBMMessage);
524  static const char buf3[] = "Pixel/AdditionalPixelErrors/FED_%d/TBMType_siPixelDigis_%d";
525  char hname3[sizeof(buf3)+4];
526  sprintf(hname3,buf3,FedId,FedId);
527  me = theDMBE->get(hname3);
528  if(me) me->Fill((int)TBMType);
529  static const char buf4[] = "Pixel/AdditionalPixelErrors/FED_%d/errorType_siPixelDigis_%d";
530  char hname4[sizeof(buf4)+4];
531  sprintf(hname4,buf4,FedId,FedId);
532  me = theDMBE->get(hname4);
533  if(me) me->Fill((int)errorType);
534  static const char buf5[] = "Pixel/AdditionalPixelErrors/FED_%d/fullType_siPixelDigis_%d";
535  char hname5[sizeof(buf5)+4];
536  sprintf(hname5,buf5,FedId,FedId);
537  me = theDMBE->get(hname5);
538  if(me) me->Fill((int)fullType);
539  static const char buf6[] = "Pixel/AdditionalPixelErrors/FED_%d/EvtNbr_siPixelDigis_%d";
540  char hname6[sizeof(buf6)+4];
541  sprintf(hname6,buf6,FedId,FedId);
542  me = theDMBE->get(hname6);
543  if(me) me->Fill((int)evtNbr);
544  static const char buf7[] = "Pixel/AdditionalPixelErrors/FED_%d/evtSize_siPixelDigis_%d";
545  char hname7[sizeof(buf7)+4];
546  sprintf(hname7,buf7,FedId,FedId);
547  me = theDMBE->get(hname7);
548  if(me) me->Fill((int)evtSize);
549  theDMBE->cd(currDir);
550  }
551  }//end for loop over all errors on module
552  }//end if not an empty iterator
553 
554  return numberOfSeriousErrors;
555 }
556 
558  //std::cout<<"Entering SiPixelRawDataErrorModule::fillFED: "<<static_cast<int>(id_)<<std::endl;
559  DQMStore* theDMBE = edm::Service<DQMStore>().operator->();
560  unsigned int numberOfSeriousErrors = 0;
561 
562  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(0xffffffff); // search errors of detid
563  if( isearch != input.end() ) { // Not an empty iterator
564  // Look at FED errors now
566  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
567  int FedId = di->getFedId(); // FED the error came from
568  int chanNmbr = -1;
569  int errorType = 0; // type of error
570  if(FedId==static_cast<int>(id_)) {
571  errorType = di->getType(); // type of error
572  (meErrorType_)->Fill((int)errorType);
573  //bool notReset=true;
574  int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int fullType=-1;
575  const int LINK_bits = 6;
576  const int LINK_shift = 26;
577  const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
578  if((errorType == 32)||(errorType == 33)||(errorType == 34)) {
579  long long errorWord = di->getWord64(); // for 64-bit error words
580  chanNmbr = 0;
581  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
582  case(32) : {
583  break; }
584  case(33) : {
585  break; }
586  case(34) : {
587  evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
588  if(!(FedId==38&&chanNmbr==7)) (meEvtSize_)->Fill((int)evtSize);
589  break; }
590  default : break;
591  };
592  } else {
593  uint32_t errorWord = di->getWord32(); // for 32-bit error words
594  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
595  case(25) : case(39) : {
596  chanNmbr = 0;
597  break; }
598  case(28) : {
599  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
600  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
601  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
602  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
603  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
604  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
605  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
606  if (NFa==1) fullType = 1; (meFullType_)->Fill((int)fullType);
607  if (NFb==1) fullType = 2; (meFullType_)->Fill((int)fullType);
608  if (NFc==1) fullType = 3; (meFullType_)->Fill((int)fullType);
609  if (NFd==1) fullType = 4; (meFullType_)->Fill((int)fullType);
610  if (NFe==1) fullType = 5; (meFullType_)->Fill((int)fullType);
611  if (NF2==1) fullType = 6; (meFullType_)->Fill((int)fullType);
612  if (L1A==1) fullType = 7; (meFullType_)->Fill((int)fullType);
613  chanNmbr = 0;
614  break; }
615  case(29) : {
616  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
617  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
618  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
619  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
620  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
621  int BLOCK_bits = 3;
622  int BLOCK_shift = 8;
623  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
624  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
625  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
626  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
627  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
628  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
629  break; }
630  case(30) : {
631  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
632  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
633  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
634  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
635  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
636  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
637  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
638  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
639  if(!(FedId==38&&chanNmbr==7)){
640  if (T0==1) { TBMMessage=0; (meTBMMessage_)->Fill((int)TBMMessage); }
641  if (T1==1) { TBMMessage=1; (meTBMMessage_)->Fill((int)TBMMessage); }
642  if (T2==1) { TBMMessage=2; (meTBMMessage_)->Fill((int)TBMMessage); }
643  if (T3==1) { TBMMessage=3; (meTBMMessage_)->Fill((int)TBMMessage); }
644  if (T4==1) { TBMMessage=4; (meTBMMessage_)->Fill((int)TBMMessage); }
645  if (T5==1) { TBMMessage=5; (meTBMMessage_)->Fill((int)TBMMessage); }
646  if (T6==1) { TBMMessage=6; (meTBMMessage_)->Fill((int)TBMMessage); }
647  if (T7==1) { TBMMessage=7; (meTBMMessage_)->Fill((int)TBMMessage); }
648  }
649  //if(TBMMessage==5 || TBMMessage==6) notReset=false;
650  int StateMach_bits = 4;
651  int StateMach_shift = 8;
652  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
653  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
654  switch(StateMach) {
655  case(0) : {
656  TBMType = 0;
657  break; }
658  case(1) : case(9) : {
659  TBMType = 1;
660  break; }
661  case(2) : case(4) : case(6) : {
662  TBMType = 2;
663  break; }
664  case(8) : {
665  TBMType = 3;
666  break; }
667  default : TBMType = 4;
668  };
669  if(!(FedId==38&&chanNmbr==7)) (meTBMType_)->Fill((int)TBMType);
670  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
671  break; }
672  case(31) : {
673  int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
674  if(!(FedId==38&&chanNmbr==7))(meEvtNbr_)->Fill((int)evtNbr);
675  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
676  break; }
677  case(35) : case(36) : case(37) : case(38) : {
678  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
679  break; }
680  default : break;
681  };
682  }// end if errorType
683 
684  //if(!(errorType==30) || notReset){
685  if(errorType==29 || (errorType==30 && TBMType==1)){ // consider only TIMEOUT and OVERFLOW as serious errors right now
686  if(!(FedId==38&&chanNmbr==7)){ // mask slow channel that spits out lots of EventNumber errors even when in STDBY!
687  std::string hid;
688  //cout<<"FEDERROR: "<<errorType<<" "<<TBMType<<endl;
689  static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErrArray_%d";
690  char chNbuf[sizeof(chNfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
691  sprintf(chNbuf, chNfmt, FedId, chanNmbr);
692  hid = chNbuf;
693  meFedChNErrArray_[chanNmbr] = theDMBE->get(hid);
694  if(meFedChNErrArray_[chanNmbr]) meFedChNErrArray_[chanNmbr]->Fill(meFedChNErrArray_[chanNmbr]->getIntValue()+1);
695 
696  static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErrArray_%d";
697  char chLbuf[sizeof(chLfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
698  sprintf(chLbuf, chLfmt, FedId, chanNmbr);
699  hid = chLbuf;
700  meFedChLErrArray_[chanNmbr] = theDMBE->get(hid);
701  if(meFedChLErrArray_[chanNmbr]) meFedChLErrArray_[chanNmbr]->Fill(errorType);
702 
703  numberOfSeriousErrors++;
704  int messageType = 99;
705  if(errorType<30) messageType = errorType-25;
706  else if(errorType>30) messageType = errorType-19;
707  else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
708  else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
709  else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
710  else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
711  else if(errorType==30 && TBMType==1) messageType = errorType-21;
712  else if(errorType==30 && TBMType==2) messageType = errorType-20;
713  else if(errorType==30 && TBMType==3) messageType = errorType-19;
714  if(messageType<=20){
715  static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErrArray_%d";
716  char buf[sizeof(fmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
717  sprintf(buf, fmt, FedId, messageType);
718  hid = buf;
719  meFedETypeNErrArray_[messageType] = theDMBE->get(hid);
720  if(meFedETypeNErrArray_[messageType]) meFedETypeNErrArray_[messageType]->Fill(meFedETypeNErrArray_[messageType]->getIntValue()+1);
721  }
722  }//end if bad channel
723  }//end if not 30 || notReset
724  }//end if
725  }//end for
726  if(numberOfSeriousErrors>0) (meNErrors_)->Fill((float)numberOfSeriousErrors);
727 
728  }// end if not an empty iterator
729 
730 //std::cout<<"...leaving SiPixelRawDataErrorModule::fillFED. "<<std::endl;
731  return numberOfSeriousErrors;
732 }
const int DCOL_bits
Definition: ErrorChecker.cc:23
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
iterator find(det_id_type id)
Definition: DetSetVector.h:285
MonitorElement * meFedChLErrArray_[37]
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:411
const int DCOL_shift
Definition: ErrorChecker.cc:31
MonitorElement * meFedChNErrArray_[37]
static const long long TRLRBGN_mask
void bookFED(const edm::ParameterSet &iConfig)
Book FED histograms.
const int PXID_shift
Definition: ErrorChecker.cc:30
void Fill(long long x)
int fillFED(const edm::DetSetVector< SiPixelRawDataError > &input)
Fill FED histograms.
static const char * fmt
Definition: Version.cc:9
MonitorElement * meFedETypeNErrArray_[21]
int fill(const edm::DetSetVector< SiPixelRawDataError > &input, bool modon=true, bool ladon=false, bool bladeon=false)
Fill histograms.
static const long long TRLREND_mask
void book(const edm::ParameterSet &iConfig, int type=0)
Book histograms.
static const uint32_t DataBit_mask
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
const int ADC_shift
Definition: ErrorChecker.cc:29
int j
Definition: DBlmapReader.cc:9
const int ROC_bits
Definition: ErrorChecker.cc:22
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
SiPixelRawDataErrorModule()
Default constructor.
const int ADC_bits
Definition: ErrorChecker.cc:25
Definition: DetId.h:20
const int LINK_bits
Definition: ErrorChecker.cc:21
static const long long EVTLGT_mask
const int ROC_shift
Definition: ErrorChecker.cc:32
std::string const & label() const
Definition: InputTag.h:42
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:341
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:106
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
const int PXID_bits
Definition: ErrorChecker.cc:24
const std::string & pwd(void) const
Definition: DQMStore.cc:406