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