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