StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St_svtRDOstrippedC.cxx
1 #include <assert.h>
2 #include "TMath.h"
3 #include "TDatime.h"
4 #include "TString.h"
5 #include "Stiostream.h"
6 #include "St_svtRDOstrippedC.h"
7 ClassImp(St_svtRDOstrippedC);
8 St_svtRDOstrippedC *St_svtRDOstrippedC::fgsvtRDOstrippedC = 0;
9 struct RDO_t {
10  const Char_t *name;
11  Int_t ladNum, barNum;
12  const Char_t *rdo;
13  Int_t ndet1, ndet2; // wafers range
14 };
15 static const Int_t NRDOS = 72;
16 static const RDO_t RDOS[NRDOS] = {
17  {"L01B1E", 1,1, "E1",1,2},{"L02B1E", 2,1, "E2",1,2},{"L03B1E", 3,1, "E4",1,2},{"L04B1E", 4,1, "E5",1,2},{"L05B1E", 5,1, "E7",1,2},
18  {"L06B1E", 6,1, "E8",1,2},{"L07B1E", 7,1,"E10",1,2},{"L08B1E", 8,1,"E11",1,2},
19 
20  {"L01B2E", 1,2, "E3",1,3},{"L02B2E", 2,2, "E3",1,3},
21  {"L03B2E", 3,2, "E3",1,3},{"L04B2E", 4,2, "E6",1,3},{"L05B2E", 5,2, "E6",1,3},{"L06B2E", 6,2, "E6",1,3},{"L07B2E", 7,2, "E9",1,3},
22  {"L08B2E", 8,2, "E9",1,3},{"L09B2E", 9,2, "E9",1,3},{"L10B2E",10,2,"E12",1,3},{"L11B2E",11,2,"E12",1,3},{"L12B2E",12,2,"E12",1,3},
23 
24  {"L01B3E", 1,3, "E1",1,3},{"L02B3E", 2,3, "E1",1,4},{"L03B3E", 3,3, "E2",1,3},{"L04B3E", 4,3, "E2",1,4},{"L05B3E", 5,3, "E4",1,3},
25  {"L06B3E", 6,3, "E4",1,4},{"L07B3E", 7,3, "E5",1,3},{"L08B3E", 8,3, "E5",1,4},{"L09B3E", 9,3, "E7",1,3},{"L10B3E",10,3, "E7",1,4},
26  {"L11B3E",11,3, "E8",1,3},{"L12B3E",12,3, "E8",1,4},{"L13B3E",13,3,"E10",1,3},{"L14B3E",14,3,"E10",1,4},{"L15B3E",15,3,"E11",1,3},
27  {"L16B3E",16,3,"E11",1,4},
28 
29  {"L01B1W", 1,1, "W1",3,4},{"L02B1W", 2,1, "W2",3,4},{"L03B1W", 3,1, "W4",3,4},{"L04B1W", 4,1, "W5",3,4},{"L05B1W", 5,1, "W7",3,4},
30  {"L06B1W", 6,1, "W8",3,4},{"L07B1W", 7,1,"W10",3,4},{"L08B1W", 8,1,"W11",3,4},
31 
32  {"L01B2W", 1,2, "W3",4,6},{"L02B2W", 2,2, "W3",4,6},
33  {"L03B2W", 3,2, "W3",4,6},{"L04B2W", 4,2, "W6",4,6},{"L05B2W", 5,2, "W6",4,6},{"L06B2W", 6,2, "W6",4,6},{"L07B2W", 7,2, "W9",4,6},
34  {"L08B2W", 8,2, "W9",4,6},{"L09B2W", 9,2, "W9",4,6},{"L10B2W",10,2,"W12",4,6},{"L11B2W",11,2,"W12",4,6},{"L12B2W",12,2,"W12",4,6},
35 
36  {"L01B3W", 1,3, "W1",4,7},{"L02B3W", 2,3, "W1",5,7},{"L03B3W", 3,3, "W2",4,7},{"L04B3W", 4,3, "W2",5,7},{"L05B3W", 5,3, "W4",4,7},
37  {"L06B3W", 6,3, "W4",5,7},{"L07B3W", 7,3, "W5",4,7},{"L08B3W", 8,3, "W5",5,7},{"L09B3W", 9,3, "W7",4,7},{"L10B3W",10,3, "W7",5,7},
38  {"L11B3W",11,3, "W8",4,7},{"L12B3W",12,3, "W8",5,7},{"L13B3W",13,3,"W10",4,7},{"L14B3W",14,3,"W10",5,7},{"L15B3W",15,3,"W11",4,7},
39  {"L16B3W",16,3,"W11",5,7}
40 };
41 static const Int_t NB = 3;
42 static const Int_t NL = 16;
43 static const Int_t NWmax = 7;
44 static svtRDOstripped_st *pointers[3][16][7];
45 static svtRDOstripped_st *DataOld = 0;
46 static Int_t _debug = 0;
47 //________________________________________________________________________________
48 St_svtRDOstrippedC::St_svtRDOstrippedC (St_svtRDOstripped *table) : TChair(table), fDate(0), fDelay(0), fSwitchedOff(0) {
49  if (fgsvtRDOstrippedC) delete fgsvtRDOstrippedC; fgsvtRDOstrippedC = this;
50  Init();
51 }
52 //________________________________________________________________________________
53 void St_svtRDOstrippedC::Init() {
54  memset (&pointers[0][0][0], 0, NB*NL*NWmax*sizeof(svtRDOstripped_st *));
55  St_svtRDOstripped *Table = (St_svtRDOstripped *) GetThisTable();
56  if (Table) {
57  svtRDOstripped_st *Data = Table->GetTable();
58  DataOld = Data;
59  Int_t N = Table->GetNRows();
60  TString rdo, RDO;
61  Int_t i, j;
62  for (j = 0; j < N; j++) {
63  Int_t barrel = Data[j].barNum;
64  Int_t ladder = Data[j].ladNum;
65  Int_t NW = NWmax;
66  if (barrel == 1) NW = 4;
67  if (barrel == 2) NW = 6;
68  rdo = Data[j].rdo;
69  for (Int_t wafer = 1; wafer <= NW; wafer++) {
70  Int_t k = -1;
71  for (i = 0; i < NRDOS; i++) { // West or East
72  RDO = RDOS[i].rdo;
73  if (RDOS[i].barNum == barrel &&
74  RDOS[i].ladNum == ladder &&
75  rdo == RDO &&
76  RDOS[i].ndet1 <= wafer && wafer <= RDOS[i].ndet2) {k = i; break;}
77  }
78  if (k >= 0)
79  pointers[barrel-1][ladder-1][wafer-1] = Data + j;
80  }
81  }
82  }
83 }
84 //________________________________________________________________________________
85 svtRDOstripped_st *St_svtRDOstrippedC::pRDO(Int_t barrel, Int_t ladder, Int_t wafer) {
86  svtRDOstripped_st *p = 0;
87  if (! GetThisTable()) return p;
88  if (((St_svtRDOstripped *)GetThisTable())->GetTable() != DataOld) Init();
89  if (barrel >= 1 && barrel <= NB &&
90  ladder >= 1 && ladder <= NL &&
91  wafer >= 1 && wafer <= NWmax) p = pointers[barrel-1][ladder-1][wafer-1];
92  return p;
93 }
94 //________________________________________________________________________________
95 Int_t St_svtRDOstrippedC::svtRDOstrippedStatus(Int_t barrel, Int_t ladder, Int_t wafer) {
96  svtRDOstripped_st *p = pRDO(barrel, ladder, wafer);
97  Int_t iOK = 8; // barrel, ladder, wafer is missing
98  if (p) {
99  iOK = 0;
100  if (TMath::Abs(-1500 - p->hvVolt) > 2) iOK += 1; // bad voltage
101  if (p->lvFault) iOK += 2; // RDO fail
102  if (! iOK && fDate && fDelay) {// Check time
103  if (_debug) {
104  TDatime t; t.Set(fDate);
105  cout << " fSwitchedOff " << fSwitchedOff
106  << " fDelay " << fDelay << "\t"; t.Print();
107  }
108  Int_t utOff = 0;
109  if (p->dateOff > 0) {
110  TDatime tOff(p->dateOff,p->timeOff);
111  if (_debug) {cout << " tOff "; tOff.Print();}
112  utOff = tOff.Convert();
113  }
114  Int_t utOn = 0;
115  if (p->date > 0) {
116  TDatime tOn(p->date,p->time);
117  utOn = tOn.Convert();
118  if (_debug) {cout << " tOn "; tOn.Print();}
119  }
120  Int_t DifOffOn = utOn - utOff;
121  if (DifOffOn > fSwitchedOff) {
122  Int_t DifOn = fDate - utOn;
123  if (_debug) {cout << "DiffOffOn " << DifOffOn << "\tDifOn " << DifOn << endl;}
124  if (DifOn < fDelay) {
125  iOK += 4; // out of date
126  }
127  }
128  }
129  }
130  return iOK;
131 }
132 //________________________________________________________________________________
133 void St_svtRDOstrippedC::PrintRDOmap() {
134  Int_t status = -1;
135  Int_t N = NRDOS/2;
136  cout << "Half Ladder L/B RDO ndet1 ndet2 sta: 0 - o.k.; 1 - bad voltage; 2 - RDO fail; 4 - out of date; 8 - barrel, ladder, wafer is missing" << endl;
137  St_svtRDOstrippedC *svtRDOS = St_svtRDOstrippedC::instance();
138  for (Int_t i = 0; i < N; i++) {
139  if (svtRDOS) status = svtRDOS->svtRDOstrippedStatus(RDOS[i].barNum,RDOS[i].ladNum,RDOS[i].ndet1);
140  cout << Form("%11s %2i/%1i %3s %3i %3i %3i", RDOS[i].name, RDOS[i].ladNum, RDOS[i].barNum, RDOS[i].rdo, RDOS[i].ndet1,RDOS[i].ndet2,status);
141  cout << Form("%11s %2i/%1i %3s %3i %3i %3i", RDOS[N+i].name, RDOS[N+i].ladNum, RDOS[N+i].barNum, RDOS[N+i].rdo, RDOS[N+i].ndet1, RDOS[i].ndet2,status)
142  << endl;
143  }
144 }
145 
Definition: TChair.h:27