24 bool checkDbTable(
char* fileSource,
char* MAXENTRY =
"2030-01-01 00:00:00",
char* flavor =
"ofl")
27 TFile* tableFile=
new TFile(fileSource);
29 TString tempString = fileSource;
31 int index = tempString.Last(slash);
32 TString fileName = tempString(index+1,tempString.Length()-index);
34 int index2 = fileName.Index(
".");
36 TString tableName = fileName(0,index2);
37 TString date = fileName(index2+1,4) +
"-" +
38 fileName(index2+5,2) +
"-" +
41 TString time = fileName(index2+10,2) +
":" +
42 fileName(index2+12,2) +
":" +
43 fileName(index2+14,2);
45 TString timeStamp = date +
" " + time;
48 cout <<
"Requesting table name=" << tableName <<
", timestamp=" << timeStamp <<
" flavor=" << flavor <<
" maxentry=" << MAXENTRY << endl;
49 dbHandler->setTableName(tableName.Data());
50 dbHandler->setTimeStamp(timeStamp.Data());
51 dbHandler->setMaxEntryTime(MAXENTRY);
52 dbHandler->setFlavor(flavor);
55 DBTIME = dbHandler->timeToSqlTime(table->getBeginDateTime());
56 if (tableName==
"bemcCalib" || tableName==
"bprsCalib" )
58 emcCalib_st* tableInFile = (emcCalib_st*) ((St_emcCalib*)tableFile->Get(tableName.Data()))->GetTable();
59 emcCalib_st* tableInDb = (emcCalib_st*) table->GetTable();
60 equal=compare(tableInFile,tableInDb);
63 if (tableName==
"bsmdeCalib" || tableName==
"bsmdpCalib" )
65 smdCalib_st* tableInFile = (smdCalib_st*) ((St_smdCalib*)tableFile->Get(tableName.Data()))->GetTable();
66 smdCalib_st* tableInDb = (smdCalib_st*) table->GetTable();
67 equal=compare(tableInFile,tableInDb);
70 if (tableName==
"bemcGain" || tableName==
"bprsGain" )
72 emcGain_st* tableInFile = (emcGain_st*) ((St_emcGain*)tableFile->Get(tableName.Data()))->GetTable();
73 emcGain_st* tableInDb = (emcGain_st*) table->GetTable();
74 equal=compare(tableInFile,tableInDb);
77 if (tableName==
"bsmdeGain" || tableName==
"bsmdpGain" )
79 smdGain_st* tableInFile = (smdGain_st*) ((St_smdGain*)tableFile->Get(tableName.Data()))->GetTable();
80 smdGain_st* tableInDb = (smdGain_st*) table->GetTable();
81 equal=compare(tableInFile,tableInDb);
84 if (tableName==
"bemcPed" || tableName==
"bprsPed" )
86 emcPed_st* tableInFile = (emcPed_st*) ((St_emcPed*)tableFile->Get(tableName.Data()))->GetTable();
87 emcPed_st* tableInDb = (emcPed_st*) table->GetTable();
88 equal=compare(tableInFile,tableInDb);
91 if (tableName==
"bsmdePed" || tableName==
"bsmdpPed" )
93 smdPed_st* tableInFile = (smdPed_st*) ((St_smdPed*)tableFile->Get(tableName.Data()))->GetTable();
94 smdPed_st* tableInDb = (smdPed_st*) table->GetTable();
95 equal=compare(tableInFile,tableInDb);
98 if (tableName==
"bemcStatus" || tableName==
"bprsStatus" )
100 emcStatus_st* tableInFile = (emcStatus_st*) ((St_emcStatus*)tableFile->Get(tableName.Data()))->GetTable();
101 emcStatus_st* tableInDb = (emcStatus_st*) table->GetTable();
102 equal=compare(tableInFile,tableInDb);
105 if (tableName==
"bsmdeStatus" || tableName==
"bsmdpStatus" )
107 smdStatus_st* tableInFile = (smdStatus_st*) ((St_smdStatus*)tableFile->Get(tableName.Data()))->GetTable();
108 smdStatus_st* tableInDb = (smdStatus_st*) table->GetTable();
109 equal=compare(tableInFile,tableInDb);
112 if (tableName==
"emcTriggerPed")
114 emcTriggerPed_st* tableInFile = (emcTriggerPed_st*) ((St_emcTriggerPed*)tableFile->Get(tableName.Data()))->GetTable();
115 emcTriggerPed_st* tableInDb = (emcTriggerPed_st*) table->GetTable();
116 equal=compare(tableInFile,tableInDb);
119 if (tableName==
"emcTriggerStatus")
121 emcTriggerStatus_st* tableInFile = (emcTriggerStatus_st*) ((St_emcTriggerStatus*)tableFile->Get(tableName.Data()))->GetTable();
122 emcTriggerStatus_st* tableInDb = (emcTriggerStatus_st*) table->GetTable();
123 equal=compare(tableInFile,tableInDb);
126 if (tableName==
"emcTriggerLUT")
128 emcTriggerLUT_st* tableInFile = (emcTriggerLUT_st*) ((St_emcTRiggerLUT*)tableFile->Get(tableName.Data()))->GetTable();
129 emcTriggerLUT_st* tableInDb = (emcTriggerLUT_st*) table->GetTable();
130 equal=compare(tableInFile,tableInDb);
135 cout << (equal ?
"EQUAL" :
"NOT EQUAL") << endl;
142 bool compare(emcCalib_st* t1, emcCalib_st* t2)
145 for(
int i = 0; i<4800;i++)
148 if(t1->AdcToE[i][j]!=t2->AdcToE[i][j]) equal =
false;
149 if(t1->Status[i]!=t2->Status[i]) equal =
false;
154 bool compare(smdCalib_st* t1, smdCalib_st* t2)
157 for(
int i = 0; i<18000;i++)
160 if(t1->AdcToE[i][j]!=t2->AdcToE[i][j]) equal =
false;
161 if(t1->Status[i]!=t2->Status[i]) equal =
false;
166 bool compare(emcStatus_st* t1, emcStatus_st* t2)
169 for(
int i = 0; i<4800;i++)
171 if(t1->Status[i]!=t2->Status[i])
180 bool compare(smdStatus_st* t1, smdStatus_st* t2)
183 for(
int i = 0; i<18000;i++)
185 if(t1->Status[i]!=t2->Status[i]) equal =
false;
190 bool compare(emcGain_st* t1, emcGain_st* t2)
193 for(
int i = 0; i<4800;i++)
195 if(t1->Gain[i]!=t2->Gain[i]) equal =
false;
200 bool compare(smdGain_st* t1, smdGain_st* t2)
203 for(
int i = 0; i<18000;i++)
205 if(t1->Gain[i]!=t2->Gain[i]) equal =
false;
210 bool compare(emcPed_st* t1, emcPed_st* t2)
213 for(
int i = 0; i<4800;i++)
215 if(t1->AdcPedestal[i]!=t2->AdcPedestal[i]) equal =
false;
216 if(t1->AdcPedestalRMS[i]!=t2->AdcPedestalRMS[i]) equal =
false;
217 if(t1->Status[i]!=t2->Status[i]) equal =
false;
222 bool compare(smdPed_st* t1, smdPed_st* t2)
225 for(
int i = 0; i<18000;i++)
227 if(t1->AdcPedestal[i][0]!=t2->AdcPedestal[i][0]) equal =
false;
228 if(t1->AdcPedestal[i][1]!=t2->AdcPedestal[i][1]) equal =
false;
229 if(t1->AdcPedestal[i][2]!=t2->AdcPedestal[i][2]) equal =
false;
230 if(t1->AdcPedestalRMS[i]!=t2->AdcPedestalRMS[i]) equal =
false;
231 if(t1->Status[i]!=t2->Status[i]) equal =
false;
236 bool compare(emcTriggerPed_st* t1, emcTriggerPed_st* t2)
239 for(
int i = 0; i<4800;i++)
241 if(t1->PedShift!=t2->PedShift) equal =
false;
242 for(
int c=0;c<30;c++)
244 for(
int p=0;p<10;p++)
245 if(t1->BitConversionMode[c][p]!=t2->BitConversionMode[c][p]) equal =
false;
246 for(
int p=0;p<160;p++)
247 if(t1->Ped[c][p]!=t2->Ped[c][p]) equal =
false;
253 bool compare(emcTriggerStatus_st* t1, emcTriggerStatus_st* t2)
256 for(
int i = 0; i<4800;i++)
258 if(t1->PedShift!=t2->PedShift) equal =
false;
259 for(
int c=0;c<30;c++)
261 for(
int p=0;p<10;p++)
263 if(t1->PatchStatus[c][p]!=t2->PatchStaus[c][p]) equal =
false;
264 if(t1->HighTowerStatus[c][p]!=t2->HighTowerStaus[c][p]) equal =
false;
266 for(
int p=0;p<160;p++)
267 if(t1->TowerStatus[c][p]!=t2->TowerStatus[c][p]) equal =
false;
273 bool compare(emcTriggerLUT_st* t1, emcTriggerLUT_st* t2)
275 if(notLoaded) loadLibrariesCompare();
277 for(
int c=0;c<30;c++)
279 for(
int p=0;p<10;p++)
281 if(t1->FormulaTag[c][p]!=t2->FormulaTag[c][p]) equal =
false;
282 if(t1->FormulaParameter0[c][p]!=t2->FormulaParameter0[c][p]) equal =
false;
283 if(t1->FormulaParameter1[c][p]!=t2->FormulaParameter1[c][p]) equal =
false;
284 if(t1->FormulaParameter2[c][p]!=t2->FormulaParameter2[c][p]) equal =
false;
285 if(t1->FormulaParameter3[c][p]!=t2->FormulaParameter3[c][p]) equal =
false;
286 if(t1->FormulaParameter4[c][p]!=t2->FormulaParameter4[c][p]) equal =
false;
287 if(t1->FormulaParameter5[c][p]!=t2->FormulaParameter5[c][p]) equal =
false;