4 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #if !defined(__CINT__) || defined(__MAKECINT__)
12 #include "Riostream.h"
19 #include "TObjString.h"
20 #include "tables/St_svtRDOstripped_Table.h"
24 class svtRDOstripped_st;
31 const Double_t DeltahVolt = 5;
35 static const Int_t NRDOS = 72;
36 static const RDO_t RDOS[72] = {
37 {
"L01B1E", 1,1,
"E1", 2},{
"L02B1E", 2,1,
"E2", 2},{
"L03B1E", 3,1,
"E4", 2},{
"L04B1E", 4,1,
"E5", 2},{
"L05B1E", 5,1,
"E7", 2},
38 {
"L06B1E", 6,1,
"E8", 2},{
"L07B1E", 7,1,
"E10", 2},{
"L08B1E", 8,1,
"E11", 2},
39 {
"L01B2E", 1,2,
"E3", 2},{
"L02B2E", 2,2,
"E3", 3},
40 {
"L03B2E", 3,2,
"E3", 3},{
"L04B2E", 4,2,
"E6", 3},{
"L05B2E", 5,2,
"E6", 3},{
"L06B2E", 6,2,
"E6", 3},{
"L07B2E", 7,2,
"E9", 3},
41 {
"L08B2E", 8,2,
"E9", 3},{
"L09B2E", 9,2,
"E9", 3},{
"L10B2E",10,2,
"E12", 3},{
"L11B2E",11,2,
"E12", 3},{
"L12B2E",12,2,
"E12", 3},
43 {
"L01B3E", 1,3,
"E1", 3},{
"L02B3E", 2,3,
"E1", 4},{
"L03B3E", 3,3,
"E2", 3},{
"L04B3E", 4,3,
"E2", 4},{
"L05B3E", 5,3,
"E4", 3},
44 {
"L06B3E", 6,3,
"E4", 4},{
"L07B3E", 7,3,
"E5", 3},{
"L08B3E", 8,3,
"E5", 4},{
"L09B3E", 9,3,
"E7", 3},{
"L10B3E",10,3,
"E7", 4},
45 {
"L11B3E",11,3,
"E8", 3},{
"L12B3E",12,3,
"E8", 4},{
"L13B3E",13,3,
"E10", 3},{
"L14B3E",14,3,
"E10", 4},{
"L15B3E",15,3,
"E11", 3},
46 {
"L16B3E",16,3,
"E11", 4},
48 {
"L01B1W", 1,1,
"W1", 4},{
"L02B1W", 2,1,
"W2", 4},{
"L03B1W", 3,1,
"W4", 4},{
"L04B1W", 4,1,
"W5", 4},{
"L05B1W", 5,1,
"W7", 4},
49 {
"L06B1W", 6,1,
"W8", 4},{
"L07B1W", 7,1,
"W10", 4},{
"L08B1W", 8,1,
"W11", 4},
50 {
"L01B2W", 1,2,
"W3", 4},{
"L02B2W", 2,2,
"W3", 6},
51 {
"L03B2W", 3,2,
"W3", 6},{
"L04B2W", 4,2,
"W6", 6},{
"L05B2W", 5,2,
"W6", 6},{
"L06B2W", 6,2,
"W6", 6},{
"L07B2W", 7,2,
"W9", 6},
52 {
"L08B2W", 8,2,
"W9", 6},{
"L09B2W", 9,2,
"W9", 6},{
"L10B2W",10,2,
"W12", 6},{
"L11B2W",11,2,
"W12", 6},{
"L12B2W",12,2,
"W12", 6},
54 {
"L01B3W", 1,3,
"W1", 7},{
"L02B3W", 2,3,
"W1", 7},{
"L03B3W", 3,3,
"W2", 7},{
"L04B3W", 4,3,
"W2", 7},{
"L05B3W", 5,3,
"W4", 7},
55 {
"L06B3W", 6,3,
"W4", 7},{
"L07B3W", 7,3,
"W5", 7},{
"L08B3W", 8,3,
"W5", 7},{
"L09B3W", 9,3,
"W7", 7},{
"L10B3W",10,3,
"W7", 7},
56 {
"L11B3W",11,3,
"W8", 7},{
"L12B3W",12,3,
"W8", 7},{
"L13B3W",13,3,
"W10", 7},{
"L14B3W",14,3,
"W10", 7},{
"L15B3W",15,3,
"W11", 7},
57 {
"L16B3W",16,3,
"W11", 7}
60 Int_t CheckRows(svtRDOstripped_st *rows) {
62 for (Int_t i = 0; i < NRDOS; i++, rows++) {
63 if (! rows->lvFault) iok++;
68 void WritesvtRDOstripped(svtRDOstripped_st *rows, Int_t date, Int_t time) {
69 TString fOut = Form(
"svtRDOstripped.%8i.%06i.C",date,time);
70 if (! CheckRows(rows)) {
72 if (nCFWFault) fOut += Form(
"_%i",nCFWFault);
76 cout <<
"Create " << fOut << endl;
77 out.open(fOut.Data());
78 out <<
"TDataSet *CreateTable() {" << endl;
79 out <<
" if (!gROOT->GetClass(\"St_svtRDOstripped\")) return 0;" << endl;
80 out <<
" svtRDOstripped_st row[" << NRDOS <<
"] = {" << endl;
81 for (Int_t i = 0; i < NRDOS; i++, rows++) {
82 out <<
"\t{" << Form(
"%1i,%2i,\"%s\",\t",rows->barNum,rows->ladNum, rows->rdo);
83 out << Form(
"%13.7f, %13.7f, %13.7f,%13.7f, %13.7f", rows->northTemp, rows->southTemp,rows->hvBoardTemp,rows->hvVolt,rows->hvCurr);
84 out << Form(
", %2i, %8i, %6i, %8i, %6i}" ,rows->lvFault, rows->date, rows->time, rows->dateOff, rows->timeOff);
85 if (i != NRDOS - 1) out <<
",";
86 if (tags[i]) out <<
"// " << tags[i];
90 out <<
" St_svtRDOstripped *tableSet = new St_svtRDOstripped(\"svtRDOstripped\"," << NRDOS <<
");" << endl;
91 out <<
" for (Int_t i = 0; i < " << NRDOS <<
"; i++) tableSet->AddAt(&row[i].barNum, i);" << endl;
92 out <<
" return (TDataSet *)tableSet;" << endl;
98 void MakesvtRDOstripped(Char_t *FileName=
"./svtRDOs.txt") {
105 gSystem->Load(
"libStDb_Tables.so");
106 FILE *fp = fopen(FileName,
"r");
108 svtRDOstripped_st rows[72];
109 memset(rows, 0, NRDOS*
sizeof(svtRDOstripped_st));
110 memset(tags, 0, 72*14);
111 for (Int_t i = 0; i < NRDOS; i++) {
112 rows[i].barNum = RDOS[i].barNum;
113 rows[i].ladNum = RDOS[i].ladNum;
114 strcpy(rows[i].rdo,RDOS[i].rdo);
115 rows[i].lvFault = -1;
118 svtRDOstripped_st row;
119 Int_t year, month, day;
120 Int_t hour, mins, secs;
121 Int_t date, time, dateOld = 0, timeOld = 0;
122 Double_t datimeOld = 0;
127 fgets(&line[0],120,fp);
128 Int_t nRowsModified = 0;
129 while (fgets(&line[0],120,fp)) {
131 if (nCFW > 100)
break;
133 memset (&row, 0,
sizeof(svtRDOstripped_st));
141 sscanf(&line[0],
"%4d-%2d-%2d %02d:%02d:%02d %s %d %d %d %s %f %f %f %f %f %d",
142 &year,&month,&day, &hour,&mins,&secs,
144 &row.barNum,&row.ladNum,row.rdo,&row.northTemp,
145 &row.southTemp,&row.hvBoardTemp,&row.hvVolt,&row.hvCurr,&row.lvFault);
147 printf(
"%4i-%02i-%02i %02i:%02i:%02i %s %i %i %i %s %f %f %f %f %f %i\n",
148 year,month,day, hour,mins,secs,
150 row.barNum,row.ladNum,row.rdo,row.northTemp,
151 row.southTemp,row.hvBoardTemp,row.hvVolt,row.hvCurr,row.lvFault);
153 date = day + 100*(month + 100*year);
154 time = secs + 100*(mins + 100*hour);
157 printf(
"%8d.%06d %s %d %d %d %s %f %f %f %f %f %d",
160 row.barNum,row.ladNum,row.rdo,row.northTemp,
161 row.southTemp,row.hvBoardTemp,row.hvVolt,row.hvCurr,row.lvFault);
164 if (Ofl !=
"ofl")
continue;
166 cout <<
"Wrong date: " << line;
169 Double_t datime = date + ((Double_t) time)/1000000.;
170 if (TMath::Abs(row.hvVolt+1500) >= DeltahVolt) row.hvVolt = 0;
171 if (datimeOld > 0 && datime < datimeOld) {
172 cout <<
"incosistent date time new " << date <<
"/" << time <<
" and old " << dateOld <<
"/" << timeOld << endl;
173 cout << date <<
"\t" << time <<
"\t"
174 << row.barNum <<
"\t" << row.ladNum <<
"\t" << row.rdo <<
"\t" << row.northTemp <<
"\t"
175 << row.southTemp <<
"\t" << row.hvBoardTemp <<
"\t" << row.hvVolt <<
"\t" << row.hvCurr <<
"\t"
176 << row.lvFault << endl;
178 cout << Form(
"Read %8d.%06d",date,time) << endl;
180 if (row.barNum < 1 || row.barNum > 3 ||
181 row.ladNum < 1 || row.ladNum > 16) {
183 cout << date <<
"\t" << time << endl;
184 cout <<
"Wrong barel or ladder number "
185 << row.barNum <<
"\t" << row.ladNum <<
"\t" << row.rdo <<
"\t" << row.northTemp <<
"\t"
186 << row.southTemp <<
"\t" << row.hvBoardTemp <<
"\t" << row.hvVolt <<
"\t" << row.hvCurr <<
"\t"
187 << row.lvFault << endl;
190 if (date != dateOld || time != timeOld) {
191 if (nRowsModified > 10) {
193 WritesvtRDOstripped(rows,dateOld,timeOld);
196 dateOld = date; timeOld = time;
197 datimeOld = dateOld + ((Double_t) timeOld)/1000000.;
201 for (Int_t i = 0; i <= NRDOS; i++) {
202 if (row.barNum != rows[i].barNum ||
203 row.ladNum != rows[i].ladNum ||
204 strcmp(row.rdo,rows[i].rdo))
continue;
206 if ( rows[i].lvFault == -1 && row.lvFault) {
break;}
207 if ( rows[i].lvFault == row.lvFault && TMath::Abs(rows[i].hvVolt - row.hvVolt) < DeltahVolt) {
break;}
210 if ( TMath::Abs(rows[i].hvVolt - row.hvVolt) >= DeltahVolt) {
211 if (TMath::Abs(rows[i].hvVolt + 1500) < DeltahVolt &&
212 TMath::Abs( row.hvVolt + 1500) >= DeltahVolt) {
213 rows[i].dateOff = date;
214 rows[i].timeOff = time;
221 if (TMath::Abs(rows[i].hvVolt + 1500) < DeltahVolt && rows[i].lvFault != row.lvFault) nRowsModified++;
222 rows[i].northTemp = row.northTemp;
223 rows[i].southTemp = row.southTemp;
224 rows[i].hvBoardTemp = row.hvBoardTemp;
225 rows[i].hvVolt = row.hvVolt;
226 rows[i].hvCurr = row.hvCurr;
227 rows[i].lvFault = row.lvFault;
228 strcpy(tags[i],flavor);
233 cout << date <<
"\t" << time << endl;
234 cout <<
"Match has not been found for "
235 << row.barNum <<
"\t" << row.ladNum <<
"\t" << row.rdo <<
"\t" << row.northTemp <<
"\t"
236 << row.southTemp <<
"\t" << row.hvBoardTemp <<
"\t" << row.hvVolt <<
"\t" << row.hvCurr <<
"\t"
237 << row.lvFault << endl;
241 if (nRowsModified > 0) WritesvtRDOstripped(rows,dateOld,timeOld);