QwAnalysis
QwF1TDContainer.cc
Go to the documentation of this file.
1 
2 #include "QwF1TDContainer.h"
3 
4 #include "QwColor.h"
5 #include "QwLog.h"
6 
7 #include "TROOT.h"
8 #include "TFile.h"
9 
10 
11 /**
12  * \file QwF1TDContainer.cc
13  * \brief
14  * \author jhlee@jlab.org
15  * \date Tuesday, September 14 23:04:36 EDT 2010
16  */
17 
22 
23 //
24 //
25 //
26 // QwF1TDC
27 //
28 //
29 //
30 //
31 
32 
33 const Int_t QwF1TDC::fWordsPerBuffer = 16;
34 const Int_t QwF1TDC::fMaxF1TDCChannelNumber = 64;
35 
36 // prefare when I decide to use Stream...
37 //
38 // QwF1TDC::QwF1TDC()
39 // {
40 // fROC = -1;
41 // fSlot = -1;
42 
43 // fChannelNumber = 0;
44 
45 // fF1TDC_refcnt = 0;
46 // fF1TDC_hsdiv = 0;
47 // fF1TDC_refclkdiv = 0;
48 // fF1TDC_trigwin = 0;
49 // fF1TDC_triglat = 0;
50 
51 // fF1TDC_tframe_ns = 0.0;
52 // fF1TDC_full_range_ns = 0.0;
53 // fF1TDC_window_ns = 0.0;
54 // fF1TDC_latency_ns = 0.0;
55 // fF1TDC_resolution_ns = 0.0;
56 
57 // fF1TDC_t_offset = 0.0;
58 
59 // fF1TDC_SEU_counter = NULL;
60 // fF1TDC_EMM_counter = NULL;
61 // fF1TDC_SYN_counter = NULL;
62 // fF1TDC_TFO_counter = NULL;
63 
64 // fF1TDC_RLF_counter = NULL;
65 // fF1TDC_HFO_counter = NULL;
66 // fF1TDC_OFO_counter = NULL;
67 
68 // fF1TDC_FDF_counter = NULL;
69 // fF1TDC_S30_counter = NULL;
70 
71 
72 // fReferenceSignals = NULL;
73 
74 // fReferenceSlotFlag = false;
75 // fF1TDCNormResFlag = true;
76 // fF1TDCSyncFlag = true;
77 
78 // fF1TDCFactor = 0.0;
79 
80 // fF1TDCIndex = -1;
81 // fF1BankIndex = -1;
82 
83 // fBuffer = NULL;
84 
85 // }
86 
88 {
89  fROC = -1;
90  fSlot = -1;
91 
92  fChannelNumber = 0;
93 
94  fF1TDC_refcnt = 0;
95  fF1TDC_hsdiv = 0;
96  fF1TDC_refclkdiv = 0;
97  fF1TDC_trigwin = 0;
98  fF1TDC_triglat = 0;
99 
100  fF1TDC_tframe_ns = 0.0;
101  fF1TDC_full_range_ns = 0.0;
102  fF1TDC_window_ns = 0.0;
103  fF1TDC_latency_ns = 0.0;
104  fF1TDC_resolution_ns = 0.0;
105 
106  fF1TDC_t_offset = 0.0;
107 
112 
116 
119 
120  fF1TDC_RFM_counter = 0;
121 
122  fReferenceSignals = NULL;
123 
124  fReferenceSlotFlag = false;
125  fF1TDCNormResFlag = true;
126  fF1TDCSyncFlag = true;
127 
128  fF1TDCFactor = 0.0;
129 
130  fF1TDCIndex = -1;
131  fF1BankIndex = -1;
132 
133  fBuffer = new UInt_t[fWordsPerBuffer];
134 
135  ResetCounters();
136 }
137 
138 
139 
140 QwF1TDC::QwF1TDC(const Int_t roc, const Int_t slot)
141 {
142  fROC = roc;
143  // fROCIndex = -1;
144  fSlot = slot;
145 
146  fChannelNumber = 0;
147 
148  fF1TDC_refcnt = 0;
149  fF1TDC_hsdiv = 0;
150  fF1TDC_refclkdiv = 0;
151  fF1TDC_trigwin = 0;
152  fF1TDC_triglat = 0;
153 
154  fF1TDC_tframe_ns = 0.0;
155  fF1TDC_full_range_ns = 0.0;
156  fF1TDC_window_ns = 0.0;
157  fF1TDC_latency_ns = 0.0;
158  fF1TDC_resolution_ns = 0.0;
159 
160  fF1TDC_t_offset = 0.0;
161 
166 
170 
173 
174  fF1TDC_RFM_counter = 0;
175 
176  fReferenceSignals = NULL;
177 
178  fReferenceSlotFlag = false;
179  fF1TDCNormResFlag = true;
180  fF1TDCSyncFlag = true;
181 
182  fF1TDCFactor = 0.0;
183 
184  fF1TDCIndex = -1;
185  fF1BankIndex = -1;
186 
187  fBuffer = new UInt_t[fWordsPerBuffer];
188 
189  ResetCounters();
190 }
191 
192 
194 {
195  delete [] fBuffer;
196  delete [] fReferenceSignals;
197  //delete [] fF1TDCReferenceChannels;
198  delete [] fF1TDC_SEU_counter;
199  delete [] fF1TDC_EMM_counter;
200  delete [] fF1TDC_SYN_counter;
201  delete [] fF1TDC_TFO_counter;
202 
203  delete [] fF1TDC_RLF_counter;
204  delete [] fF1TDC_HFO_counter;
205  delete [] fF1TDC_OFO_counter;
206 
207  delete [] fF1TDC_FDF_counter;
208  delete [] fF1TDC_S30_counter;
209 
210 }
211 
212 void
213 QwF1TDC::SetF1TDCBuffer(UInt_t *buffer, UInt_t num_words)
214 {
215  UInt_t i = 0;
216  Int_t j = 0;
217  UInt_t start_index = 0;
218 
219  for(i=0; i<num_words; i++ ) {
220  if(buffer[i] == (UInt_t) fSlot) start_index = i;
221  }
222 
223 
224  // reassign buffer with 16 bits trim, because f1 configuration register is 16 bits
225  Int_t F1_16Bits = 0xFFFF;
226  Int_t F1_9Bits = 0x01FF;
227 
228  Double_t buffer_range = (Double_t) F1_16Bits + 1.0;
229  Double_t trig_range = (Double_t) F1_9Bits + 1.0;
230 
231  for(j=0; j<fWordsPerBuffer; j++) {
232  // exclude the first buffer, because it contains "slot" number.
233  fBuffer[j] = buffer[start_index+1+j] & F1_16Bits;
234  }
235 
236 
237  // decide Normal or High Resolution Mode
238  if ( fBuffer[1] & 0x8000 ) {
239  fF1TDCFactor = 0.5;
240  fF1TDCNormResFlag = false;
241  }
242  else {
243  fF1TDCFactor = 1.0;
244  fF1TDCNormResFlag = true;
245  }
246 
247 
248  // check whether Synchronous mode or not
249  if( fBuffer[15] & 0x4 ) {
250  fF1TDCSyncFlag = true;
251  }
252  else {
253  fF1TDCSyncFlag = false;
254  }
255  // calculate resolution_ns or bin_size_ns and full_range_ns
256  Double_t f1tdc_internal_reference_clock_ns = 25.0; // 40MHz
257  // decide max channel number of F1TDC according to "resolution mode"
258 
260 
261  // get refcnt and calculate tframe_ns
262  fF1TDC_refcnt = (fBuffer[7]>>6) & 0x1FF;
263  fF1TDC_tframe_ns = (Double_t)(f1tdc_internal_reference_clock_ns * (fF1TDC_refcnt +2 ));
264 
265 
266  // calculate refclkdiv
267  UInt_t exponent = 0;
268  exponent = ( fBuffer[10] >> 8 ) & 0x7;
269 
270  fF1TDC_refclkdiv = 1;
271  for(UInt_t ii = 0; ii < exponent; ii++) fF1TDC_refclkdiv = 2 * fF1TDC_refclkdiv;
272 
273  // get hsdiv
274  fF1TDC_hsdiv = fBuffer[10] & 0xFF;
275 
276 
277  fF1TDC_resolution_ns = fF1TDCFactor * (f1tdc_internal_reference_clock_ns/152.0) * ( (Double_t) fF1TDC_refclkdiv )/( (Double_t) fF1TDC_hsdiv );
279 
280  // get trigwin and triglat
281  fF1TDC_trigwin = fBuffer[8] & F1_16Bits;
282  fF1TDC_triglat = fBuffer[9] & F1_16Bits;
283 
284  // calculate trigger window_ns and trigger latency_ns
285  fF1TDC_window_ns = ((Double_t)fF1TDC_trigwin) * fF1TDC_resolution_ns / fF1TDCFactor;
286  fF1TDC_latency_ns = ((Double_t)fF1TDC_triglat) * fF1TDC_resolution_ns / fF1TDCFactor;
287 
288  // calculate trigger resolution_ns
289  fF1TDC_trig_resolution_ns = fF1TDC_resolution_ns * 128.0; // buffer_range / trig_range = 65536 /512 = 128
290 
291  // calculate the rollover counter (t_offset) if synchronoues mode is used
292  if(fF1TDCSyncFlag) {
295  }
296  else {
297  fF1TDC_t_offset = buffer_range; // no offset (rollover)
298  fF1TDC_trig_t_offset = trig_range;
299  }
300 
301  return;
302 }
303 
304 
305 Double_t
306 QwF1TDC::ReferenceSignalCorrection(Double_t raw_time, Double_t ref_time)
307 {
308 
309 
310  Double_t actual_time_difference = 0.0;
311 
312 
313  // If we don't have the reference signal in the case that
314  // it is recorded as "0.0" or it isn't recorded at the same time when the raw_time is recoreded
315  // return zero corrected time, because without a reference time, raw_time has no meaning
316  // Friday, January 20 13:04:33 EST 2012 , jhlee
317 
318  if (ref_time !=0.0) {
319 
320  Double_t trigger_window = (Double_t) fF1TDC_trigwin;
321  Double_t time_offset = (Double_t) fF1TDC_t_offset; // effective total bin numbers
322  Double_t time_condition = 0.0;
323  Double_t local_time_difference = 0.0;
324 
325  local_time_difference = raw_time - ref_time;
326 
327  if(local_time_difference != 0.0) {
328 
329  time_condition = fabs(local_time_difference);
330  // maximum value is trigger_window -1,
331  if(time_condition < trigger_window) {
332  // there is no ROLLEVENT within trigger window
333  actual_time_difference = local_time_difference;
334  }
335  else {
336  // there is an ROLLOVER event within trigger window
337  if (local_time_difference > 0.0) {
338  // ref_time is in after ROLLOVER event
339  actual_time_difference = local_time_difference - time_offset;
340  }
341  else {
342  // we already excluded local_time_diffrence == 0 case.
343  // ref_time is in before ROLLOVER event
344  actual_time_difference = local_time_difference + time_offset;
345  }
346  }
347  }
348  else {
349  // raw_time is the same as ref_time
350  // std::cout << "QwF1TDC::ReferenceSignalCorrection "
351  // << local_time_difference
352  // << " ref " << ref_time
353  // << " raw " << raw_time
354  // << std::endl;
355  actual_time_difference = local_time_difference;
356  }
357 
358  }
359  else {
361  }
362  // Double_t trigger_window = (Double_t) fF1TDC_trigwin;
363  // Double_t time_offset = (Double_t) fF1TDC_t_offset;
364 
365 
366  // Double_t time_condition = 0.0;
367  // Double_t local_time_difference = 0.0;
368  // Double_t actual_time_difference = 0.0;
369 
370  // local_time_difference = raw_time - ref_time;
371 
372  // if(local_time_difference == 0.0) {
373  // // raw_time is the same as ref_time
374  // // std::cout << "QwF1TDC::ReferenceSignalCorrection "
375  // // << local_time_difference
376  // // << " ref " << ref_time
377  // // << " raw " << raw_time
378  // // << std::endl;
379  // actual_time_difference = local_time_difference;
380  // }
381  // else {
382  // time_condition = fabs(local_time_difference);
383  // // maximum value is trigger_window -1,
384  // if(time_condition < trigger_window) {
385  // // there is no ROLLEVENT within trigger window
386  // actual_time_difference = local_time_difference;
387  // }
388  // else {
389  // // there is an ROLLOVER event within trigger window
390  // if (local_time_difference > 0.0) {
391  // // ref_time is in after ROLLOVER event
392  // actual_time_difference = local_time_difference - time_offset;
393  // }
394  // else {
395  // // we already excluded local_time_diffrence == 0 case.
396  // // ref_time is in before ROLLOVER event
397  // actual_time_difference = local_time_difference + time_offset;
398  // }
399 
400  // }
401  // }
402  return actual_time_difference;
403 }
404 
405 
406 
407 void
409 {
410  Int_t i = 0;
411 
412  printf("System %s F1TDC ROC %2d, Slot %2d TDC id %2d Bank id %2d\n",
414  for(i=0; i<fWordsPerBuffer; i++) {
415  printf("0x%x ", fBuffer[i]);
416  }
417  printf("\n");
418 
419  return;
420 }
421 
422 
423 void
425 {
426 
427  printf("%s, ROC%2d slot%2d ", GetF1SystemName().Data(), GetROCNumber(), GetSlotNumber());
428  if(IsNormResolution()) printf("Normal Resolution mode ");
429  else printf("High Resolution mMode ");
430 
431  printf(" with the total channel number %d\n", fChannelNumber);
432 
433  if(IsSyncMode()) {
434  printf("Synchronous mode ");
435  printf(" with the rollover counter data %8.2f and trigger time %6.2f \n", fF1TDC_t_offset, fF1TDC_trig_t_offset);
436  }
437  else {
438  printf("Non Synchronouse mode \n");
439  printf(" with the full range %8.1f\n", fF1TDC_t_offset);
440  }
441 
442  printf("refcnt = %5d, tframe(ns) = %5.4f\n", fF1TDC_refcnt, fF1TDC_tframe_ns);
443  printf("refclkdiv = %5d, hsdiv = %6d, bin_size(ns) = %10.5f, full_range(ns) = %8.2f\n",
445  printf("trigwin = %5d, triglat = %6d, window (ns) = %10.5f, latency (ns) = %8.2f\n",
447  printf("trig_bin_size(ns) = %10.5f\n", fF1TDC_trig_resolution_ns);
448 
449  printf("\n");
450 
451  return;
452 }
453 
454 
455 
456 void
458 {
459  Int_t i = 0;
460 
461  fF1TDC_RFM_counter = 0;
462 
463  for(i=0; i<fMaxF1TDCChannelNumber; i++)
464  {
465  fF1TDC_SEU_counter[i] = 0;
466  fF1TDC_SYN_counter[i] = 0;
467  fF1TDC_EMM_counter[i] = 0;
468 
469  fF1TDC_TFO_counter[i] = 0;
470 
471  fF1TDC_RLF_counter[i] = 0;
472  fF1TDC_HFO_counter[i] = 0;
473  fF1TDC_OFO_counter[i] = 0;
474  fF1TDC_FDF_counter[i] = 0;
475  fF1TDC_S30_counter[i] = 0;
476  }
477  return;
478 }
479 
480 
481 UInt_t
482 QwF1TDC::GetTotal(UInt_t *error_counter)
483 {
484  UInt_t error = 0;
485  Int_t i = 0;
486 
487  for(i=0; i<fMaxF1TDCChannelNumber; i++)
488  {
489  error += error_counter[i];
490  }
491  return error;
492 }
493 
494 UInt_t
496 {
498 }
499 
500 UInt_t
502 {
504 }
505 
506 UInt_t
508 {
510 }
511 
512 UInt_t
514 {
516 }
517 
518 UInt_t
520 {
522 }
523 
524 UInt_t
526 {
528 }
529 
530 UInt_t
532 {
534 }
535 
536 UInt_t
538 {
540 }
541 
542 UInt_t
544 {
546 }
547 
548 
549 void
551 {
552  TString system_name = this->GetF1SystemName();
553  if(system_name.Contains("R2") || system_name.Contains("R3")){
554  QwMessage << "System " << std::setw(4) << system_name
555  << " QwF1TDC obj at " << this
556  << *this
557  << " CH " << std::setw(2) << channel
558  << " OFO " << this->GetOFO(channel)
559  << " RLF " << this->GetRLF(channel)
560  << " TFO " << this->GetTFO(channel)
561  << " EMM " << this->GetEMM(channel)
562  << " SEU " << this->GetSEU(channel)
563  << " FDF " << this->GetFDF(channel)
564  << " SYN " << this->GetSYN(channel)
565  << " HFO " << this->GetHFO(channel)
566  // << " S30 " << this->GetS30(channel)
567  << QwLog::endl;
568  }
569  return;
570 }
571 
572 
573 
574 void
576 {
577  QwVerbose << "System " << this->GetF1SystemName()
578  << " QwF1TDC object at " << this
579  << *this
580  << " " << QwLog::endl;
581 
582  Int_t i = 0;
583 
584  for(i=0; i<fMaxF1TDCChannelNumber; i++)
585  {
587  }
588  return;
589 }
590 
591 
592 
593 void
595 {
596  QwMessage << "System " << this->GetF1SystemName()
597  << " QwF1TDC object at " << this
598  << *this
599  << " "
600  << " OFO " << this->GetTotalOFO()
601  << " RLF " << this->GetTotalRLF()
602  << " TFO " << this->GetTotalTFO()
603  << " EMM " << this->GetTotalEMM()
604  << " SEU " << this->GetTotalSEU()
605  << " FDF " << this->GetTotalFDF()
606  << " SYN " << this->GetTotalSYN()
607  << " RFM " << this->GetTotalRFM()
608  << " HFO " << this->GetTotalHFO()
609  // << " S30 " << this->GetTotalS30()
610  << QwLog::endl;
611  return;
612 }
613 
614 
615 
616 TString
618 {
619  TString error_counter;
620  error_counter = Form("Error Counter F1TDC ROC%2d", fROC);
621  error_counter += Form(" Slot%2d", fSlot);
622  error_counter += Form(" Index%2d", fF1TDCIndex);
623  error_counter += " OFO : ";
624  error_counter += this->GetOFO(channel);
625  error_counter += " RLF : ";
626  error_counter += this->GetRLF(channel);
627  error_counter += " TFO : ";
628  error_counter += this->GetTFO(channel);
629  error_counter += " EMM : ";
630  error_counter += this->GetEMM(channel);
631  error_counter += " SEU : ";
632  error_counter += this->GetSEU(channel);
633  error_counter += " FDC : " ;
634  error_counter += this->GetFDF(channel);
635  error_counter += " SYN : ";
636  error_counter += this->GetSYN(channel);
637  error_counter += " RFM : ";
638  error_counter += this->GetTotalRFM();
639  error_counter += " HFO : ";
640  error_counter += this->GetHFO(channel);
641  // error_counter += " S30 : ";
642  // error_counter += this->GetS30(channel);
643 
644  return error_counter;
645 }
646 
647 
648 
649 TString
651 {
652  TString error_counter;
653 
654  error_counter = Form("Error Counter F1TDC ROC%2d", fROC);
655  error_counter += Form(" Slot%2d", fSlot);
656  error_counter += Form(" Index%2d", fF1TDCIndex);
657  Int_t i = 0;
658 
659  for(i=0; i<fMaxF1TDCChannelNumber; i++)
660  {
661  error_counter += GetChannelErrorCounter(i);
662  }
663  return error_counter;
664 }
665 
666 
667 TString
669 {
670  TString error_counter;
671 
672  error_counter = Form("Error Counter F1TDC ROC%2d", fROC);
673  error_counter += Form(" Slot%2d", fSlot);
674  error_counter += Form(" Index%2d", fF1TDCIndex);
675  error_counter += " OFO : ";
676  error_counter += this->GetTotalOFO();
677  error_counter += " RLF : ";
678  error_counter += this->GetTotalRLF();
679  error_counter += " TFO : ";
680  error_counter += this->GetTotalTFO();
681  error_counter += " EMM : ";
682  error_counter += this->GetTotalEMM();
683  error_counter += " SEU : ";
684  error_counter += this->GetTotalSEU();
685  error_counter += " FDC : " ;
686  error_counter += this->GetTotalFDF();
687  error_counter += " SYN : ";
688  error_counter += this->GetTotalSYN();
689  error_counter += " HFO : ";
690  error_counter += this->GetTotalHFO();
691  // error_counter += " S30 : ";
692  // error_counter += this->GetTotalS30();
693  return error_counter;
694 }
695 
696 
697 void
699 {
700  printf("-------------------------------------------------------------------------------- \n");
701  printf("%s : Roc%2d, slot%d is trouble now, please contact jhlee or rakithab immediately\n",
703  printf("-------------------------------------------------------------------------------- \n");
704  return;
705 }
706 
707 // void
708 // SetRefernceSignals(Int_t chan, Double_t val)
709 // {
710 // if( IsReFerenceSlot() )
711 // {
712 // fF1TDCReferenceChannels[chan] = val;
713 // }
714 // return;
715 // }
716 
717 
718 std::ostream& operator<< (std::ostream& os, const QwF1TDC &f1tdc)
719 {
720  os << " ROC ";
721  os << std::setw(2) << f1tdc.fROC;
722  os << " Slot ";
723  os << std::setw(2) << f1tdc.fSlot;
724  os << " TDC idx ";
725  os << std::setw(2) << f1tdc.fF1TDCIndex;
726  os << " Bank idx ";
727  os << std::setw(2) << f1tdc.fF1BankIndex;
728 
729  return os;
730 }
731 
732 
733 
734 
735 //----------------------------------
736 //
737 //
738 //
739 // QwF1TDContainer
740 //
741 //
742 //
743 //
744 //----------------------------------
745 
746 
747 
748 
749 
750 
751 // QwF1TDContainer::QwF1TDContainer()
752 // {
753 // fQwF1TDCList = NULL;
754 // fError2DHist = NULL;
755 // fNQwF1TDCs = 0;
756 // fDetectorType = kTypeNull;
757 // fRegion = kRegionIDNull;
758 
759 
760 // fLocalF1RawDecodeDebug = false; // Before checking "subsystem"
761 // fLocalF1DecodeDebug = false; // After cheking "subsystem"
762 // //level 0
763 
764 // fLocalDebug = false; // level 1 // not well defined...
765 // fLocalDebug2 = false;// level 2// not well defined...
766 
767 // }
768 
769 
771 {
772  fQwF1TDCList = new TObjArray();
773 
774  fQwF1TDCList -> Clear();
775  fQwF1TDCList -> SetOwner(kTRUE);
776 
777  fError2DHist = new TH2F;
778  fError2DHist -> SetBins(3,0,3,2,0,2);
779 
780  // kCanRebin removed in ROOT 6
781  // Ref: https://root.cern.ch/content/main-histogram-changes-root-6
782 #if ROOT_VERSION_CODE < ROOT_VERSION(5,90,0)
783  fError2DHist -> SetBit(TH1::kCanRebin);
784 #else
785  fError2DHist -> SetCanExtend(TH1::kAllAxes);
786 #endif
787  fError2DHist -> SetStats(0);
788 
789  fNQwF1TDCs = 0;
792 
793 
794  fLocalF1RawDecodeDebug = false; // Before checking "subsystem"
795  fLocalF1DecodeDebug = false; // After cheking "subsystem"
796  //level 0
797 
798  fLocalDebug = false; // level 1 // not well defined...
799  fLocalF1ErrorDebug = false; // Error logs
800 
801 }
802 
803 
805 {
806  if(fQwF1TDCList) delete fQwF1TDCList; fQwF1TDCList = NULL;
807  if(fError2DHist) delete fError2DHist; fError2DHist = NULL;
808 }
809 
810 
811 
812 void
814 {
815  Int_t pos = 0;
816 
817  pos = fQwF1TDCList -> AddAtFree(in);
818  if(fLocalDebug) {
819  printf("AddQwF1TDC at pos %d\n", pos);
820  }
821 
822  fNQwF1TDCs++;
823  return;
824 }
825 
826 
827 QwF1TDC *
828 QwF1TDContainer::GetF1TDC(Int_t roc, Int_t slot)
829 {
830  Int_t roc_num = 0;
831  Int_t slot_num = 0;
832 
833  // Int_t unique_id = 0;
834 
835 
836  QwF1TDC* F1 = NULL;
837 
838  TObjArrayIter next(fQwF1TDCList);
839  TObject* obj = NULL;
840 
841 
842  while ( (obj = next()) )
843  {
844 
845  F1 = (QwF1TDC*) obj;
846  // unique_id = F1->GetUniqueID();
847  roc_num = F1->GetROCNumber();
848  slot_num = F1->GetSlotNumber();
849  if((roc_num == roc) && (slot_num == slot) ) {
850  // if(fLocalDebug) {
851  // std::cout << "System " << F1->GetF1SystemName()
852  // << " QwF1TDContainer::GetF1TDC F1TDC address at" << F1 << std::endl;
853  // }
854  return F1;
855  }
856  }
857 
858  return NULL;
859 }
860 
861 
862 QwF1TDC *
864 {
865  Int_t f1_idx = 0;
866 
867  TObjArrayIter next(fQwF1TDCList);
868  TObject* obj = NULL;
869  QwF1TDC* F1 = NULL;
870 
871  while ( (obj = next()) )
872  {
873  F1 = (QwF1TDC*) obj;
874  f1_idx = F1->GetF1TDCIndex();
875  if( f1_idx == tdc_index ) {
876  // if(fLocalDebug) {
877  // std::cout << "System " << F1->GetF1SystemName()
878  // << " QwF1TDContainer::GetF1TDCIndex F1TDC address at" << F1 << std::endl;
879  // }
880  return F1;
881  }
882  }
883 
884  return NULL;
885 }
886 
887 QwF1TDC *
888 QwF1TDContainer::GetF1TDCwithBankIndexSLOT(Int_t bank_index, Int_t slot)
889 {
890  Int_t bank_idx = 0;
891  Int_t slot_num = 0;
892 
893  TObjArrayIter next(fQwF1TDCList);
894  TObject* obj = NULL;
895  QwF1TDC* F1 = NULL;
896 
897  while ( (obj = next()) )
898  {
899  F1 = (QwF1TDC*) obj;
900  bank_idx = F1->GetF1BankIndex();
901  slot_num = F1->GetSlotNumber();
902  if((bank_idx == bank_index) && (slot_num == slot) ) {
903  // if(fLocalDebug) {
904  // std::cout << "System " << F1->GetF1SystemName()
905  // << " QwF1TDContainer::GetF1TDC F1TDC address at" << F1 << std::endl;
906  // }
907  return F1;
908  }
909  }
910 
911  return NULL;
912 }
913 
914 
915 void
916 QwF1TDContainer::AddSYN(Int_t roc, Int_t slot, Int_t channel)
917 {
918  QwF1TDC* F1 = NULL;
919  F1 = this->GetF1TDC(roc, slot);
920 
921  if(F1) {
922  F1->AddSYN(channel);
924  }
925  else {
926  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddSYN : " << PrintNoF1TDC(roc,slot) << std::endl;
927  }
928  return;
929 }
930 
931 void
932 QwF1TDContainer::AddEMM(Int_t roc, Int_t slot, Int_t channel)
933 {
934  QwF1TDC* F1 = NULL;
935  F1 = this->GetF1TDC(roc, slot);
936 
937  if(F1) {
938  F1->AddEMM(channel);
940  }
941  else {
942  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddEMM : " << PrintNoF1TDC(roc,slot) << std::endl;
943  }
944  return;
945 }
946 
947 
948 void
949 QwF1TDContainer::AddSEU(Int_t roc, Int_t slot, Int_t channel)
950 {
951  QwF1TDC* F1 = NULL;
952  F1 = this->GetF1TDC(roc, slot);
953 
954  if(F1) {
955  F1->AddSEU(channel);
957  }
958  else {
959  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddSEU : " << PrintNoF1TDC(roc,slot) << std::endl;
960  }
961  return;
962 }
963 
964 
965 void
966 QwF1TDContainer::AddTFO(Int_t roc, Int_t slot, Int_t channel)
967 {
968  QwF1TDC* F1 = NULL;
969  F1 = this->GetF1TDC(roc, slot);
970 
971  if(F1) {
972  F1->AddTFO(channel);
974  }
975  else {
976  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddTFO : " << PrintNoF1TDC(roc,slot) << std::endl;
977  }
978  return;
979 }
980 
981 
982 void
983 QwF1TDContainer::AddRLF(Int_t roc, Int_t slot, Int_t channel)
984 {
985  QwF1TDC* F1 = NULL;
986  F1 = this->GetF1TDC(roc, slot);
987 
988  if(F1) {
989  F1->AddRLF(channel);
991  }
992  else {
993  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddRLF : " << PrintNoF1TDC(roc,slot) << std::endl;
994  }
995  return;
996 }
997 
998 
999 void
1000 QwF1TDContainer::AddHFO(Int_t roc, Int_t slot, Int_t channel)
1001 {
1002  QwF1TDC* F1 = NULL;
1003  F1 = this->GetF1TDC(roc, slot);
1004 
1005  if(F1) {
1006  F1->AddHFO(channel);
1008  }
1009  else {
1010  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddHFO : " << PrintNoF1TDC(roc,slot) << std::endl;
1011  }
1012  return;
1013 }
1014 
1015 void
1016 QwF1TDContainer::AddOFO(Int_t roc, Int_t slot, Int_t channel)
1017 {
1018  QwF1TDC* F1 = NULL;
1019  F1 = this->GetF1TDC(roc, slot);
1020 
1021  if(F1) {
1022  F1->AddOFO(channel);
1024  }
1025  else {
1026  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddOFO : " << PrintNoF1TDC(roc,slot) << std::endl;
1027  }
1028  return;
1029 }
1030 
1031 
1032 void
1033 QwF1TDContainer::AddFDF(Int_t roc, Int_t slot, Int_t channel)
1034 {
1035  QwF1TDC* F1 = NULL;
1036  F1 = this->GetF1TDC(roc, slot);
1037 
1038  if(F1) {
1039  F1->AddFDF(channel);
1041  }
1042  else {
1043  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddFDF : " << PrintNoF1TDC(roc,slot) << std::endl;
1044  }
1045  return;
1046 }
1047 
1048 
1049 
1050 void
1051 QwF1TDContainer::AddS30(Int_t roc, Int_t slot, Int_t channel)
1052 {
1053  QwF1TDC* F1 = NULL;
1054  F1 = this->GetF1TDC(roc, slot);
1055  if(F1) {
1056  F1->AddS30(channel);
1058  }
1059  else {
1060  if(fLocalF1ErrorDebug) std::cout << "QwF1TDContainer::AddS30 : " << PrintNoF1TDC(roc,slot) << std::endl;
1061  }
1062  return;
1063 }
1064 
1065 
1066 
1067 Double_t
1069  Double_t raw_time,
1070  Double_t ref_time,
1071  Int_t bank_index,
1072  Int_t slot_num
1073  )
1074 {
1075  QwF1TDC* F1 = NULL;
1076  F1 = this->GetF1TDCwithBankIndexSLOT(bank_index, slot_num);
1077 
1078  if(F1) {
1079  return F1->ReferenceSignalCorrection(raw_time, ref_time);
1080  }
1081  else {
1082  // printf("There is no F1TDC with Bank index %2d slot %2d\n", bank_index, slot_num);
1083  return -1.0;
1084  }
1085 }
1086 
1087 
1088 void
1090 {
1091  // Types are defined in QwType.h
1092  if(fSystemName.IsNull()) {
1093  fSystemName = name;
1094  if(fSystemName == "R1") {
1096  fRegion = kRegionID1;
1097  }
1098  else if(fSystemName == "R2") {
1100  fRegion = kRegionID2;
1101  }
1102  else if(fSystemName == "R3") {
1104  fRegion = kRegionID3;
1105  }
1106 
1107  else if(fSystemName == "MD" ) {
1110  }
1111  else if(fSystemName == "TS" ) {
1114  }
1115  else if(fSystemName == "FPS") {
1118  }
1119  else {
1122  }
1123  }
1124  else {
1125  QwWarning << "QwF1TDContainer::SetSystemName "
1126  << fSystemName
1127  << " is already registered."
1128  << QwLog::endl;
1129  }
1130 
1131  fError2DHist -> SetNameTitle(
1132  Form("%s_F1ErrorHist",fSystemName.Data()),
1133  Form("%s F1TDC Board Error Status Histogram", fSystemName.Data())
1134  );
1135  return;
1136 }
1137 
1138 void
1139 QwF1TDContainer::Print(const Option_t* options) const
1140 {
1141 
1142  Int_t size = 0;
1143  size = this->GetSize();
1144 
1145  QwMessage << "\nQwF1TDContainer::Print() "
1146  << " QwF1TDContainer in System : "
1147  << this->GetSystemName()
1148  << ", DetectorType "
1149  << this->GetDetectorType()
1150  << ", RegionType "
1151  << this->GetRegion()
1152  << ", How many F1TDCs are : "
1153  << size
1154  << QwLog::endl;
1155 
1156  TObjArrayIter next(fQwF1TDCList);
1157  TObject* obj;
1158  while ( (obj = next()) )
1159  {
1160  QwF1TDC* F1 = (QwF1TDC*) obj;
1161  QwMessage << "F1TDC object " << F1 << QwLog::endl;
1162  F1 -> PrintF1TDCBuffer();
1163  F1 -> PrintF1TDCConfigure();
1164  }
1165 
1166  return;
1167 }
1168 
1169 
1170 TString
1171 QwF1TDContainer::PrintNoF1TDC(Int_t roc, Int_t slot)
1172 {
1173  TString tmp = Form("There is no F1TDC with ROC%2d and SLOT%2d in System %s\n",
1174  roc, slot, GetSystemName().Data());
1175  return tmp;
1176 
1177 }
1178 
1179 TString
1181 {
1182  TString tmp = Form("There is no F1TDC with TDCINDEX%2d in System %s\n",
1183  tdc_index, GetSystemName().Data());
1184 
1185  return tmp;
1186 }
1187 
1188 // // This function will be removed after several tests..
1189 // //
1190 // Double_t
1191 // QwF1TDContainer::GetF1TDCResolution()
1192 // {
1193 
1194 // // F1TDC resolution must be the same
1195 // // among VME crates and among F1TDC boards
1196 // // We cannot change it on each F1TDC board.QwF1TDContainer::GetF1TDCResolution()
1197 // // Thus, this function return one value of them.
1198 // // Wednesday, September 1 16:52:05 EDT 2010, jhlee
1199 
1200 // Double_t old_r = 0.0;
1201 // Double_t new_r = 0.0;
1202 // Int_t cnt = 0;
1203 
1204 // TObjArrayIter next(fQwF1TDCList);
1205 // TObject* obj = NULL;
1206 
1207 // while ( (obj = next()) )
1208 // {
1209 // QwF1TDC* F1 = (QwF1TDC*) obj;
1210 // new_r = F1->GetF1TDC_resolution();
1211 // if(cnt not_eq 0) {
1212 // if(old_r not_eq new_r) {
1213 // F1->PrintContact();
1214 // printf("%s : QwF1TDContainer::GetF1TDCResolution(): F1TDC configurations are corrupted!\n",
1215 // GetSystemName().Data());
1216 // F1->PrintF1TDCConfigure();
1217 
1218 // return 0.0;
1219 // }
1220 
1221 // }
1222 // old_r = new_r;
1223 // cnt++;
1224 // }
1225 
1226 // return old_r;
1227 // }
1228 
1229 
1230 Double_t
1232 {
1233 
1234  // F1TDC resolution must be the same
1235  // among VME crates and among F1TDC boards
1236  // We cannot change it on each F1TDC board.QwF1TDContainer::GetF1TDCResolution()
1237  // Thus, this function return one value of them.
1238  // Wednesday, September 1 16:52:05 EDT 2010, jhlee
1239 
1240  Double_t old_r = 0.0;
1241  Double_t new_r = 0.0;
1242  Int_t cnt = 0;
1243 
1244  TObjArrayIter next(fQwF1TDCList);
1245  TObject* obj = NULL;
1246 
1247  while ( (obj = next()) )
1248  {
1249  QwF1TDC* F1 = (QwF1TDC*) obj;
1250  new_r = F1->GetF1TDC_resolution();
1251  if(cnt not_eq 0) {
1252  if(old_r not_eq new_r) {
1253  F1->PrintContact();
1254  printf("%s : QwF1TDContainer::GetF1TDCResolution(): F1TDC configurations are corrupted!\n",
1255  GetSystemName().Data());
1256  F1->PrintF1TDCConfigure();
1257 
1258  return 0.0;
1259  }
1260 
1261  }
1262  old_r = new_r;
1263  cnt++;
1264  }
1265 
1266  return old_r;
1267 }
1268 
1269 
1270 
1271 Double_t
1273 {
1274 
1275  Double_t old_r = 0.0;
1276  Double_t new_r = 0.0;
1277  Int_t cnt = 0;
1278 
1279  TObjArrayIter next(fQwF1TDCList);
1280  TObject* obj = NULL;
1281 
1282  if(fLocalDebug) printf("\nHow many F1TDC in %s : %d\n", GetSystemName().Data(), fQwF1TDCList->GetEntriesFast());
1283 
1284  while ( (obj = next()) )
1285  {
1286  QwF1TDC* F1 = (QwF1TDC*) obj;
1287  new_r = F1->GetF1TDC_trig_t_offset();
1288  // printf("QwF1TDContainer::GetF1TDCTriggerRollover():: cnt %d, new %f , old %f\n", cnt, new_r, old_r);
1289  if(cnt not_eq 0) {
1290  if(old_r not_eq new_r) {
1291  F1->PrintContact();
1292  printf("%s : QwF1TDContainer::GetF1TDCTriggerRollover(): F1TDC configurations are corrupted!\n",
1293  GetSystemName().Data());
1294  F1->PrintF1TDCConfigure();
1295  return 0.0;
1296  }
1297 
1298  }
1299  old_r = new_r;
1300  cnt++;
1301  }
1302 
1303  return old_r;
1304 }
1305 
1306 
1307 
1308 
1309 Int_t
1311 {
1312 
1313  // F1TDC max channel number must be the same
1314  // among VME crates and among F1TDC boards
1315  // We cannot change it on each F1TDC board.
1316  // Thus, this function return one value of them. (32 or 64)
1317  // Friday, September 3 13:09:01 EDT 2010, jhlee
1318 
1319  Int_t old_c = 0;
1320  Int_t new_c = 0;
1321  Int_t cnt = 0;
1322 
1323  TObjArrayIter next(fQwF1TDCList);
1324  TObject* obj = NULL;
1325 
1326  while ( (obj = next()) )
1327  {
1328  QwF1TDC* F1 = (QwF1TDC*) obj;
1329  new_c = F1->GetChannelNumber();
1330  // printf("QwF1TDContainer::GetF1TDCChannelNumber() cnt %d, new %d , old %d\n", cnt, new_c, old_c);
1331  if(cnt not_eq 0) {
1332  if(old_c not_eq new_c) {
1333  F1->PrintContact();
1334  printf("%s : QwF1TDContainer::GetF1TDCChannelNumber(): F1TDC configurations are corrupted!\n",
1335  GetSystemName().Data());
1336  F1->PrintF1TDCConfigure();
1337  return 0;
1338  }
1339 
1340  }
1341  old_c = new_c;
1342  cnt++;
1343  }
1344 
1345  return old_c;
1346 }
1347 
1348 
1349 
1350 void
1352 {
1353  printf("-----------------------\n");
1354  TObjArrayIter next(fQwF1TDCList);
1355  TObject* obj = NULL;
1356  while ( (obj = next()) )
1357  {
1358  QwF1TDC* F1 = (QwF1TDC*) obj;
1359 
1360  F1 -> PrintTotalErrorCounter();
1361  }
1362  printf("-----------------------\n");
1363  return;
1364 }
1365 
1366 
1367 TList *
1369 {
1370 
1371  TList *error_list = new TList;
1372  error_list->SetOwner(true);
1373 
1374  TObjArrayIter next(fQwF1TDCList);
1375  TObject* obj = NULL;
1376 
1377  while ( (obj = next()) )
1378  {
1379  QwF1TDC* F1 = (QwF1TDC*) obj;
1380  TString error = F1->GetErrorCounter();
1381  error_list -> Add(new TObjString(error));
1382  }
1383 
1384  return error_list;
1385 }
1386 
1387 
1388 // Check Trigger Time Mismatch
1389 // Event Number Mismatch
1390 // Trigger FIFO overflow
1391 // if one of them is "false", return false
1392 //
1393 // Count the following
1394 // OFO : Output FIFO Overflow
1395 // RLF : Resolution Lock Failed
1396 // TFO : Trigger FIFO Overflow
1397 // EMM : Event(Trigger) Number Mismatch
1398 // SEU : Single Event Upset
1399 // FDF : Fake Data Flag
1400 // SYN : Trigger Time mismatch
1401 // HFO : Hit FIFO Overflow
1402 // S30 : Slot 30 dataword when the F1 chip has no response within "a reasonable time"
1403 
1404 Bool_t
1405 QwF1TDContainer::CheckDataIntegrity(const UInt_t roc_id, UInt_t *buffer, UInt_t num_words)
1406 {
1407 
1408 
1409 
1410  // three counter flags
1411  Bool_t hit_fifo_overflow_flag = kFALSE;
1412  Bool_t output_fifo_overflow_flag = kFALSE;
1413  Bool_t chip_resolution_lock_flag = kTRUE;
1414 
1415  // real DataIntegrity Check
1416  Bool_t event_ok_flag = kFALSE;
1417  Bool_t trig_time_ok_flag = kFALSE;
1418  Bool_t trig_fifo_ok_flag = kFALSE;
1419 
1420  // data integrity flags
1421  Bool_t data_integrity_flag = kFALSE;
1422  Bool_t data_integrity_unlock_flag = kTRUE; // unlock first
1423 
1424 
1425  // SEU
1426  Bool_t xor_setup_flag = kFALSE;
1427  Bool_t fake_data_flag = kFALSE;
1428 
1429 
1430  UInt_t slot_number = 0;
1431  UInt_t channel_number = 0;
1432  UInt_t chip_address = 0;
1433  UInt_t channel_address = 0;
1434 
1435  UInt_t reference_trig_time = 0;
1436  UInt_t reference_event_num = 0;
1437 
1438 
1439  Double_t trigger_rollover = 0.0;
1440  Int_t rounded_trigger_rollover = 0;
1441  Int_t diff_trigger_time = 0;
1442 
1443  trigger_rollover = GetF1TDCTriggerRollover();
1444  rounded_trigger_rollover = (Int_t) trigger_rollover;
1445 
1446  // fLocalDebug = true;
1447  if(fLocalDebug) printf("roc_id %d trigger rollover %f, %d\n", roc_id, trigger_rollover, rounded_trigger_rollover);
1448 
1449 
1450  const Int_t valid_trigger_time_offset[3] = {0, 1, rounded_trigger_rollover};
1451 
1452 
1453  if(fLocalF1DecodeDebug) {
1454  QwMessage << "\n\n" << QwLog::endl;
1456  << " ROC " << roc_id
1457  << " num_words (buffer size) " << num_words
1458  << QwLog::endl;
1459  }
1460 
1461  Int_t subsystem_cnt = 0;
1462  TString roc_idx;
1463 
1465  printf("%s at %s nwrds %d\n",
1466  __PRETTY_FUNCTION__, GetSystemName().Data(), num_words);
1467  }
1468 
1469  for (UInt_t i=0; i<num_words ; i++)
1470  {
1471  fF1TDCDecoder.DecodeTDCWord(buffer[i], roc_id);
1472  // without any further process
1473  // check the decoding....
1474 
1476  std::cout << "[" << std::setw(3) << i
1477  << "," << std::setw(3) << i
1478  << "] "
1479  << fF1TDCDecoder << std::endl;
1480  }
1481 
1482 
1483  slot_number = fF1TDCDecoder.GetTDCSlotNumber();
1484 
1486  // Check F1TDC slot, provided by buffer[i], is valid (1<=slot<=21)
1487  //, because sometimes, slot 30 data (junk) is placed in the first one
1488  // or two buffers.
1489 
1490  chip_address = fF1TDCDecoder.GetTDCChipAddress();
1491  channel_address = fF1TDCDecoder.GetTDCChannelAddress();
1492  channel_number = fF1TDCDecoder.GetTDCChannelNumber();
1493 
1494 
1495  // if(fLocalDebug) {
1496  // // this is for tracking down missing wires in Region 2
1497  // // a quick and dirty way to check
1498  // // Monday, December 20 10:38:38 EST 2010, jhlee
1499  // it turned out "loosing cabling....
1500  // Saturday, January 8 01:54:02 EST 2011, jhlee
1501 
1502  // if( (slot_number==10) and (roc_id==3) ) {
1503  // if( (channel_number == 19) || (channel_number == 21) || (channel_number == 23) || (channel_number == 25)
1504  // || (channel_number == 27) || (channel_number == 29) || (channel_number == 31) || (channel_number == 17)
1505  // )
1506  // {
1507  // printf("Roc %2d Slot%2d Ch %2d \n", roc_id, slot_number, channel_number);
1508  // }
1509  // }
1510  // }
1511 
1512  roc_idx = Form("R%2d-S%2d", roc_id, slot_number);
1513 
1514  // We use the multiblock data transfer for F1TDC, thus
1515  // we must get the event number and the trigger time from the first buffer
1516  // (buffer[0]), and these valuse can be used to check "data" integrity
1517  // over all F1TDCs.
1518  // Each Subsystem uses the same buffer[0] even if their interesting F1
1519  // is not in the SLOT 4
1520 
1521  if ( i ==0 ) {
1522  if ( fF1TDCDecoder.IsHeaderword() ) {
1523  reference_event_num = fF1TDCDecoder.GetTDCEventNumber();
1524  reference_trig_time = fF1TDCDecoder.GetTDCTriggerTime();
1525 
1526  trig_fifo_ok_flag = fF1TDCDecoder.IsNotHeaderTrigFIFO();
1527  if(not trig_fifo_ok_flag) {
1528  // temp solution ....
1529  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1530  this -> AddTFO(roc_id, slot_number, channel_number);
1531  fError2DHist -> Fill(roc_idx.Data(), "TFO",1);
1532  }
1533  }
1534 
1535  }
1536  else {
1537  printf("The first word of F1TDC must be header word. Check CODA stream and QwF1TDContainer::CheckDataIntegrity fucntion.\n");
1538  return false;
1539  }
1540  }
1541 
1542  // Check F1TDC status is inside a subsystem
1543 
1544  if( CheckRegisteredF1(roc_id, slot_number) ) {
1545 
1546  // Check F1TDC data, provided by buffer[i], is valid in each subsystem
1547  // subsystem_cnt = 0;
1548 
1549  if(fLocalF1DecodeDebug) {
1550 
1551  std::cout << "[" << std::setw(3) << i
1552  << "," << std::setw(3) << subsystem_cnt
1553  << "] "
1554  << fF1TDCDecoder << std::endl;
1555  }
1556  subsystem_cnt++;
1557  // Both header and data words have HFO, OFO, and RLF
1558  hit_fifo_overflow_flag = fF1TDCDecoder.IsHitFIFOOverFlow();
1559  output_fifo_overflow_flag = fF1TDCDecoder.IsOutputFIFOOverFlow();
1560  chip_resolution_lock_flag = fF1TDCDecoder.IsResolutionLock();
1561 
1562 
1563  if(hit_fifo_overflow_flag) {
1564  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1565  this->AddHFO(roc_id, slot_number, channel_number);
1566  // one event creates the maximum 9 HFOs
1567  // but the number is within the range of 1 - 9
1568 
1569  fError2DHist -> Fill(roc_idx.Data(), "HFO",1);
1570 
1571  if(fLocalDebug) {
1572  std::cout << "There is the Hit FIFO Overflow on the F1TDC board at"
1573  << " ROC " << roc_id
1574  << " Slot " << slot_number
1575  << " Ch " << std::setw(3) << channel_number
1576  << "[" << chip_address
1577  << "," << channel_address
1578  << "]\n";
1579  }
1580  }
1581  }
1582 
1583  if(output_fifo_overflow_flag) {
1584  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1585  this->AddOFO(roc_id, slot_number, channel_number);
1586  fError2DHist -> Fill(roc_idx.Data(), "OFO",1);
1587  if(fLocalDebug) {
1588  std::cout << "There is the Output FIFO Overflow on the F1TDC board at"
1589  << " ROC " << roc_id
1590  << " Slot " << slot_number
1591  << " Ch " << std::setw(3) << channel_number
1592  << "[" << chip_address
1593  << "," << channel_address
1594  << "]\n";
1595 
1596  }
1597  }
1598  }
1599 
1600  if(not chip_resolution_lock_flag) {
1601  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1602  this->AddRLF(roc_id, slot_number, channel_number);
1603  fError2DHist -> Fill(roc_idx.Data(), "RLF",1);
1604  if(fLocalDebug) {
1605  std::cout << "There is the Resolution Lock Failed on the F1TDC board at"
1606  << " ROC " << roc_id
1607  << " Slot " << slot_number
1608  << " Ch " << std::setw(3) << channel_number
1609  << "[" << chip_address
1610  << "," << channel_address
1611  << "]\n";
1612  }
1613  }
1614  }
1615 
1616  // check only header word
1617 
1618  if ( fF1TDCDecoder.IsHeaderword() ) {
1619 
1620 
1621  xor_setup_flag = fF1TDCDecoder.IsHeaderXorSetup();
1622  trig_fifo_ok_flag = fF1TDCDecoder.IsNotHeaderTrigFIFO();
1623  event_ok_flag = ( reference_event_num==fF1TDCDecoder.GetTDCHeaderEventNumber() );
1624  diff_trigger_time = abs( int(reference_trig_time)-int(fF1TDCDecoder.GetTDCHeaderTriggerTime()) );
1625 
1626  trig_time_ok_flag =
1627  (diff_trigger_time == valid_trigger_time_offset[0])
1628  ||
1629  (diff_trigger_time == valid_trigger_time_offset[1])
1630  ||
1631  (diff_trigger_time == valid_trigger_time_offset[2]);
1632 
1633  // trig_time_ok_flag = abs( reference_trig_time-fF1TDCDecoder.GetTDCHeaderTriggerTime() ) <= valid_trigger_time_offset;
1634 
1635  // if no SEU, check Trigger FIFO Overflow, Trigger Time, and Event Number
1636 
1637  if (xor_setup_flag) {
1638 
1639  if(not trig_fifo_ok_flag) {
1640  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1641  this -> AddTFO(roc_id, slot_number, channel_number);
1642  fError2DHist -> Fill(roc_idx.Data(), "TFO",1);
1643  if(fLocalDebug) {
1644  std::cout << "There is the Trigger FIFO overflow at"
1645  << " ROC " << roc_id
1646  << " Slot " << slot_number
1647  << " Ch " << std::setw(3) << channel_number
1648  << "[" << chip_address
1649  << "," << channel_address
1650  << "]\n";
1651 
1652  }
1653  }
1654  }
1655 
1656  // Trigger Time difference of up to 1 count among the chips is acceptable
1657  // For the Trigger Time, this assumes that an external SYNC_RESET signal has
1658  // been successfully applied at the start of the run
1659 
1660  if (not trig_time_ok_flag) {
1661  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1662  this->AddSYN(roc_id, slot_number, channel_number);
1663  fError2DHist -> Fill(roc_idx.Data(), "SYN",1);
1664  if(fLocalDebug) {
1665  std::cout << "There is the Trigger Time Mismatch on the F1TDC board at"
1666  << " ROC " << roc_id
1667  << " Slot " << slot_number
1668  << " Ch " << std::setw(3) << channel_number
1669  << "[" << chip_address
1670  << "," << channel_address
1671  << "]\n";
1672  }
1673  }
1674 
1675  }
1676  // Any difference in the Event Number among the chips indicates a serious error
1677  // that requires a reset of the board.
1678 
1679  if (not event_ok_flag) {
1680  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1681  this->AddEMM(roc_id, slot_number, channel_number);
1682  fError2DHist -> Fill(roc_idx.Data(), "EMM",1);
1683  if(fLocalDebug) {
1684  std::cout << "There is the Event Number Mismatch issue on the F1TDC board at"
1685  << " ROC " << roc_id
1686  << " Slot " << slot_number
1687  << " Ch " << std::setw(3) << channel_number
1688  << "[" << chip_address
1689  << "," << channel_address
1690  << "]\n";
1691  }
1692  }
1693  }
1694 
1695 
1696  if(data_integrity_unlock_flag) {
1697  // check data_integrity_flag = false once (not initial value),
1698  // if so, we skip the further process to check
1699  // data integrity, because it is alreay invalid
1700  // data we have.
1701 
1702  data_integrity_flag = (event_ok_flag) && (trig_time_ok_flag) && (trig_fifo_ok_flag) ;
1703  if(data_integrity_flag) data_integrity_unlock_flag = true; // true -> not lock -> check it again
1704  else data_integrity_unlock_flag = false; // false -> lock -> no check it again -> return false;
1705  }
1706  } // if(xor_setup_flag) {
1707 
1708 
1709  // ignore SEU first, then we count them how frequently they are,
1710  // because there is no way to seperate SEU and the data integrity.
1711  // data integrity is valid within all buffer, but SEU is valid
1712  // for only when it is (header and dataword)
1713 
1714  else {
1715  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1716  this->AddSEU(roc_id, slot_number, channel_number);
1717  fError2DHist -> Fill(roc_idx.Data(), "SEU",1);
1718  if (fLocalDebug) {
1719  std::cout << "There is the Single Event Upset (SEU) on the F1TDC board at"
1720  << " ROC " << roc_id
1721  << " Slot " << slot_number
1722  << " Ch " << std::setw(3) << channel_number
1723  << "[" << chip_address
1724  << "," << channel_address
1725  << "]\n";
1726  }
1727  }
1728  }
1729  } // if ( fF1TDCDecoder.IsHeaderword() ) {
1730  else {
1731  // fF1TDCDecoder.Print(true);
1732  fake_data_flag = fF1TDCDecoder.IsFakeData();
1733  if(fake_data_flag) {
1734  if(not CheckSlot20Chan30(slot_number, channel_number)) {
1735  this->AddFDF(roc_id, slot_number, channel_number);
1736  fError2DHist -> Fill(roc_idx.Data(), "FDF",1);
1737  if(fLocalDebug) {
1738  std::cout << "There is the Fake Data on the F1TDC board at"
1739  << " ROC " << roc_id
1740  << " Slot " << slot_number
1741  << " Ch " << std::setw(3) << channel_number
1742  << "[" << chip_address
1743  << "," << channel_address
1744  << "]\n";
1745  }
1746  }
1747  }
1748 
1749  // dataword
1750 
1751  // if(!fF1TDCDecoder.IsOverFlowEntry()) fF1TDCDecoder.PrintTDCData(fLocalDebug);
1752  }//;;
1753 
1754  } // if( CheckRegisteredF1(roc_id, slot_number) ) {
1755 
1756 
1757 
1758 
1759  }//if(fF1TDCDecoder.IsValidDataSlot()) {
1760  else {
1761 
1762  // slot_number = fF1TDCDecoder.GetTDCSlotNumber();
1763  if( slot_number == 0 ) {
1764  if(fLocalDebug) {
1765  std::cout << "Slot " << slot_number << " is a filler word,"
1766  << " then we ignore it." << std::endl;
1767  }
1768  }
1769  else if( slot_number == 30 ) {
1770  // Slot 30 is not in the list of F1TDCs in a subsystem.
1771  // we cannot add this counter into QwF1TDC.
1772  // Now just leave what I wrote for a possible future release.
1773  // Tuesday, September 21 15:19:34 EDT 2010, jhlee
1774  // this->AddS30(roc_id, slot_number);
1775  if(fLocalDebug) {
1776  std::cout << "Slot " << slot_number << " is a junk word,"
1777  << " then we ignore it." << std::endl;
1778  }
1779  }
1780  else {
1781  std::cout << "Slot " << slot_number << " is not in the reasonable slot,"
1782  << " then we ignore it, but it is better to check what it is going on CODA stream." << std::endl;
1783  }
1784  }
1785 
1786 
1787 
1788  }//for (UInt_t i=0; i<num_words ; i++) {
1789 
1790  if(fLocalF1RawDecodeDebug) printf("\n");
1791  return (data_integrity_flag);
1792 }
1793 
1794 void
1796 {
1797  const char* opt = "TEXT";
1798  fError2DHist->SetMarkerSize(1.4);
1799  fError2DHist->SetOption(opt);
1800  fError2DHist->LabelsDeflate("X");
1801  fError2DHist->LabelsDeflate("Y");
1802  fError2DHist->LabelsOption("a", "X");
1803  fError2DHist->LabelsOption("a", "Y");
1804  return;
1805 }
1806 
1807 
1808 // send the historgram to a subsystem, then
1809 // the subsystem can send it to ROOT file(s)
1810 const TH2F*
1812 {
1813  this->SetErrorHistOptions();
1814  return fError2DHist;
1815 }
1816 
1817 
1818 
1819 // direct write histogram into ROOT file(s)
1820 void
1822 {
1823  if (fError2DHist->GetEntries() not_eq 0) {
1824 
1825  TSeqCollection *file_list = gROOT->GetListOfFiles();
1826 
1827  if (file_list) {
1828 
1829  Int_t size = file_list->GetSize();
1830 
1831  TString error_summary_name = this-> GetSystemName();
1832  error_summary_name += "_F1TDCs_Status";
1833 
1834  for (Int_t i=0; i<size; i++)
1835  {
1836  TFile *file = (TFile*) file_list->At(i);
1837  if(hist_flag) {
1838  TString hist_name = fError2DHist->GetName();
1839  TH2F *error_hist = (TH2F*) file->FindObjectAny(hist_name);
1840  if (not error_hist) {
1841  this->SetErrorHistOptions();
1842  file->WriteObject(fError2DHist, hist_name);
1843  }
1844  }
1845  else {
1846  TList *error_summary = (TList*) file->FindObjectAny(error_summary_name);
1847  if (not error_summary) {
1848  file->WriteObject(this->GetErrorSummary(), error_summary_name);
1849  }
1850  }
1851  if(fLocalDebug) {
1852  std::cout << "i " << i
1853  << " size " << size
1854  << " error_summary_name " << error_summary_name
1855  << std::endl;
1856  }
1857  }
1858  }
1859  }
1860  return;
1861 }
1862 
1863 
1864 
1865 // void
1866 // QwF1TDContainer::WriteErrorSummaryToDedicatedRootFile(QwRootFile* rootfile, Bool_t hist_flag)
1867 // {
1868 // if (fError2DHist->GetEntries() not_eq 0) {
1869 
1870 // TString error_summary_name = this-> GetSystemName();
1871 // error_summary_name += "_F1TDCs_Status";
1872 
1873 // if(hist_flag) {
1874 // TString hist_name = fError2DHist->GetName();
1875 // this->SetErrorHistOptions();
1876 // rootfile->WriteObject(fError2DHist, hist_name);
1877 // }
1878 // else {
1879 // rootfile->WriteObject(this->GetErrorSummary(), error_summary_name);
1880 // }
1881 // }
1882 // return;
1883 // }
1884 
1885 
1886 Bool_t
1888 {
1889  QwF1TDC* F1 = NULL;
1890  F1 = this->GetF1TDC(roc, slot);
1891 
1892  if(F1) return true;
1893  else return false;
1894 }
1895 
1896 
1897 Bool_t
1898 QwF1TDContainer::CheckSlot20Chan30(Int_t slot, Int_t chan)
1899 {
1900  return ( (slot==20) and (chan==30) );
1901 }
1902 
1903 //
1904 // return F1TDC resolution for possible further check
1905 //
1906 Double_t
1908 {
1909  //
1910  // reduce call "GetF1TDCsResolution" inside subsystem...
1911  //
1913  return fF1TDCOneResolutionNS;
1914 }
1915 
1916 
1917 
1918 
1919 //----------------------------------
1920 //
1921 //
1922 //
1923 // F1TDCReferenceSignal
1924 //
1925 //
1926 //
1927 //
1928 //----------------------------------
1929 
1930 
1931 
1932 const UInt_t F1TDCReferenceSignal::fNoRefTimeArbUnit = 0xFFFFF; // whatever number which is out of the F1TDC hardware range FFFF.
1933 
1934 
1936 {
1937  fSlot = -1;
1938  fChannelNumber = -1;
1939  fBankIndex = -1;
1940  fRefSignalName = "";
1941  fSystemName = "";
1942  Clear();
1943 }
1944 
1945 
1946 
1948  const Int_t bank_index,
1949  const Int_t slot,
1950  const Int_t channel
1951  )
1952 {
1953  fSlot = slot;
1954  fChannelNumber = channel;
1955  fBankIndex = bank_index;
1956  fRefSignalName = "";
1957  fSystemName = "";
1958  Clear();
1959 
1960 }
1961 
1962 
1963 
1965  const Int_t bank_index,
1966  const Int_t slot,
1967  const Int_t channel,
1968  const TString name
1969  )
1970 {
1971  fSlot = slot;
1972  fChannelNumber = channel;
1973  fBankIndex = bank_index;
1974  fRefSignalName = name;
1975  fSystemName = "";
1976  fCounter = 0;
1977  Clear();
1978 }
1979 
1980 
1981 
1982 
1983 
1984 
1985 std::ostream& operator<< (std::ostream& os, const F1TDCReferenceSignal &f1tdcref)
1986 {
1987  os << " Name ";
1988  os << std::setw(22) << f1tdcref.fRefSignalName;
1989  os << " Bank idx ";
1990  os << std::setw(2) << f1tdcref.fBankIndex;
1991  os << " Slot ";
1992  os << std::setw(2) << f1tdcref.fSlot;
1993  os << " Chan ";
1994  os << std::setw(2) << f1tdcref.fChannelNumber;
1995  os << " RefTime (a.u.) ";
1996  os << std::setw(8) << f1tdcref.fRefTimeArbUnit;
1997  os << " Counter ";
1998  os << std::setw(12) << f1tdcref.fCounter;
1999 
2000  return os;
2001 }
2002 
2003 
2004 Bool_t
2005 F1TDCReferenceSignal::SetRefTimeAU(const Double_t ref_time)
2006 {
2007  // always save the first hit as the reference signal
2008  Bool_t status = false;
2009  if( not HasFirstHit() ) {
2010  // save the reference fime
2011  fRefTimeArbUnit = ref_time;
2012  // fRefTimeFlag = true;
2013  fFirstHitFlag = true;
2014  status = true;
2015  fCounter++;
2016  }
2017  return status;
2018 };
2019 
2020 
2021 
2022 Bool_t
2024 {
2025  if( (Double_t) fNoRefTimeArbUnit == fRefTimeArbUnit) {
2026  fRefTimeFlag = false;
2027  }
2028  else {
2029  fRefTimeFlag = true;
2030  }
2031  return fRefTimeFlag;
2032 };
2033 
2034 
2035 void
2037 {
2038  std::cout << " Name " << std::setw(20) << fRefSignalName
2039  << " Bank idx " << std::setw(2) << fBankIndex
2040  << " Slot " << std::setw(2) << fSlot
2041  << " Chan " << std::setw(2) << fChannelNumber
2042  << " Counter " << std::setw(20) << fCounter
2043  << std::endl;
2044  return;
2045 };
2046 
2047 
2048 
2049 //----------------------------------
2050 //
2051 //
2052 //
2053 // F1TDCReferenceContainer
2054 //
2055 //
2056 //
2057 //
2058 //----------------------------------
2059 
2060 
2062 {
2063  fF1TDCReferenceSignalsList = new TObjArray();
2064 
2065  fF1TDCReferenceSignalsList -> Clear();
2066  fF1TDCReferenceSignalsList -> SetOwner(kTRUE);
2067 
2068 
2070 
2071 }
2072 
2073 
2075 {
2079  }
2080 }
2081 
2082 
2083 
2084 void
2086 {
2087  /* Int_t pos = */ fF1TDCReferenceSignalsList -> AddAtFree(in);
2088  // printf("AddF1TDCReferenceSignal at pos %d\n", pos);
2089  std::cout << *in << std::endl;
2091  return;
2092 }
2093 
2094 
2095 
2096 // F1TDCReferenceSignal *
2097 // F1TDCReferenceContainer::GetReferenceSignal(Int_t bank_index,
2098 // Int_t slot,
2099 // Int_t chan
2100 // )
2101 // {
2102 // Int_t bank_idx = 0;
2103 // Int_t slot_num = 0;
2104 // Int_t chan_num = 0;
2105 // // Int_t time_au = 0;
2106 
2107 // TObjArrayIter next(fF1TDCReferenceSignalsList);
2108 // TObject* obj = NULL;
2109 // F1TDCReferenceSignal* F1RefSignal = NULL;
2110 
2111 // while ( (obj = next()) )
2112 // {
2113 // F1RefSignal = (F1TDCReferenceSignal*) obj;
2114 
2115 // bank_idx = F1RefSignal->GetBankIndex();
2116 // slot_num = F1RefSignal->GetSlotNumber();
2117 // chan_num = F1RefSignal->GetChannelNumber();
2118 // // time_au = F1RefSignal->
2119 // if( (bank_idx == bank_index) and (slot_num == slot) and (chan_num == chan) ) {
2120 // if ( F1RefSignal->HasFirstHit() ) return NULL;
2121 // else return F1RefSignal;
2122 // }
2123 // }
2124 
2125 // return NULL;
2126 // }
2127 
2128 
2129 
2130 void
2132  Int_t slot,
2133  Int_t chan,
2134  UInt_t data,
2135  Bool_t debug
2136  )
2137 {
2138  Int_t bank_idx = 0;
2139  Int_t slot_num = 0;
2140  Int_t chan_num = 0;
2141  // Int_t time_au = 0;
2142 
2143  TObjArrayIter next(fF1TDCReferenceSignalsList);
2144  TObject* obj = NULL;
2145  F1TDCReferenceSignal* F1RefSignal = NULL;
2146 
2147  while ( (obj = next()) )
2148  {
2149  F1RefSignal = (F1TDCReferenceSignal*) obj;
2150 
2151  bank_idx = F1RefSignal->GetBankIndex();
2152  slot_num = F1RefSignal->GetSlotNumber();
2153  chan_num = F1RefSignal->GetChannelNumber();
2154 
2155  if( (bank_idx == bank_index) and (slot_num == slot) and (chan_num == chan) ) {
2156  if ( not F1RefSignal->HasFirstHit() ) {
2157  F1RefSignal -> SetRefTimeAU (data);
2158  if(debug) std::cout << *F1RefSignal << std::endl;
2159  }
2160  }
2161  }
2162 
2163  return;
2164 }
2165 
2166 
2167 Double_t
2169  Int_t bank_index,
2170  TString name
2171  )
2172 {
2173  Int_t bank_idx = 0;
2174  TString ref_name = "";
2175 
2176  TObjArrayIter next(fF1TDCReferenceSignalsList);
2177  TObject* obj = NULL;
2178  F1TDCReferenceSignal* F1RefSignal = NULL;
2179 
2180  while ( (obj = next()) )
2181  {
2182  F1RefSignal = (F1TDCReferenceSignal*) obj;
2183 
2184  bank_idx = F1RefSignal->GetBankIndex();
2185  ref_name = F1RefSignal->GetRefSignalName();
2186 
2187  if( (bank_idx == bank_index) and (ref_name == name) ) {
2188  // find the reference signals,
2189  if(F1RefSignal->HasRefTime()) {
2190  // return a ref time if the reference time is filled up
2191  // can be zero.
2192  return F1RefSignal->GetRefTimeAU();
2193  }
2194  // return F1RefSignal->GetRefTimeAU();
2195  }
2196  }
2197 
2198  return 0.0; // they cannot find a reference signal for bank_index and name.
2199 }
2200 
2201 
2202 
2203 void
2205 {
2206 
2207  TObjArrayIter next(fF1TDCReferenceSignalsList);
2208  TObject* obj = NULL;
2209  F1TDCReferenceSignal* F1RefSignal = NULL;
2210 
2211  while ( (obj = next()) )
2212  {
2213  F1RefSignal = (F1TDCReferenceSignal*) obj;
2214  F1RefSignal->ClearEventData();
2215  }
2216 
2217  return;
2218 }
2219 
2220 void
2222 {
2223  TObjArrayIter next(fF1TDCReferenceSignalsList);
2224  TObject* obj = NULL;
2225  F1TDCReferenceSignal* F1RefSignal = NULL;
2226 
2227 
2228  std::cout << "F1Reference Signal Counters at System " << fSystemName << std::endl;
2229  while ( (obj = next()) )
2230  {
2231  F1RefSignal = (F1TDCReferenceSignal*) obj;
2232  F1RefSignal->PrintCounterSummary();
2233  }
2234  return;
2235 };
2236 
2237 
2238 void
2240 {
2241  // Types are defined in QwType.h
2242  if(fSystemName.IsNull()) {
2243  fSystemName = name;
2244  }
2245  else {
2246  std::cout << "F1TDCReferenceContainer::SetSystemName "
2247  << fSystemName
2248  << " is already registered."
2249  << std::endl;
2250  }
2251  return;
2252 }
2253 
2254 
2255 
2256 // Double_t
2257 // F1TDCReferenceContainer::GetNoReferenceTimeAU(
2258 // Int_t bank_index,
2259 // TString name
2260 // )
2261 // {
2262 // Int_t bank_idx = 0;
2263 // TString ref_name = "";
2264 
2265 // TObjArrayIter next(fF1TDCReferenceSignalsList);
2266 // TObject* obj = NULL;
2267 // F1TDCReferenceSignal* F1RefSignal = NULL;
2268 
2269 // while ( (obj = next()) )
2270 // {
2271 // F1RefSignal = (F1TDCReferenceSignal*) obj;
2272 
2273 // bank_idx = F1RefSignal->GetBankIndex();
2274 // ref_name = F1RefSignal->GetRefSignalName();
2275 
2276 // if( (bank_idx == bank_index) and (ref_name == name) ) {
2277 // return F1RefSignal->GetNoRefTimeAU();
2278 // }
2279 // }
2280 
2281 // return 0.0;
2282 // }
Double_t fF1TDC_resolution_ns
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
UInt_t * fF1TDC_SYN_counter
Int_t GetROCNumber() const
void AddQwF1TDC(QwF1TDC *in)
Double_t fF1TDC_full_range_ns
Double_t fF1TDC_t_offset
TArrayD * fReferenceSignals
UInt_t GetTotalFDF()
Int_t GetBankIndex() const
F1TDCs configuration and reference siganls container.
Bool_t fReferenceSlotFlag
void AddSYN(Int_t roc, Int_t slot, Int_t channel)
UInt_t fF1TDC_RFM_counter
Int_t GetSlotNumber() const
Int_t GetSize() const
void SetF1TDCBuffer(UInt_t *buffer, UInt_t num_words)
QwF1TDC * GetF1TDCwithBankIndexSLOT(Int_t bank_index, Int_t slot)
std::ostream & operator<<(std::ostream &out, const QwColor &color)
Output stream operator which uses the enum-to-escape-code mapping.
Definition: QwColor.h:153
Double_t fF1TDC_trig_resolution_ns
UInt_t GetTotalRLF()
void AddRLF(Int_t roc, Int_t slot, Int_t channel)
static const double in
Definition: QwUnits.h:66
EQwRegionID fRegion
UInt_t GetTDCHeaderTriggerTime() const
Definition: MQwF1TDC.h:74
Int_t GetF1TDCIndex() const
static const Int_t fMaxF1TDCChannelNumber
Bool_t fLocalF1RawDecodeDebug
const UInt_t & GetTDCChipAddress() const
Definition: MQwF1TDC.h:46
Bool_t fLocalF1DecodeDebug
Double_t GetF1TDCTriggerRollover()
void SetSystemName(const TString name)
UInt_t GetFDF(Int_t channel) const
void AddEMM(Int_t channel)
void SetSystemName(const TString name)
TString GetErrorCounter()
TObjArray * fQwF1TDCList
Bool_t IsValidDataSlot() const
Definition: MQwF1TDC.h:77
Bool_t IsHeaderXorSetup() const
Definition: MQwF1TDC.h:79
const Bool_t & IsHeaderword() const
Definition: MQwF1TDC.h:42
void AddSEU(Int_t roc, Int_t slot, Int_t channel)
TString GetChannelErrorCounter(Int_t channel)
QwF1TDC * GetF1TDC(Int_t roc, Int_t slot)
UInt_t fF1TDC_refcnt
TObjArray * fF1TDCReferenceSignalsList
Double_t GetF1TDC_trig_t_offset() const
#define QwVerbose
Predefined log drain for verbose messages.
Definition: QwLog.h:55
one F1TDC configuration and reference signal(s) holder
Bool_t IsHitFIFOOverFlow() const
Definition: MQwF1TDC.h:83
Double_t GetReferenceTimeAU(Int_t bank_index, TString name)
Bool_t CheckDataIntegrity(const UInt_t roc_id, UInt_t *buffer, UInt_t num_words)
void AddSYN(Int_t channel)
void PrintTotalErrorCounter()
void PrintContact()
UInt_t GetHFO(Int_t channel) const
UInt_t GetTotalEMM()
Double_t fF1TDC_latency_ns
Bool_t fF1TDCSyncFlag
UInt_t GetTDCTriggerTime() const
Definition: MQwF1TDC.h:54
const TString GetSystemName() const
void AddS30(Int_t channel)
const TString GetF1SystemName() const
virtual ~QwF1TDContainer()
void PrintChannelErrorCounter(Int_t channel)
Int_t GetF1BankIndex() const
Int_t GetChannelNumber() const
MQwF1TDC fF1TDCDecoder
UInt_t * fF1TDC_FDF_counter
UInt_t fF1TDC_trigwin
Bool_t CheckSlot20Chan30(Int_t slot, Int_t chan)
void WriteErrorSummary(Bool_t hist_flag=true)
void AddRLF(Int_t channel)
UInt_t GetTotalHFO()
UInt_t * fF1TDC_SEU_counter
TString fSystemName
Bool_t IsNotHeaderTrigFIFO() const
Definition: MQwF1TDC.h:80
void AddFDF(Int_t channel)
Bool_t IsSyncMode() const
UInt_t * fF1TDC_TFO_counter
const UInt_t & GetTDCSlotNumber() const
Definition: MQwF1TDC.h:44
const Double_t GetRefTimeAU() const
UInt_t GetTDCEventNumber() const
Definition: MQwF1TDC.h:53
UInt_t fF1TDC_refclkdiv
Int_t GetChannelNumber() const
UInt_t fF1TDC_triglat
const UInt_t & GetTDCChannelNumber() const
Definition: MQwF1TDC.h:45
const UInt_t & GetTDCChannelAddress() const
Definition: MQwF1TDC.h:47
void AddSEU(Int_t channel)
UInt_t * fBuffer
void AddTFO(Int_t roc, Int_t slot, Int_t channel)
A logfile class, based on an identical class in the Hermes analyzer.
Double_t ReferenceSignalCorrection(Double_t raw_time, Double_t ref_time)
Bool_t IsNormResolution() const
UInt_t GetTFO(Int_t channel) const
void AddHFO(Int_t roc, Int_t slot, Int_t channel)
UInt_t GetTotalSEU()
UInt_t GetTDCHeaderEventNumber() const
Definition: MQwF1TDC.h:73
UInt_t fF1TDC_hsdiv
Bool_t fF1TDCNormResFlag
Double_t ReferenceSignalCorrection(Double_t raw_time, Double_t ref_time, Int_t bank_index, Int_t slot)
void AddF1TDCReferenceSignal(F1TDCReferenceSignal *in)
TString GetTotalErrorCounter()
void SetReferenceSignal(Int_t bank_index, Int_t slot, Int_t chan, UInt_t data, Bool_t debug=false)
void AddOFO(Int_t channel)
Bool_t IsResolutionLock() const
Definition: MQwF1TDC.h:85
Double_t DoneF1TDCsConfiguration()
UInt_t * fF1TDC_OFO_counter
void PrintErrorCounter()
UInt_t GetSEU(Int_t channel) const
Int_t fChannelNumber
void PrintF1TDCConfigure()
void AddTFO(Int_t channel)
Int_t fF1BankIndex
Bool_t IsOutputFIFOOverFlow() const
Definition: MQwF1TDC.h:84
const TH2F * GetF1TDCErrorHist()
UInt_t GetTotalOFO()
UInt_t * fF1TDC_HFO_counter
UInt_t * fF1TDC_S30_counter
void AddS30(Int_t roc, Int_t slot, Int_t channel)
Double_t fF1TDC_trig_t_offset
EQwDetectorType fDetectorType
EQwRegionID GetRegion() const
QwF1TDC * GetF1TDCwithIndex(Int_t tdc_index)
UInt_t GetRLF(Int_t channel) const
void AddFDF(Int_t roc, Int_t slot, Int_t channel)
void AddOFO(Int_t roc, Int_t slot, Int_t channel)
UInt_t GetTotalSYN()
UInt_t GetSYN(Int_t channel) const
static std::ostream & endl(std::ostream &)
End of the line.
Definition: QwLog.cc:299
static const Int_t fWordsPerBuffer
ClassImp(QwF1TDC)
void PrintF1TDCBuffer()
Double_t fF1TDCFactor
Bool_t CheckRegisteredF1(Int_t roc, Int_t slot)
UInt_t GetEMM(Int_t channel) const
void AddHFO(Int_t channel)
const TString GetRefSignalName() const
TString PrintNoF1TDC(Int_t roc, Int_t slot)
UInt_t GetOFO(Int_t channel) const
UInt_t GetTotalS30()
Double_t GetF1TDCsResolution()
Double_t fF1TDC_tframe_ns
UInt_t GetTotalTFO()
Int_t GetSlotNumber() const
#define QwWarning
Predefined log drain for warnings.
Definition: QwLog.h:45
Int_t GetF1TDCChannelNumber()
Double_t GetF1TDCResolution();.
void Print(const Option_t *options=0) const
TList * GetErrorSummary()
Bool_t IsFakeData() const
Definition: MQwF1TDC.h:87
virtual ~QwF1TDC()
Int_t fF1TDCIndex
Double_t fF1TDCOneResolutionNS
Double_t fF1TDC_window_ns
void DecodeTDCWord(UInt_t &word, const UInt_t roc_id)
Definition: MQwF1TDC.cc:84
Bool_t SetRefTimeAU(const Double_t ref_time)
UInt_t GetTotal(UInt_t *error_counter)
static const UInt_t fNoRefTimeArbUnit
UInt_t * fF1TDC_RLF_counter
UInt_t * fF1TDC_EMM_counter
Double_t GetF1TDC_resolution() const
EQwDetectorType GetDetectorType() const
void AddEMM(Int_t roc, Int_t slot, Int_t channel)
void ResetCounters()
UInt_t GetTotalRFM()