58 |
* @param debug debug flag. |
* @param debug debug flag. |
59 |
* @param tlefilename ascii file with TLE 3 line elements. |
* @param tlefilename ascii file with TLE 3 line elements. |
60 |
*/ |
*/ |
61 |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp, Bool_t gpamela){ |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp, Bool_t gpamela, Bool_t keepenv){ |
62 |
// |
// |
63 |
chewbacca = false; |
chewbacca = false; |
64 |
chminentry = 0; |
chminentry = 0; |
76 |
// |
// |
77 |
}; |
}; |
78 |
// |
// |
79 |
|
KEEPENV = false; |
80 |
|
if ( keepenv ) KEEPENV=true; |
81 |
STATIC=false; |
STATIC=false; |
82 |
if ( staticp ) STATIC=true; |
if ( staticp ) STATIC=true; |
83 |
// |
// |
101 |
if (INSERT_RAW) SetRawName(filerawname); |
if (INSERT_RAW) SetRawName(filerawname); |
102 |
// |
// |
103 |
INSERT_ROOT = !filerootname.IsNull(); |
INSERT_ROOT = !filerootname.IsNull(); |
104 |
|
if ( INSERT_ROOT ) this->SetRootName(filerootname); |
105 |
this->SetOrbitNo(dwinput); |
this->SetOrbitNo(dwinput); |
106 |
// |
// |
107 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
135 |
stringstream qu; |
stringstream qu; |
136 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
137 |
TSQLResult *result2 = 0; |
TSQLResult *result2 = 0; |
138 |
|
TSQLResult *result3 = 0; |
139 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
140 |
TSQLRow *row2 = 0; |
TSQLRow *row2 = 0; |
141 |
|
TSQLRow *row3 = 0; |
142 |
TString chpath; |
TString chpath; |
143 |
TString chfile; |
TString chfile; |
144 |
UInt_t ridn = 0; |
UInt_t ridn = 0; |
145 |
qu.str(""); |
qu.str(""); |
146 |
qu << "SELECT ROOT_ID_N,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
qu << "SELECT ROOT_ID_N,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,INSERTED_BY from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
147 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
148 |
result = conn->Query(qu.str().c_str()); |
result = conn->Query(qu.str().c_str()); |
149 |
if ( result ){ |
if ( result ){ |
154 |
chpktmax = (UInt_t)atoll(row->GetField(2)); |
chpktmax = (UInt_t)atoll(row->GetField(2)); |
155 |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
156 |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
157 |
|
chiby = (TString)(row->GetField(5)); |
158 |
} else { |
} else { |
159 |
throw -84; |
throw -84; |
160 |
}; |
}; |
163 |
}; |
}; |
164 |
delete result; |
delete result; |
165 |
qu.str(""); |
qu.str(""); |
166 |
qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL from ROOT_TABLE where ID_N=" << ridn << ";"; |
qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,REAL_TIME_INIT from ROOT_TABLE where ID_N=" << ridn << ";"; |
167 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
168 |
result2 = conn->Query(qu.str().c_str()); |
result2 = conn->Query(qu.str().c_str()); |
169 |
if ( result2 ){ |
if ( result2 ){ |
170 |
row2 = result2->Next(); |
row2 = result2->Next(); |
171 |
if ( row2 ){ |
if ( row2 ){ |
172 |
chpath = (TString)gSystem->ExpandPathName(row2->GetField(0))+'/'; |
if ( KEEPENV ){ |
173 |
|
chpath = (TString)(row2->GetField(0))+'/'; |
174 |
|
} else { |
175 |
|
chpath = (TString)gSystem->ExpandPathName(row2->GetField(0))+'/'; |
176 |
|
}; |
177 |
chfile = (TString)(row2->GetField(1)); |
chfile = (TString)(row2->GetField(1)); |
178 |
chobtts = (UInt_t)atoll(row2->GetField(2)); |
chobtts = (UInt_t)atoll(row2->GetField(2)); |
179 |
chlastts = (UInt_t)atoll(row2->GetField(3)); |
chlastts = (UInt_t)atoll(row2->GetField(3)); |
180 |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
181 |
chboot = (UInt_t)atoll(row2->GetField(5)); |
chboot = (UInt_t)atoll(row2->GetField(5)); |
182 |
// |
// |
183 |
|
if ( !chboot ){ |
184 |
|
qu.str(""); |
185 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND (REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc limit 1;"; |
186 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
187 |
|
result3 = conn->Query(qu.str().c_str()); |
188 |
|
if ( result3 ){ |
189 |
|
row3 = result3->Next(); |
190 |
|
if ( row3 ){ |
191 |
|
chboot = (UInt_t)atoll(row3->GetField(0)); |
192 |
|
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
193 |
|
} else { |
194 |
|
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
195 |
|
}; |
196 |
|
}; |
197 |
|
}; |
198 |
|
// |
199 |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
200 |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
201 |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
208 |
throw -85; |
throw -85; |
209 |
}; |
}; |
210 |
filerootname = chpath + chfile;// + ".root"; |
filerootname = chpath + chfile;// + ".root"; |
|
if ( debug ) printf(" chewbacca: filename is %s \n",filerootname.Data()); |
|
211 |
}; |
}; |
212 |
this->SetRootName(filerootname); |
this->SetRootName(filerootname); |
|
file = TFile::Open(this->GetRootName().Data()); |
|
|
} else { |
|
|
this->SetRootName(""); |
|
213 |
}; |
}; |
214 |
|
if ( debug ) printf(" Filename is %s \n",filerootname.Data()); |
215 |
|
file = TFile::Open(this->GetRootName().Data()); |
216 |
|
// } else { |
217 |
|
// this->SetRootName(""); |
218 |
|
// this->SetRootName(filerootname); |
219 |
|
// }; |
220 |
} |
} |
221 |
|
|
222 |
// |
// |
416 |
return; |
return; |
417 |
}; |
}; |
418 |
// |
// |
419 |
TString name = this->GetRootFile(); |
if ( !chewbacca ){ |
420 |
Int_t nlength = name.Length(); |
TString name = this->GetRootFile(); |
421 |
if ( nlength < 5 ) return; |
Int_t nlength = name.Length(); |
422 |
TString dwo = 0; |
if ( nlength < 5 ){ |
423 |
for (Int_t i = 0; i<5; i++){ |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
424 |
dwo.Append(name[i],1); |
return; |
425 |
}; |
}; |
426 |
if ( dwo.IsDigit() ){ |
TString dwo = 0; |
427 |
dworbit = (UInt_t)dwo.Atoi(); |
for (Int_t i = 0; i<5; i++){ |
|
} else { |
|
|
dwo=""; |
|
|
for (Int_t i = 8; i<13; i++){ |
|
428 |
dwo.Append(name[i],1); |
dwo.Append(name[i],1); |
429 |
}; |
}; |
430 |
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
if ( dwo.IsDigit() ){ |
431 |
|
dworbit = (UInt_t)dwo.Atoi(); |
432 |
|
} else { |
433 |
|
dwo=""; |
434 |
|
for (Int_t i = 8; i<13; i++){ |
435 |
|
dwo.Append(name[i],1); |
436 |
|
}; |
437 |
|
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
438 |
|
}; |
439 |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
440 |
}; |
}; |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
|
441 |
return; |
return; |
442 |
}; |
}; |
443 |
|
|
468 |
|
|
469 |
TString PamelaDBOperations::GetRootPath(){ |
TString PamelaDBOperations::GetRootPath(){ |
470 |
if ( STATIC ){ |
if ( STATIC ){ |
471 |
return((TString)gSystem->DirName(filerootname.Data())+'/'); |
return((TString)gSystem->DirName(this->GetRootName().Data())+'/'); |
472 |
} else { |
} else { |
473 |
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
if ( KEEPENV ){ |
474 |
|
return((TString)gSystem->ExpandPathName(gSystem->DirName(filerootname.Data()))+'/'); |
475 |
|
} else { |
476 |
|
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
477 |
|
}; |
478 |
}; |
}; |
479 |
}; |
}; |
480 |
|
|
686 |
UInt_t tjump = 50000; |
UInt_t tjump = 50000; |
687 |
//UInt_t tjump = 100; |
//UInt_t tjump = 100; |
688 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
689 |
pktlast = numeric_limits<UInt_t>::max(); |
// pktlast = numeric_limits<UInt_t>::max(); |
690 |
while ( pktlast > chpktmax && (Int_t)(nevent-1-it) >= 0 ){ |
pktlast = chpktmax + 1; |
691 |
|
while ( PKT(pktlast) > PKT(chpktmax) && (Int_t)(nevent-1-it) >= 0 ){ |
692 |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
693 |
T->GetEntry(nevent-1-it); |
T->GetEntry(nevent-1-it); |
694 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
696 |
} else { |
} else { |
697 |
pktlast = chpktmax + 1; |
pktlast = chpktmax + 1; |
698 |
}; |
}; |
699 |
if ( (!(it%1000) || abs((int)pktlast - (int)chpktmax)<1000 ) && debug ) printf(" look for up %i %i %i nevent %u (nevent-1-it) %i \n",it,pktlast,chpktmax,nevent,(Int_t)(nevent-1-it)); |
if ( (!(it%1000) || abs((int)(PKT(pktlast) - PKT(chpktmax)))<1000 ) && debug ) printf(" look for up %i %i %i nevent %u (nevent-1-it) %i \n",it,pktlast,chpktmax,nevent,(Int_t)(nevent-1-it)); |
700 |
it += tjump; |
it += tjump; |
701 |
}; |
}; |
702 |
if ( tjump > 1 ) it -= 2*tjump; |
if ( tjump > 1 ) it -= 2*tjump; |
720 |
tjump = 50000; |
tjump = 50000; |
721 |
//tjump = 100; |
//tjump = 100; |
722 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
723 |
pktlast = 0; |
// pktlast = 0; |
724 |
while ( pktlast < chpktmin && it < (Int_t)nevent ){ |
pktlast = chpktmin - 1; |
725 |
|
if ( debug ) printf("LLlook for down %i %i %llu %llu \n",it,pktlast,PKT(pktlast),PKT(chpktmin)); |
726 |
|
while ( PKT(pktlast) < PKT(chpktmin) && it < (Int_t)nevent ){ |
727 |
if ( it < (Int_t)nevent ){ |
if ( it < (Int_t)nevent ){ |
728 |
T->GetEntry(it); |
T->GetEntry(it); |
729 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
1165 |
stringstream oss; |
stringstream oss; |
1166 |
// |
// |
1167 |
oss.str(""); |
oss.str(""); |
1168 |
oss << "INSERT INTO _RUNID_GEN VALUES (NULL);"; |
if ( chewbacca ){// if chewbacca and tag=none then use chewbacca tag (chiby = chewbacca inserted by), if chewbacca and tag!=none then use tag, if not chewbacca use tag. |
1169 |
|
if ( !strcmp(tag.Data(),"NONE") ){ |
1170 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< chiby.Data() <<"');"; |
1171 |
|
} else { |
1172 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< tag.Data() <<"');"; |
1173 |
|
}; |
1174 |
|
} else { |
1175 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< tag.Data() <<"');"; |
1176 |
|
}; |
1177 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1178 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1179 |
oss.str(""); |
oss.str(""); |
1321 |
stringstream oss; |
stringstream oss; |
1322 |
// |
// |
1323 |
oss.str(""); |
oss.str(""); |
1324 |
oss << "lock table GL_RUN write, GL_ROOT write, GL_RAW write, GL_TIMESYNC write, GL_RESURS_OFFSET write, GL_PARAM write, GL_TLE write, GL_RUN_FRAGMENTS write, GL_RUN_TRASH write, GL_CALO_CALIB write, GL_CALOPULSE_CALIB write, GL_TRK_CALIB write, GL_S4_CALIB write, ROOT_TABLE_MERGING write, ROOT_TABLE write, _RUNID_GEN write;"; |
oss << "lock table GL_RUN write, GL_ROOT write, GL_RAW write, GL_TIMESYNC write, GL_RESURS_OFFSET write, GL_PARAM write, GL_TLE write, GL_RUN_FRAGMENTS write, GL_RUN_TRASH write, GL_CALO_CALIB write, GL_CALOPULSE_CALIB write, GL_TRK_CALIB write, GL_S4_CALIB write, ROOT_TABLE_MERGING write, ROOT_TABLE_BAD write, ROOT_TABLE write, _RUNID_GEN write;"; |
1325 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
1326 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1327 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1378 |
// |
// |
1379 |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
1380 |
// |
// |
1381 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
1382 |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
1383 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
1384 |
}; |
}; |
1425 |
UInt_t lastPkt = 0; |
UInt_t lastPkt = 0; |
1426 |
UInt_t rhtime = 0; |
UInt_t rhtime = 0; |
1427 |
UInt_t rttime = 0; |
UInt_t rttime = 0; |
1428 |
|
// |
1429 |
|
if ( IsDebug() ) printf(" A firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1430 |
|
// |
1431 |
if ( !mishead ){ |
if ( !mishead ){ |
1432 |
codh = ehh->GetCounter(); |
codh = ehh->GetCounter(); |
1433 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1) ){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1) ){ |
1434 |
|
if ( IsDebug() ) printf(" B firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1435 |
firstev = 1; |
firstev = 1; |
1436 |
lastev = 0; |
lastev = 0; |
1437 |
} else { |
} else { |
1444 |
}; |
}; |
1445 |
if ( !mistrail ){ |
if ( !mistrail ){ |
1446 |
codt = eht->GetCounter(); |
codt = eht->GetCounter(); |
1447 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1)){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1)){ |
1448 |
|
if ( IsDebug() ) printf(" C firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1449 |
lastev = 0; |
lastev = 0; |
1450 |
firstev = lastev+1; |
firstev = lastev+1; |
1451 |
} else { |
} else { |
1462 |
if ( mishead ) { |
if ( mishead ) { |
1463 |
glrun->Set_GL_RUNH0(); |
glrun->Set_GL_RUNH0(); |
1464 |
// |
// |
1465 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1) ){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1) ){ |
1466 |
firstObt = lastObt; |
firstObt = lastObt; |
1467 |
firstPkt = lastPkt; |
firstPkt = lastPkt; |
1468 |
rhtime = rttime; |
rhtime = rttime; |
1481 |
if ( mistrail ){ |
if ( mistrail ){ |
1482 |
glrun->Set_GL_RUNT0(); |
glrun->Set_GL_RUNT0(); |
1483 |
// |
// |
1484 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1) ){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1) ){ |
1485 |
lastObt = firstObt; |
lastObt = firstObt; |
1486 |
lastPkt = firstPkt; |
lastPkt = firstPkt; |
1487 |
rttime = rhtime; |
rttime = rhtime; |
1516 |
* Insert a new row into GL_RAW table. |
* Insert a new row into GL_RAW table. |
1517 |
*/ |
*/ |
1518 |
Int_t PamelaDBOperations::insertPamelaRawFile(){ |
Int_t PamelaDBOperations::insertPamelaRawFile(){ |
1519 |
|
|
1520 |
|
// |
1521 |
|
Bool_t idr = this->SetID_RAW(); |
1522 |
|
if ( idr ) return(1); |
1523 |
|
|
1524 |
|
GL_RAW glraw = GL_RAW(); |
1525 |
|
|
1526 |
|
glraw.PATH = GetRawPath(); |
1527 |
|
glraw.NAME = GetRawFile(); |
1528 |
|
// glraw.BOOT_NUMBER = 0;//??? |
1529 |
|
glraw.BOOT_NUMBER = this->GetBOOTnumber(); |
1530 |
|
|
1531 |
|
if( insertPamelaRawFile(&glraw) )return(1); |
1532 |
|
// |
1533 |
|
idr = this->SetID_RAW(); |
1534 |
|
if ( !idr ) throw -11; |
1535 |
|
|
1536 |
|
return(0); |
1537 |
|
} |
1538 |
|
/** |
1539 |
|
* Insert a new row into GL_RAW table. |
1540 |
|
*/ |
1541 |
|
Int_t PamelaDBOperations::insertPamelaRawFile(GL_RAW *glraw){ |
1542 |
// |
// |
1543 |
stringstream oss; |
if(!glraw)return(1);//?? ok I think |
1544 |
// |
// |
1545 |
Bool_t idr = this->SetID_RAW(); |
stringstream oss; |
1546 |
if ( idr ) return(1); |
// |
1547 |
// |
oss.str(""); |
1548 |
oss.str(""); |
if ( STATIC ){ |
1549 |
if ( STATIC ){ |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
1550 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
<< glraw->PATH << "', '" << glraw->NAME << "')"; |
1551 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
} else { |
1552 |
} else { |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << glraw->NAME << "')"; |
1553 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
}; |
1554 |
}; |
if ( debug ) cout <<oss.str().c_str() <<endl; |
1555 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1556 |
// |
// |
1557 |
idr = this->SetID_RAW(); |
oss.str(""); |
1558 |
if ( !idr ) throw -11; |
oss << "SELECT ID FROM GL_RAW WHERE NAME=\""<<glraw->NAME<<"\";"; |
1559 |
// |
if ( debug ) cout << oss.str().c_str()<<endl; |
1560 |
return(0); |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1561 |
|
// |
1562 |
|
TSQLResult *result = 0; |
1563 |
|
TSQLRow *row = 0; |
1564 |
|
result = conn->Query(oss.str().c_str()); |
1565 |
|
if ( result == NULL ) throw -4; |
1566 |
|
row = result->Next(); |
1567 |
|
if ( !row ) return(1); |
1568 |
|
glraw->ID = (UInt_t)atoll(row->GetField(0)); |
1569 |
|
if ( debug ) printf(" The ID of the RAW file is %u \n",glraw->ID); |
1570 |
|
delete result; |
1571 |
|
delete row; |
1572 |
|
// |
1573 |
|
return(0); |
1574 |
} |
} |
1575 |
|
|
1576 |
|
|
1603 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1604 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1605 |
row = result->Next(); |
row = result->Next(); |
1606 |
|
if ( !row ) throw -92; |
1607 |
idresof = (UInt_t)atoll(row->GetField(0)); |
idresof = (UInt_t)atoll(row->GetField(0)); |
1608 |
existsts = true; |
existsts = true; |
1609 |
goto eout; |
goto eout; |
1883 |
* The raw file indicates in the parameters should be already been stored in the database. |
* The raw file indicates in the parameters should be already been stored in the database. |
1884 |
*/ |
*/ |
1885 |
Int_t PamelaDBOperations::insertPamelaRootFile(){ |
Int_t PamelaDBOperations::insertPamelaRootFile(){ |
1886 |
stringstream oss; |
|
1887 |
TSQLResult *result = 0; |
stringstream oss; |
1888 |
TSQLRow *row = 0; |
TSQLResult *result = 0; |
1889 |
UInt_t idtimesync = 0; |
TSQLRow *row = 0; |
|
// |
|
|
// |
|
|
if ( chewbacca ){ |
|
|
oss.str(""); |
|
|
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
|
|
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -3; |
|
1890 |
// |
// |
1891 |
row = result->Next(); |
// ---------------------- |
1892 |
|
// determine the timesync |
1893 |
|
// ---------------------- |
1894 |
|
UInt_t idtimesync = 0; |
1895 |
// |
// |
1896 |
if ( !row ) throw -3; |
if ( chewbacca ){ |
1897 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
oss.str(""); |
1898 |
} else { |
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
1899 |
oss.str(""); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
1900 |
if ( STATIC ){ |
result = conn->Query(oss.str().c_str()); |
1901 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
// |
1902 |
<< " LEFT JOIN GL_ROOT " |
if ( !result ) throw -3; |
1903 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
// |
1904 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
row = result->Next(); |
1905 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
// |
1906 |
|
if ( !row ) throw -3; |
1907 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
1908 |
} else { |
} else { |
1909 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
oss.str(""); |
1910 |
<< " LEFT JOIN GL_ROOT " |
if ( STATIC ){ |
1911 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1912 |
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
<< " LEFT JOIN GL_ROOT " |
1913 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1914 |
|
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
1915 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1916 |
|
} else { |
1917 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1918 |
|
<< " LEFT JOIN GL_ROOT " |
1919 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1920 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
1921 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1922 |
|
}; |
1923 |
|
result = conn->Query(oss.str().c_str()); |
1924 |
|
// |
1925 |
|
if ( !result ) throw -12; |
1926 |
|
// |
1927 |
|
row = result->Next(); |
1928 |
|
// |
1929 |
|
if ( !row ) throw -10; |
1930 |
|
if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
1931 |
|
idroot = (UInt_t)atoll(row->GetField(2)); |
1932 |
|
delete row; |
1933 |
|
delete result; |
1934 |
|
return(1); |
1935 |
|
}; |
1936 |
|
// |
1937 |
|
// determine which timesync has to be used |
1938 |
|
// |
1939 |
|
oss.str(""); |
1940 |
|
oss << "SELECT GL_TIMESYNC.ID FROM GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW ORDER BY GL_TIMESYNC.ID DESC LIMIT 1;"; |
1941 |
|
result = conn->Query(oss.str().c_str()); |
1942 |
|
// |
1943 |
|
if ( !result ) throw -3; |
1944 |
|
// |
1945 |
|
row = result->Next(); |
1946 |
|
// |
1947 |
|
if ( !row ) throw -3; |
1948 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
1949 |
}; |
}; |
1950 |
result = conn->Query(oss.str().c_str()); |
|
1951 |
// |
delete row; |
1952 |
if ( !result ) throw -12; |
delete result; |
1953 |
// |
|
1954 |
row = result->Next(); |
// ---------------------- |
1955 |
// |
// insert root file |
1956 |
if ( !row ) throw -10; |
// ---------------------- |
1957 |
if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
|
1958 |
idroot = (UInt_t)atoll(row->GetField(2)); |
GL_ROOT glroot = GL_ROOT(); |
1959 |
return(1); |
|
1960 |
|
glroot.ID_RAW = GetID_RAW(); |
1961 |
|
glroot.ID_TIMESYNC = idtimesync; |
1962 |
|
if ( STATIC ){ |
1963 |
|
glroot.PATH = GetRootPath(); |
1964 |
|
} else { |
1965 |
|
if ( KEEPENV ){ |
1966 |
|
glroot.PATH = gSystem->DirName(filerootname.Data()); |
1967 |
|
} else { |
1968 |
|
glroot.PATH = "$PAM_L0"; |
1969 |
|
}; |
1970 |
}; |
}; |
1971 |
// |
glroot.NAME = GetRootFile(); |
1972 |
// determine which timesync has to be used |
|
1973 |
// |
if ( insertPamelaRootFile(&glroot) )return 1; |
1974 |
oss.str(""); |
|
1975 |
oss << "SELECT GL_TIMESYNC.ID FROM GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW ORDER BY GL_TIMESYNC.ID DESC LIMIT 1;"; |
SetID_ROOT(glroot.ID); |
1976 |
result = conn->Query(oss.str().c_str()); |
|
1977 |
// |
|
1978 |
if ( !result ) throw -3; |
return (0); |
1979 |
// |
} |
1980 |
row = result->Next(); |
/** |
1981 |
// |
* Insert all the new rows into GL_ROOT. |
1982 |
if ( !row ) throw -3; |
* The raw file indicates in the parameters should be already been stored in the database. |
1983 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
*/ |
1984 |
}; |
Int_t PamelaDBOperations::insertPamelaRootFile(GL_ROOT *glroot){ |
1985 |
|
stringstream oss; |
1986 |
|
TSQLResult *result = 0; |
1987 |
|
TSQLRow *row = 0; |
1988 |
|
// |
1989 |
// |
// |
1990 |
oss.str(""); |
oss.str(""); |
1991 |
if ( STATIC ){ |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
1992 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
<< glroot->ID_RAW << "', '" << glroot->ID_TIMESYNC << "', '" << glroot->PATH << "', '" << glroot->NAME << "')"; |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
|
|
} else { |
|
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
|
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
|
|
}; |
|
1993 |
// |
// |
1994 |
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
1995 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
1996 |
// |
// |
1997 |
delete result; |
delete result; |
1998 |
// |
// |
1999 |
oss.str(""); |
oss.str(""); |
2000 |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
2001 |
if ( STATIC ){ |
oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << glroot->PATH << "' and NAME='"<< glroot->NAME <<"';"; |
|
oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << this->GetRootPath().Data() << "' and NAME='"<< this->GetRootFile().Data() <<"';"; |
|
|
} else { |
|
|
oss << "SELECT ID FROM GL_ROOT WHERE PATH='$PAM_L0' and NAME='"<< this->GetRootFile().Data() <<"';"; |
|
|
}; |
|
2002 |
// |
// |
2003 |
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
2004 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
2005 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
2006 |
row = result->Next(); |
row = result->Next(); |
2007 |
if ( !row ) throw -3; |
if ( !row ) throw -3; |
2008 |
this->SetID_ROOT((UInt_t)atoll(row->GetField(0))); |
|
2009 |
if ( debug ) printf(" The ID of the ROOT file is %u \n",this->GetID_ROOT()); |
glroot->ID = (UInt_t)atoll(row->GetField(0)); |
2010 |
|
|
2011 |
|
if ( debug ) printf(" The ID of the ROOT file is %u \n",glroot->ID); |
2012 |
// |
// |
2013 |
delete result; |
delete result; |
2014 |
// |
// |
2266 |
ptht = cod->Get(pctp->RunHeader) - 1; |
ptht = cod->Get(pctp->RunHeader) - 1; |
2267 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2268 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2269 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2270 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2271 |
if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics)); |
if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics)); |
2272 |
// |
// |
2305 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
2306 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2307 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2308 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2309 |
evbefh = TMath::Max(chminentry,(tcod-1)); |
evbefh = TMath::Max(chminentry,(tcod-1)); |
2310 |
// |
// |
2311 |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
2344 |
// |
// |
2345 |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
2346 |
// |
// |
2347 |
|
// what about pth=ptht-1 |
2348 |
}; |
}; |
2349 |
}; |
}; |
2350 |
// |
// |
2367 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2368 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2369 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2370 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2371 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2372 |
rh->GetEntry(pth); |
rh->GetEntry(pth); |
2373 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
2407 |
// if ( ptt+1 == rtev){ |
// if ( ptt+1 == rtev){ |
2408 |
if ( conptt+1 == nrtev ){ |
if ( conptt+1 == nrtev ){ |
2409 |
// if ( conptt+1 == (nrtev+nrtbef )){ |
// if ( conptt+1 == (nrtev+nrtbef )){ |
2410 |
|
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
2411 |
ptht++; |
ptht++; |
2412 |
if ( ptht < rhev ){ |
if ( ptht < rhev ){ |
2413 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
2414 |
|
//pth++; |
2415 |
|
//if ( pth < rhev ){ |
2416 |
|
//rh->GetEntry(pth); |
2417 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
2418 |
pkth = phh->GetCounter(); |
pkth = phh->GetCounter(); |
2419 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
2437 |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
2438 |
if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1); |
if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1); |
2439 |
// |
// |
2440 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
// if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
2441 |
rt->GetEntry(ptt-1); |
if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here! |
2442 |
|
// rt->GetEntry(ptt-1); |
2443 |
|
rt->GetEntry(rtev-1); |
2444 |
cod = eht->GetCounter(); |
cod = eht->GetCounter(); |
2445 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics)+1; |
2446 |
evbefh = TMath::Max(chminentry,tcod); |
evbefh = TMath::Max(chminentry,tcod); |
2447 |
// evbefh = cod->Get(pctp->Physics); |
// evbefh = cod->Get(pctp->Physics); |
2448 |
rt->GetEntry(ptt); |
rt->GetEntry(ptt); |
2673 |
// |
// |
2674 |
// we have now the good first piece of a run, fill the glrun object |
// we have now the good first piece of a run, fill the glrun object |
2675 |
// |
// |
2676 |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
if ( firstev != (lastev+1) ){ // could be a problem sometimes (?) |
2677 |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
2678 |
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
2679 |
|
}; |
2680 |
// |
// |
2681 |
|
if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev); |
2682 |
this->FillClass(mishead,mistrail,firstev,lastev); |
this->FillClass(mishead,mistrail,firstev,lastev); |
2683 |
|
if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev); |
2684 |
// |
// |
2685 |
if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
2686 |
if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
2775 |
// |
// |
2776 |
found = false; // default value |
found = false; // default value |
2777 |
// |
// |
2778 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" A Found a possible candidate, checking if it is the good one... \n"); |
2779 |
// |
// |
2780 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// if we have both runheader and runtrailer we can check with pkt_counter: |
2781 |
// |
// |
2791 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
2792 |
// |
// |
2793 |
found = true; |
found = true; |
2794 |
|
if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev); |
2795 |
// |
// |
2796 |
} else { |
} else { |
2797 |
// |
// |
2857 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " ID="<<row->GetField(0)<<";"; |
2858 |
// |
// |
2859 |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
2860 |
|
if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev); |
2861 |
// |
// |
2862 |
// merge infos |
// merge infos |
2863 |
// |
// |
2888 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
2889 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
2890 |
// |
// |
2891 |
|
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
2892 |
|
// |
2893 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
2894 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
2895 |
// |
// |
2982 |
// |
// |
2983 |
found = false; // default value |
found = false; // default value |
2984 |
// |
// |
2985 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" B Found a possible candidate, checking if it is the good one... \n"); |
2986 |
// |
// |
2987 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// if we have both runheader and runtrailer we can check with pkt_counter: |
2988 |
// |
// |
3211 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
3212 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
3213 |
glrun->Fill_GL_RUN(conn); // it'ok we arrive here only inside a file hence in the middle of the runs... |
glrun->Fill_GL_RUN(conn); // it'ok we arrive here only inside a file hence in the middle of the runs... |
3214 |
}; |
}; |
3215 |
// |
// |
3216 |
}; |
}; |
3217 |
// |
// |
3255 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
3256 |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
3257 |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
3258 |
|
firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files |
3259 |
// return true is correct |
// return true is correct |
3260 |
return(true); |
return(true); |
3261 |
// |
// |
3285 |
// |
// |
3286 |
} else { |
} else { |
3287 |
// |
// |
3288 |
if ( IsDebug() ) printf(" There are no-phyics packets inside the run!\n"); |
if ( IsDebug() ) printf(" There are no-physics packets inside the run!\n"); |
3289 |
// |
// |
3290 |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
3291 |
// |
// |
3295 |
UInt_t check = 0; |
UInt_t check = 0; |
3296 |
UInt_t lastevtemp = lastev; |
UInt_t lastevtemp = lastev; |
3297 |
UInt_t firstevno = firstev; |
UInt_t firstevno = firstev; |
3298 |
|
UInt_t rhchko=0; |
3299 |
|
UInt_t rhchk=0; |
3300 |
// |
// |
3301 |
for (UInt_t i=firstev; i<=lastev; i++){ |
for (UInt_t i=firstev; i<=lastev; i++){ |
3302 |
// |
// |
3305 |
// |
// |
3306 |
check = 0; |
check = 0; |
3307 |
// |
// |
3308 |
|
|
3309 |
|
// if we have a runheader set lastev then exit |
3310 |
|
// |
3311 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
3312 |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
3313 |
}; |
}; |
3314 |
|
// check here if we have a runheader |
3315 |
|
rhchko = rhchk; |
3316 |
|
rhchk = code->Get(GetPacketType("RunHeader")); |
3317 |
// |
// |
3318 |
if ( checkfirst < check || i == lastev ){ |
if ( checkfirst < check || i == lastev ){ |
3319 |
// |
// |
3397 |
// this->HandleRunFragments(true,mistrail,firstentry,lastentry); // cannot call it here since it enters a loop which will destroy the already stored variables if we arrive here from HandleRunFragments |
// this->HandleRunFragments(true,mistrail,firstentry,lastentry); // cannot call it here since it enters a loop which will destroy the already stored variables if we arrive here from HandleRunFragments |
3398 |
// |
// |
3399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3400 |
mishead = true; |
mishead = true; |
3401 |
|
|
3402 |
|
|
3511 |
// |
// |
3512 |
found = false; // default value |
found = false; // default value |
3513 |
// |
// |
3514 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" C Found a possible candidate, checking if it is the good one... \n"); |
3515 |
// |
// |
3516 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// if we have both runheader and runtrailer we can check with pkt_counter: |
3517 |
// |
// |
3716 |
}; // EEE |
}; // EEE |
3717 |
|
|
3718 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3719 |
} else { |
} else { |
3720 |
if ( !IsRunAlreadyInserted() ){ |
if ( !IsRunAlreadyInserted() ){ |
3721 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
3730 |
// |
// |
3731 |
}; |
}; |
3732 |
// |
// |
3733 |
|
if ( i > firstev ){ |
3734 |
|
if ( rhchko != rhchk ){ |
3735 |
|
if ( IsDebug() ) printf("oh oh... we have a runheader! stop here and handle later the remaining piece\n"); |
3736 |
|
lastev = i; |
3737 |
|
return(false); |
3738 |
|
}; |
3739 |
|
}; |
3740 |
|
// |
3741 |
if ( check == checklast && i != lastev ){ |
if ( check == checklast && i != lastev ){ |
3742 |
lastevtemp = i - 1; |
lastevtemp = i - 1; |
3743 |
i = lastev - 1; |
i = lastev - 1; |
4558 |
* Fill the GL_TRK_CALIB table |
* Fill the GL_TRK_CALIB table |
4559 |
*/ |
*/ |
4560 |
void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
4561 |
// |
|
4562 |
TSQLResult *result = 0; |
GL_TRK_CALIB *glcal = new GL_TRK_CALIB(); |
|
TSQLRow *row = 0; |
|
|
// |
|
|
stringstream oss; |
|
|
oss.str(""); |
|
|
// |
|
|
UInt_t totime = 0; |
|
|
// |
|
|
if ( !pk1 && !pk2 ){ |
|
|
if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
|
|
return; |
|
|
}; |
|
|
// |
|
|
// check if the calibration has already been inserted |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
|
|
<< " BOOT_NUMBER = "<< this->GetBOOTnumber(); // |
|
|
oss << " AND ( ( "; |
|
|
if ( pk1 ){ |
|
|
oss << " OBT1 = "<< obt1 << " AND " |
|
|
<< " PKT1 = "<< pkt1 |
|
|
<< " ) OR ( "; |
|
|
} else { |
|
|
oss << " PKT1 = "<< pkt2-1 |
|
|
<< " ) OR ( "; |
|
|
}; |
|
|
if ( pk2 ){ |
|
|
oss << " OBT2 = "<< obt2 << " AND " |
|
|
<< " PKT2 = "<< pkt2; |
|
|
} else { |
|
|
oss << " PKT2 = "<< pkt1+1; |
|
|
}; |
|
|
oss << " ) );"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( row ){ |
|
4563 |
// |
// |
4564 |
if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
glcal->ID = 0; |
4565 |
if ( PEDANTIC ) throw -80; |
glcal->ID_ROOT_L0 = GetID_ROOT(); |
4566 |
|
glcal->EV_ROOT_CALIBTRK1 = t1; |
4567 |
|
glcal->EV_ROOT_CALIBTRK2 = t2; |
4568 |
|
glcal->FROM_TIME = fromtime; |
4569 |
|
glcal->TO_TIME = 0; |
4570 |
|
glcal->OBT1 = obt1; |
4571 |
|
glcal->OBT2 = obt2; |
4572 |
|
glcal->PKT1 = pkt1; |
4573 |
|
glcal->PKT2 = pkt2; |
4574 |
|
glcal->BOOT_NUMBER = GetBOOTnumber(); |
4575 |
|
glcal->VALIDATION = valid; |
4576 |
// |
// |
4577 |
} else { |
HandleTRK_CALIB(glcal); |
4578 |
|
// |
4579 |
|
delete glcal; |
4580 |
|
} |
4581 |
|
/** |
4582 |
|
* Fill the GL_TRK_CALIB table |
4583 |
|
*/ |
4584 |
|
void PamelaDBOperations::HandleTRK_CALIB(GL_TRK_CALIB *glcal){ |
4585 |
|
|
4586 |
|
Bool_t pk1 = (glcal->OBT1>0&&glcal->PKT1>0); |
4587 |
|
Bool_t pk2 = (glcal->OBT2>0&&glcal->PKT2>0); |
4588 |
|
UInt_t boot_number = glcal->BOOT_NUMBER; |
4589 |
|
UInt_t obt1 = glcal->OBT1; |
4590 |
|
UInt_t obt2 = glcal->OBT2; |
4591 |
|
UInt_t pkt1 = glcal->PKT1; |
4592 |
|
UInt_t pkt2 = glcal->PKT2; |
4593 |
|
UInt_t fromtime = glcal->FROM_TIME; |
4594 |
|
UInt_t totime = 0; |
4595 |
|
UInt_t idroot = glcal->ID_ROOT_L0; |
4596 |
|
UInt_t t1 = glcal->EV_ROOT_CALIBTRK1; |
4597 |
|
UInt_t t2 = glcal->EV_ROOT_CALIBTRK2; |
4598 |
|
UInt_t valid = glcal->VALIDATION; |
4599 |
|
// |
4600 |
|
TSQLResult *result = 0; |
4601 |
|
TSQLRow *row = 0; |
4602 |
|
// |
4603 |
|
stringstream oss; |
4604 |
|
oss.str(""); |
4605 |
// |
// |
4606 |
// we have to insert a new calibration, check where to place it |
// |
4607 |
|
if ( !pk1 && !pk2 ){ |
4608 |
|
if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
4609 |
|
return; |
4610 |
|
}; |
4611 |
|
// |
4612 |
|
// check if the calibration has already been inserted |
4613 |
// |
// |
4614 |
oss.str(""); |
oss.str(""); |
4615 |
oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
4616 |
<< " FROM_TIME < "<< fromtime << " AND " |
<< " BOOT_NUMBER = "<< boot_number; // |
4617 |
<< " TO_TIME > "<< fromtime << ";"; |
oss << " AND FROM_TIME="<<fromtime; /// NEWNEWNEW -- VA BENE ?!?!?!?! |
4618 |
|
oss << " AND ( ( "; |
4619 |
|
if ( pk1 ){ |
4620 |
|
oss << " OBT1 = "<< obt1 << " AND " |
4621 |
|
<< " PKT1 = "<< pkt1 |
4622 |
|
<< " ) OR ( "; |
4623 |
|
} else { |
4624 |
|
oss << " PKT1 = "<< pkt2-1 |
4625 |
|
<< " ) OR ( "; |
4626 |
|
}; |
4627 |
|
if ( pk2 ){ |
4628 |
|
oss << " OBT2 = "<< obt2 << " AND " |
4629 |
|
<< " PKT2 = "<< pkt2; |
4630 |
|
} else { |
4631 |
|
oss << " PKT2 = "<< pkt1+1; |
4632 |
|
}; |
4633 |
|
oss << " ) );"; |
4634 |
// |
// |
4635 |
if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
4636 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
4637 |
// |
// |
4638 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
4639 |
// |
// |
4640 |
row = result->Next(); |
row = result->Next(); |
4641 |
// |
// |
4642 |
if ( !row ){ |
if ( row ){ |
4643 |
// |
// |
4644 |
// no calibrations in the db contain our calibration |
if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
4645 |
// |
if ( PEDANTIC ) throw -80; |
4646 |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
// |
|
if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
|
|
<< " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
if ( !row ){ |
|
|
totime = numeric_limits<UInt_t>::max(); |
|
|
} else { |
|
|
totime = (UInt_t)atoll(row->GetField(0)); |
|
|
}; |
|
|
// |
|
4647 |
} else { |
} else { |
4648 |
// |
// |
4649 |
// determine upper and lower limits and make space for the new calibration |
// we have to insert a new calibration, check where to place it |
4650 |
// |
// |
4651 |
totime = (UInt_t)atoll(row->GetField(1)); |
oss.str(""); |
4652 |
// |
oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
4653 |
oss.str(""); |
<< " FROM_TIME < "<< fromtime << " AND " |
4654 |
oss << " UPDATE GL_TRK_CALIB SET " |
<< " TO_TIME > "<< fromtime << ";"; |
4655 |
<< " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
// |
4656 |
<< " ID = "<< row->GetField(0) << ";"; |
if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
4657 |
// |
result = conn->Query(oss.str().c_str()); |
4658 |
if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
// |
4659 |
result = conn->Query(oss.str().c_str()); |
if ( !result ) throw -4; |
4660 |
// |
// |
4661 |
if ( !result ) throw -4; |
row = result->Next(); |
4662 |
// |
// |
4663 |
|
if ( !row ){ |
4664 |
|
// |
4665 |
|
// no calibrations in the db contain our calibration |
4666 |
|
// |
4667 |
|
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
4668 |
|
if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
4669 |
|
// |
4670 |
|
oss.str(""); |
4671 |
|
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
4672 |
|
<< " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
4673 |
|
// |
4674 |
|
if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
4675 |
|
result = conn->Query(oss.str().c_str()); |
4676 |
|
// |
4677 |
|
if ( !result ) throw -4; |
4678 |
|
// |
4679 |
|
row = result->Next(); |
4680 |
|
if ( !row ){ |
4681 |
|
totime = numeric_limits<UInt_t>::max(); |
4682 |
|
} else { |
4683 |
|
totime = (UInt_t)atoll(row->GetField(0)); |
4684 |
|
}; |
4685 |
|
// |
4686 |
|
} else { |
4687 |
|
// |
4688 |
|
// determine upper and lower limits and make space for the new calibration |
4689 |
|
// |
4690 |
|
totime = (UInt_t)atoll(row->GetField(1)); |
4691 |
|
// |
4692 |
|
oss.str(""); |
4693 |
|
oss << " UPDATE GL_TRK_CALIB SET " |
4694 |
|
<< " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
4695 |
|
<< " ID = "<< row->GetField(0) << ";"; |
4696 |
|
// |
4697 |
|
if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4698 |
|
result = conn->Query(oss.str().c_str()); |
4699 |
|
// |
4700 |
|
if ( !result ) throw -4; |
4701 |
|
// |
4702 |
|
}; |
4703 |
|
// |
4704 |
|
oss.str(""); |
4705 |
|
oss << " INSERT INTO GL_TRK_CALIB (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) " |
4706 |
|
<< " VALUES (NULL,' " |
4707 |
|
<< idroot << "',"; |
4708 |
|
// |
4709 |
|
if ( !pk1 ){ |
4710 |
|
oss << "NULL,"; |
4711 |
|
} else { |
4712 |
|
oss << "'" |
4713 |
|
<< t1 << "',"; |
4714 |
|
}; |
4715 |
|
// |
4716 |
|
if ( !pk2 ){ |
4717 |
|
oss << "NULL,'"; |
4718 |
|
} else { |
4719 |
|
oss << "'" |
4720 |
|
<< t2 << "','"; |
4721 |
|
}; |
4722 |
|
// |
4723 |
|
oss << fromtime << "','" |
4724 |
|
<< totime << "','" |
4725 |
|
<< obt1 << "','" |
4726 |
|
<< pkt1 << "','" |
4727 |
|
<< obt2 << "','" |
4728 |
|
<< pkt2 << "','" |
4729 |
|
<< boot_number << "','" |
4730 |
|
<< valid << "');"; |
4731 |
|
// |
4732 |
|
if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4733 |
|
// |
4734 |
|
result = conn->Query(oss.str().c_str()); |
4735 |
|
// |
4736 |
|
if ( !result ) throw -4; |
4737 |
|
// |
4738 |
}; |
}; |
4739 |
// |
|
4740 |
oss.str(""); |
oss.str(""); |
4741 |
oss << " INSERT INTO GL_TRK_CALIB (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) " |
oss << " SELECT ID FROM GL_TRK_CALIB ORDER BY ID DESC LIMIT 1 ;"; |
4742 |
<< " VALUES (NULL,' " |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
|
<< idroot << "',"; |
|
|
// |
|
|
if ( !pk1 ){ |
|
|
oss << "NULL,"; |
|
|
} else { |
|
|
oss << "'" |
|
|
<< t1 << "',"; |
|
|
}; |
|
|
// |
|
|
if ( !pk2 ){ |
|
|
oss << "NULL,'"; |
|
|
} else { |
|
|
oss << "'" |
|
|
<< t2 << "','"; |
|
|
}; |
|
|
// |
|
|
oss << fromtime << "','" |
|
|
<< totime << "','" |
|
|
<< obt1 << "','" |
|
|
<< pkt1 << "','" |
|
|
<< obt2 << "','" |
|
|
<< pkt2 << "','" |
|
|
<< this->GetBOOTnumber() << "','" |
|
|
<< valid << "');"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
|
|
// |
|
4743 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
4744 |
|
if ( !result ) throw -4;; |
4745 |
|
row = result->Next(); |
4746 |
|
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
4747 |
|
|
4748 |
// |
// |
|
if ( !result ) throw -4; |
|
|
// |
|
|
}; |
|
|
// |
|
4749 |
}; |
}; |
4750 |
|
|
4751 |
/** |
/** |
4752 |
* Scan tracker calibrations packets, fill the GL_TRK_CALIB table |
* Scan tracker calibrations packets, fill the GL_TRK_CALIB table |
4753 |
*/ |
*/ |
4754 |
Int_t PamelaDBOperations::insertTRK_CALIB(){ |
Int_t PamelaDBOperations::insertTRK_CALIB(){ |
|
// |
|
|
CalibTrk1Event *caltrk1 = 0; |
|
|
CalibTrk2Event *caltrk2 = 0; |
|
|
TTree *tr1 = 0; |
|
|
TTree *tr2 = 0; |
|
|
EventHeader *eh1 = 0; |
|
|
PscuHeader *ph1 = 0; |
|
|
EventHeader *eh2 = 0; |
|
|
PscuHeader *ph2 = 0; |
|
|
// |
|
|
PacketType *pctp=0; |
|
|
EventCounter *codt2=0; |
|
|
// |
|
|
Int_t nevents1 = 0; |
|
|
Int_t nevents2 = 0; |
|
|
// |
|
|
fromtime = 0; |
|
|
// |
|
|
obt1 = 0; |
|
|
pkt1 = 0; |
|
|
obt2 = 0; |
|
|
pkt2 = 0; |
|
|
// |
|
|
tr1 = (TTree*)file->Get("CalibTrk1"); |
|
|
if ( !tr1 || tr1->IsZombie() ) throw -22; |
|
|
tr2 = (TTree*)file->Get("CalibTrk2"); |
|
|
if ( !tr2 || tr2->IsZombie() ) throw -23; |
|
|
// |
|
|
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
|
|
tr1->SetBranchAddress("Header", &eh1); |
|
|
nevents1 = tr1->GetEntries(); |
|
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
|
|
tr2->SetBranchAddress("Header", &eh2); |
|
|
nevents2 = tr2->GetEntries(); |
|
|
// |
|
|
if ( !nevents1 && !nevents2 ) return(1); |
|
|
// |
|
|
t2 = -1; |
|
|
Int_t pret2 = 0; |
|
|
Int_t t2t1cal = 0; |
|
|
// |
|
|
for (t1=0; t1 < nevents1; t1++){ |
|
4755 |
// |
// |
4756 |
pret2 = t2; |
CalibTrk1Event *caltrk1 = 0; |
4757 |
tr1->GetEntry(t1); |
CalibTrk2Event *caltrk2 = 0; |
4758 |
|
TTree *tr1 = 0; |
4759 |
|
TTree *tr2 = 0; |
4760 |
|
EventHeader *eh1 = 0; |
4761 |
|
PscuHeader *ph1 = 0; |
4762 |
|
EventHeader *eh2 = 0; |
4763 |
|
PscuHeader *ph2 = 0; |
4764 |
// |
// |
4765 |
ph1 = eh1->GetPscuHeader(); |
PacketType *pctp=0; |
4766 |
obt1 = ph1->GetOrbitalTime(); |
EventCounter *codt2=0; |
|
pkt1 = ph1->GetCounter(); |
|
|
fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); |
|
4767 |
// |
// |
4768 |
// valid = 1; |
Int_t nevents1 = 0; |
4769 |
// // |
Int_t nevents2 = 0; |
|
// if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 |
|
4770 |
// |
// |
4771 |
|
fromtime = 0; |
4772 |
// |
// |
4773 |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
obt1 = 0; |
4774 |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
pkt1 = 0; |
4775 |
// |
obt2 = 0; |
4776 |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); |
pkt2 = 0; |
4777 |
// |
// |
4778 |
valid = ValidateTrkCalib( caltrk1, eh1 ); |
tr1 = (TTree*)file->Get("CalibTrk1"); |
4779 |
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
if ( !tr1 || tr1->IsZombie() ) throw -22; |
4780 |
// |
tr2 = (TTree*)file->Get("CalibTrk2"); |
4781 |
// Do we have the second calibration packet? |
if ( !tr2 || tr2->IsZombie() ) throw -23; |
4782 |
// |
// |
4783 |
while ( t2t1cal < t1+1 ){ // get the calibration packet2 that follows the packet1 |
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
4784 |
|
tr1->SetBranchAddress("Header", &eh1); |
4785 |
|
nevents1 = tr1->GetEntries(); |
4786 |
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
4787 |
|
tr2->SetBranchAddress("Header", &eh2); |
4788 |
|
nevents2 = tr2->GetEntries(); |
4789 |
|
// |
4790 |
|
if ( !nevents1 && !nevents2 ) return(1); |
4791 |
|
// |
4792 |
|
t2 = -1; |
4793 |
|
Int_t pret2 = 0; |
4794 |
|
Int_t t2t1cal = 0; |
4795 |
|
// |
4796 |
|
bool MISSING_pkt1 = true; |
4797 |
|
bool MISSING_pkt2 = true; |
4798 |
|
int ncalib = 0; |
4799 |
|
bool try_to_recover = false; |
4800 |
|
// |
4801 |
|
for (t1=0; t1 < nevents1; t1++){//loop over packet1 |
4802 |
// |
// |
4803 |
t2++; |
pret2 = t2; |
4804 |
|
tr1->GetEntry(t1); |
4805 |
// |
// |
4806 |
pret2 = t2 - 1; // EMILIANO |
ph1 = eh1->GetPscuHeader(); |
4807 |
|
obt1 = ph1->GetOrbitalTime(); |
4808 |
|
pkt1 = ph1->GetCounter(); |
4809 |
|
fromtime = GetAbsTime(ph1->GetOrbitalTime()); |
4810 |
// |
// |
4811 |
if ( t2 < nevents2 ){ |
// chek if the packet number and obt are consistent with the other packets ??? |
4812 |
tr2->GetEntry(t2); |
// |
4813 |
codt2 = eh2->GetCounter(); |
if ( PKT(pkt1) >= PKT(pktfirst) && PKT(pkt1) <= upperpkt && OBT(obt1) >= OBT(obtfirst) && OBT(obt1) <= upperobt ){ |
4814 |
t2t1cal = codt2->Get(pctp->CalibTrk1); |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
4815 |
// |
// |
4816 |
ph2 = eh2->GetPscuHeader(); |
if ( IsDebug() ) printf("\n Trk calibration1 %u at time %u obt %u pkt %u \n",t1,fromtime,obt1,pkt1); |
4817 |
obt2 = ph2->GetOrbitalTime(); |
// |
4818 |
pkt2 = ph2->GetCounter(); |
valid = ValidateTrkCalib( caltrk1, eh1 ); |
4819 |
// |
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
4820 |
if ( IsDebug() ) printf(" This is a trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
// |
4821 |
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
// Do we have the second calibration packet? |
4822 |
// |
// |
4823 |
|
if ( IsDebug() ) cout << " Loop over calibration2 to search associated calibration: "<<endl; |
4824 |
|
while ( t2t1cal < t1+1 ){ // get the calibration packet2 that follows the packet1 |
4825 |
|
// |
4826 |
|
t2++; |
4827 |
|
// |
4828 |
|
pret2 = t2 - 1; // EMILIANO |
4829 |
|
// |
4830 |
|
if ( t2 < nevents2 ){ |
4831 |
|
tr2->GetEntry(t2); |
4832 |
|
codt2 = eh2->GetCounter(); |
4833 |
|
t2t1cal = codt2->Get(pctp->CalibTrk1); |
4834 |
|
// |
4835 |
|
ph2 = eh2->GetPscuHeader(); |
4836 |
|
obt2 = ph2->GetOrbitalTime(); |
4837 |
|
pkt2 = ph2->GetCounter(); |
4838 |
|
// |
4839 |
|
if ( IsDebug() ) printf(" >> trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
4840 |
|
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
4841 |
|
// |
4842 |
|
} else { |
4843 |
|
// |
4844 |
|
// running out of vector without finding the corresponding calibration, sig |
4845 |
|
// |
4846 |
|
if ( IsDebug() ) printf(" t2 >= nevents2 \n"); |
4847 |
|
pret2 = t2; |
4848 |
|
obt2 = 0; |
4849 |
|
// pkt2 = pkt1+2; |
4850 |
|
pkt2 = 0; |
4851 |
|
t2t1cal = t1+1; |
4852 |
|
}; |
4853 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
4854 |
|
|
4855 |
|
// EMILIANO |
4856 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
4857 |
|
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
4858 |
|
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
4859 |
|
// // |
4860 |
|
// // running out of vector without finding the corresponding calibration, sig |
4861 |
|
// // |
4862 |
|
// pret2 = t2; |
4863 |
|
// obt2 = 0; |
4864 |
|
// // pkt2 = pkt1+2; |
4865 |
|
// pkt2 = 0; |
4866 |
|
// t2t1cal = t1+1; |
4867 |
|
// }; |
4868 |
|
|
4869 |
|
|
4870 |
|
// |
4871 |
|
}; |
4872 |
|
// |
4873 |
|
if ( IsDebug() ) printf(" Check if trk calibration2 is the right one \n"); |
4874 |
|
// |
4875 |
|
// EMILIANO |
4876 |
|
if ( ( PKT(pkt2) < PKT(pktfirst) || PKT(pkt2) > upperpkt) || (OBT(obt2) < OBT(obtfirst) || OBT(obt2) > upperobt) ){ |
4877 |
|
// if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
4878 |
|
if ( IsDebug() ) printf(" *WARNING* The calibration found is outside the interval, sig \n"); |
4879 |
|
// |
4880 |
|
// running out of vector without finding the corresponding calibration, sig |
4881 |
|
// |
4882 |
|
pret2 = t2; |
4883 |
|
obt2 = 0; |
4884 |
|
pkt2 = 0; |
4885 |
|
}; |
4886 |
|
if ( PKT(pkt2) == PKT(pkt1)+1 ){ |
4887 |
|
if ( IsDebug() ) cout << " ...OK"<<endl; |
4888 |
|
// ======================= |
4889 |
|
// The calibration is good |
4890 |
|
// ======================= |
4891 |
|
// |
4892 |
|
// if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2); |
4893 |
|
// if ( IsDebug() ) printf(" Trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); |
4894 |
|
// if ( IsDebug() ) printf("\n Trk calibration2 at time %u obt %u pkt %u \n",fromtime,obt2,pkt2); |
4895 |
|
if ( IsDebug() ) printf(" Trk calibration2 %u at time %u obt %u pkt %u \n",t2,fromtime,obt2,pkt2); |
4896 |
|
// |
4897 |
|
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
4898 |
|
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
4899 |
|
// valid = valid & valid2; |
4900 |
|
valid = valid & valid2; //QUESTO VA CAMBIATO |
4901 |
|
// |
4902 |
|
// Handle good calib |
4903 |
|
// |
4904 |
|
MISSING_pkt1 = false; |
4905 |
|
MISSING_pkt2 = false; |
4906 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
4907 |
|
// |
4908 |
|
// Check for missing calibtrk1 |
4909 |
|
// |
4910 |
|
if ( t2 != pret2+1 ){ |
4911 |
|
// |
4912 |
|
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2); |
4913 |
|
// |
4914 |
|
while ( t2 > pret2+1 ){ |
4915 |
|
// |
4916 |
|
// handle missing calib1 |
4917 |
|
// |
4918 |
|
pret2++; |
4919 |
|
// |
4920 |
|
obt1 = 0; |
4921 |
|
pkt1 = 0; |
4922 |
|
// |
4923 |
|
tr2->GetEntry(pret2); |
4924 |
|
ph2 = eh2->GetPscuHeader(); |
4925 |
|
obt2 = ph2->GetOrbitalTime(); |
4926 |
|
pkt2 = ph2->GetCounter(); |
4927 |
|
// |
4928 |
|
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
4929 |
|
// |
4930 |
|
valid = 0; |
4931 |
|
MISSING_pkt1 = true; |
4932 |
|
MISSING_pkt2 = false; |
4933 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
4934 |
|
// |
4935 |
|
}; |
4936 |
|
// |
4937 |
|
}; |
4938 |
|
// |
4939 |
|
} else if ( this->PKT(pkt2) > this->PKT(pkt1)+1 ){ |
4940 |
|
// |
4941 |
|
// Check for missing calibtrk2 |
4942 |
|
// |
4943 |
|
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
4944 |
|
t2 = pret2; |
4945 |
|
// |
4946 |
|
// handle missing calib2 |
4947 |
|
// |
4948 |
|
obt2 = 0; |
4949 |
|
pkt2 = 0; |
4950 |
|
valid = 0; |
4951 |
|
MISSING_pkt1 = false; |
4952 |
|
MISSING_pkt2 = true; |
4953 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
4954 |
|
// |
4955 |
|
}; |
4956 |
|
// |
4957 |
|
|
4958 |
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
4959 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
4960 |
|
ncalib++; |
4961 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
4962 |
|
} |
4963 |
|
|
4964 |
|
|
4965 |
} else { |
} else { |
4966 |
// |
// |
4967 |
// running out of vector without finding the corresponding calibration, sig |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
4968 |
// |
// if ( PEDANTIC ) throw -79; |
4969 |
if ( IsDebug() ) printf(" t2 >= nevents2 \n"); |
// |
|
pret2 = t2; |
|
|
obt2 = 0; |
|
|
// pkt2 = pkt1+2; |
|
|
pkt2 = 0; |
|
|
t2t1cal = t1+1; |
|
4970 |
}; |
}; |
4971 |
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
// |
4972 |
|
|
4973 |
// EMILIANO |
}; //end loop on pkt1 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
|
|
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
|
|
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
|
|
// // |
|
|
// // running out of vector without finding the corresponding calibration, sig |
|
|
// // |
|
|
// pret2 = t2; |
|
|
// obt2 = 0; |
|
|
// // pkt2 = pkt1+2; |
|
|
// pkt2 = 0; |
|
|
// t2t1cal = t1+1; |
|
|
// }; |
|
4974 |
|
|
4975 |
|
|
4976 |
|
|
4977 |
|
// |
4978 |
|
// we have one more calib pkt2 ! |
4979 |
|
// |
4980 |
|
t2++; |
4981 |
|
while ( t2 < nevents2 ){ |
4982 |
// |
// |
4983 |
}; |
// handle missing calib1 |
|
// |
|
|
if ( IsDebug() ) printf(" Check if trk calibration2 exists \n"); |
|
|
// |
|
|
// EMILIANO |
|
|
if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
|
|
// if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
|
|
if ( IsDebug() ) printf(" The calibration found is outside the interval, sig \n"); |
|
|
// |
|
|
// running out of vector without finding the corresponding calibration, sig |
|
|
// |
|
|
pret2 = t2; |
|
|
obt2 = 0; |
|
|
pkt2 = 0; |
|
|
}; |
|
|
// |
|
|
// The calibration is good |
|
|
// |
|
|
if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){ |
|
|
// |
|
|
if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2); |
|
|
if ( IsDebug() ) printf(" The trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); |
|
|
// |
|
|
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
|
|
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
|
|
valid = valid & valid2; |
|
|
// |
|
|
// Handle good calib |
|
4984 |
// |
// |
4985 |
this->HandleTRK_CALIB(true,true); |
if ( IsDebug() ) printf(" t2 is %u nevents2 is %u \n",t2,nevents2); |
4986 |
|
obt1 = 0; |
4987 |
|
pkt1 = 0; |
4988 |
// |
// |
4989 |
// Check for missing calibtrk1 |
tr2->GetEntry(t2); |
4990 |
|
ph2 = eh2->GetPscuHeader(); |
4991 |
|
obt2 = ph2->GetOrbitalTime(); |
4992 |
|
pkt2 = ph2->GetCounter(); |
4993 |
// |
// |
4994 |
if ( t2 != pret2+1 ){ |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
4995 |
// |
valid = 0; |
4996 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2); |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
4997 |
// |
// EMILIANO |
4998 |
while ( t2 > pret2+1 ){ |
if ( this->PKT(pkt2) >= this->PKT(pktfirst) && this->PKT(pkt2 <= upperpkt) && this->OBT(obt2) >= this->OBT(obtfirst) && this->OBT(obt2) <= upperobt ){ |
4999 |
// |
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
|
// handle missing calib1 |
|
|
// |
|
|
pret2++; |
|
|
// |
|
|
obt1 = 0; |
|
|
pkt1 = 0; |
|
|
// |
|
|
tr2->GetEntry(pret2); |
|
|
ph2 = eh2->GetPscuHeader(); |
|
|
obt2 = ph2->GetOrbitalTime(); |
|
|
pkt2 = ph2->GetCounter(); |
|
5000 |
// |
// |
5001 |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
5002 |
// |
// |
5003 |
valid = 0; |
MISSING_pkt1 = true; |
5004 |
this->HandleTRK_CALIB(false,true); |
MISSING_pkt2 = false; |
5005 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5006 |
|
ncalib++; |
5007 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
5008 |
// |
// |
|
}; |
|
|
// |
|
5009 |
}; |
}; |
5010 |
// |
// |
5011 |
} else if ( this->PKT(pkt2) > this->PKT(pkt1)+1 ){ |
t2++; |
|
// |
|
|
// Check for missing calibtrk2 |
|
|
// |
|
|
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
|
|
t2 = pret2; |
|
5012 |
// |
// |
5013 |
// handle missing calib2 |
}; |
5014 |
|
|
5015 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5016 |
|
// ----------------------------------------------------------------- |
5017 |
|
// in case of corruption, check if the calibration can be recovered |
5018 |
|
// from another chewbacca file |
5019 |
|
// ----------------------------------------------------------------- |
5020 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5021 |
|
|
5022 |
|
// cout <<" TRY TO RECOVER ?? "<<try_to_recover<<endl; |
5023 |
|
|
5024 |
|
if(chewbacca&&try_to_recover){ |
5025 |
|
|
5026 |
|
|
5027 |
|
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
5028 |
|
|
5029 |
|
TSQLResult *result = 0; |
5030 |
|
TSQLRow *row = 0; |
5031 |
// |
// |
5032 |
obt2 = 0; |
stringstream oss; |
5033 |
pkt2 = 0; |
oss.str(""); |
|
valid = 0; |
|
|
this->HandleTRK_CALIB(true,false); |
|
5034 |
// |
// |
5035 |
}; |
|
5036 |
// |
//////////////////////////////////////////////////////////////////////// |
5037 |
} else { |
// retrieve the name of the current file: |
5038 |
// |
//////////////////////////////////////////////////////////////////////// |
5039 |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
oss.str(""); |
5040 |
// if ( PEDANTIC ) throw -79; |
oss << "SELECT NAME FROM GL_ROOT where ID=" << GetID_ROOT() <<";"; |
5041 |
// |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5042 |
}; |
|
5043 |
// |
result = conn->Query(oss.str().c_str()); |
5044 |
}; |
if ( !result ) throw -4;; |
5045 |
// |
row = result->Next(); |
5046 |
// we have one more calib pkt2 ! |
TString thisfilename = (TString)row->GetField(0); |
5047 |
// |
if ( IsDebug() ) cout << "Current file ==> "<<thisfilename<<endl; |
5048 |
t2++; |
|
5049 |
while ( t2 < nevents2 ){ |
//////////////////////////////////////////////////////////////////////// |
5050 |
// |
// read all the calibrations inserted |
5051 |
// handle missing calib1 |
//////////////////////////////////////////////////////////////////////// |
5052 |
// |
oss.str(""); |
5053 |
if ( IsDebug() ) printf(" t2 is %u nevents2 is %u \n",t2,nevents2); |
oss << " SELECT "; |
5054 |
obt1 = 0; |
oss << " ID,FROM_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,TO_TIME"; |
5055 |
pkt1 = 0; |
oss << " FROM GL_TRK_CALIB "; |
5056 |
// |
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
5057 |
tr2->GetEntry(t2); |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5058 |
ph2 = eh2->GetPscuHeader(); |
|
5059 |
obt2 = ph2->GetOrbitalTime(); |
result = conn->Query(oss.str().c_str()); |
5060 |
pkt2 = ph2->GetCounter(); |
if ( !result ) throw -4;; |
5061 |
// |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5062 |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
|
5063 |
valid = 0; |
// ----------------------------------- |
5064 |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
// loop over calibrations ... |
5065 |
// EMILIANO |
// ----------------------------------- |
5066 |
if ( this->PKT(pkt2) >= this->PKT(pktfirst) && this->PKT(pkt2 <= upperpkt) && this->OBT(obt2) >= this->OBT(obtfirst) && this->OBT(obt2) <= upperobt ){ |
UInt_t nn=0; |
5067 |
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
do { |
5068 |
// |
row = result->Next(); |
5069 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
if(!row)break; |
5070 |
// |
|
5071 |
this->HandleTRK_CALIB(false,true); |
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5072 |
// |
UInt_t fromtime = (UInt_t)atoll(row->GetField(1)); |
5073 |
}; |
UInt_t obt1 = (UInt_t)atoll(row->GetField(2)); |
5074 |
// |
UInt_t pkt1 = (UInt_t)atoll(row->GetField(3)); |
5075 |
t2++; |
UInt_t obt2 = (UInt_t)atoll(row->GetField(4)); |
5076 |
// |
UInt_t pkt2 = (UInt_t)atoll(row->GetField(5)); |
5077 |
}; |
UInt_t boot = (UInt_t)atoll(row->GetField(6)); |
5078 |
|
UInt_t valid = (UInt_t)atoll(row->GetField(7)); |
5079 |
|
bool MISSING_pkt1 = (row->GetFieldLength(8)==0); |
5080 |
|
bool MISSING_pkt2 = (row->GetFieldLength(9)==0); |
5081 |
|
UInt_t totime = (UInt_t)atoll(row->GetField(10)); |
5082 |
|
|
5083 |
|
// ------------------------------------- |
5084 |
|
// ...check if the entry is corrupted... |
5085 |
|
// ------------------------------------- |
5086 |
|
cout <<"*** "<< MISSING_pkt1 << MISSING_pkt2 << valid <<endl; |
5087 |
|
bool CORRUPTED = (MISSING_pkt1||MISSING_pkt2||!valid); |
5088 |
|
|
5089 |
|
if ( IsDebug() ) cout << "("<<nn<<") ID = "<<id<<" from GL_TRK_CALIB ==> corrupted ? "<<CORRUPTED<<endl; |
5090 |
|
|
5091 |
|
// if( !CORRUPTED )continue; // nothing to do |
5092 |
|
|
5093 |
|
///////////////////////////////////////////////////////// |
5094 |
|
// if it is corrupted, ...look for ather chewbacca files |
5095 |
|
// containing the same calibrations ... |
5096 |
|
///////////////////////////////////////////////////////// |
5097 |
|
|
5098 |
|
bool this_MISSING_pkt1 = false; |
5099 |
|
bool this_MISSING_pkt2 = false; |
5100 |
|
int this_t1=0; |
5101 |
|
int this_t2=0;; |
5102 |
|
UInt_t this_valid = 0; |
5103 |
|
|
5104 |
|
TString path = ""; |
5105 |
|
TString name = ""; |
5106 |
|
TString raw = ""; |
5107 |
|
UInt_t obt0 = 0; |
5108 |
|
UInt_t timesync = 0; |
5109 |
|
UInt_t boot_number = 0; |
5110 |
|
bool FOUND = false; |
5111 |
|
|
5112 |
|
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5113 |
|
|
5114 |
|
// for(int itable=0; itable<2; itable++){ |
5115 |
|
for(int itable=0; itable<1; itable++){ |
5116 |
|
|
5117 |
|
// ------------------------------------------------------ |
5118 |
|
// loop over both ROOT_TABLE and ROOT_TABLE_BAD |
5119 |
|
// ------------------------------------------------------ |
5120 |
|
|
5121 |
|
TString table = "ROOT_TABLE"; |
5122 |
|
if(itable==1)table = "ROOT_TABLE_BAD"; |
5123 |
|
|
5124 |
|
oss.str(""); |
5125 |
|
oss << " SELECT "; |
5126 |
|
oss << " FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,BOOT_NUMBER,INPUT_NAME "; |
5127 |
|
oss << " FROM "<<table; |
5128 |
|
oss << " WHERE 1 " << endl; |
5129 |
|
oss << " AND FILE_NAME != \""<< thisfilename<<"\""; |
5130 |
|
if( !MISSING_pkt1 ){ |
5131 |
|
oss << " AND "; |
5132 |
|
oss << " PKT_NUMBER_INIT < "<<pkt1; |
5133 |
|
oss << " AND "; |
5134 |
|
oss << " PKT_NUMBER_FINAL > "<<pkt1; |
5135 |
|
oss << " AND "; |
5136 |
|
oss << " PKT_OBT_INIT < "<<obt1; |
5137 |
|
oss << " AND "; |
5138 |
|
oss << " PKT_OBT_FINAL > "<<obt1; |
5139 |
|
}else{ |
5140 |
|
if(pkt2>1) pkt1 = pkt2-1;//serve dopo |
5141 |
|
} |
5142 |
|
if( !MISSING_pkt2 ){ |
5143 |
|
oss << " AND "; |
5144 |
|
oss << " PKT_NUMBER_INIT < "<<pkt2; |
5145 |
|
oss << " AND "; |
5146 |
|
oss << " PKT_NUMBER_FINAL > "<<pkt2; |
5147 |
|
oss << " AND "; |
5148 |
|
oss << " PKT_OBT_INIT < "<<obt2; |
5149 |
|
oss << " AND "; |
5150 |
|
oss << " PKT_OBT_FINAL > "<<obt2; |
5151 |
|
}else{ |
5152 |
|
if(pkt1>0) pkt2 = pkt1+1;//serve dopo |
5153 |
|
} |
5154 |
|
if( boot> 0 ){ |
5155 |
|
oss << " AND "; |
5156 |
|
oss << " BOOT_NUMBER = "<<boot; |
5157 |
|
}else{ |
5158 |
|
} |
5159 |
|
oss << " ORDER BY BAD_PKT_CALREAD ASC; "; |
5160 |
|
|
5161 |
|
TSQLResult *result2 = 0; |
5162 |
|
TSQLRow *row2 = 0; |
5163 |
|
|
5164 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5165 |
|
result2 = conn->Query(oss.str().c_str()); |
5166 |
|
if ( !result2 ) throw -4;; |
5167 |
|
if ( IsDebug() ) cout <<"Rows: "<<result2->GetRowCount()<<endl; |
5168 |
|
|
5169 |
|
// ------------------------------------------------------ |
5170 |
|
// loop over files containing repetition (if any) |
5171 |
|
// ------------------------------------------------------ |
5172 |
|
do { |
5173 |
|
row2 = result2->Next(); |
5174 |
|
if(!row2)break; |
5175 |
|
|
5176 |
|
// ------------------------------------------------------ |
5177 |
|
// ... a repetition is found ... |
5178 |
|
// ------------------------------------------------------ |
5179 |
|
path = (TString)row2->GetField(0); |
5180 |
|
name = (TString)row2->GetField(1); |
5181 |
|
raw = (TString)row2->GetField(5); |
5182 |
|
obt0 = (UInt_t)atoll(row2->GetField(2)); |
5183 |
|
timesync = (UInt_t)atoll(row2->GetField(3)); |
5184 |
|
boot_number = (UInt_t)atoll(row2->GetField(4)); |
5185 |
|
|
5186 |
|
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
5187 |
|
// cout << path <<endl; |
5188 |
|
// cout << "File : " <<name <<endl; |
5189 |
|
// cout << obt0 <<endl; |
5190 |
|
// cout << timesync <<endl; |
5191 |
|
// cout << "boot n. : "<<boot_number <<endl; |
5192 |
|
// cout << raw <<endl; |
5193 |
|
|
5194 |
|
// ------------------------------------------------------ |
5195 |
|
// ... retrieve the calibration packets. |
5196 |
|
// ------------------------------------------------------ |
5197 |
|
if ( IsDebug() ) printf(" file is %s/%s \n",((TString)gSystem->ExpandPathName(path.Data())).Data(),name.Data()); |
5198 |
|
TFile *file = new TFile(((TString)gSystem->ExpandPathName(path.Data()))+"/"+name); // EM, path could be symbolic and we must expand it |
5199 |
|
if(!file)throw -100; |
5200 |
|
if(file->IsZombie())throw -100; |
5201 |
|
// |
5202 |
|
tr1 = (TTree*)file->Get("CalibTrk1"); |
5203 |
|
if ( !tr1 || tr1->IsZombie() ) throw -22; |
5204 |
|
tr2 = (TTree*)file->Get("CalibTrk2"); |
5205 |
|
if ( !tr2 || tr2->IsZombie() ) throw -23; |
5206 |
|
// |
5207 |
|
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
5208 |
|
tr1->SetBranchAddress("Header", &eh1); |
5209 |
|
nevents1 = tr1->GetEntries(); |
5210 |
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
5211 |
|
tr2->SetBranchAddress("Header", &eh2); |
5212 |
|
nevents2 = tr2->GetEntries(); |
5213 |
|
for(this_t1=0; this_t1<nevents1; this_t1++){ |
5214 |
|
tr1->GetEntry(this_t1); |
5215 |
|
if( |
5216 |
|
(UInt_t)eh1->GetPscuHeader()->GetCounter() == pkt1 && |
5217 |
|
true) break; |
5218 |
|
this_MISSING_pkt1 = true; |
5219 |
|
} |
5220 |
|
for(this_t2=0; this_t2<nevents2; this_t2++){ |
5221 |
|
tr2->GetEntry(this_t2); |
5222 |
|
if( |
5223 |
|
(UInt_t)eh2->GetPscuHeader()->GetCounter() == pkt2 && |
5224 |
|
true) break; |
5225 |
|
this_MISSING_pkt2 = true; |
5226 |
|
} |
5227 |
|
this_valid = |
5228 |
|
ValidateTrkCalib( caltrk1, eh1, file ) |
5229 |
|
* |
5230 |
|
ValidateTrkCalib( caltrk2, eh2, file ); |
5231 |
|
|
5232 |
|
// --------------------------------------------------------------------- |
5233 |
|
// accept the calibration if it is better than the previous: |
5234 |
|
// |
5235 |
|
// - if the new calibration is perfect (both valid packets) |
5236 |
|
// - if the new calibration has both the packets and the previous does not |
5237 |
|
// --------------------------------------------------------------------- |
5238 |
|
if( |
5239 |
|
( !this_MISSING_pkt1&&!this_MISSING_pkt2&&this_valid )|| |
5240 |
|
( (MISSING_pkt1||MISSING_pkt2) && (!this_MISSING_pkt1&&!this_MISSING_pkt2) )|| |
5241 |
|
false)FOUND=true; |
5242 |
|
|
5243 |
|
if(file)file->Close(); |
5244 |
|
|
5245 |
|
if(FOUND)break; |
5246 |
|
|
5247 |
|
}while(1);//endl loop over root table entries |
5248 |
|
|
5249 |
|
if(FOUND)break; |
5250 |
|
|
5251 |
|
}//end loop over tables |
5252 |
|
|
5253 |
|
if(FOUND){ |
5254 |
|
|
5255 |
|
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
5256 |
|
|
5257 |
|
//////////////////////////////////////////// |
5258 |
|
// insert a new entry in GL_TRK_CALIB and |
5259 |
|
// modify the time-tag of the previous one |
5260 |
|
//////////////////////////////////////////// |
5261 |
|
|
5262 |
|
// --------------------------------------------------------------------- |
5263 |
|
// step 1: insert a new raw file in GL_RAW |
5264 |
|
// --------------------------------------------------------------------- |
5265 |
|
// |
5266 |
|
// check if the raw file already exist |
5267 |
|
// |
5268 |
|
UInt_t id_raw = 0; // EM GL_RAW is there only for backward compatibility so we do not need to fill it when in "chewbacca" mode |
5269 |
|
// oss.str(""); |
5270 |
|
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
5271 |
|
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5272 |
|
|
5273 |
|
// result = conn->Query(oss.str().c_str()); |
5274 |
|
// if ( !result ) throw -4;; |
5275 |
|
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5276 |
|
// if( result->GetRowCount() == 0){ |
5277 |
|
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
5278 |
|
// // - - - - - - - - - - - |
5279 |
|
// // insert new raw file |
5280 |
|
// // - - - - - - - - - - - |
5281 |
|
// GL_RAW glraw = GL_RAW(); |
5282 |
|
// glraw.PATH = gSystem->DirName(raw.Data()); |
5283 |
|
// glraw.NAME = gSystem->BaseName(raw.Data()); |
5284 |
|
// glraw.BOOT_NUMBER = boot_number; |
5285 |
|
// // |
5286 |
|
// insertPamelaRawFile( &glraw ); |
5287 |
|
// // |
5288 |
|
// id_raw = glraw.ID; |
5289 |
|
// }else{ |
5290 |
|
// row = result->Next(); |
5291 |
|
// id_raw = (UInt_t)atoll(row->GetField(0)); |
5292 |
|
// } |
5293 |
|
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
5294 |
|
|
5295 |
|
// --------------------------------------------------------------------- |
5296 |
|
// step 1(bis): retrieve the timesync id associated to the file |
5297 |
|
// (NB, uso lo stesso associato al file iniziale) |
5298 |
|
// --------------------------------------------------------------------- |
5299 |
|
UInt_t idtimesync = 0; |
5300 |
|
oss.str(""); |
5301 |
|
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
5302 |
|
if ( debug ) printf(" %s \n",oss.str().c_str()); |
5303 |
|
result = conn->Query(oss.str().c_str()); |
5304 |
|
if ( !result ) throw -3; |
5305 |
|
row = result->Next(); |
5306 |
|
if ( !row ) throw -3; |
5307 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
5308 |
|
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
5309 |
|
|
5310 |
|
// --------------------------------------------------------------------- |
5311 |
|
// step 2: insert a new root file in GL_ROOT |
5312 |
|
// --------------------------------------------------------------------- |
5313 |
|
// |
5314 |
|
// check if the root file already exist |
5315 |
|
// |
5316 |
|
UInt_t id_root = 0; |
5317 |
|
oss.str(""); |
5318 |
|
oss << "SELECT ID FROM GL_ROOT where NAME=\"" << gSystem->BaseName(name.Data()) <<"\";"; |
5319 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5320 |
|
|
5321 |
|
result = conn->Query(oss.str().c_str()); |
5322 |
|
if ( !result ) throw -4;; |
5323 |
|
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5324 |
|
if( result->GetRowCount() == 0){ |
5325 |
|
if ( IsDebug() ) cout << " << Insert new ROOT file >> "<<endl; |
5326 |
|
// - - - - - - - - - - - |
5327 |
|
// insert new root file |
5328 |
|
// - - - - - - - - - - - |
5329 |
|
GL_ROOT glroot = GL_ROOT(); |
5330 |
|
glroot.ID_RAW = id_raw; |
5331 |
|
glroot.ID_TIMESYNC = idtimesync; |
5332 |
|
// |
5333 |
|
// EM STATIC = the full expanded path must be put in the DB, KEEPENV = the path given as input (or found in ROOT_TABLE) must be used, |
5334 |
|
// NOT STATIC NOT KEEPENV = $PAM_L0 must be used in the DB |
5335 |
|
// |
5336 |
|
if ( STATIC ){ |
5337 |
|
glroot.PATH = (TString)gSystem->ExpandPathName(path); |
5338 |
|
} else { |
5339 |
|
if ( KEEPENV ){ |
5340 |
|
glroot.PATH = path; |
5341 |
|
} else { |
5342 |
|
glroot.PATH = "$PAM_L0"; |
5343 |
|
}; |
5344 |
|
}; |
5345 |
|
// glroot.PATH = path; |
5346 |
|
glroot.NAME = name; |
5347 |
|
// |
5348 |
|
insertPamelaRootFile( &glroot ); |
5349 |
|
// |
5350 |
|
id_root = glroot.ID; |
5351 |
|
}else{ |
5352 |
|
row = result->Next(); |
5353 |
|
if(row)id_root = (UInt_t)atoll(row->GetField(0)); |
5354 |
|
} |
5355 |
|
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
5356 |
|
|
5357 |
|
// --------------------------------------------------------------------- |
5358 |
|
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
5359 |
|
// --------------------------------------------------------------------- |
5360 |
|
if ( IsDebug() ) cout << " << Modify time-tag of calibration ID="<<id<<" >> "<<endl; |
5361 |
|
oss.str(""); |
5362 |
|
oss << " UPDATE GL_TRK_CALIB SET " |
5363 |
|
<< " TO_TIME=0 , FROM_TIME=0 WHERE " |
5364 |
|
<< " ID = "<< id << ";"; |
5365 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5366 |
|
result = conn->Query(oss.str().c_str()); |
5367 |
|
if ( !result ) throw -4;; |
5368 |
|
|
5369 |
|
// --------------------------------------------------------------------- |
5370 |
|
// step 4: insert the new calibration: |
5371 |
|
// --------------------------------------------------------------------- |
5372 |
|
if ( IsDebug() ) cout << " << Insert new TRK calibration >> "<<endl; |
5373 |
|
// |
5374 |
|
GL_TRK_CALIB glcal = GL_TRK_CALIB(); |
5375 |
|
// |
5376 |
|
glcal.ID_ROOT_L0 = id_root; |
5377 |
|
glcal.EV_ROOT_CALIBTRK1 = this_t1; |
5378 |
|
glcal.EV_ROOT_CALIBTRK2 = this_t2; |
5379 |
|
glcal.FROM_TIME = fromtime; |
5380 |
|
glcal.TO_TIME = totime; |
5381 |
|
glcal.OBT1 = obt1; |
5382 |
|
glcal.OBT2 = obt2; |
5383 |
|
glcal.PKT1 = pkt1; |
5384 |
|
glcal.PKT2 = pkt1; |
5385 |
|
glcal.BOOT_NUMBER = GetBOOTnumber(); |
5386 |
|
glcal.VALIDATION = this_valid; |
5387 |
|
// |
5388 |
|
HandleTRK_CALIB(&glcal); |
5389 |
|
if ( IsDebug() ) cout << "ID = "<<glcal.ID<<endl; |
5390 |
|
// |
5391 |
|
|
5392 |
|
} |
5393 |
|
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5394 |
|
|
5395 |
|
}while(1);//end loop over calibrations |
5396 |
|
|
5397 |
|
|
5398 |
|
if( result )delete result; |
5399 |
|
if( row )delete row; |
5400 |
|
|
5401 |
|
|
5402 |
|
|
5403 |
|
|
5404 |
|
|
5405 |
|
|
5406 |
|
} |
5407 |
|
|
5408 |
|
|
5409 |
|
// // ------------------------------ |
5410 |
|
// // try to recover the calibration |
5411 |
|
// // ------------------------------ |
5412 |
|
// cout << "TRY TO RECOVER TRACKER CALIBRATION"<<endl; |
5413 |
|
// // |
5414 |
|
// ULong64_t time = 0; //absolute time |
5415 |
|
// string path[100]; //mettere un limite massimo |
5416 |
|
// int nrows = 0; |
5417 |
|
// UInt_t pkt = 0; |
5418 |
|
// UInt_t obt = 0; |
5419 |
|
// char *type = ""; |
5420 |
|
// EventHeader *eh = new EventHeader(); |
5421 |
|
// CalibTrk1Event *c = new CalibTrk1Event(); |
5422 |
|
|
5423 |
|
// // |
5424 |
|
// if(which_is_not_valid==1 || which_is_not_valid==3){ |
5425 |
|
// // |
5426 |
|
// cout << "PKT1 --> missing or corrupted "<<endl; |
5427 |
|
// type = "CalibTrk1"; |
5428 |
|
// pkt = pkt1; |
5429 |
|
// obt = obt1; |
5430 |
|
// time = this->GetAbsTime(obt1); |
5431 |
|
// if( pkt1 == 0 ){//missing |
5432 |
|
// time = this->GetAbsTime(obt2); |
5433 |
|
// pkt = pkt2-1; |
5434 |
|
// } |
5435 |
|
// // |
5436 |
|
// }else if (which_is_not_valid==2 || which_is_not_valid==3){ |
5437 |
|
// // |
5438 |
|
// cout << "PKT2--> missing or corrupted "<<endl; |
5439 |
|
// type = "CalibTrk2 "; |
5440 |
|
// pkt = pkt2; |
5441 |
|
// obt = obt2; |
5442 |
|
// time = this->GetAbsTime(obt2); |
5443 |
|
// if( pkt2 == 0 ){//missing |
5444 |
|
// time = this->GetAbsTime(obt1); |
5445 |
|
// pkt = pkt1+1; |
5446 |
|
// } |
5447 |
|
// // |
5448 |
|
// }else{ |
5449 |
|
// cout << "this should not happen!!! "<<endl; |
5450 |
|
// trow -666; |
5451 |
|
// } |
5452 |
|
|
5453 |
|
// nrows = Query_ROOT_TABLE(time,conn,path);// get the list of file which might contain the packet |
5454 |
|
|
5455 |
|
|
5456 |
|
// for(int r=0; r<nrows; r++){ //loop over rows |
5457 |
|
// if(path)cout << r << " >>>> "<<(path+r)->c_str() << endl; |
5458 |
|
// /// verifica che il file non sia quello gia` aperto |
5459 |
|
// } |
5460 |
|
|
5461 |
|
// //////////////////////////////////////////////////////////////////////// |
5462 |
|
|
5463 |
|
// TSQLResult *result = 0; |
5464 |
|
// TSQLRow *row = 0; |
5465 |
|
// // |
5466 |
|
// stringstream oss; |
5467 |
|
// oss.str(""); |
5468 |
|
// // ---------------------------------------- |
5469 |
|
// // read the id of last calibration inserted |
5470 |
|
// // ---------------------------------------- |
5471 |
|
// oss.str(""); |
5472 |
|
// oss << " SELECT "; |
5473 |
|
// oss << " (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) "; |
5474 |
|
// oss << " ORDER BY ID DESC LIMIT 1; "; |
5475 |
|
|
5476 |
|
// result = conn->Query(oss.str().c_str()); |
5477 |
|
// row = result->Next(); |
5478 |
|
// if( !row )throw -666; |
5479 |
|
|
5480 |
|
// if( result )delete result; |
5481 |
|
// if( row )delete row; |
5482 |
|
|
5483 |
|
// UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5484 |
|
|
5485 |
|
// // ------------------------------------- |
5486 |
|
// // ...and modify it with new parameters |
5487 |
|
// // ------------------------------------- |
5488 |
|
|
5489 |
|
|
5490 |
|
// } |
5491 |
// |
// |
5492 |
return(0); |
return(0); |
5493 |
}; |
}; |
6119 |
// 2) get the OBT of the last validated run |
// 2) get the OBT of the last validated run |
6120 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
6121 |
oss.str(""); |
oss.str(""); |
6122 |
oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
// oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
6123 |
|
oss << " SELECT * FROM GL_RUN WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start |
6124 |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
6125 |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
6126 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
6263 |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
6264 |
|
|
6265 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
6266 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
// for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
6267 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION); |
6268 |
nseq=0; |
nseq=0; |
6269 |
} |
} |
6270 |
|
|
6285 |
if( CHECK ){ |
if( CHECK ){ |
6286 |
// check if calibration exists |
// check if calibration exists |
6287 |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
6288 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
// Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
6289 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
UInt_t MISSING = MissingTRK_CALIB(t1,t2); |
6290 |
|
UInt_t val = 0; |
6291 |
|
if ( MISSING == 1 ) val = 0; |
6292 |
|
if ( MISSING == 0 ) val = 1; |
6293 |
|
if ( MISSING == 2 ) val = 2; |
6294 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val); |
6295 |
nseq=0; |
nseq=0; |
6296 |
}; |
}; |
6297 |
//-------------- |
//-------------- |
6321 |
* @param t2 To absolute time |
* @param t2 To absolute time |
6322 |
* @return true if there might be a missing calibration |
* @return true if there might be a missing calibration |
6323 |
*/ |
*/ |
6324 |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
//Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
6325 |
|
UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
6326 |
|
|
6327 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
6328 |
|
|
6329 |
// get the closest VALIDATED calibration before the run start (t2) |
// get the closest calibration before the run start (t2) |
6330 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
// if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
6331 |
|
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1); //>>> missing |
6332 |
|
|
6333 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
// if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
6334 |
|
if ( trkcalib->TO_TIME < t2 ) return(1); //>>> missing |
6335 |
|
|
6336 |
//============================================================== |
//============================================================== |
6337 |
// Check is done first on the basis of time between calibration, |
// Check is done first on the basis of time between calibration, |
6348 |
//============================================================== |
//============================================================== |
6349 |
Bool_t DOWNLOAD = false; |
Bool_t DOWNLOAD = false; |
6350 |
// check if the calib was skipped becouse of download .... DA FARE!! |
// check if the calib was skipped becouse of download .... DA FARE!! |
6351 |
if(DOWNLOAD)return(false); |
// if(DOWNLOAD)return(false); |
6352 |
|
if(DOWNLOAD)return(0); |
6353 |
|
|
6354 |
return(true); //>>> missing |
// return(true); //>>> missing |
6355 |
|
return(1); //>>> missing |
6356 |
|
|
6357 |
}; |
}; |
6358 |
|
|
6362 |
//============================================================== |
//============================================================== |
6363 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
6364 |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
6365 |
return(false); |
if ( trkcalib->VALIDATION ) return(0); |
6366 |
|
if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n"); |
6367 |
|
return(2); |
6368 |
|
|
6369 |
}; |
}; |
6370 |
/** |
/** |
6373 |
* @param validation true/false |
* @param validation true/false |
6374 |
*/ |
*/ |
6375 |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
6376 |
|
return(this->assignVALIDATION(idrun,(UInt_t)validation)); |
6377 |
|
} |
6378 |
|
|
6379 |
|
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){ |
6380 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
6381 |
stringstream oss; |
stringstream oss; |
6382 |
oss.str(""); |
oss.str(""); |
6573 |
stringstream myquery; |
stringstream myquery; |
6574 |
// |
// |
6575 |
myquery.str(""); |
myquery.str(""); |
6576 |
myquery << " SELECT ID, ID_RAW FROM GL_ROOT where NAME='"<<remfile.Data() <<"';"; |
myquery << " SELECT ID,ID_RAW,ID_TIMESYNC FROM GL_ROOT where NAME='"<<remfile.Data() <<"';"; |
6577 |
// |
// |
6578 |
pResult = conn->Query(myquery.str().c_str()); |
pResult = conn->Query(myquery.str().c_str()); |
6579 |
// |
// |
6589 |
// |
// |
6590 |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
6591 |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
6592 |
|
UInt_t idtsy=(UInt_t)atoll(Row->GetField(2)); |
6593 |
// |
// |
6594 |
this->ValidationOFF(); |
this->ValidationOFF(); |
6595 |
// |
// |
6597 |
// |
// |
6598 |
this->RemoveRUNS(); |
this->RemoveRUNS(); |
6599 |
// |
// |
6600 |
this->RemoveFILES(); |
this->RemoveFILES(idtsy); |
6601 |
// |
// |
6602 |
this->SetID_ROOT(0); |
this->SetID_ROOT(0); |
6603 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
6817 |
* Rearrange calibration tables |
* Rearrange calibration tables |
6818 |
* |
* |
6819 |
**/ |
**/ |
6820 |
void PamelaDBOperations::RemoveFILES(){ |
void PamelaDBOperations::RemoveFILES(UInt_t idtsy){ |
6821 |
stringstream myquery; |
stringstream myquery; |
6822 |
// |
// |
6823 |
myquery.str(""); |
myquery.str(""); |
6827 |
// |
// |
6828 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
6829 |
// |
// |
6830 |
|
myquery.str(""); |
6831 |
|
myquery << " DELETE FROM GL_ROOT WHERE ID=" <<this->GetID_ROOT() <<";"; |
6832 |
|
// |
6833 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
6834 |
|
// |
6835 |
|
conn->Query(myquery.str().c_str()); // |
6836 |
|
// |
6837 |
|
if ( !chewbacca ){ |
6838 |
|
myquery.str(""); |
6839 |
|
myquery << " DELETE FROM GL_TIMESYNC WHERE ID=" << idtsy <<";"; |
6840 |
|
// |
6841 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
6842 |
|
// |
6843 |
|
conn->Query(myquery.str().c_str()); |
6844 |
|
}; |
6845 |
|
// |
6846 |
}; |
}; |
6847 |
|
|
6848 |
/** |
/** |
7047 |
* Rearrange calibration tables |
* Rearrange calibration tables |
7048 |
* |
* |
7049 |
**/ |
**/ |
7050 |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh , TFile *file){ |
7051 |
|
|
7052 |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
if(!caltrk) return 0; |
|
UInt_t timeaftercalib=120000; //2000; |
|
|
// ---------- |
|
|
// Check CRCs |
|
|
// ---------- |
|
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
|
|
if( caltrk->crc_hcal[ipkt] )return 0; // :-( |
|
|
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( |
|
|
} |
|
|
// ----------------------- |
|
|
// Check missing packets: |
|
|
// ----------------------- |
|
|
// Readout order: |
|
|
// ------------------ |
|
|
// DSP packet board |
|
|
// ------------------ |
|
|
// 12 0 1 |
|
|
// 10 1 1 |
|
|
// 8 2 1 |
|
|
// 4 3 1 |
|
|
// 6 4 1 |
|
|
// 2 5 1 |
|
|
// ------------------ |
|
|
// 11 0 2 |
|
|
// 9 1 2 |
|
|
// 7 2 2 |
|
|
// 3 3 2 |
|
|
// 5 4 2 |
|
|
// 1 5 2 |
|
|
// ------------------ |
|
|
// ------------------------------------------------- |
|
|
// Check if it is first or second calibration packet |
|
|
// ------------------------------------------------- |
|
|
UInt_t build=0; |
|
|
TString classname = caltrk->GetName(); |
|
|
UInt_t base=0; |
|
|
UInt_t mask=0; |
|
|
if(classname.Contains("CalibTrk1Event")){ |
|
|
base=12; |
|
|
mask=0x03F000; |
|
|
} |
|
|
if(classname.Contains("CalibTrk2Event")){ |
|
|
base=18; |
|
|
mask=0xFC0000; |
|
|
} |
|
|
// ------------------------------------------------- |
|
|
// Count number of packets and set build variable |
|
|
// ------------------------------------------------- |
|
|
Int_t npkts=0; |
|
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
|
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
|
|
npkts++; |
|
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
|
|
} |
|
|
} |
|
|
// if( npkts==6 )return 1; // :-) |
|
7053 |
|
|
7054 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
if ( IsDebug() ) cout << "ValidateTrkCalib:"<<endl; |
7055 |
|
|
7056 |
// ----------------------------------------------- |
UInt_t validate = 1; |
7057 |
// If missing packets: check the acq configuration |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
7058 |
// (some DSPs might be excluded from acquisition) |
UInt_t timeaftercalib=120000; //2000; |
7059 |
// ----------------------------------------------- |
TString classname = caltrk->GetName(); |
7060 |
|
|
7061 |
// ----------------------------------------------- |
// ---------------------------------- |
7062 |
// retrieve the first run header after calib |
// Check CRCs and failed calibrations |
7063 |
// ----------------------------------------------- |
// ---------------------------------- |
7064 |
PacketType *pctp; |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7065 |
EventCounter *cod; |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7066 |
cod = eh->GetCounter(); |
if( caltrk->crc_hcal[ipkt] ){ |
7067 |
Int_t irun = cod->Get(pctp->RunHeader); |
// if(IsDebug())cout<<"(CRC Header)"; |
7068 |
TTree *rh=(TTree*)file->Get("RunHeader"); |
validate = 0; |
7069 |
if ( !rh || rh->IsZombie() ) throw -17; |
if(IsDebug())cout <<endl<<" *** CRC *** (header DSPn "<<caltrk->DSPnumber[ipkt]<<")"; |
7070 |
if( rh->GetEntries() == irun ){ |
|
7071 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
} |
7072 |
return 0; // :-( |
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
7073 |
} |
// if(IsDebug())cout<<"(CRC Pkt-"<<ilad<<")"; |
7074 |
|
if(IsDebug())cout <<endl<<" *** CRC *** (data DSPn "<<caltrk->DSPnumber[ipkt]<<" ladder "<<ilad<<")"; |
7075 |
|
validate = 0; |
7076 |
|
} |
7077 |
|
if( !(caltrk->ncalib_event[ipkt]==0 && caltrk->cal_flag[ipkt]==0) ){ |
7078 |
|
if(IsDebug())cout <<endl<<" *** FAILURE *** (data DSPn "<<caltrk->DSPnumber[ipkt]<<")"; |
7079 |
|
validate = 0; |
7080 |
|
} |
7081 |
|
}else{ |
7082 |
|
// validate=0; |
7083 |
|
if(IsDebug())cout <<endl<<" *** DSPn *** ("<< caltrk->DSPnumber[ipkt] <<" @pkt "<<ipkt<<")"; |
7084 |
|
} |
7085 |
|
} |
7086 |
|
|
7087 |
RunHeaderEvent *run = 0; |
// ----------------------- |
7088 |
EventHeader *hrun = 0; |
// Check missing packets: |
7089 |
rh->SetBranchAddress("RunHeader", &run); |
// ----------------------- |
7090 |
rh->SetBranchAddress("Header", &hrun); |
// Readout order: |
7091 |
rh->GetEntry(irun); |
// ------------------ |
7092 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
// DSP packet board |
7093 |
|
// ------------------ |
7094 |
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
// 12 0 1 |
7095 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
// 10 1 1 |
7096 |
return 0; // :-( |
// 8 2 1 |
7097 |
} |
// 4 3 1 |
7098 |
|
// 6 4 1 |
7099 |
if( !run->RM_ACQ_AFTER_CALIB ){ |
// 2 5 1 |
7100 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
// ------------------ |
7101 |
return 0; // :-( |
// 11 0 2 |
7102 |
} |
// 9 1 2 |
7103 |
|
// 7 2 2 |
7104 |
|
// 3 3 2 |
7105 |
|
// 5 4 2 |
7106 |
|
// 1 5 2 |
7107 |
|
// ------------------ |
7108 |
|
// ------------------------------------------------- |
7109 |
|
// Check if it is first or second calibration packet |
7110 |
|
// ------------------------------------------------- |
7111 |
|
UInt_t build=0; |
7112 |
|
UInt_t base=0; |
7113 |
|
UInt_t mask=0; |
7114 |
|
if(classname.Contains("CalibTrk1Event")){ |
7115 |
|
base=12; |
7116 |
|
mask=0x03F000; |
7117 |
|
} |
7118 |
|
if(classname.Contains("CalibTrk2Event")){ |
7119 |
|
base=18; |
7120 |
|
mask=0xFC0000; |
7121 |
|
} |
7122 |
|
// ---------------------------------------------------- |
7123 |
|
// Count number of valid packets and set build variable |
7124 |
|
// ---------------------------------------------------- |
7125 |
|
if(IsDebug())cout <<endl<< " DSP: "; |
7126 |
|
Int_t npkts=0; |
7127 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7128 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7129 |
|
if(IsDebug())cout <<" "<<caltrk->DSPnumber[ipkt]; |
7130 |
|
npkts++; |
7131 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
7132 |
|
// cout << caltrk->DSPnumber[ipkt] |
7133 |
|
}; |
7134 |
|
} |
7135 |
|
if(IsDebug())cout << " ==> "<< hex << build << dec; |
7136 |
|
// ---------------------------------------------------- |
7137 |
|
// If the number of valid packets is 6, ok exit... |
7138 |
|
// ---------------------------------------------------- |
7139 |
|
if( npkts==6 ){ |
7140 |
|
return validate; // exit |
7141 |
|
} |
7142 |
|
//////////////////////////////////////////////////////// |
7143 |
|
// ...otherwise there might be some missing packets |
7144 |
|
// |
7145 |
|
// In this case check the acq configuration |
7146 |
|
// (some DSPs might be excluded from acquisition) |
7147 |
|
//////////////////////////////////////////////////////// |
7148 |
|
|
7149 |
|
if(!eh || !file || (file&&file->IsZombie()) ){ |
7150 |
|
if ( IsDebug() )cout << " *** MISSING VIEW *** eh="<<eh<<" file="<<file<<" cannot validate"<<endl; |
7151 |
|
return (0); |
7152 |
|
} |
7153 |
|
|
7154 |
|
// ----------------------------------------------- |
7155 |
|
// retrieve the first run header after calib |
7156 |
|
// ----------------------------------------------- |
7157 |
|
|
7158 |
|
PacketType *pctp; |
7159 |
|
EventCounter *cod; |
7160 |
|
cod = eh->GetCounter(); |
7161 |
|
Int_t irun = cod->Get(pctp->RunHeader); |
7162 |
|
TTree *rh=(TTree*)file->Get("RunHeader"); |
7163 |
|
if ( !rh || rh->IsZombie() ) throw -17; |
7164 |
|
if( rh->GetEntries() <= irun ){ |
7165 |
|
if ( IsDebug() ) cout << " *** MISSING-PKT *** no runs after calib (1) -- cannot validate :-( "<<endl; |
7166 |
|
return 0; // :-( |
7167 |
|
} |
7168 |
|
RunHeaderEvent *run = 0; |
7169 |
|
EventHeader *hrun = 0; |
7170 |
|
rh->SetBranchAddress("RunHeader", &run); |
7171 |
|
rh->SetBranchAddress("Header", &hrun); |
7172 |
|
rh->GetEntry(irun); |
7173 |
|
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
7174 |
|
if ( IsDebug() ) cout << " *** MISSING-PKT *** no runs after calib (2) -- cannot validate :-( "<<endl; |
7175 |
|
return 0; // :-( |
7176 |
|
} |
7177 |
|
|
7178 |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
7179 |
if( dtime > timeaftercalib ){ |
if( dtime > timeaftercalib ){ |
7180 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
if ( IsDebug() ) cout << " *** MISSING-PKT *** run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
7181 |
return 0; // :-( |
return 0; // :-( |
7182 |
} |
} |
|
|
|
7183 |
|
|
7184 |
|
if ( IsDebug() ) cout <<endl<< " ACQ_BUILD_INFO ==> "<<hex<<(run->ACQ_BUILD_INFO & mask)<<dec; |
7185 |
|
|
7186 |
|
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
7187 |
|
validate=0; // :-( |
7188 |
|
cout <<endl<< " *** MISSING-PKT *** packet mismatch: ACQ_BUILD_INFO="<<hex<<(run->ACQ_BUILD_INFO&mask)<<" != "<<build<<dec; |
7189 |
|
}; |
7190 |
|
|
7191 |
|
return validate; |
7192 |
|
|
|
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
|
|
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
|
|
return 0; // :-( |
|
|
} |
|
|
return 1; // :-) |
|
7193 |
|
|
7194 |
} |
} |
7195 |
|
|