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, DQMStore::IBooker & iBooker, int type, bool isUpgrade) {}
97 //
98 // Fill histograms
99 //
100 int SiPixelRawDataErrorModule::fill(const edm::DetSetVector<SiPixelRawDataError>& input, std::map<std::string,MonitorElement**> *meMapFEDs, bool modon, bool ladon, bool bladeon) {
101  bool barrel = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel);
102  bool endcap = DetId(id_).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap);
103 
104  // Get DQM interface
105 
106  unsigned int numberOfSeriousErrors = 0;
107 
108  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(id_); // search errors of detid
109 
110  if( isearch != input.end() ) { // Not at empty iterator
111  // Look at errors now
113  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
114  int FedId = di->getFedId(); // FED the error came from
115  int chanNmbr = 0;
116  int errorType = di->getType(); // type of error
117  int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int evtNbr=-1; int fullType=-1;
118  bool notReset = true;
119  const int LINK_bits = 6;
120  const int LINK_shift = 26;
121  const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
122 
123  if(modon){
124  if(errorType == 32 || errorType == 33 || errorType == 34) {
125  long long errorWord = di->getWord64(); // for 64-bit error words
126  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
127  if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
128  } else {
129  uint32_t errorWord = di->getWord32(); // for 32-bit error words
130  chanNmbr = (errorWord >> LINK_shift) & LINK_mask; // default way to get channel number. Only different for case 29 below.
131  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
132  case(28) : {
133  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
134  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
135  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
136  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
137  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
138  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
139  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
140  if (NFa==1) fullType = 1; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
141  if (NFb==1) fullType = 2; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
142  if (NFc==1) fullType = 3; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
143  if (NFd==1) fullType = 4; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
144  if (NFe==1) fullType = 5; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
145  if (NF2==1) fullType = 6; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
146  if (L1A==1) fullType = 7; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
147  chanNmbr = 0; // signifies channel not known
148  break; }
149  case(29) : {
150  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
151  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
152  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
153  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
154  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
155  int BLOCK_bits = 3;
156  int BLOCK_shift = 8;
157  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
158  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
159  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
160  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
161  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
162  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
163  break; }
164  case(30) : {
165  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
166  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
167  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
168  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
169  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
170  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
171  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
172  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
173  if (T0==1) TBMMessage=0;
174  if (T1==1) TBMMessage=1;
175  if (T2==1) TBMMessage=2;
176  if (T3==1) TBMMessage=3;
177  if (T4==1) TBMMessage=4;
178  if (T5==1) TBMMessage=5;
179  if (T6==1) TBMMessage=6;
180  if (T7==1) TBMMessage=7;
181  if(TBMMessage==5 || TBMMessage==6) notReset=false;
182  int StateMach_bits = 4;
183  int StateMach_shift = 8;
184  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
185  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
186  switch(StateMach) {
187  case(0) : {
188  TBMType = 0;
189  break; }
190  case(1) : case(9) : {
191  TBMType = 1;
192  break; }
193  case(2) : case(4) : case(6) : {
194  TBMType = 2;
195  break; }
196  case(8) : {
197  TBMType = 3;
198  break; }
199  default : TBMType = 4;
200  };
201  break; }
202  case(31) : {
203  evtNbr = (errorWord >> ADC_shift) & ADC_mask;
204  break; }
205  case(36) : {
206  //ROCId = (errorWord >> ROC_shift) & ROC_mask;
207  break; }
208  case(37) : {
209  //DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
210  //PXId = (errorWord >> PXID_shift) & PXID_mask;
211  break; }
212  case(38) : {
213  //ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
214  break; }
215  default : break;
216  };
217  }//end if not double precision
218  }//end if modon
219 
220  if(ladon && barrel){
221  if(errorType == 32 || errorType == 33 || errorType == 34){
222  long long errorWord = di->getWord64(); // for 64-bit error words
223  if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
224  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
225  } else {
226  uint32_t errorWord = di->getWord32(); // for 32-bit error words
227  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
228  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
229  case(28) : {
230  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
231  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
232  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
233  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
234  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
235  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
236  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
237  if (NFa==1) fullType = 1; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
238  if (NFb==1) fullType = 2; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
239  if (NFc==1) fullType = 3; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
240  if (NFd==1) fullType = 4; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
241  if (NFe==1) fullType = 5; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
242  if (NF2==1) fullType = 6; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
243  if (L1A==1) fullType = 7; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
244  chanNmbr = 0;
245  break; }
246  case(29) : {
247  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
248  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
249  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
250  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
251  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
252  int BLOCK_bits = 3;
253  int BLOCK_shift = 8;
254  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
255  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
256  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
257  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
258  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
259  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
260  break; }
261  case(30) : {
262  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
263  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
264  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
265  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
266  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
267  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
268  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
269  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
270  if (T0==1) TBMMessage=0;
271  if (T1==1) TBMMessage=1;
272  if (T2==1) TBMMessage=2;
273  if (T3==1) TBMMessage=3;
274  if (T4==1) TBMMessage=4;
275  if (T5==1) TBMMessage=5;
276  if (T6==1) TBMMessage=6;
277  if (T7==1) TBMMessage=7;
278  int StateMach_bits = 4;
279  int StateMach_shift = 8;
280  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
281  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
282  switch(StateMach) {
283  case(0) : {
284  TBMType = 0;
285  break; }
286  case(1) : case(9) : {
287  TBMType = 1;
288  break; }
289  case(2) : case(4) : case(6) : {
290  TBMType = 2;
291  break; }
292  case(8) : {
293  TBMType = 3;
294  break; }
295  default : TBMType = 4;
296  };
297  break; }
298  case(31) : {
299  evtNbr = (errorWord >> ADC_shift) & ADC_mask;
300  break; }
301  case(36) : {
302  //int ROCId = (errorWord >> ROC_shift) & ROC_mask;
303  break; }
304  case(37) : {
305  //int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
306  //int PXId = (errorWord >> PXID_shift) & PXID_mask;
307  break; }
308  case(38) : {
309  //int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
310  break; }
311  default : break;
312  };
313  }
314  }//end if ladderon
315 
316  if(bladeon && endcap){
317  if(errorType == 32 || errorType == 33 || errorType == 34){
318  long long errorWord = di->getWord64(); // for 64-bit error words
319  if(errorType == 34) evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
320  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
321  } else {
322  uint32_t errorWord = di->getWord32(); // for 32-bit error words
323  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
324  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
325  case(28) : {
326  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
327  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
328  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
329  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
330  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
331  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
332  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
333  if (NFa==1) fullType = 1; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
334  if (NFb==1) fullType = 2; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
335  if (NFc==1) fullType = 3; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
336  if (NFd==1) fullType = 4; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
337  if (NFe==1) fullType = 5; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
338  if (NF2==1) fullType = 6; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
339  if (L1A==1) fullType = 7; ((*meMapFEDs)["meFullType_"][FedId])->Fill((int)fullType);
340  chanNmbr = 0;
341  break; }
342  case(29) : {
343  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
344  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
345  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
346  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
347  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
348  int BLOCK_bits = 3;
349  int BLOCK_shift = 8;
350  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
351  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
352  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
353  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
354  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
355  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
356  break; }
357  case(30) : {
358  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
359  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
360  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
361  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
362  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
363  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
364  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
365  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
366  if (T0==1) TBMMessage=0;
367  if (T1==1) TBMMessage=1;
368  if (T2==1) TBMMessage=2;
369  if (T3==1) TBMMessage=3;
370  if (T4==1) TBMMessage=4;
371  if (T5==1) TBMMessage=5;
372  if (T6==1) TBMMessage=6;
373  if (T7==1) TBMMessage=7;
374  int StateMach_bits = 4;
375  int StateMach_shift = 8;
376  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
377  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
378  switch(StateMach) {
379  case(0) : {
380  TBMType = 0;
381  break; }
382  case(1) : case(9) : {
383  TBMType = 1;
384  break; }
385  case(2) : case(4) : case(6) : {
386  TBMType = 2;
387  break; }
388  case(8) : {
389  TBMType = 3;
390  break; }
391  default : TBMType = 4;
392  };
393  break; }
394  case(31) : {
395  evtNbr = (errorWord >> ADC_shift) & ADC_mask;
396  break; }
397  case(36) : {
398  //int ROCId = (errorWord >> ROC_shift) & ROC_mask;
399  break; }
400  case(37) : {
401  //int DCOLId = (errorWord >> DCOL_shift) & DCOL_mask;
402  //int PXId = (errorWord >> PXID_shift) & PXID_mask;
403  break; }
404  case(38) : {
405  //int ROCNmbr = (errorWord >> ROC_shift) & ROC_mask;
406  break; }
407  default : break;
408  };
409  }
410  }//end if bladeon
411 
412  // Example to mask a specific bad channel --> if(!(FedId==38&&chanNmbr==7)){
413  if(!(errorType==30) || notReset){
414  std::string hid;
415  static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErr_%d";
416  char chNbuf[sizeof(chNfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
417  sprintf(chNbuf, chNfmt, FedId, chanNmbr);
418  hid = chNbuf;
419  if((*meMapFEDs)["meFedChNErr_"][FedId]) (*meMapFEDs)["meFedChNErr_"][FedId]->Fill(chanNmbr);
420 
421  static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErr_%d";
422  char chLbuf[sizeof(chLfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
423  sprintf(chLbuf, chLfmt, FedId, chanNmbr);
424  hid = chLbuf;
425  if((*meMapFEDs)["meFedChLErr_"][FedId]) (*meMapFEDs)["meFedChLErr_"][FedId]->setBinContent(chanNmbr+1,errorType);
426 
427  numberOfSeriousErrors++;
428  int messageType = 99;
429  if(errorType<30) messageType = errorType-25;
430  else if(errorType>30) messageType = errorType-19;
431  else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
432  else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
433  else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
434  else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
435  else if(errorType==30 && TBMType==1) messageType = errorType-21;
436  else if(errorType==30 && TBMType==2) messageType = errorType-20;
437  else if(errorType==30 && TBMType==3) messageType = errorType-19;
438  if(messageType<=20){
439  static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErr_%d";
440  char buf[sizeof(fmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
441  sprintf(buf, fmt, FedId, messageType);
442  hid = buf;
443  if((*meMapFEDs)["meFedETypeNErr_"][FedId]) (*meMapFEDs)["meFedETypeNErr_"][FedId]->Fill(messageType);
444  }
445  }
446 
447  (*meMapFEDs)["meNErrors_"][FedId]->Fill((int)numberOfSeriousErrors);
448  (*meMapFEDs)["meTBMMessage_"][FedId]->Fill((int)TBMMessage);
449  (*meMapFEDs)["meTBMType_"][FedId]->Fill((int)TBMType);
450  (*meMapFEDs)["meErrorType_"][FedId]->Fill((int)errorType);
451  (*meMapFEDs)["meFullType_"][FedId]->Fill((int)fullType);
452  (*meMapFEDs)["meEvtNbr_"][FedId]->setBinContent(1,(int)evtNbr);
453  (*meMapFEDs)["meEvtSize_"][FedId]->setBinContent(1,(int)evtSize);
454  }
455  }//end if not an empty iterator
456  return numberOfSeriousErrors;
457 }
458 
459 int SiPixelRawDataErrorModule::fillFED(const edm::DetSetVector<SiPixelRawDataError>& input, std::map<std::string,MonitorElement**> *meMapFEDs) {
460  unsigned int numberOfSeriousErrors = 0;
461 
462  edm::DetSetVector<SiPixelRawDataError>::const_iterator isearch = input.find(0xffffffff); // search errors of detid
463  if( isearch != input.end() ) { // Not an empty iterator
464  // Look at FED errors now
466  for(di = isearch->data.begin(); di != isearch->data.end(); di++) {
467  int FedId = di->getFedId(); // FED the error came from
468  int chanNmbr = -1;
469  int errorType = 0; // type of error
470  if(FedId==static_cast<int>(id_)) {
471  errorType = di->getType(); // type of error
472  ((*meMapFEDs)["meErrorType_"][id_])->Fill((int)errorType);
473  bool notReset=true;
474  int TBMType=-1; int TBMMessage=-1; int evtSize=-1; int fullType=-1;
475  const int LINK_bits = 6;
476  const int LINK_shift = 26;
477  const uint32_t LINK_mask = ~(~(uint32_t)(0) << LINK_bits);
478  if((errorType == 32)||(errorType == 33)||(errorType == 34)) {
479  long long errorWord = di->getWord64(); // for 64-bit error words
480  chanNmbr = 0;
481  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
482  case(32) : {
483  break; }
484  case(33) : {
485  break; }
486  case(34) : {
487  evtSize = (errorWord >> EVTLGT_shift) & EVTLGT_mask;
488  ((*meMapFEDs)["meEvtSize_"][id_])->setBinContent(1,(int)evtSize);
489  break; }
490  default : break;
491  };
492  } else {
493  uint32_t errorWord = di->getWord32(); // for 32-bit error words
494  switch(errorType) { // fill in the appropriate monitorables based on the information stored in the error word
495  case(25) : case(39) : {
496  chanNmbr = 0;
497  break; }
498  case(28) : {
499  int NFa = (errorWord >> DB0_shift) & DataBit_mask;
500  int NFb = (errorWord >> DB1_shift) & DataBit_mask;
501  int NFc = (errorWord >> DB2_shift) & DataBit_mask;
502  int NFd = (errorWord >> DB3_shift) & DataBit_mask;
503  int NFe = (errorWord >> DB4_shift) & DataBit_mask;
504  int NF2 = (errorWord >> DB6_shift) & DataBit_mask;
505  int L1A = (errorWord >> DB7_shift) & DataBit_mask;
506  if (NFa==1) fullType = 1; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
507  if (NFb==1) fullType = 2; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
508  if (NFc==1) fullType = 3; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
509  if (NFd==1) fullType = 4; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
510  if (NFe==1) fullType = 5; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
511  if (NF2==1) fullType = 6; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
512  if (L1A==1) fullType = 7; ((*meMapFEDs)["meFullType_"][id_])->Fill((int)fullType);
513  chanNmbr = 0;
514  break; }
515  case(29) : {
516  int CH1 = (errorWord >> DB0_shift) & DataBit_mask;
517  int CH2 = (errorWord >> DB1_shift) & DataBit_mask;
518  int CH3 = (errorWord >> DB2_shift) & DataBit_mask;
519  int CH4 = (errorWord >> DB3_shift) & DataBit_mask;
520  int CH5 = (errorWord >> DB4_shift) & DataBit_mask;
521  int BLOCK_bits = 3;
522  int BLOCK_shift = 8;
523  uint32_t BLOCK_mask = ~(~uint32_t(0) << BLOCK_bits);
524  int BLOCK = (errorWord >> BLOCK_shift) & BLOCK_mask;
525  int localCH = 1*CH1+2*CH2+3*CH3+4*CH4+5*CH5;
526  if (BLOCK%2==0) chanNmbr=(BLOCK/2)*9+localCH;
527  else chanNmbr = ((BLOCK-1)/2)*9+4+localCH;
528  if ((chanNmbr<1)||(chanNmbr>36)) chanNmbr=0; // signifies unexpected result
529  break; }
530  case(30) : {
531  int T0 = (errorWord >> DB0_shift) & DataBit_mask;
532  int T1 = (errorWord >> DB1_shift) & DataBit_mask;
533  int T2 = (errorWord >> DB2_shift) & DataBit_mask;
534  int T3 = (errorWord >> DB3_shift) & DataBit_mask;
535  int T4 = (errorWord >> DB4_shift) & DataBit_mask;
536  int T5 = (errorWord >> DB5_shift) & DataBit_mask;
537  int T6 = (errorWord >> DB6_shift) & DataBit_mask;
538  int T7 = (errorWord >> DB7_shift) & DataBit_mask;
539  if(!(FedId==38&&chanNmbr==7)){
540  if (T0==1) { TBMMessage=0; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
541  if (T1==1) { TBMMessage=1; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
542  if (T2==1) { TBMMessage=2; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
543  if (T3==1) { TBMMessage=3; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
544  if (T4==1) { TBMMessage=4; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
545  if (T5==1) { TBMMessage=5; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
546  if (T6==1) { TBMMessage=6; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
547  if (T7==1) { TBMMessage=7; ((*meMapFEDs)["meTBMMessage_"][id_])->Fill((int)TBMMessage); }
548  }
549  if(TBMMessage==5 || TBMMessage==6) notReset=false;
550  int StateMach_bits = 4;
551  int StateMach_shift = 8;
552  uint32_t StateMach_mask = ~(~uint32_t(0) << StateMach_bits);
553  int StateMach = (errorWord >> StateMach_shift) & StateMach_mask;
554  switch(StateMach) {
555  case(0) : {
556  TBMType = 0;
557  break; }
558  case(1) : case(9) : {
559  TBMType = 1;
560  break; }
561  case(2) : case(4) : case(6) : {
562  TBMType = 2;
563  break; }
564  case(8) : {
565  TBMType = 3;
566  break; }
567  default : TBMType = 4;
568  };
569  if(!(FedId==38&&chanNmbr==7)) ((*meMapFEDs)["meTBMType_"][id_])->Fill((int)TBMType);
570  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
571  break; }
572  case(31) : {
573  int evtNbr = (errorWord >> ADC_shift) & ADC_mask;
574  if(!(FedId==38&&chanNmbr==7))((*meMapFEDs)["meEvtNbr_"][id_])->setBinContent(1,(int)evtNbr);
575  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
576  break; }
577  case(35) : case(36) : case(37) : case(38) : {
578  chanNmbr = (errorWord >> LINK_shift) & LINK_mask;
579  break; }
580  default : break;
581  };
582  }// end if errorType
583 
584  if(!(errorType==30) || notReset){
585  std::string hid;
586  static const char chNfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChNErr_%d";
587  char chNbuf[sizeof(chNfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
588  sprintf(chNbuf, chNfmt, FedId, chanNmbr);
589  hid = chNbuf;
590  if((*meMapFEDs)["meFedChNErr_"][id_]) (*meMapFEDs)["meFedChNErr_"][id_]->Fill(chanNmbr);
591 
592  static const char chLfmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedChLErr_%d";
593  char chLbuf[sizeof(chLfmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
594  sprintf(chLbuf, chLfmt, FedId, chanNmbr);
595  hid = chLbuf;
596  if((*meMapFEDs)["meFedChLErr_"][id_]) (*meMapFEDs)["meFedChLErr_"][id_]->setBinContent(chanNmbr+1,errorType);
597 
598  numberOfSeriousErrors++;
599  int messageType = 99;
600  if(errorType<30) messageType = errorType-25;
601  else if(errorType>30) messageType = errorType-19;
602  else if(errorType==30 && TBMMessage==0) messageType = errorType-25;
603  else if(errorType==30 && TBMMessage==1) messageType = errorType-24;
604  else if(errorType==30 && (TBMMessage==2 || TBMMessage==3 || TBMMessage==4)) messageType = errorType-23;
605  else if(errorType==30 && TBMMessage==7) messageType = errorType-22;
606  else if(errorType==30 && TBMType==1) messageType = errorType-21;
607  else if(errorType==30 && TBMType==2) messageType = errorType-20;
608  else if(errorType==30 && TBMType==3) messageType = errorType-19;
609  if(messageType<=20){
610  static const char fmt[] = "Pixel/AdditionalPixelErrors/FED_%d/FedETypeNErr_%d";
611  char buf[sizeof(fmt) + 2*32]; // 32 digits is enough for up to 2^105 + sign.
612  sprintf(buf, fmt, FedId, messageType);
613  hid = buf;
614  if((*meMapFEDs)["meFedETypeNErr_"][id_]) (*meMapFEDs)["meFedETypeNErr_"][id_]->Fill(messageType);
615  }
616  }//end if not 30 || notReset
617  }//end if
618  }//end for
619  if(numberOfSeriousErrors>0) ((*meMapFEDs)["meNErrors_"][id_])->Fill((float)numberOfSeriousErrors);
620  }// end if not an empty iterator
621  return numberOfSeriousErrors;
622 }
type
Definition: HCALResponse.h:21
iterator find(det_id_type id)
Definition: DetSetVector.h:290
static const long long TRLRBGN_mask
void book(const edm::ParameterSet &iConfig, DQMStore::IBooker &, int type=0, bool isUpgrade=false)
Book histograms.
int fillFED(const edm::DetSetVector< SiPixelRawDataError > &input, std::map< std::string, MonitorElement ** > *meMapFEDs)
Fill FED histograms.
static std::string const input
Definition: EdmProvDump.cc:44
int fill(const edm::DetSetVector< SiPixelRawDataError > &input, std::map< std::string, MonitorElement ** > *meMapFEDs, bool modon=true, bool ladon=false, bool bladeon=false)
Fill histograms.
static const char * fmt
Definition: Version.cc:9
static const long long TRLREND_mask
static const uint32_t DataBit_mask
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
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:361
SiPixelRawDataErrorModule()
Default constructor.
Definition: DetId.h:18
static const long long EVTLGT_mask
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104