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 |
|
RELAXED = false; |
64 |
chewbacca = false; |
chewbacca = false; |
65 |
chminentry = 0; |
chminentry = 0; |
66 |
chID = 0; |
chID = 0; |
77 |
// |
// |
78 |
}; |
}; |
79 |
// |
// |
80 |
|
KEEPENV = false; |
81 |
|
if ( keepenv ) KEEPENV=true; |
82 |
STATIC=false; |
STATIC=false; |
83 |
if ( staticp ) STATIC=true; |
if ( staticp ) STATIC=true; |
84 |
// |
// |
102 |
if (INSERT_RAW) SetRawName(filerawname); |
if (INSERT_RAW) SetRawName(filerawname); |
103 |
// |
// |
104 |
INSERT_ROOT = !filerootname.IsNull(); |
INSERT_ROOT = !filerootname.IsNull(); |
105 |
|
if ( INSERT_ROOT ) this->SetRootName(filerootname); |
106 |
this->SetOrbitNo(dwinput); |
this->SetOrbitNo(dwinput); |
107 |
// |
// |
108 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
136 |
stringstream qu; |
stringstream qu; |
137 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
138 |
TSQLResult *result2 = 0; |
TSQLResult *result2 = 0; |
139 |
|
TSQLResult *result3 = 0; |
140 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
141 |
TSQLRow *row2 = 0; |
TSQLRow *row2 = 0; |
142 |
|
TSQLRow *row3 = 0; |
143 |
TString chpath; |
TString chpath; |
144 |
TString chfile; |
TString chfile; |
145 |
UInt_t ridn = 0; |
UInt_t ridn = 0; |
146 |
qu.str(""); |
qu.str(""); |
147 |
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,REAL_TIME_INIT from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
148 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
149 |
result = conn->Query(qu.str().c_str()); |
result = conn->Query(qu.str().c_str()); |
150 |
if ( result ){ |
if ( result ){ |
155 |
chpktmax = (UInt_t)atoll(row->GetField(2)); |
chpktmax = (UInt_t)atoll(row->GetField(2)); |
156 |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
157 |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
158 |
|
chiby = (TString)(row->GetField(5)); |
159 |
|
chrtinit = (UInt_t)atoll(row->GetField(6)); |
160 |
} else { |
} else { |
161 |
throw -84; |
throw -84; |
162 |
}; |
}; |
165 |
}; |
}; |
166 |
delete result; |
delete result; |
167 |
qu.str(""); |
qu.str(""); |
168 |
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 << ";"; |
169 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
170 |
result2 = conn->Query(qu.str().c_str()); |
result2 = conn->Query(qu.str().c_str()); |
171 |
if ( result2 ){ |
if ( result2 ){ |
172 |
row2 = result2->Next(); |
row2 = result2->Next(); |
173 |
if ( row2 ){ |
if ( row2 ){ |
174 |
chpath = (TString)gSystem->ExpandPathName(row2->GetField(0))+'/'; |
if ( KEEPENV ){ |
175 |
|
chpath = (TString)(row2->GetField(0))+'/'; |
176 |
|
} else { |
177 |
|
chpath = (TString)gSystem->ExpandPathName(row2->GetField(0))+'/'; |
178 |
|
}; |
179 |
chfile = (TString)(row2->GetField(1)); |
chfile = (TString)(row2->GetField(1)); |
180 |
chobtts = (UInt_t)atoll(row2->GetField(2)); |
chobtts = (UInt_t)atoll(row2->GetField(2)); |
181 |
chlastts = (UInt_t)atoll(row2->GetField(3)); |
chlastts = (UInt_t)atoll(row2->GetField(3)); |
182 |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
183 |
chboot = (UInt_t)atoll(row2->GetField(5)); |
chboot = (UInt_t)atoll(row2->GetField(5)); |
184 |
// |
// |
185 |
|
if ( !chboot ){ |
186 |
|
qu.str(""); |
187 |
|
// qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; |
188 |
|
// qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<40000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29] |
189 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] |
190 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
191 |
|
result3 = conn->Query(qu.str().c_str()); |
192 |
|
if ( result3 ){ |
193 |
|
row3 = result3->Next(); |
194 |
|
if ( row3 && result3->GetRowCount() == 1 ){ |
195 |
|
chboot = (UInt_t)atoll(row3->GetField(0)); |
196 |
|
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
197 |
|
} else { |
198 |
|
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
199 |
|
throw -29; |
200 |
|
}; |
201 |
|
}; |
202 |
|
}; |
203 |
|
// |
204 |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
205 |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
206 |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
213 |
throw -85; |
throw -85; |
214 |
}; |
}; |
215 |
filerootname = chpath + chfile;// + ".root"; |
filerootname = chpath + chfile;// + ".root"; |
|
if ( debug ) printf(" chewbacca: filename is %s \n",filerootname.Data()); |
|
216 |
}; |
}; |
217 |
this->SetRootName(filerootname); |
this->SetRootName(filerootname); |
|
file = TFile::Open(this->GetRootName().Data()); |
|
|
} else { |
|
|
this->SetRootName(""); |
|
218 |
}; |
}; |
219 |
|
if ( debug ) printf(" Filename is %s \n",filerootname.Data()); |
220 |
|
file = TFile::Open(this->GetRootName().Data()); |
221 |
|
// } else { |
222 |
|
// this->SetRootName(""); |
223 |
|
// this->SetRootName(filerootname); |
224 |
|
// }; |
225 |
} |
} |
226 |
|
|
227 |
// |
// |
421 |
return; |
return; |
422 |
}; |
}; |
423 |
// |
// |
424 |
TString name = this->GetRootFile(); |
if ( !chewbacca ){ |
425 |
Int_t nlength = name.Length(); |
TString name = this->GetRootFile(); |
426 |
if ( nlength < 5 ) return; |
Int_t nlength = name.Length(); |
427 |
TString dwo = 0; |
if ( nlength < 5 ){ |
428 |
for (Int_t i = 0; i<5; i++){ |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
429 |
dwo.Append(name[i],1); |
return; |
430 |
}; |
}; |
431 |
if ( dwo.IsDigit() ){ |
TString dwo = ""; |
432 |
dworbit = (UInt_t)dwo.Atoi(); |
for (Int_t i = 0; i<5; i++){ |
|
} else { |
|
|
dwo=""; |
|
|
for (Int_t i = 8; i<13; i++){ |
|
433 |
dwo.Append(name[i],1); |
dwo.Append(name[i],1); |
434 |
}; |
}; |
435 |
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
if ( dwo.IsDigit() ){ |
436 |
|
dworbit = (UInt_t)dwo.Atoi(); |
437 |
|
} else { |
438 |
|
dwo=""; |
439 |
|
for (Int_t i = 8; i<13; i++){ |
440 |
|
dwo.Append(name[i],1); |
441 |
|
}; |
442 |
|
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
443 |
|
}; |
444 |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
445 |
}; |
}; |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
|
446 |
return; |
return; |
447 |
}; |
}; |
448 |
|
|
473 |
|
|
474 |
TString PamelaDBOperations::GetRootPath(){ |
TString PamelaDBOperations::GetRootPath(){ |
475 |
if ( STATIC ){ |
if ( STATIC ){ |
476 |
return((TString)gSystem->DirName(filerootname.Data())+'/'); |
return((TString)gSystem->DirName(this->GetRootName().Data())+'/'); |
477 |
} else { |
} else { |
478 |
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
if ( KEEPENV ){ |
479 |
|
return((TString)gSystem->ExpandPathName(gSystem->DirName(filerootname.Data()))+'/'); |
480 |
|
} else { |
481 |
|
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
482 |
|
}; |
483 |
}; |
}; |
484 |
}; |
}; |
485 |
|
|
691 |
UInt_t tjump = 50000; |
UInt_t tjump = 50000; |
692 |
//UInt_t tjump = 100; |
//UInt_t tjump = 100; |
693 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
694 |
pktlast = numeric_limits<UInt_t>::max(); |
// pktlast = numeric_limits<UInt_t>::max(); |
695 |
while ( pktlast > chpktmax && (Int_t)(nevent-1-it) >= 0 ){ |
pktlast = chpktmax + 1; |
696 |
|
while ( PKT(pktlast) > PKT(chpktmax) && (Int_t)(nevent-1-it) >= 0 ){ |
697 |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
698 |
T->GetEntry(nevent-1-it); |
T->GetEntry(nevent-1-it); |
699 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
701 |
} else { |
} else { |
702 |
pktlast = chpktmax + 1; |
pktlast = chpktmax + 1; |
703 |
}; |
}; |
704 |
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)); |
705 |
it += tjump; |
it += tjump; |
706 |
}; |
}; |
707 |
if ( tjump > 1 ) it -= 2*tjump; |
if ( tjump > 1 ) it -= 2*tjump; |
725 |
tjump = 50000; |
tjump = 50000; |
726 |
//tjump = 100; |
//tjump = 100; |
727 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
728 |
pktlast = 0; |
// pktlast = 0; |
729 |
while ( pktlast < chpktmin && it < (Int_t)nevent ){ |
pktlast = chpktmin - 1; |
730 |
|
if ( debug ) printf("LLlook for down %i %i %llu %llu \n",it,pktlast,PKT(pktlast),PKT(chpktmin)); |
731 |
|
while ( PKT(pktlast) < PKT(chpktmin) && it < (Int_t)nevent ){ |
732 |
if ( it < (Int_t)nevent ){ |
if ( it < (Int_t)nevent ){ |
733 |
T->GetEntry(it); |
T->GetEntry(it); |
734 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
822 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
823 |
pktlast = ph->GetCounter(); |
pktlast = ph->GetCounter(); |
824 |
nevent = upperentry - chminentry; |
nevent = upperentry - chminentry; |
825 |
|
if ( ((Int_t)upperentry - (Int_t)chminentry) < 0 ) nevent = 0; // nevent is UInt_t! 090112 [8RED: error -88] |
826 |
|
if ( IsDebug() ) printf(" Setting nevent to %u - upperentry %i chminentry %i \n",nevent,upperentry,chminentry); |
827 |
// |
// |
828 |
} else { |
} else { |
829 |
upperpkt = PKT(pktlast); |
upperpkt = PKT(pktlast); |
832 |
}; |
}; |
833 |
// |
// |
834 |
if ( chewbacca && nevent < 1 ) { |
if ( chewbacca && nevent < 1 ) { |
835 |
|
if ( IsDebug() ) printf(" chewbacca and no events in the file \n"); |
836 |
pktfirst = chpktmin; |
pktfirst = chpktmin; |
837 |
upperpkt = PKT(chpktmax); |
upperpkt = PKT(chpktmax); |
838 |
pktlast = chpktmax; |
pktlast = chpktmax; |
858 |
// if ( nevent < jump ) jump = int(nevent/10); |
// if ( nevent < jump ) jump = int(nevent/10); |
859 |
// if ( !jump ) jump = 1; |
// if ( !jump ) jump = 1; |
860 |
// |
// |
861 |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) && nevent > deltapkt ){ |
|
862 |
|
if ( ((PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt)) && nevent > deltapkt ){ |
863 |
// |
// |
864 |
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
865 |
// if ( IsDebug() ) printf(" (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) %llu < %llu && %llu > %llu \n OR \n (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) %llu > %llu && %llu < %llu \n",PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst),PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst)); |
// if ( IsDebug() ) printf(" (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) %llu < %llu && %llu > %llu \n OR \n (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) %llu > %llu && %llu < %llu \n",PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst),PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst)); |
1174 |
stringstream oss; |
stringstream oss; |
1175 |
// |
// |
1176 |
oss.str(""); |
oss.str(""); |
1177 |
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. |
1178 |
|
if ( !strcmp(tag.Data(),"NONE") ){ |
1179 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< chiby.Data() <<"');"; |
1180 |
|
} else { |
1181 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< tag.Data() <<"');"; |
1182 |
|
}; |
1183 |
|
} else { |
1184 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< tag.Data() <<"');"; |
1185 |
|
}; |
1186 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1187 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1188 |
oss.str(""); |
oss.str(""); |
1330 |
stringstream oss; |
stringstream oss; |
1331 |
// |
// |
1332 |
oss.str(""); |
oss.str(""); |
1333 |
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;"; |
1334 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
1335 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1336 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1387 |
// |
// |
1388 |
// 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)); |
1389 |
// |
// |
1390 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
1391 |
// 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()); |
1392 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
1393 |
}; |
}; |
1434 |
UInt_t lastPkt = 0; |
UInt_t lastPkt = 0; |
1435 |
UInt_t rhtime = 0; |
UInt_t rhtime = 0; |
1436 |
UInt_t rttime = 0; |
UInt_t rttime = 0; |
1437 |
|
// |
1438 |
|
if ( IsDebug() ) printf(" A firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1439 |
|
// |
1440 |
if ( !mishead ){ |
if ( !mishead ){ |
1441 |
codh = ehh->GetCounter(); |
codh = ehh->GetCounter(); |
1442 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1) ){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1) ){ |
1443 |
|
if ( IsDebug() ) printf(" B firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1444 |
firstev = 1; |
firstev = 1; |
1445 |
lastev = 0; |
lastev = 0; |
1446 |
} else { |
} else { |
1453 |
}; |
}; |
1454 |
if ( !mistrail ){ |
if ( !mistrail ){ |
1455 |
codt = eht->GetCounter(); |
codt = eht->GetCounter(); |
1456 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1)){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1)){ |
1457 |
|
if ( IsDebug() ) printf(" C firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1458 |
lastev = 0; |
lastev = 0; |
1459 |
firstev = lastev+1; |
firstev = lastev+1; |
1460 |
} else { |
} else { |
1471 |
if ( mishead ) { |
if ( mishead ) { |
1472 |
glrun->Set_GL_RUNH0(); |
glrun->Set_GL_RUNH0(); |
1473 |
// |
// |
1474 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1) ){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1) ){ |
1475 |
firstObt = lastObt; |
firstObt = lastObt; |
1476 |
firstPkt = lastPkt; |
firstPkt = lastPkt; |
1477 |
rhtime = rttime; |
rhtime = rttime; |
1490 |
if ( mistrail ){ |
if ( mistrail ){ |
1491 |
glrun->Set_GL_RUNT0(); |
glrun->Set_GL_RUNT0(); |
1492 |
// |
// |
1493 |
if ( lastev+1 == firstev || (lastev == firstev && lastev != -1) ){ |
if ( (lastev+1 == firstev && lastev != -1) || (lastev == firstev && lastev != -1) ){ |
1494 |
lastObt = firstObt; |
lastObt = firstObt; |
1495 |
lastPkt = firstPkt; |
lastPkt = firstPkt; |
1496 |
rttime = rhtime; |
rttime = rhtime; |
1506 |
glrun->SetRUNTRAILER_PKT(lastPkt); |
glrun->SetRUNTRAILER_PKT(lastPkt); |
1507 |
// |
// |
1508 |
}; |
}; |
1509 |
|
// |
1510 |
|
// ad hoc solution for INF EV_TO [8RED] 090113 |
1511 |
|
// |
1512 |
|
if ( !firstev && lastev == -1 ){ |
1513 |
|
if ( IsDebug() ) printf(" EE firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1514 |
|
firstev = 1; |
1515 |
|
lastev = 0; |
1516 |
|
}; |
1517 |
glrun->SetEV_FROM((UInt_t)firstev); |
glrun->SetEV_FROM((UInt_t)firstev); |
1518 |
glrun->SetEV_TO((UInt_t)lastev); |
glrun->SetEV_TO((UInt_t)lastev); |
1519 |
glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1); |
glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1); |
1533 |
* Insert a new row into GL_RAW table. |
* Insert a new row into GL_RAW table. |
1534 |
*/ |
*/ |
1535 |
Int_t PamelaDBOperations::insertPamelaRawFile(){ |
Int_t PamelaDBOperations::insertPamelaRawFile(){ |
1536 |
|
|
1537 |
|
// |
1538 |
|
Bool_t idr = this->SetID_RAW(); |
1539 |
|
if ( idr ) return(1); |
1540 |
|
|
1541 |
|
GL_RAW glraw = GL_RAW(); |
1542 |
|
|
1543 |
|
glraw.PATH = GetRawPath(); |
1544 |
|
glraw.NAME = GetRawFile(); |
1545 |
|
// glraw.BOOT_NUMBER = 0;//??? |
1546 |
|
glraw.BOOT_NUMBER = this->GetBOOTnumber(); |
1547 |
|
|
1548 |
|
if( insertPamelaRawFile(&glraw) )return(1); |
1549 |
|
// |
1550 |
|
idr = this->SetID_RAW(); |
1551 |
|
if ( !idr ) throw -11; |
1552 |
|
|
1553 |
|
return(0); |
1554 |
|
} |
1555 |
|
/** |
1556 |
|
* Insert a new row into GL_RAW table. |
1557 |
|
*/ |
1558 |
|
Int_t PamelaDBOperations::insertPamelaRawFile(GL_RAW *glraw){ |
1559 |
// |
// |
1560 |
stringstream oss; |
if(!glraw)return(1);//?? ok I think |
1561 |
// |
// |
1562 |
Bool_t idr = this->SetID_RAW(); |
stringstream oss; |
1563 |
if ( idr ) return(1); |
// |
1564 |
// |
oss.str(""); |
1565 |
oss.str(""); |
if ( STATIC ){ |
1566 |
if ( STATIC ){ |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
1567 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
<< glraw->PATH << "', '" << glraw->NAME << "')"; |
1568 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
} else { |
1569 |
} else { |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << glraw->NAME << "')"; |
1570 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
}; |
1571 |
}; |
if ( debug ) cout <<oss.str().c_str() <<endl; |
1572 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1573 |
// |
// |
1574 |
idr = this->SetID_RAW(); |
oss.str(""); |
1575 |
if ( !idr ) throw -11; |
oss << "SELECT ID FROM GL_RAW WHERE NAME=\""<<glraw->NAME<<"\";"; |
1576 |
// |
if ( debug ) cout << oss.str().c_str()<<endl; |
1577 |
return(0); |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1578 |
|
// |
1579 |
|
TSQLResult *result = 0; |
1580 |
|
TSQLRow *row = 0; |
1581 |
|
result = conn->Query(oss.str().c_str()); |
1582 |
|
if ( result == NULL ) throw -4; |
1583 |
|
row = result->Next(); |
1584 |
|
if ( !row ) return(1); |
1585 |
|
glraw->ID = (UInt_t)atoll(row->GetField(0)); |
1586 |
|
if ( debug ) printf(" The ID of the RAW file is %u \n",glraw->ID); |
1587 |
|
delete result; |
1588 |
|
delete row; |
1589 |
|
// |
1590 |
|
return(0); |
1591 |
} |
} |
1592 |
|
|
1593 |
|
|
1620 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1621 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1622 |
row = result->Next(); |
row = result->Next(); |
1623 |
|
if ( !row ) throw -92; |
1624 |
idresof = (UInt_t)atoll(row->GetField(0)); |
idresof = (UInt_t)atoll(row->GetField(0)); |
1625 |
existsts = true; |
existsts = true; |
1626 |
goto eout; |
goto eout; |
1642 |
if ( !row ){ |
if ( !row ){ |
1643 |
oss.str(""); |
oss.str(""); |
1644 |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
1645 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< dworbit << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;"; |
1646 |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
1647 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1648 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1900 |
* 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. |
1901 |
*/ |
*/ |
1902 |
Int_t PamelaDBOperations::insertPamelaRootFile(){ |
Int_t PamelaDBOperations::insertPamelaRootFile(){ |
1903 |
stringstream oss; |
|
1904 |
TSQLResult *result = 0; |
stringstream oss; |
1905 |
TSQLRow *row = 0; |
TSQLResult *result = 0; |
1906 |
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; |
|
1907 |
// |
// |
1908 |
row = result->Next(); |
// ---------------------- |
1909 |
|
// determine the timesync |
1910 |
|
// ---------------------- |
1911 |
|
UInt_t idtimesync = 0; |
1912 |
// |
// |
1913 |
if ( !row ) throw -3; |
if ( chewbacca ){ |
1914 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
oss.str(""); |
1915 |
} else { |
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
1916 |
oss.str(""); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
1917 |
if ( STATIC ){ |
result = conn->Query(oss.str().c_str()); |
1918 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
// |
1919 |
<< " LEFT JOIN GL_ROOT " |
if ( !result ) throw -3; |
1920 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
// |
1921 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
row = result->Next(); |
1922 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
// |
1923 |
|
if ( !row ) throw -3; |
1924 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
1925 |
} else { |
} else { |
1926 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
oss.str(""); |
1927 |
<< " LEFT JOIN GL_ROOT " |
if ( STATIC ){ |
1928 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1929 |
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
<< " LEFT JOIN GL_ROOT " |
1930 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1931 |
|
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
1932 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1933 |
|
} else { |
1934 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1935 |
|
<< " LEFT JOIN GL_ROOT " |
1936 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1937 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
1938 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1939 |
|
}; |
1940 |
|
result = conn->Query(oss.str().c_str()); |
1941 |
|
// |
1942 |
|
if ( !result ) throw -12; |
1943 |
|
// |
1944 |
|
row = result->Next(); |
1945 |
|
// |
1946 |
|
if ( !row ) throw -10; |
1947 |
|
if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
1948 |
|
idroot = (UInt_t)atoll(row->GetField(2)); |
1949 |
|
delete row; |
1950 |
|
delete result; |
1951 |
|
return(1); |
1952 |
|
}; |
1953 |
|
// |
1954 |
|
// determine which timesync has to be used |
1955 |
|
// |
1956 |
|
oss.str(""); |
1957 |
|
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;"; |
1958 |
|
result = conn->Query(oss.str().c_str()); |
1959 |
|
// |
1960 |
|
if ( !result ) throw -3; |
1961 |
|
// |
1962 |
|
row = result->Next(); |
1963 |
|
// |
1964 |
|
if ( !row ) throw -3; |
1965 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
1966 |
}; |
}; |
1967 |
result = conn->Query(oss.str().c_str()); |
|
1968 |
// |
delete row; |
1969 |
if ( !result ) throw -12; |
delete result; |
1970 |
// |
|
1971 |
row = result->Next(); |
// ---------------------- |
1972 |
// |
// insert root file |
1973 |
if ( !row ) throw -10; |
// ---------------------- |
1974 |
if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
|
1975 |
idroot = (UInt_t)atoll(row->GetField(2)); |
GL_ROOT glroot = GL_ROOT(); |
1976 |
return(1); |
|
1977 |
|
glroot.ID_RAW = GetID_RAW(); |
1978 |
|
glroot.ID_TIMESYNC = idtimesync; |
1979 |
|
if ( STATIC ){ |
1980 |
|
glroot.PATH = GetRootPath(); |
1981 |
|
} else { |
1982 |
|
if ( KEEPENV ){ |
1983 |
|
glroot.PATH = gSystem->DirName(filerootname.Data()); |
1984 |
|
} else { |
1985 |
|
glroot.PATH = "$PAM_L0"; |
1986 |
|
}; |
1987 |
}; |
}; |
1988 |
// |
glroot.NAME = GetRootFile(); |
1989 |
// determine which timesync has to be used |
|
1990 |
// |
if ( insertPamelaRootFile(&glroot) )return 1; |
1991 |
oss.str(""); |
|
1992 |
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); |
1993 |
result = conn->Query(oss.str().c_str()); |
|
1994 |
// |
|
1995 |
if ( !result ) throw -3; |
return (0); |
1996 |
// |
} |
1997 |
row = result->Next(); |
/** |
1998 |
// |
* Insert all the new rows into GL_ROOT. |
1999 |
if ( !row ) throw -3; |
* The raw file indicates in the parameters should be already been stored in the database. |
2000 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
*/ |
2001 |
}; |
Int_t PamelaDBOperations::insertPamelaRootFile(GL_ROOT *glroot){ |
2002 |
|
stringstream oss; |
2003 |
|
TSQLResult *result = 0; |
2004 |
|
TSQLRow *row = 0; |
2005 |
|
// |
2006 |
// |
// |
2007 |
oss.str(""); |
oss.str(""); |
2008 |
if ( STATIC ){ |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
2009 |
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() << "')"; |
|
|
}; |
|
2010 |
// |
// |
2011 |
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
2012 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
2013 |
// |
// |
2014 |
delete result; |
delete result; |
2015 |
// |
// |
2016 |
oss.str(""); |
oss.str(""); |
2017 |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
2018 |
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() <<"';"; |
|
|
}; |
|
2019 |
// |
// |
2020 |
if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
2021 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
2022 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
2023 |
row = result->Next(); |
row = result->Next(); |
2024 |
if ( !row ) throw -3; |
if ( !row ) throw -3; |
2025 |
this->SetID_ROOT((UInt_t)atoll(row->GetField(0))); |
|
2026 |
if ( debug ) printf(" The ID of the ROOT file is %u \n",this->GetID_ROOT()); |
glroot->ID = (UInt_t)atoll(row->GetField(0)); |
2027 |
|
|
2028 |
|
if ( debug ) printf(" The ID of the ROOT file is %u \n",glroot->ID); |
2029 |
// |
// |
2030 |
delete result; |
delete result; |
2031 |
// |
// |
2283 |
ptht = cod->Get(pctp->RunHeader) - 1; |
ptht = cod->Get(pctp->RunHeader) - 1; |
2284 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2285 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2286 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2287 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2288 |
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)); |
2289 |
// |
// |
2322 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
2323 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2324 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2325 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2326 |
evbefh = TMath::Max(chminentry,(tcod-1)); |
evbefh = TMath::Max(chminentry,(tcod-1)); |
2327 |
// |
// |
2328 |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
2361 |
// |
// |
2362 |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
2363 |
// |
// |
2364 |
|
// what about pth=ptht-1 |
2365 |
}; |
}; |
2366 |
}; |
}; |
2367 |
// |
// |
2384 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2385 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2386 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2387 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2388 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2389 |
rh->GetEntry(pth); |
rh->GetEntry(pth); |
2390 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
2424 |
// if ( ptt+1 == rtev){ |
// if ( ptt+1 == rtev){ |
2425 |
if ( conptt+1 == nrtev ){ |
if ( conptt+1 == nrtev ){ |
2426 |
// if ( conptt+1 == (nrtev+nrtbef )){ |
// if ( conptt+1 == (nrtev+nrtbef )){ |
2427 |
|
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
2428 |
ptht++; |
ptht++; |
2429 |
if ( ptht < rhev ){ |
if ( ptht < rhev ){ |
2430 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
2431 |
|
//pth++; |
2432 |
|
//if ( pth < rhev ){ |
2433 |
|
//rh->GetEntry(pth); |
2434 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
2435 |
pkth = phh->GetCounter(); |
pkth = phh->GetCounter(); |
2436 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
2454 |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
2455 |
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); |
2456 |
// |
// |
2457 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
// if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
2458 |
rt->GetEntry(ptt-1); |
if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here! |
2459 |
|
// rt->GetEntry(ptt-1); |
2460 |
|
rt->GetEntry(rtev-1); |
2461 |
cod = eht->GetCounter(); |
cod = eht->GetCounter(); |
2462 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics)+1; |
2463 |
evbefh = TMath::Max(chminentry,tcod); |
evbefh = TMath::Max(chminentry,tcod); |
2464 |
// evbefh = cod->Get(pctp->Physics); |
// evbefh = cod->Get(pctp->Physics); |
2465 |
rt->GetEntry(ptt); |
rt->GetEntry(ptt); |
2690 |
// |
// |
2691 |
// 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 |
2692 |
// |
// |
2693 |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
if ( firstev != (lastev+1) ){ // could be a problem sometimes (?) |
2694 |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
2695 |
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
2696 |
|
}; |
2697 |
// |
// |
2698 |
|
if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev); |
2699 |
this->FillClass(mishead,mistrail,firstev,lastev); |
this->FillClass(mishead,mistrail,firstev,lastev); |
2700 |
|
if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev); |
2701 |
// |
// |
2702 |
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"); |
2703 |
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()); |
2739 |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
2740 |
// |
// |
2741 |
} else { |
} else { |
2742 |
if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); |
if ( IsDebug() ) printf(" The run is already present in the fragment table, relaxed %u \n",RELAXED); |
2743 |
if ( PEDANTIC ) throw -69; |
if ( !RELAXED ){ |
2744 |
return; |
if ( PEDANTIC ) throw -69; |
2745 |
|
return; |
2746 |
|
} else { |
2747 |
|
glrun->SetID((UInt_t)atoll(row->GetField(0))); |
2748 |
|
glrun->SetID_RUN_FRAG(0); |
2749 |
|
}; |
2750 |
}; |
}; |
2751 |
// |
// |
2752 |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
2797 |
// |
// |
2798 |
found = false; // default value |
found = false; // default value |
2799 |
// |
// |
2800 |
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"); |
2801 |
// |
// |
2802 |
// 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: |
2803 |
// |
// |
2813 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
2814 |
// |
// |
2815 |
found = true; |
found = true; |
2816 |
|
if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev); |
2817 |
// |
// |
2818 |
} else { |
} else { |
2819 |
// |
// |
2879 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " ID="<<row->GetField(0)<<";"; |
2880 |
// |
// |
2881 |
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 |
2882 |
|
if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev); |
2883 |
// |
// |
2884 |
// merge infos |
// merge infos |
2885 |
// |
// |
2910 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
2911 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
2912 |
// |
// |
2913 |
|
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
2914 |
|
// |
2915 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
2916 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
2917 |
// |
// |
3004 |
// |
// |
3005 |
found = false; // default value |
found = false; // default value |
3006 |
// |
// |
3007 |
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"); |
3008 |
// |
// |
3009 |
// 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: |
3010 |
// |
// |
3104 |
apkt = PKT(ph->GetCounter()); |
apkt = PKT(ph->GetCounter()); |
3105 |
aobt = OBT(ph->GetOrbitalTime()); |
aobt = OBT(ph->GetOrbitalTime()); |
3106 |
lastev--; |
lastev--; |
3107 |
if ( PEDANTIC ) throw -72; |
if ( PEDANTIC && !RELAXED) throw -72; |
3108 |
}; |
}; |
3109 |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
3110 |
// |
// |
3172 |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
3173 |
// |
// |
3174 |
oss.str(""); |
oss.str(""); |
3175 |
oss << " SELECT ID FROM GL_RUN WHERE " |
oss << " SELECT ID,ID_ROOT_L0 FROM GL_RUN WHERE " |
3176 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
3177 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
3178 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
3195 |
row = result->Next(); |
row = result->Next(); |
3196 |
// |
// |
3197 |
if ( row ){ |
if ( row ){ |
3198 |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
// |
3199 |
if ( PEDANTIC ) throw -70; |
// we end up here if chewbacca and we have RH---| small gap |---RT, in this case the two pieces are attached and moved to GL_RUN. We are now processing the |
3200 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
3201 |
|
// |
3202 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
3203 |
|
// |
3204 |
|
Bool_t OK = false; |
3205 |
|
UInt_t IDRL2A = 0; |
3206 |
|
UInt_t IDRL2B = 0; |
3207 |
|
if ( chewbacca ){ |
3208 |
|
if ( result->GetRowCount() == 2 ){ |
3209 |
|
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3210 |
|
UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
3211 |
|
row = result->Next(); |
3212 |
|
IDRL2B = (UInt_t)atoll(row->GetField(0)); |
3213 |
|
UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
3214 |
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
3215 |
|
if ( IDRL0A == IDRL0B ){ |
3216 |
|
TSQLResult *result2 = 0; |
3217 |
|
TSQLRow *row2 = 0; |
3218 |
|
oss.str(""); |
3219 |
|
oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
3220 |
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3221 |
|
result2 = conn->Query(oss.str().c_str()); |
3222 |
|
// |
3223 |
|
if ( !result2 ) throw -4; |
3224 |
|
// |
3225 |
|
row2 = result2->Next(); |
3226 |
|
// |
3227 |
|
if ( row2 ){ |
3228 |
|
UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
3229 |
|
delete result2; |
3230 |
|
oss.str(""); |
3231 |
|
oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
3232 |
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3233 |
|
result2 = conn->Query(oss.str().c_str()); |
3234 |
|
// |
3235 |
|
if ( !result2 ) throw -4; |
3236 |
|
// |
3237 |
|
row2 = result2->Next(); |
3238 |
|
// |
3239 |
|
if ( row2 ){ |
3240 |
|
UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
3241 |
|
// |
3242 |
|
if ( IsDebug() ) printf(" PKT(PKA) + 1 %llu == runheaderpkt %llu && PKB = runtrailer %llu + 1 %llu \n",PKT(PKA)+1LL, PKT(glrun->GetRUNHEADER_PKT()),PKT(PKB), PKT(glrun->GetRUNTRAILER_PKT())+1LL); |
3243 |
|
if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
3244 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3245 |
|
OK = true; |
3246 |
|
}; |
3247 |
|
}; |
3248 |
|
}; |
3249 |
|
}; |
3250 |
|
}; |
3251 |
|
}; |
3252 |
|
if ( OK ){ |
3253 |
|
// |
3254 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
3255 |
|
// |
3256 |
|
// we have to update with runheader/trailer infos our run and we have to change the ROOT_ID_FRAG of the header piece ( 1/2 2/1 must become 1/3 3/2 2/1 ) |
3257 |
|
// |
3258 |
|
GL_RUN *glA = new GL_RUN(); |
3259 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
3260 |
|
// |
3261 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3262 |
|
// |
3263 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
3264 |
|
// |
3265 |
|
oss.str(""); |
3266 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3267 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
3268 |
|
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3269 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
3270 |
|
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
3271 |
|
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
3272 |
|
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
3273 |
|
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
3274 |
|
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
3275 |
|
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
3276 |
|
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
3277 |
|
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
3278 |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
3279 |
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
3280 |
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
3281 |
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
3282 |
|
// |
3283 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3284 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
3285 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3286 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
3287 |
|
// |
3288 |
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
3289 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
3290 |
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
3291 |
|
conn->Query(oss.str().c_str()); |
3292 |
|
// |
3293 |
|
} else { |
3294 |
|
// |
3295 |
|
// sig no runheader, let set anyway what is possible... |
3296 |
|
// |
3297 |
|
oss.str(""); |
3298 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3299 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
3300 |
|
// |
3301 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3302 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
3303 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3304 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
3305 |
|
// |
3306 |
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3307 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
3308 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
3309 |
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
3310 |
|
conn->Query(oss.str().c_str()); |
3311 |
|
}; |
3312 |
|
// |
3313 |
|
// update runheader ROOT_ID_FRAG |
3314 |
|
// |
3315 |
|
oss.str(""); |
3316 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
3317 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3318 |
|
conn->Query(oss.str().c_str()); |
3319 |
|
// |
3320 |
|
// now let's look for runtrailer if any in the last run |
3321 |
|
// |
3322 |
|
glA->Query_GL_RUN(IDRL2B,conn); |
3323 |
|
// |
3324 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3325 |
|
// |
3326 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
3327 |
|
// |
3328 |
|
oss.str(""); |
3329 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3330 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3331 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
3332 |
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
3333 |
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
3334 |
|
// |
3335 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3336 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3337 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
3338 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3339 |
|
// |
3340 |
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
3341 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
3342 |
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
3343 |
|
conn->Query(oss.str().c_str()); |
3344 |
|
// |
3345 |
|
} else { |
3346 |
|
// |
3347 |
|
// sig no runtrailer, let set anyway what is possible... |
3348 |
|
// |
3349 |
|
oss.str(""); |
3350 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3351 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3352 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
3353 |
|
// |
3354 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3355 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3356 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
3357 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3358 |
|
// |
3359 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
3360 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
3361 |
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
3362 |
|
conn->Query(oss.str().c_str()); |
3363 |
|
}; |
3364 |
|
// |
3365 |
|
UInt_t myi = glrun->GetID(); |
3366 |
|
oss.str(""); |
3367 |
|
oss << " ID= "<< myi; |
3368 |
|
// |
3369 |
|
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
3370 |
|
// |
3371 |
|
// fill the new run in GL_RUN |
3372 |
|
// |
3373 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
3374 |
|
glrun->Fill_GL_RUN(conn); |
3375 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3376 |
|
delete glA; |
3377 |
|
// |
3378 |
|
} else { |
3379 |
|
// |
3380 |
|
// is just a repetition |
3381 |
|
// |
3382 |
|
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
3383 |
|
if ( PEDANTIC ) throw -70; |
3384 |
|
}; |
3385 |
|
// |
3386 |
} else { |
} else { |
3387 |
if ( NoFrag() ){ |
if ( NoFrag() ){ |
3388 |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
3419 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
3420 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
3421 |
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... |
3422 |
}; |
}; |
3423 |
// |
// |
3424 |
}; |
}; |
3425 |
// |
// |
3463 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
3464 |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
3465 |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
3466 |
|
firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files |
3467 |
// return true is correct |
// return true is correct |
3468 |
return(true); |
return(true); |
3469 |
// |
// |
3493 |
// |
// |
3494 |
} else { |
} else { |
3495 |
// |
// |
3496 |
if ( IsDebug() ) printf(" There are no-phyics packets inside the run!\n"); |
if ( IsDebug() ) printf(" There are no-physics packets inside the run!\n"); |
3497 |
// |
// |
3498 |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
3499 |
// |
// |
3503 |
UInt_t check = 0; |
UInt_t check = 0; |
3504 |
UInt_t lastevtemp = lastev; |
UInt_t lastevtemp = lastev; |
3505 |
UInt_t firstevno = firstev; |
UInt_t firstevno = firstev; |
3506 |
|
UInt_t rhchko=0; |
3507 |
|
UInt_t rhchk=0; |
3508 |
// |
// |
3509 |
for (UInt_t i=firstev; i<=lastev; i++){ |
for (UInt_t i=firstev; i<=lastev; i++){ |
3510 |
// |
// |
3513 |
// |
// |
3514 |
check = 0; |
check = 0; |
3515 |
// |
// |
3516 |
|
|
3517 |
|
// if we have a runheader set lastev then exit |
3518 |
|
// |
3519 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
3520 |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
3521 |
}; |
}; |
3522 |
|
// check here if we have a runheader |
3523 |
|
rhchko = rhchk; |
3524 |
|
rhchk = code->Get(GetPacketType("RunHeader")); |
3525 |
// |
// |
3526 |
if ( checkfirst < check || i == lastev ){ |
if ( checkfirst < check || i == lastev ){ |
3527 |
// |
// |
3605 |
// 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 |
3606 |
// |
// |
3607 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3608 |
mishead = true; |
mishead = true; |
3609 |
|
|
3610 |
|
|
3719 |
// |
// |
3720 |
found = false; // default value |
found = false; // default value |
3721 |
// |
// |
3722 |
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"); |
3723 |
// |
// |
3724 |
// 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: |
3725 |
// |
// |
3924 |
}; // EEE |
}; // EEE |
3925 |
|
|
3926 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3927 |
} else { |
} else { |
3928 |
if ( !IsRunAlreadyInserted() ){ |
if ( !IsRunAlreadyInserted() ){ |
3929 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
3938 |
// |
// |
3939 |
}; |
}; |
3940 |
// |
// |
3941 |
|
if ( i > firstev ){ |
3942 |
|
if ( rhchko != rhchk ){ |
3943 |
|
if ( IsDebug() ) printf("oh oh... we have a runheader! stop here and handle later the remaining piece\n"); |
3944 |
|
lastev = i; |
3945 |
|
return(false); |
3946 |
|
}; |
3947 |
|
}; |
3948 |
|
// |
3949 |
if ( check == checklast && i != lastev ){ |
if ( check == checklast && i != lastev ){ |
3950 |
lastevtemp = i - 1; |
lastevtemp = i - 1; |
3951 |
i = lastev - 1; |
i = lastev - 1; |
4237 |
UInt_t totime = 0; |
UInt_t totime = 0; |
4238 |
UInt_t obt = 0; |
UInt_t obt = 0; |
4239 |
UInt_t pkt = 0; |
UInt_t pkt = 0; |
4240 |
|
Float_t totped = 0.; |
4241 |
// |
// |
4242 |
tr = (TTree*)file->Get("CalibCalPed"); |
tr = (TTree*)file->Get("CalibCalPed"); |
4243 |
if ( !tr || tr->IsZombie() ) throw -21; |
if ( !tr || tr->IsZombie() ) throw -21; |
4255 |
if ( calibCalPed->cstwerr[section] ){ |
if ( calibCalPed->cstwerr[section] ){ |
4256 |
valid = 1; |
valid = 1; |
4257 |
if ( calibCalPed->cperror[section] ) valid = 0; |
if ( calibCalPed->cperror[section] ) valid = 0; |
4258 |
|
// |
4259 |
|
// check pedestal values for one plane, if all zeros calibration is not valid (calorimeter power problems) [8th data reduction bug, fixed on 25/11/2009 by E.M.] |
4260 |
|
// |
4261 |
|
totped = 0.; |
4262 |
|
Int_t ns = 0; |
4263 |
|
if ( section == 2 ) ns = 3; |
4264 |
|
if ( section == 3 ) ns = 1; |
4265 |
|
if ( section == 1 ) ns = 2; |
4266 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4267 |
|
totped += fabs(calibCalPed->calped[ns][0][ss]); |
4268 |
|
} |
4269 |
|
if ( totped < 1. ){ |
4270 |
|
if ( IsDebug() ) printf(" Section %i totped %f - No calibration data! Calorimeter power problems? \n",section,totped); |
4271 |
|
valid = 0; |
4272 |
|
}; |
4273 |
|
// |
4274 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4275 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4276 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4438 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
4439 |
nevents = tr->GetEntries(); |
nevents = tr->GetEntries(); |
4440 |
// |
// |
4441 |
|
Float_t totpul = 0.; |
4442 |
|
// |
4443 |
if ( nevents > 0 ){ |
if ( nevents > 0 ){ |
4444 |
// |
// |
4445 |
for (UInt_t i=0; i < nevents; i++){ |
for (UInt_t i=0; i < nevents; i++){ |
4449 |
if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ |
if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ |
4450 |
valid = 1; |
valid = 1; |
4451 |
if ( cp1->pperror[section] ) valid = 0; |
if ( cp1->pperror[section] ) valid = 0; |
4452 |
|
// |
4453 |
|
// check pulse values for one plane, if all zeros calibration is not valid (calorimeter power problems) [8th data reduction bug, fixed on 25/11/2009 by E.M.] |
4454 |
|
// |
4455 |
|
totpul = 0.; |
4456 |
|
Int_t ns = 0; |
4457 |
|
if ( section == 2 ) ns = 3; |
4458 |
|
if ( section == 3 ) ns = 1; |
4459 |
|
if ( section == 1 ) ns = 2; |
4460 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4461 |
|
totpul += cp1->calpuls[ns][0][ss]; |
4462 |
|
} |
4463 |
|
if ( totpul >= 3145632. ){ |
4464 |
|
if ( IsDebug() ) printf(" PULSE1 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); |
4465 |
|
valid = 0; |
4466 |
|
}; |
4467 |
|
// |
4468 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4469 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4470 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4622 |
if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ |
if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ |
4623 |
valid = 1; |
valid = 1; |
4624 |
if ( cp2->pperror[section] ) valid = 0; |
if ( cp2->pperror[section] ) valid = 0; |
4625 |
|
// |
4626 |
|
// check pulse values for one plane, if all zeros calibration is not valid (calorimeter power problems) [8th data reduction bug, fixed on 25/11/2009 by E.M.] |
4627 |
|
// |
4628 |
|
totpul = 0.; |
4629 |
|
Int_t ns = 0; |
4630 |
|
if ( section == 2 ) ns = 3; |
4631 |
|
if ( section == 3 ) ns = 1; |
4632 |
|
if ( section == 1 ) ns = 2; |
4633 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4634 |
|
totpul += cp2->calpuls[ns][0][ss]; |
4635 |
|
} |
4636 |
|
if ( totpul >= 3145632. ){ |
4637 |
|
if ( IsDebug() ) printf(" PULSE2 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); |
4638 |
|
valid = 0; |
4639 |
|
}; |
4640 |
|
// |
4641 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4642 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4643 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4817 |
* Fill the GL_TRK_CALIB table |
* Fill the GL_TRK_CALIB table |
4818 |
*/ |
*/ |
4819 |
void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
4820 |
// |
|
4821 |
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 ){ |
|
4822 |
// |
// |
4823 |
if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
glcal->ID = 0; |
4824 |
if ( PEDANTIC ) throw -80; |
glcal->ID_ROOT_L0 = GetID_ROOT(); |
4825 |
|
glcal->EV_ROOT_CALIBTRK1 = t1; |
4826 |
|
glcal->EV_ROOT_CALIBTRK2 = t2; |
4827 |
|
glcal->FROM_TIME = fromtime; |
4828 |
|
glcal->TO_TIME = 0; |
4829 |
|
glcal->OBT1 = obt1; |
4830 |
|
glcal->OBT2 = obt2; |
4831 |
|
glcal->PKT1 = pkt1; |
4832 |
|
glcal->PKT2 = pkt2; |
4833 |
|
glcal->BOOT_NUMBER = GetBOOTnumber(); |
4834 |
|
glcal->VALIDATION = valid; |
4835 |
// |
// |
4836 |
} else { |
HandleTRK_CALIB(glcal); |
|
// |
|
|
// we have to insert a new calibration, check where to place it |
|
4837 |
// |
// |
4838 |
oss.str(""); |
delete glcal; |
4839 |
oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
} |
4840 |
<< " FROM_TIME < "<< fromtime << " AND " |
/** |
4841 |
<< " TO_TIME > "<< fromtime << ";"; |
* Fill the GL_TRK_CALIB table |
4842 |
|
*/ |
4843 |
|
void PamelaDBOperations::HandleTRK_CALIB(GL_TRK_CALIB *glcal){ |
4844 |
|
|
4845 |
|
Bool_t pk1 = (glcal->OBT1>0&&glcal->PKT1>0); |
4846 |
|
Bool_t pk2 = (glcal->OBT2>0&&glcal->PKT2>0); |
4847 |
|
UInt_t boot_number = glcal->BOOT_NUMBER; |
4848 |
|
UInt_t obt1 = glcal->OBT1; |
4849 |
|
UInt_t obt2 = glcal->OBT2; |
4850 |
|
UInt_t pkt1 = glcal->PKT1; |
4851 |
|
UInt_t pkt2 = glcal->PKT2; |
4852 |
|
UInt_t fromtime = glcal->FROM_TIME; |
4853 |
|
UInt_t totime = 0; |
4854 |
|
UInt_t idroot = glcal->ID_ROOT_L0; |
4855 |
|
UInt_t t1 = glcal->EV_ROOT_CALIBTRK1; |
4856 |
|
UInt_t t2 = glcal->EV_ROOT_CALIBTRK2; |
4857 |
|
UInt_t valid = glcal->VALIDATION; |
4858 |
// |
// |
4859 |
if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
TSQLResult *result = 0; |
4860 |
result = conn->Query(oss.str().c_str()); |
TSQLRow *row = 0; |
4861 |
// |
// |
4862 |
if ( !result ) throw -4; |
stringstream oss; |
4863 |
|
oss.str(""); |
4864 |
// |
// |
|
row = result->Next(); |
|
4865 |
// |
// |
4866 |
if ( !row ){ |
if ( !pk1 && !pk2 ){ |
4867 |
// |
if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
4868 |
// no calibrations in the db contain our calibration |
return; |
|
// |
|
|
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)); |
|
|
}; |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// determine upper and lower limits and make space for the new calibration |
|
|
// |
|
|
totime = (UInt_t)atoll(row->GetField(1)); |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " UPDATE GL_TRK_CALIB SET " |
|
|
<< " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
|
|
<< " ID = "<< row->GetField(0) << ";"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
4869 |
}; |
}; |
4870 |
// |
// |
4871 |
oss.str(""); |
// check if the calibration has already been inserted |
|
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) " |
|
|
<< " VALUES (NULL,' " |
|
|
<< idroot << "',"; |
|
4872 |
// |
// |
4873 |
if ( !pk1 ){ |
oss.str(""); |
4874 |
oss << "NULL,"; |
oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
4875 |
|
<< " BOOT_NUMBER = "<< boot_number; // |
4876 |
|
oss << " AND FROM_TIME="<<fromtime; /// NEWNEWNEW -- VA BENE ?!?!?!?! |
4877 |
|
oss << " AND ( ( "; |
4878 |
|
if ( pk1 ){ |
4879 |
|
oss << " OBT1 = "<< obt1 << " AND " |
4880 |
|
<< " PKT1 = "<< pkt1 |
4881 |
|
<< " ) OR ( "; |
4882 |
} else { |
} else { |
4883 |
oss << "'" |
oss << " PKT1 = "<< pkt2-1 |
4884 |
<< t1 << "',"; |
<< " ) OR ( "; |
4885 |
}; |
}; |
4886 |
// |
if ( pk2 ){ |
4887 |
if ( !pk2 ){ |
oss << " OBT2 = "<< obt2 << " AND " |
4888 |
oss << "NULL,'"; |
<< " PKT2 = "<< pkt2; |
4889 |
} else { |
} else { |
4890 |
oss << "'" |
oss << " PKT2 = "<< pkt1+1; |
4891 |
<< t2 << "','"; |
}; |
4892 |
}; |
oss << " ) );"; |
4893 |
|
// |
4894 |
|
if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
4895 |
|
result = conn->Query(oss.str().c_str()); |
4896 |
// |
// |
4897 |
oss << fromtime << "','" |
if ( !result ) throw -4; |
|
<< totime << "','" |
|
|
<< obt1 << "','" |
|
|
<< pkt1 << "','" |
|
|
<< obt2 << "','" |
|
|
<< pkt2 << "','" |
|
|
<< this->GetBOOTnumber() << "','" |
|
|
<< valid << "');"; |
|
4898 |
// |
// |
4899 |
if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
row = result->Next(); |
4900 |
// |
// |
4901 |
|
if ( row ){ |
4902 |
|
// |
4903 |
|
if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
4904 |
|
if ( PEDANTIC ) throw -80; |
4905 |
|
// |
4906 |
|
} else { |
4907 |
|
// |
4908 |
|
// we have to insert a new calibration, check where to place it |
4909 |
|
// |
4910 |
|
oss.str(""); |
4911 |
|
oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
4912 |
|
<< " FROM_TIME < "<< fromtime << " AND " |
4913 |
|
<< " TO_TIME > "<< fromtime << ";"; |
4914 |
|
// |
4915 |
|
if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
4916 |
|
result = conn->Query(oss.str().c_str()); |
4917 |
|
// |
4918 |
|
if ( !result ) throw -4; |
4919 |
|
// |
4920 |
|
row = result->Next(); |
4921 |
|
// |
4922 |
|
if ( !row ){ |
4923 |
|
// |
4924 |
|
// no calibrations in the db contain our calibration |
4925 |
|
// |
4926 |
|
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
4927 |
|
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 |
4928 |
|
// |
4929 |
|
oss.str(""); |
4930 |
|
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
4931 |
|
<< " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
4932 |
|
// |
4933 |
|
if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
4934 |
|
result = conn->Query(oss.str().c_str()); |
4935 |
|
// |
4936 |
|
if ( !result ) throw -4; |
4937 |
|
// |
4938 |
|
row = result->Next(); |
4939 |
|
if ( !row ){ |
4940 |
|
totime = numeric_limits<UInt_t>::max(); |
4941 |
|
} else { |
4942 |
|
totime = (UInt_t)atoll(row->GetField(0)); |
4943 |
|
}; |
4944 |
|
// |
4945 |
|
} else { |
4946 |
|
// |
4947 |
|
// determine upper and lower limits and make space for the new calibration |
4948 |
|
// |
4949 |
|
totime = (UInt_t)atoll(row->GetField(1)); |
4950 |
|
// |
4951 |
|
oss.str(""); |
4952 |
|
oss << " UPDATE GL_TRK_CALIB SET " |
4953 |
|
<< " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
4954 |
|
<< " ID = "<< row->GetField(0) << ";"; |
4955 |
|
// |
4956 |
|
if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4957 |
|
result = conn->Query(oss.str().c_str()); |
4958 |
|
// |
4959 |
|
if ( !result ) throw -4; |
4960 |
|
// |
4961 |
|
}; |
4962 |
|
// |
4963 |
|
oss.str(""); |
4964 |
|
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) " |
4965 |
|
<< " VALUES (NULL,' " |
4966 |
|
<< idroot << "',"; |
4967 |
|
// |
4968 |
|
if ( !pk1 ){ |
4969 |
|
oss << "NULL,"; |
4970 |
|
} else { |
4971 |
|
oss << "'" |
4972 |
|
<< t1 << "',"; |
4973 |
|
}; |
4974 |
|
// |
4975 |
|
if ( !pk2 ){ |
4976 |
|
oss << "NULL,'"; |
4977 |
|
} else { |
4978 |
|
oss << "'" |
4979 |
|
<< t2 << "','"; |
4980 |
|
}; |
4981 |
|
// |
4982 |
|
oss << fromtime << "','" |
4983 |
|
<< totime << "','" |
4984 |
|
<< obt1 << "','" |
4985 |
|
<< pkt1 << "','" |
4986 |
|
<< obt2 << "','" |
4987 |
|
<< pkt2 << "','" |
4988 |
|
<< boot_number << "','" |
4989 |
|
<< valid << "');"; |
4990 |
|
// |
4991 |
|
if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
4992 |
|
// |
4993 |
|
result = conn->Query(oss.str().c_str()); |
4994 |
|
// |
4995 |
|
if ( !result ) throw -4; |
4996 |
|
// |
4997 |
|
}; |
4998 |
|
|
4999 |
|
oss.str(""); |
5000 |
|
oss << " SELECT ID FROM GL_TRK_CALIB ORDER BY ID DESC LIMIT 1 ;"; |
5001 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5002 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
5003 |
|
if ( !result ) throw -4;; |
5004 |
|
row = result->Next(); |
5005 |
|
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
5006 |
// |
// |
5007 |
if ( !result ) throw -4; |
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5008 |
// |
// |
|
}; |
|
|
// |
|
5009 |
}; |
}; |
5010 |
|
|
5011 |
/** |
/** |
5012 |
* Scan tracker calibrations packets, fill the GL_TRK_CALIB table |
* Scan tracker calibrations packets, fill the GL_TRK_CALIB table |
5013 |
*/ |
*/ |
5014 |
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++){ |
|
5015 |
// |
// |
5016 |
pret2 = t2; |
CalibTrk1Event *caltrk1 = 0; |
5017 |
tr1->GetEntry(t1); |
CalibTrk2Event *caltrk2 = 0; |
5018 |
|
TTree *tr1 = 0; |
5019 |
|
TTree *tr2 = 0; |
5020 |
|
EventHeader *eh1 = 0; |
5021 |
|
PscuHeader *ph1 = 0; |
5022 |
|
EventHeader *eh2 = 0; |
5023 |
|
PscuHeader *ph2 = 0; |
5024 |
// |
// |
5025 |
ph1 = eh1->GetPscuHeader(); |
PacketType *pctp=0; |
5026 |
obt1 = ph1->GetOrbitalTime(); |
EventCounter *codt2=0; |
|
pkt1 = ph1->GetCounter(); |
|
|
fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); |
|
5027 |
// |
// |
5028 |
// valid = 1; |
Int_t nevents1 = 0; |
5029 |
// // |
Int_t nevents2 = 0; |
|
// if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 |
|
5030 |
// |
// |
5031 |
|
fromtime = 0; |
5032 |
// |
// |
5033 |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
obt1 = 0; |
5034 |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
pkt1 = 0; |
5035 |
// |
obt2 = 0; |
5036 |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); |
pkt2 = 0; |
5037 |
// |
// |
5038 |
valid = ValidateTrkCalib( caltrk1, eh1 ); |
tr1 = (TTree*)file->Get("CalibTrk1"); |
5039 |
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
if ( !tr1 || tr1->IsZombie() ) throw -22; |
5040 |
// |
tr2 = (TTree*)file->Get("CalibTrk2"); |
5041 |
// Do we have the second calibration packet? |
if ( !tr2 || tr2->IsZombie() ) throw -23; |
5042 |
// |
// |
5043 |
while ( t2t1cal < t1+1 ){ // get the calibration packet2 that follows the packet1 |
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
5044 |
|
tr1->SetBranchAddress("Header", &eh1); |
5045 |
|
nevents1 = tr1->GetEntries(); |
5046 |
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
5047 |
|
tr2->SetBranchAddress("Header", &eh2); |
5048 |
|
nevents2 = tr2->GetEntries(); |
5049 |
|
// |
5050 |
|
if ( !nevents1 && !nevents2 ) return(1); |
5051 |
|
// |
5052 |
|
t2 = -1; |
5053 |
|
Int_t pret2 = 0; |
5054 |
|
Int_t t2t1cal = 0; |
5055 |
|
// |
5056 |
|
bool MISSING_pkt1 = true; |
5057 |
|
bool MISSING_pkt2 = true; |
5058 |
|
int ncalib = 0; |
5059 |
|
bool try_to_recover = false; |
5060 |
|
// |
5061 |
|
for (t1=0; t1 < nevents1; t1++){//loop over packet1 |
5062 |
// |
// |
5063 |
t2++; |
pret2 = t2; |
5064 |
|
tr1->GetEntry(t1); |
5065 |
// |
// |
5066 |
pret2 = t2 - 1; // EMILIANO |
ph1 = eh1->GetPscuHeader(); |
5067 |
|
obt1 = ph1->GetOrbitalTime(); |
5068 |
|
pkt1 = ph1->GetCounter(); |
5069 |
|
fromtime = GetAbsTime(ph1->GetOrbitalTime()); |
5070 |
// |
// |
5071 |
if ( t2 < nevents2 ){ |
// chek if the packet number and obt are consistent with the other packets ??? |
5072 |
tr2->GetEntry(t2); |
// |
5073 |
codt2 = eh2->GetCounter(); |
if ( PKT(pkt1) >= PKT(pktfirst) && PKT(pkt1) <= upperpkt && OBT(obt1) >= OBT(obtfirst) && OBT(obt1) <= upperobt ){ |
5074 |
t2t1cal = codt2->Get(pctp->CalibTrk1); |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ |
5075 |
// |
// |
5076 |
ph2 = eh2->GetPscuHeader(); |
if ( IsDebug() ) printf("\n Trk calibration1 %u at time %u obt %u pkt %u \n",t1,fromtime,obt1,pkt1); |
5077 |
obt2 = ph2->GetOrbitalTime(); |
// |
5078 |
pkt2 = ph2->GetCounter(); |
valid = ValidateTrkCalib( caltrk1, eh1 ); |
5079 |
// |
if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl; |
5080 |
if ( IsDebug() ) printf(" This is a trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
// |
5081 |
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
// Do we have the second calibration packet? |
5082 |
// |
// |
5083 |
|
if ( IsDebug() ) cout << " Loop over calibration2 to search associated calibration: "<<endl; |
5084 |
|
while ( t2t1cal < t1+1 ){ // get the calibration packet2 that follows the packet1 |
5085 |
|
// |
5086 |
|
t2++; |
5087 |
|
// |
5088 |
|
pret2 = t2 - 1; // EMILIANO |
5089 |
|
// |
5090 |
|
if ( t2 < nevents2 ){ |
5091 |
|
tr2->GetEntry(t2); |
5092 |
|
codt2 = eh2->GetCounter(); |
5093 |
|
t2t1cal = codt2->Get(pctp->CalibTrk1); |
5094 |
|
// |
5095 |
|
ph2 = eh2->GetPscuHeader(); |
5096 |
|
obt2 = ph2->GetOrbitalTime(); |
5097 |
|
pkt2 = ph2->GetCounter(); |
5098 |
|
// |
5099 |
|
if ( IsDebug() ) printf(" >> trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
5100 |
|
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
5101 |
|
// |
5102 |
|
} else { |
5103 |
|
// |
5104 |
|
// running out of vector without finding the corresponding calibration, sig |
5105 |
|
// |
5106 |
|
if ( IsDebug() ) printf(" t2 >= nevents2 \n"); |
5107 |
|
pret2 = t2; |
5108 |
|
obt2 = 0; |
5109 |
|
// pkt2 = pkt1+2; |
5110 |
|
pkt2 = 0; |
5111 |
|
t2t1cal = t1+1; |
5112 |
|
}; |
5113 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
5114 |
|
|
5115 |
|
// EMILIANO |
5116 |
|
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
5117 |
|
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
5118 |
|
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
5119 |
|
// // |
5120 |
|
// // running out of vector without finding the corresponding calibration, sig |
5121 |
|
// // |
5122 |
|
// pret2 = t2; |
5123 |
|
// obt2 = 0; |
5124 |
|
// // pkt2 = pkt1+2; |
5125 |
|
// pkt2 = 0; |
5126 |
|
// t2t1cal = t1+1; |
5127 |
|
// }; |
5128 |
|
|
5129 |
|
|
5130 |
|
// |
5131 |
|
}; |
5132 |
|
// |
5133 |
|
if ( IsDebug() ) printf(" Check if trk calibration2 is the right one \n"); |
5134 |
|
// |
5135 |
|
// EMILIANO |
5136 |
|
if ( ( PKT(pkt2) < PKT(pktfirst) || PKT(pkt2) > upperpkt) || (OBT(obt2) < OBT(obtfirst) || OBT(obt2) > upperobt) ){ |
5137 |
|
// if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
5138 |
|
if ( IsDebug() ) printf(" *WARNING* The calibration found is outside the interval, sig \n"); |
5139 |
|
// |
5140 |
|
// running out of vector without finding the corresponding calibration, sig |
5141 |
|
// |
5142 |
|
pret2 = t2; |
5143 |
|
obt2 = 0; |
5144 |
|
pkt2 = 0; |
5145 |
|
}; |
5146 |
|
if ( PKT(pkt2) == PKT(pkt1)+1 ){ |
5147 |
|
if ( IsDebug() ) cout << " ...OK"<<endl; |
5148 |
|
// ======================= |
5149 |
|
// The calibration is good |
5150 |
|
// ======================= |
5151 |
|
// |
5152 |
|
// if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2); |
5153 |
|
// if ( IsDebug() ) printf(" Trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); |
5154 |
|
// if ( IsDebug() ) printf("\n Trk calibration2 at time %u obt %u pkt %u \n",fromtime,obt2,pkt2); |
5155 |
|
if ( IsDebug() ) printf(" Trk calibration2 %u at time %u obt %u pkt %u \n",t2,fromtime,obt2,pkt2); |
5156 |
|
// |
5157 |
|
UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); |
5158 |
|
if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl; |
5159 |
|
// valid = valid & valid2; |
5160 |
|
valid = valid & valid2; //QUESTO VA CAMBIATO |
5161 |
|
// |
5162 |
|
// Handle good calib |
5163 |
|
// |
5164 |
|
MISSING_pkt1 = false; |
5165 |
|
MISSING_pkt2 = false; |
5166 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5167 |
|
// |
5168 |
|
// Check for missing calibtrk1 |
5169 |
|
// |
5170 |
|
if ( t2 != pret2+1 ){ |
5171 |
|
// |
5172 |
|
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); |
5173 |
|
// |
5174 |
|
while ( t2 > pret2+1 ){ |
5175 |
|
// |
5176 |
|
// handle missing calib1 |
5177 |
|
// |
5178 |
|
pret2++; |
5179 |
|
// |
5180 |
|
obt1 = 0; |
5181 |
|
pkt1 = 0; |
5182 |
|
// |
5183 |
|
tr2->GetEntry(pret2); |
5184 |
|
ph2 = eh2->GetPscuHeader(); |
5185 |
|
obt2 = ph2->GetOrbitalTime(); |
5186 |
|
pkt2 = ph2->GetCounter(); |
5187 |
|
// |
5188 |
|
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
5189 |
|
// |
5190 |
|
valid = 0; |
5191 |
|
MISSING_pkt1 = true; |
5192 |
|
MISSING_pkt2 = false; |
5193 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5194 |
|
// |
5195 |
|
}; |
5196 |
|
// |
5197 |
|
}; |
5198 |
|
// |
5199 |
|
} else if ( this->PKT(pkt2) > this->PKT(pkt1)+1 ){ |
5200 |
|
// |
5201 |
|
// Check for missing calibtrk2 |
5202 |
|
// |
5203 |
|
if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
5204 |
|
t2 = pret2; |
5205 |
|
// |
5206 |
|
// handle missing calib2 |
5207 |
|
// |
5208 |
|
obt2 = 0; |
5209 |
|
pkt2 = 0; |
5210 |
|
valid = 0; |
5211 |
|
MISSING_pkt1 = false; |
5212 |
|
MISSING_pkt2 = true; |
5213 |
|
// this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5214 |
|
// |
5215 |
|
}; |
5216 |
|
// |
5217 |
|
|
5218 |
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
5219 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5220 |
|
ncalib++; |
5221 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
5222 |
|
} |
5223 |
|
|
5224 |
|
|
5225 |
} else { |
} else { |
5226 |
// |
// |
5227 |
// 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); |
5228 |
// |
// if ( PEDANTIC ) throw -79; |
5229 |
if ( IsDebug() ) printf(" t2 >= nevents2 \n"); |
// |
|
pret2 = t2; |
|
|
obt2 = 0; |
|
|
// pkt2 = pkt1+2; |
|
|
pkt2 = 0; |
|
|
t2t1cal = t1+1; |
|
5230 |
}; |
}; |
5231 |
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
// |
5232 |
|
|
5233 |
// 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; |
|
|
// }; |
|
5234 |
|
|
5235 |
|
|
5236 |
|
|
5237 |
|
// |
5238 |
|
// we have one more calib pkt2 ! |
5239 |
|
// |
5240 |
|
t2++; |
5241 |
|
while ( t2 < nevents2 ){ |
5242 |
// |
// |
5243 |
}; |
// 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 |
|
5244 |
// |
// |
5245 |
this->HandleTRK_CALIB(true,true); |
if ( IsDebug() ) printf(" t2 is %u nevents2 is %u \n",t2,nevents2); |
5246 |
|
obt1 = 0; |
5247 |
|
pkt1 = 0; |
5248 |
// |
// |
5249 |
// Check for missing calibtrk1 |
tr2->GetEntry(t2); |
5250 |
|
ph2 = eh2->GetPscuHeader(); |
5251 |
|
obt2 = ph2->GetOrbitalTime(); |
5252 |
|
pkt2 = ph2->GetCounter(); |
5253 |
// |
// |
5254 |
if ( t2 != pret2+1 ){ |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
5255 |
// |
valid = 0; |
5256 |
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 ){ |
5257 |
// |
// EMILIANO |
5258 |
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 ){ |
5259 |
// |
// 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(); |
|
5260 |
// |
// |
5261 |
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); |
5262 |
// |
// |
5263 |
valid = 0; |
MISSING_pkt1 = true; |
5264 |
this->HandleTRK_CALIB(false,true); |
MISSING_pkt2 = false; |
5265 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
5266 |
|
ncalib++; |
5267 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
5268 |
// |
// |
|
}; |
|
|
// |
|
5269 |
}; |
}; |
5270 |
// |
// |
5271 |
} 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; |
|
5272 |
// |
// |
5273 |
// handle missing calib2 |
}; |
5274 |
|
|
5275 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5276 |
|
// ----------------------------------------------------------------- |
5277 |
|
// in case of corruption, check if the calibration can be recovered |
5278 |
|
// from another chewbacca file |
5279 |
|
// ----------------------------------------------------------------- |
5280 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5281 |
|
|
5282 |
|
// cout <<" TRY TO RECOVER ?? "<<try_to_recover<<endl; |
5283 |
|
|
5284 |
|
if(chewbacca&&try_to_recover){ |
5285 |
|
|
5286 |
|
|
5287 |
|
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
5288 |
|
|
5289 |
|
TSQLResult *result = 0; |
5290 |
|
TSQLRow *row = 0; |
5291 |
// |
// |
5292 |
obt2 = 0; |
stringstream oss; |
5293 |
pkt2 = 0; |
oss.str(""); |
|
valid = 0; |
|
|
this->HandleTRK_CALIB(true,false); |
|
5294 |
// |
// |
5295 |
}; |
|
5296 |
// |
//////////////////////////////////////////////////////////////////////// |
5297 |
} else { |
// retrieve the name of the current file: |
5298 |
// |
//////////////////////////////////////////////////////////////////////// |
5299 |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
oss.str(""); |
5300 |
// if ( PEDANTIC ) throw -79; |
oss << "SELECT NAME FROM GL_ROOT where ID=" << GetID_ROOT() <<";"; |
5301 |
// |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5302 |
}; |
|
5303 |
// |
result = conn->Query(oss.str().c_str()); |
5304 |
}; |
if ( !result ) throw -4;; |
5305 |
// |
row = result->Next(); |
5306 |
// we have one more calib pkt2 ! |
TString thisfilename = (TString)row->GetField(0); |
5307 |
// |
if ( IsDebug() ) cout << "Current file ==> "<<thisfilename<<endl; |
5308 |
t2++; |
|
5309 |
while ( t2 < nevents2 ){ |
//////////////////////////////////////////////////////////////////////// |
5310 |
// |
// read all the calibrations inserted |
5311 |
// handle missing calib1 |
//////////////////////////////////////////////////////////////////////// |
5312 |
// |
oss.str(""); |
5313 |
if ( IsDebug() ) printf(" t2 is %u nevents2 is %u \n",t2,nevents2); |
oss << " SELECT "; |
5314 |
obt1 = 0; |
oss << " ID,FROM_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,TO_TIME"; |
5315 |
pkt1 = 0; |
oss << " FROM GL_TRK_CALIB "; |
5316 |
// |
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
5317 |
tr2->GetEntry(t2); |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5318 |
ph2 = eh2->GetPscuHeader(); |
|
5319 |
obt2 = ph2->GetOrbitalTime(); |
result = conn->Query(oss.str().c_str()); |
5320 |
pkt2 = ph2->GetCounter(); |
if ( !result ) throw -4;; |
5321 |
// |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5322 |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
|
5323 |
valid = 0; |
// ----------------------------------- |
5324 |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
// loop over calibrations ... |
5325 |
// EMILIANO |
// ----------------------------------- |
5326 |
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; |
5327 |
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
do { |
5328 |
// |
row = result->Next(); |
5329 |
if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); |
if(!row)break; |
5330 |
// |
|
5331 |
this->HandleTRK_CALIB(false,true); |
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5332 |
// |
UInt_t fromtime = (UInt_t)atoll(row->GetField(1)); |
5333 |
}; |
UInt_t obt1 = (UInt_t)atoll(row->GetField(2)); |
5334 |
// |
UInt_t pkt1 = (UInt_t)atoll(row->GetField(3)); |
5335 |
t2++; |
UInt_t obt2 = (UInt_t)atoll(row->GetField(4)); |
5336 |
// |
UInt_t pkt2 = (UInt_t)atoll(row->GetField(5)); |
5337 |
}; |
UInt_t boot = (UInt_t)atoll(row->GetField(6)); |
5338 |
|
UInt_t valid = (UInt_t)atoll(row->GetField(7)); |
5339 |
|
bool MISSING_pkt1 = (row->GetFieldLength(8)==0); |
5340 |
|
bool MISSING_pkt2 = (row->GetFieldLength(9)==0); |
5341 |
|
UInt_t totime = (UInt_t)atoll(row->GetField(10)); |
5342 |
|
|
5343 |
|
// ------------------------------------- |
5344 |
|
// ...check if the entry is corrupted... |
5345 |
|
// ------------------------------------- |
5346 |
|
cout <<"*** "<< MISSING_pkt1 << MISSING_pkt2 << valid <<endl; |
5347 |
|
bool CORRUPTED = (MISSING_pkt1||MISSING_pkt2||!valid); |
5348 |
|
|
5349 |
|
if ( IsDebug() ) cout << "("<<nn<<") ID = "<<id<<" from GL_TRK_CALIB ==> corrupted ? "<<CORRUPTED<<endl; |
5350 |
|
|
5351 |
|
// if( !CORRUPTED )continue; // nothing to do |
5352 |
|
|
5353 |
|
///////////////////////////////////////////////////////// |
5354 |
|
// if it is corrupted, ...look for ather chewbacca files |
5355 |
|
// containing the same calibrations ... |
5356 |
|
///////////////////////////////////////////////////////// |
5357 |
|
|
5358 |
|
bool this_MISSING_pkt1 = false; |
5359 |
|
bool this_MISSING_pkt2 = false; |
5360 |
|
int this_t1=0; |
5361 |
|
int this_t2=0;; |
5362 |
|
UInt_t this_valid = 0; |
5363 |
|
|
5364 |
|
TString path = ""; |
5365 |
|
TString name = ""; |
5366 |
|
TString raw = ""; |
5367 |
|
UInt_t obt0 = 0; |
5368 |
|
UInt_t timesync = 0; |
5369 |
|
UInt_t boot_number = 0; |
5370 |
|
bool FOUND = false; |
5371 |
|
|
5372 |
|
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5373 |
|
|
5374 |
|
// for(int itable=0; itable<2; itable++){ |
5375 |
|
for(int itable=0; itable<1; itable++){ |
5376 |
|
|
5377 |
|
// ------------------------------------------------------ |
5378 |
|
// loop over both ROOT_TABLE and ROOT_TABLE_BAD |
5379 |
|
// ------------------------------------------------------ |
5380 |
|
|
5381 |
|
TString table = "ROOT_TABLE"; |
5382 |
|
if(itable==1)table = "ROOT_TABLE_BAD"; |
5383 |
|
|
5384 |
|
oss.str(""); |
5385 |
|
oss << " SELECT "; |
5386 |
|
oss << " FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,BOOT_NUMBER,INPUT_NAME "; |
5387 |
|
oss << " FROM "<<table; |
5388 |
|
oss << " WHERE 1 " << endl; |
5389 |
|
oss << " AND FILE_NAME != \""<< thisfilename<<"\""; |
5390 |
|
if( !MISSING_pkt1 ){ |
5391 |
|
oss << " AND "; |
5392 |
|
oss << " PKT_NUMBER_INIT < "<<pkt1; |
5393 |
|
oss << " AND "; |
5394 |
|
oss << " PKT_NUMBER_FINAL > "<<pkt1; |
5395 |
|
oss << " AND "; |
5396 |
|
oss << " PKT_OBT_INIT < "<<obt1; |
5397 |
|
oss << " AND "; |
5398 |
|
oss << " PKT_OBT_FINAL > "<<obt1; |
5399 |
|
}else{ |
5400 |
|
if(pkt2>1) pkt1 = pkt2-1;//serve dopo |
5401 |
|
} |
5402 |
|
if( !MISSING_pkt2 ){ |
5403 |
|
oss << " AND "; |
5404 |
|
oss << " PKT_NUMBER_INIT < "<<pkt2; |
5405 |
|
oss << " AND "; |
5406 |
|
oss << " PKT_NUMBER_FINAL > "<<pkt2; |
5407 |
|
oss << " AND "; |
5408 |
|
oss << " PKT_OBT_INIT < "<<obt2; |
5409 |
|
oss << " AND "; |
5410 |
|
oss << " PKT_OBT_FINAL > "<<obt2; |
5411 |
|
}else{ |
5412 |
|
if(pkt1>0) pkt2 = pkt1+1;//serve dopo |
5413 |
|
} |
5414 |
|
if( boot> 0 ){ |
5415 |
|
oss << " AND "; |
5416 |
|
oss << " BOOT_NUMBER = "<<boot; |
5417 |
|
}else{ |
5418 |
|
} |
5419 |
|
oss << " ORDER BY BAD_PKT_CALREAD ASC; "; |
5420 |
|
|
5421 |
|
TSQLResult *result2 = 0; |
5422 |
|
TSQLRow *row2 = 0; |
5423 |
|
|
5424 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5425 |
|
result2 = conn->Query(oss.str().c_str()); |
5426 |
|
if ( !result2 ) throw -4;; |
5427 |
|
if ( IsDebug() ) cout <<"Rows: "<<result2->GetRowCount()<<endl; |
5428 |
|
|
5429 |
|
// ------------------------------------------------------ |
5430 |
|
// loop over files containing repetition (if any) |
5431 |
|
// ------------------------------------------------------ |
5432 |
|
do { |
5433 |
|
row2 = result2->Next(); |
5434 |
|
if(!row2)break; |
5435 |
|
|
5436 |
|
// ------------------------------------------------------ |
5437 |
|
// ... a repetition is found ... |
5438 |
|
// ------------------------------------------------------ |
5439 |
|
path = (TString)row2->GetField(0); |
5440 |
|
name = (TString)row2->GetField(1); |
5441 |
|
raw = (TString)row2->GetField(5); |
5442 |
|
obt0 = (UInt_t)atoll(row2->GetField(2)); |
5443 |
|
timesync = (UInt_t)atoll(row2->GetField(3)); |
5444 |
|
boot_number = (UInt_t)atoll(row2->GetField(4)); |
5445 |
|
|
5446 |
|
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
5447 |
|
// cout << path <<endl; |
5448 |
|
// cout << "File : " <<name <<endl; |
5449 |
|
// cout << obt0 <<endl; |
5450 |
|
// cout << timesync <<endl; |
5451 |
|
// cout << "boot n. : "<<boot_number <<endl; |
5452 |
|
// cout << raw <<endl; |
5453 |
|
|
5454 |
|
// ------------------------------------------------------ |
5455 |
|
// ... retrieve the calibration packets. |
5456 |
|
// ------------------------------------------------------ |
5457 |
|
if ( IsDebug() ) printf(" file is %s/%s \n",((TString)gSystem->ExpandPathName(path.Data())).Data(),name.Data()); |
5458 |
|
TFile *file = new TFile(((TString)gSystem->ExpandPathName(path.Data()))+"/"+name); // EM, path could be symbolic and we must expand it |
5459 |
|
if(!file)throw -100; |
5460 |
|
if(file->IsZombie())throw -100; |
5461 |
|
// |
5462 |
|
tr1 = (TTree*)file->Get("CalibTrk1"); |
5463 |
|
if ( !tr1 || tr1->IsZombie() ) throw -22; |
5464 |
|
tr2 = (TTree*)file->Get("CalibTrk2"); |
5465 |
|
if ( !tr2 || tr2->IsZombie() ) throw -23; |
5466 |
|
// |
5467 |
|
tr1->SetBranchAddress("CalibTrk1", &caltrk1); |
5468 |
|
tr1->SetBranchAddress("Header", &eh1); |
5469 |
|
nevents1 = tr1->GetEntries(); |
5470 |
|
tr2->SetBranchAddress("CalibTrk2", &caltrk2); |
5471 |
|
tr2->SetBranchAddress("Header", &eh2); |
5472 |
|
nevents2 = tr2->GetEntries(); |
5473 |
|
for(this_t1=0; this_t1<nevents1; this_t1++){ |
5474 |
|
tr1->GetEntry(this_t1); |
5475 |
|
if( |
5476 |
|
(UInt_t)eh1->GetPscuHeader()->GetCounter() == pkt1 && |
5477 |
|
true) break; |
5478 |
|
this_MISSING_pkt1 = true; |
5479 |
|
} |
5480 |
|
for(this_t2=0; this_t2<nevents2; this_t2++){ |
5481 |
|
tr2->GetEntry(this_t2); |
5482 |
|
if( |
5483 |
|
(UInt_t)eh2->GetPscuHeader()->GetCounter() == pkt2 && |
5484 |
|
true) break; |
5485 |
|
this_MISSING_pkt2 = true; |
5486 |
|
} |
5487 |
|
this_valid = |
5488 |
|
ValidateTrkCalib( caltrk1, eh1, file ) |
5489 |
|
* |
5490 |
|
ValidateTrkCalib( caltrk2, eh2, file ); |
5491 |
|
|
5492 |
|
// --------------------------------------------------------------------- |
5493 |
|
// accept the calibration if it is better than the previous: |
5494 |
|
// |
5495 |
|
// - if the new calibration is perfect (both valid packets) |
5496 |
|
// - if the new calibration has both the packets and the previous does not |
5497 |
|
// --------------------------------------------------------------------- |
5498 |
|
if( |
5499 |
|
( !this_MISSING_pkt1&&!this_MISSING_pkt2&&this_valid )|| |
5500 |
|
( (MISSING_pkt1||MISSING_pkt2) && (!this_MISSING_pkt1&&!this_MISSING_pkt2) )|| |
5501 |
|
false)FOUND=true; |
5502 |
|
|
5503 |
|
if(file)file->Close(); |
5504 |
|
|
5505 |
|
if(FOUND)break; |
5506 |
|
|
5507 |
|
}while(1);//endl loop over root table entries |
5508 |
|
|
5509 |
|
if(FOUND)break; |
5510 |
|
|
5511 |
|
}//end loop over tables |
5512 |
|
|
5513 |
|
if(FOUND){ |
5514 |
|
|
5515 |
|
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
5516 |
|
|
5517 |
|
//////////////////////////////////////////// |
5518 |
|
// insert a new entry in GL_TRK_CALIB and |
5519 |
|
// modify the time-tag of the previous one |
5520 |
|
//////////////////////////////////////////// |
5521 |
|
|
5522 |
|
// --------------------------------------------------------------------- |
5523 |
|
// step 1: insert a new raw file in GL_RAW |
5524 |
|
// --------------------------------------------------------------------- |
5525 |
|
// |
5526 |
|
// check if the raw file already exist |
5527 |
|
// |
5528 |
|
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 |
5529 |
|
// oss.str(""); |
5530 |
|
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
5531 |
|
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5532 |
|
|
5533 |
|
// result = conn->Query(oss.str().c_str()); |
5534 |
|
// if ( !result ) throw -4;; |
5535 |
|
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5536 |
|
// if( result->GetRowCount() == 0){ |
5537 |
|
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
5538 |
|
// // - - - - - - - - - - - |
5539 |
|
// // insert new raw file |
5540 |
|
// // - - - - - - - - - - - |
5541 |
|
// GL_RAW glraw = GL_RAW(); |
5542 |
|
// glraw.PATH = gSystem->DirName(raw.Data()); |
5543 |
|
// glraw.NAME = gSystem->BaseName(raw.Data()); |
5544 |
|
// glraw.BOOT_NUMBER = boot_number; |
5545 |
|
// // |
5546 |
|
// insertPamelaRawFile( &glraw ); |
5547 |
|
// // |
5548 |
|
// id_raw = glraw.ID; |
5549 |
|
// }else{ |
5550 |
|
// row = result->Next(); |
5551 |
|
// id_raw = (UInt_t)atoll(row->GetField(0)); |
5552 |
|
// } |
5553 |
|
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
5554 |
|
|
5555 |
|
// --------------------------------------------------------------------- |
5556 |
|
// step 1(bis): retrieve the timesync id associated to the file |
5557 |
|
// (NB, uso lo stesso associato al file iniziale) |
5558 |
|
// --------------------------------------------------------------------- |
5559 |
|
UInt_t idtimesync = 0; |
5560 |
|
oss.str(""); |
5561 |
|
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
5562 |
|
if ( debug ) printf(" %s \n",oss.str().c_str()); |
5563 |
|
result = conn->Query(oss.str().c_str()); |
5564 |
|
if ( !result ) throw -3; |
5565 |
|
row = result->Next(); |
5566 |
|
if ( !row ) throw -3; |
5567 |
|
idtimesync = (UInt_t)atoll(row->GetField(0)); |
5568 |
|
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
5569 |
|
|
5570 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5571 |
|
// --------------------------------------------------------------------- |
5572 |
|
// step 2: insert a new root file in GL_ROOT |
5573 |
|
// --------------------------------------------------------------------- |
5574 |
|
// |
5575 |
|
// check if the root file already exist |
5576 |
|
// |
5577 |
|
UInt_t id_root = 0; |
5578 |
|
oss.str(""); |
5579 |
|
oss << "SELECT ID FROM GL_ROOT where NAME=\"" << gSystem->BaseName(name.Data()) <<"\";"; |
5580 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5581 |
|
|
5582 |
|
result = conn->Query(oss.str().c_str()); |
5583 |
|
if ( !result ) throw -4;; |
5584 |
|
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5585 |
|
if( result->GetRowCount() == 0){ |
5586 |
|
if ( IsDebug() ) cout << " << Insert new ROOT file >> "<<endl; |
5587 |
|
// - - - - - - - - - - - |
5588 |
|
// insert new root file |
5589 |
|
// - - - - - - - - - - - |
5590 |
|
GL_ROOT glroot = GL_ROOT(); |
5591 |
|
glroot.ID_RAW = id_raw; |
5592 |
|
glroot.ID_TIMESYNC = idtimesync; |
5593 |
|
// |
5594 |
|
// 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, |
5595 |
|
// NOT STATIC NOT KEEPENV = $PAM_L0 must be used in the DB |
5596 |
|
// |
5597 |
|
if ( STATIC ){ |
5598 |
|
glroot.PATH = (TString)gSystem->ExpandPathName(path); |
5599 |
|
} else { |
5600 |
|
if ( KEEPENV ){ |
5601 |
|
glroot.PATH = path; |
5602 |
|
} else { |
5603 |
|
glroot.PATH = "$PAM_L0"; |
5604 |
|
}; |
5605 |
|
}; |
5606 |
|
// glroot.PATH = path; |
5607 |
|
glroot.NAME = name; |
5608 |
|
// |
5609 |
|
insertPamelaRootFile( &glroot ); |
5610 |
|
// |
5611 |
|
id_root = glroot.ID; |
5612 |
|
}else{ |
5613 |
|
row = result->Next(); |
5614 |
|
if(row)id_root = (UInt_t)atoll(row->GetField(0)); |
5615 |
|
} |
5616 |
|
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
5617 |
|
|
5618 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5619 |
|
// --------------------------------------------------------------------- |
5620 |
|
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
5621 |
|
// --------------------------------------------------------------------- |
5622 |
|
if ( IsDebug() ) cout << " << Modify time-tag of calibration ID="<<id<<" >> "<<endl; |
5623 |
|
oss.str(""); |
5624 |
|
oss << " UPDATE GL_TRK_CALIB SET " |
5625 |
|
<< " TO_TIME=0 , FROM_TIME=0 WHERE " |
5626 |
|
<< " ID = "<< id << ";"; |
5627 |
|
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5628 |
|
result = conn->Query(oss.str().c_str()); |
5629 |
|
if ( !result ) throw -4;; |
5630 |
|
|
5631 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5632 |
|
|
5633 |
|
// --------------------------------------------------------------------- |
5634 |
|
// step 4: insert the new calibration: |
5635 |
|
// --------------------------------------------------------------------- |
5636 |
|
if ( IsDebug() ) cout << " << Insert new TRK calibration >> "<<endl; |
5637 |
|
// |
5638 |
|
GL_TRK_CALIB glcal = GL_TRK_CALIB(); |
5639 |
|
// |
5640 |
|
glcal.ID_ROOT_L0 = id_root; |
5641 |
|
glcal.EV_ROOT_CALIBTRK1 = this_t1; |
5642 |
|
glcal.EV_ROOT_CALIBTRK2 = this_t2; |
5643 |
|
glcal.FROM_TIME = fromtime; |
5644 |
|
glcal.TO_TIME = totime; |
5645 |
|
glcal.OBT1 = obt1; |
5646 |
|
glcal.OBT2 = obt2; |
5647 |
|
glcal.PKT1 = pkt1; |
5648 |
|
glcal.PKT2 = pkt1; |
5649 |
|
glcal.BOOT_NUMBER = GetBOOTnumber(); |
5650 |
|
glcal.VALIDATION = this_valid; |
5651 |
|
// |
5652 |
|
HandleTRK_CALIB(&glcal); |
5653 |
|
if ( IsDebug() ) cout << "ID = "<<glcal.ID<<endl; |
5654 |
|
// |
5655 |
|
|
5656 |
|
} |
5657 |
|
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5658 |
|
|
5659 |
|
}while(1);//end loop over calibrations |
5660 |
|
|
5661 |
|
|
5662 |
|
if( result )delete result; |
5663 |
|
if( row )delete row; |
5664 |
|
|
5665 |
|
|
5666 |
|
|
5667 |
|
|
5668 |
|
|
5669 |
|
|
5670 |
|
} |
5671 |
|
|
5672 |
|
|
5673 |
|
// // ------------------------------ |
5674 |
|
// // try to recover the calibration |
5675 |
|
// // ------------------------------ |
5676 |
|
// cout << "TRY TO RECOVER TRACKER CALIBRATION"<<endl; |
5677 |
|
// // |
5678 |
|
// ULong64_t time = 0; //absolute time |
5679 |
|
// string path[100]; //mettere un limite massimo |
5680 |
|
// int nrows = 0; |
5681 |
|
// UInt_t pkt = 0; |
5682 |
|
// UInt_t obt = 0; |
5683 |
|
// char *type = ""; |
5684 |
|
// EventHeader *eh = new EventHeader(); |
5685 |
|
// CalibTrk1Event *c = new CalibTrk1Event(); |
5686 |
|
|
5687 |
|
// // |
5688 |
|
// if(which_is_not_valid==1 || which_is_not_valid==3){ |
5689 |
|
// // |
5690 |
|
// cout << "PKT1 --> missing or corrupted "<<endl; |
5691 |
|
// type = "CalibTrk1"; |
5692 |
|
// pkt = pkt1; |
5693 |
|
// obt = obt1; |
5694 |
|
// time = this->GetAbsTime(obt1); |
5695 |
|
// if( pkt1 == 0 ){//missing |
5696 |
|
// time = this->GetAbsTime(obt2); |
5697 |
|
// pkt = pkt2-1; |
5698 |
|
// } |
5699 |
|
// // |
5700 |
|
// }else if (which_is_not_valid==2 || which_is_not_valid==3){ |
5701 |
|
// // |
5702 |
|
// cout << "PKT2--> missing or corrupted "<<endl; |
5703 |
|
// type = "CalibTrk2 "; |
5704 |
|
// pkt = pkt2; |
5705 |
|
// obt = obt2; |
5706 |
|
// time = this->GetAbsTime(obt2); |
5707 |
|
// if( pkt2 == 0 ){//missing |
5708 |
|
// time = this->GetAbsTime(obt1); |
5709 |
|
// pkt = pkt1+1; |
5710 |
|
// } |
5711 |
|
// // |
5712 |
|
// }else{ |
5713 |
|
// cout << "this should not happen!!! "<<endl; |
5714 |
|
// trow -666; |
5715 |
|
// } |
5716 |
|
|
5717 |
|
// nrows = Query_ROOT_TABLE(time,conn,path);// get the list of file which might contain the packet |
5718 |
|
|
5719 |
|
|
5720 |
|
// for(int r=0; r<nrows; r++){ //loop over rows |
5721 |
|
// if(path)cout << r << " >>>> "<<(path+r)->c_str() << endl; |
5722 |
|
// /// verifica che il file non sia quello gia` aperto |
5723 |
|
// } |
5724 |
|
|
5725 |
|
// //////////////////////////////////////////////////////////////////////// |
5726 |
|
|
5727 |
|
// TSQLResult *result = 0; |
5728 |
|
// TSQLRow *row = 0; |
5729 |
|
// // |
5730 |
|
// stringstream oss; |
5731 |
|
// oss.str(""); |
5732 |
|
// // ---------------------------------------- |
5733 |
|
// // read the id of last calibration inserted |
5734 |
|
// // ---------------------------------------- |
5735 |
|
// oss.str(""); |
5736 |
|
// oss << " SELECT "; |
5737 |
|
// oss << " (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) "; |
5738 |
|
// oss << " ORDER BY ID DESC LIMIT 1; "; |
5739 |
|
|
5740 |
|
// result = conn->Query(oss.str().c_str()); |
5741 |
|
// row = result->Next(); |
5742 |
|
// if( !row )throw -666; |
5743 |
|
|
5744 |
|
// if( result )delete result; |
5745 |
|
// if( row )delete row; |
5746 |
|
|
5747 |
|
// UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5748 |
|
|
5749 |
|
// // ------------------------------------- |
5750 |
|
// // ...and modify it with new parameters |
5751 |
|
// // ------------------------------------- |
5752 |
|
|
5753 |
|
|
5754 |
|
// } |
5755 |
// |
// |
5756 |
return(0); |
return(0); |
5757 |
}; |
}; |
6081 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
6082 |
// |
// |
6083 |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
6084 |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT()<< ";"; |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT(); |
6085 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
6086 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
6087 |
}; |
}; |
6088 |
}; |
}; |
6131 |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
6132 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6133 |
// |
// |
6134 |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< ";"; |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT(); |
6135 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
6136 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
6137 |
}; |
}; |
6138 |
}; |
}; |
6183 |
row2 = result2->Next(); |
row2 = result2->Next(); |
6184 |
// |
// |
6185 |
if ( row2 ){ |
if ( row2 ){ |
6186 |
if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n"); |
if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! \n"); |
6187 |
if ( PEDANTIC ) throw -83; |
if ( PEDANTIC ) throw -83; |
6188 |
row2->Close(); |
row2->Close(); |
6189 |
}; |
}; |
6260 |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
6261 |
// |
// |
6262 |
oss.str(""); |
oss.str(""); |
6263 |
oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE " |
oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER,ID_ROOT_L0 FROM GL_RUN WHERE " |
6264 |
<< " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND (" |
<< " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND (" |
6265 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
6266 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
6318 |
moved++; |
moved++; |
6319 |
// |
// |
6320 |
} else { |
} else { |
6321 |
if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n"); |
|
6322 |
if ( PEDANTIC ) throw -83; |
// questa parte mah mah mah... da controllare |
6323 |
|
|
6324 |
|
// |
6325 |
|
// we end up here if chewbacca and we have RH---| small gap |---RT, in this case the two pieces are attached and moved to GL_RUN. We are now processing the |
6326 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
6327 |
|
// |
6328 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
6329 |
|
// |
6330 |
|
Bool_t OK = false; |
6331 |
|
UInt_t IDRL2A = 0; |
6332 |
|
UInt_t IDRL2B = 0; |
6333 |
|
if ( result2->GetRowCount() == 2 ){ |
6334 |
|
IDRL2A = (UInt_t)atoll(row2->GetField(0)); |
6335 |
|
UInt_t IDRL0A = (UInt_t)atoll(row2->GetField(4)); |
6336 |
|
row2 = result2->Next(); |
6337 |
|
IDRL2B = (UInt_t)atoll(row2->GetField(0)); |
6338 |
|
UInt_t IDRL0B = (UInt_t)atoll(row2->GetField(4)); |
6339 |
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
6340 |
|
// if ( IDRL0A == IDRL0B ){ |
6341 |
|
// TSQLResult *result2a = 0; |
6342 |
|
// TSQLRow *row2a = 0; |
6343 |
|
// oss.str(""); |
6344 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
6345 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
6346 |
|
// result2a = conn->Query(oss.str().c_str()); |
6347 |
|
// // |
6348 |
|
// if ( !result2a ) throw -4; |
6349 |
|
// // |
6350 |
|
// row2a = result2a->Next(); |
6351 |
|
// // |
6352 |
|
// if ( row2a ){ |
6353 |
|
// UInt_t PKA = (UInt_t)atoll(row2a->GetField(0)); |
6354 |
|
// delete result2a; |
6355 |
|
// oss.str(""); |
6356 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
6357 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
6358 |
|
// result2a = conn->Query(oss.str().c_str()); |
6359 |
|
// // |
6360 |
|
// if ( !result2a ) throw -4; |
6361 |
|
// // |
6362 |
|
// row2a = result2a->Next(); |
6363 |
|
// // |
6364 |
|
// if ( row2a ){ |
6365 |
|
// UInt_t PKB = (UInt_t)atoll(row2a->GetField(0)); |
6366 |
|
// // |
6367 |
|
// if ( IsDebug() ) printf(" PKT(PKA) + 1 %llu == runheaderpkt %llu && PKB = runtrailer %llu + 1 %llu \n",PKT(PKA)+1LL, PKT(glrun->GetRUNHEADER_PKT()),PKT(PKB), PKT(glrun->GetRUNTRAILER_PKT())+1LL); |
6368 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
6369 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
6370 |
|
OK = true; |
6371 |
|
// }; |
6372 |
|
// }; |
6373 |
|
// }; |
6374 |
|
// }; |
6375 |
|
}; |
6376 |
|
if ( OK ){ |
6377 |
|
// |
6378 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
6379 |
|
// |
6380 |
|
// we have to update with runheader/trailer infos our run and we have to change the ROOT_ID_FRAG of the header piece ( 1/2 2/1 must become 1/3 3/2 2/1 ) |
6381 |
|
// |
6382 |
|
GL_RUN *glA = new GL_RUN(); |
6383 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
6384 |
|
// |
6385 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
6386 |
|
// |
6387 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
6388 |
|
// |
6389 |
|
oss.str(""); |
6390 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6391 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
6392 |
|
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
6393 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
6394 |
|
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
6395 |
|
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
6396 |
|
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
6397 |
|
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
6398 |
|
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
6399 |
|
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
6400 |
|
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
6401 |
|
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
6402 |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
6403 |
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
6404 |
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
6405 |
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
6406 |
|
// |
6407 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
6408 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
6409 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
6410 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
6411 |
|
// |
6412 |
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
6413 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
6414 |
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
6415 |
|
conn->Query(oss.str().c_str()); |
6416 |
|
// |
6417 |
|
} else { |
6418 |
|
// |
6419 |
|
// sig no runheader, let set anyway what is possible... |
6420 |
|
// |
6421 |
|
oss.str(""); |
6422 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6423 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
6424 |
|
// |
6425 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
6426 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
6427 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
6428 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
6429 |
|
// |
6430 |
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
6431 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
6432 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
6433 |
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
6434 |
|
conn->Query(oss.str().c_str()); |
6435 |
|
}; |
6436 |
|
// |
6437 |
|
// update runheader ROOT_ID_FRAG |
6438 |
|
// |
6439 |
|
oss.str(""); |
6440 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
6441 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
6442 |
|
conn->Query(oss.str().c_str()); |
6443 |
|
// |
6444 |
|
// now let's look for runtrailer if any in the last run |
6445 |
|
// |
6446 |
|
glA->Query_GL_RUN(IDRL2B,conn); |
6447 |
|
// |
6448 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
6449 |
|
// |
6450 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
6451 |
|
// |
6452 |
|
oss.str(""); |
6453 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6454 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
6455 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
6456 |
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
6457 |
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
6458 |
|
// |
6459 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
6460 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
6461 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
6462 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6463 |
|
// |
6464 |
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
6465 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
6466 |
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
6467 |
|
conn->Query(oss.str().c_str()); |
6468 |
|
// |
6469 |
|
} else { |
6470 |
|
// |
6471 |
|
// sig no runtrailer, let set anyway what is possible... |
6472 |
|
// |
6473 |
|
oss.str(""); |
6474 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6475 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
6476 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
6477 |
|
// |
6478 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
6479 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
6480 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
6481 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6482 |
|
// |
6483 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
6484 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
6485 |
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
6486 |
|
conn->Query(oss.str().c_str()); |
6487 |
|
}; |
6488 |
|
// |
6489 |
|
UInt_t myi = glrun->GetID(); |
6490 |
|
oss.str(""); |
6491 |
|
oss << " ID= "<< myi; |
6492 |
|
// |
6493 |
|
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
6494 |
|
// |
6495 |
|
// fill the new run in GL_RUN |
6496 |
|
// |
6497 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
6498 |
|
glrun->Fill_GL_RUN(conn); |
6499 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
6500 |
|
delete glA; |
6501 |
|
moved++; |
6502 |
|
// |
6503 |
|
} else { |
6504 |
|
// |
6505 |
|
// is just a repetition |
6506 |
|
// |
6507 |
|
if ( IsDebug() ) printf(" The run %u is already present in the GL_RUN table...\n",glrun->GetID()); |
6508 |
|
// printf(" CCCCCCCCICCCCCCCCCCCCIOOOOOOOOOO si muove Ciccio! %u \n",glrun->GetID()); |
6509 |
|
// if ( PEDANTIC && glrun->GetID() != 61563 ) throw -83; |
6510 |
|
if ( PEDANTIC ) throw -83; |
6511 |
|
}; |
6512 |
|
// if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! ...\n"); |
6513 |
|
// if ( PEDANTIC ) throw -83; |
6514 |
}; |
}; |
6515 |
if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0)); |
if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0)); |
6516 |
// |
// |
6576 |
// 2) get the OBT of the last validated run |
// 2) get the OBT of the last validated run |
6577 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
6578 |
oss.str(""); |
oss.str(""); |
6579 |
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 |
6580 |
|
oss << " SELECT * FROM GL_RUN WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start |
6581 |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
6582 |
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()); |
6583 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
6720 |
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 |
6721 |
|
|
6722 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
6723 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
// for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
6724 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION); |
6725 |
nseq=0; |
nseq=0; |
6726 |
} |
} |
6727 |
|
|
6742 |
if( CHECK ){ |
if( CHECK ){ |
6743 |
// check if calibration exists |
// check if calibration exists |
6744 |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
6745 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
// Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
6746 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
UInt_t MISSING = MissingTRK_CALIB(t1,t2); |
6747 |
|
UInt_t val = 0; |
6748 |
|
if ( MISSING == 1 ) val = 0; |
6749 |
|
if ( MISSING == 0 ) val = 1; |
6750 |
|
if ( MISSING == 2 ) val = 2; |
6751 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val); |
6752 |
nseq=0; |
nseq=0; |
6753 |
}; |
}; |
6754 |
//-------------- |
//-------------- |
6778 |
* @param t2 To absolute time |
* @param t2 To absolute time |
6779 |
* @return true if there might be a missing calibration |
* @return true if there might be a missing calibration |
6780 |
*/ |
*/ |
6781 |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
//Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
6782 |
|
UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
6783 |
|
|
6784 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
6785 |
|
|
6786 |
// get the closest VALIDATED calibration before the run start (t2) |
// get the closest calibration before the run start (t2) |
6787 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
// if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
6788 |
|
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1); //>>> missing |
6789 |
|
|
6790 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
// if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
6791 |
|
if ( trkcalib->TO_TIME < t2 ) return(1); //>>> missing |
6792 |
|
|
6793 |
//============================================================== |
//============================================================== |
6794 |
// Check is done first on the basis of time between calibration, |
// Check is done first on the basis of time between calibration, |
6805 |
//============================================================== |
//============================================================== |
6806 |
Bool_t DOWNLOAD = false; |
Bool_t DOWNLOAD = false; |
6807 |
// check if the calib was skipped becouse of download .... DA FARE!! |
// check if the calib was skipped becouse of download .... DA FARE!! |
6808 |
if(DOWNLOAD)return(false); |
// if(DOWNLOAD)return(false); |
6809 |
|
if(DOWNLOAD)return(0); |
6810 |
|
|
6811 |
return(true); //>>> missing |
// return(true); //>>> missing |
6812 |
|
return(1); //>>> missing |
6813 |
|
|
6814 |
}; |
}; |
6815 |
|
|
6819 |
//============================================================== |
//============================================================== |
6820 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
6821 |
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); |
6822 |
return(false); |
if ( trkcalib->VALIDATION ) return(0); |
6823 |
|
if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n"); |
6824 |
|
return(2); |
6825 |
|
|
6826 |
}; |
}; |
6827 |
/** |
/** |
6830 |
* @param validation true/false |
* @param validation true/false |
6831 |
*/ |
*/ |
6832 |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
6833 |
|
return(this->assignVALIDATION(idrun,(UInt_t)validation)); |
6834 |
|
} |
6835 |
|
|
6836 |
|
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){ |
6837 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
6838 |
stringstream oss; |
stringstream oss; |
6839 |
oss.str(""); |
oss.str(""); |
7030 |
stringstream myquery; |
stringstream myquery; |
7031 |
// |
// |
7032 |
myquery.str(""); |
myquery.str(""); |
7033 |
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() <<"';"; |
7034 |
// |
// |
7035 |
pResult = conn->Query(myquery.str().c_str()); |
pResult = conn->Query(myquery.str().c_str()); |
7036 |
// |
// |
7046 |
// |
// |
7047 |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
7048 |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
7049 |
|
UInt_t idtsy=(UInt_t)atoll(Row->GetField(2)); |
7050 |
// |
// |
7051 |
this->ValidationOFF(); |
this->ValidationOFF(); |
7052 |
// |
// |
7054 |
// |
// |
7055 |
this->RemoveRUNS(); |
this->RemoveRUNS(); |
7056 |
// |
// |
7057 |
this->RemoveFILES(); |
this->RemoveFILES(idtsy); |
7058 |
// |
// |
7059 |
this->SetID_ROOT(0); |
this->SetID_ROOT(0); |
7060 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
7274 |
* Rearrange calibration tables |
* Rearrange calibration tables |
7275 |
* |
* |
7276 |
**/ |
**/ |
7277 |
void PamelaDBOperations::RemoveFILES(){ |
void PamelaDBOperations::RemoveFILES(UInt_t idtsy){ |
7278 |
stringstream myquery; |
stringstream myquery; |
7279 |
// |
// |
7280 |
myquery.str(""); |
myquery.str(""); |
7284 |
// |
// |
7285 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
7286 |
// |
// |
7287 |
|
myquery.str(""); |
7288 |
|
myquery << " DELETE FROM GL_ROOT WHERE ID=" <<this->GetID_ROOT() <<";"; |
7289 |
|
// |
7290 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
7291 |
|
// |
7292 |
|
conn->Query(myquery.str().c_str()); // |
7293 |
|
// |
7294 |
|
if ( !chewbacca ){ |
7295 |
|
myquery.str(""); |
7296 |
|
myquery << " DELETE FROM GL_TIMESYNC WHERE ID=" << idtsy <<";"; |
7297 |
|
// |
7298 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
7299 |
|
// |
7300 |
|
conn->Query(myquery.str().c_str()); |
7301 |
|
}; |
7302 |
|
// |
7303 |
}; |
}; |
7304 |
|
|
7305 |
/** |
/** |
7504 |
* Rearrange calibration tables |
* Rearrange calibration tables |
7505 |
* |
* |
7506 |
**/ |
**/ |
7507 |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh , TFile *file){ |
7508 |
|
|
7509 |
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; // :-) |
|
7510 |
|
|
7511 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
if ( IsDebug() ) cout << "ValidateTrkCalib:"<<endl; |
7512 |
|
|
7513 |
// ----------------------------------------------- |
UInt_t validate = 1; |
7514 |
// If missing packets: check the acq configuration |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
7515 |
// (some DSPs might be excluded from acquisition) |
UInt_t timeaftercalib=120000; //2000; |
7516 |
// ----------------------------------------------- |
TString classname = caltrk->GetName(); |
7517 |
|
|
7518 |
// ----------------------------------------------- |
// ---------------------------------- |
7519 |
// retrieve the first run header after calib |
// Check CRCs and failed calibrations |
7520 |
// ----------------------------------------------- |
// ---------------------------------- |
7521 |
PacketType *pctp; |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7522 |
EventCounter *cod; |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7523 |
cod = eh->GetCounter(); |
if( caltrk->crc_hcal[ipkt] ){ |
7524 |
Int_t irun = cod->Get(pctp->RunHeader); |
// if(IsDebug())cout<<"(CRC Header)"; |
7525 |
TTree *rh=(TTree*)file->Get("RunHeader"); |
validate = 0; |
7526 |
if ( !rh || rh->IsZombie() ) throw -17; |
if(IsDebug())cout <<endl<<" *** CRC *** (header DSPn "<<caltrk->DSPnumber[ipkt]<<")"; |
7527 |
if( rh->GetEntries() == irun ){ |
|
7528 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
} |
7529 |
return 0; // :-( |
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] ){ |
7530 |
} |
// if(IsDebug())cout<<"(CRC Pkt-"<<ilad<<")"; |
7531 |
|
if(IsDebug())cout <<endl<<" *** CRC *** (data DSPn "<<caltrk->DSPnumber[ipkt]<<" ladder "<<ilad<<")"; |
7532 |
|
validate = 0; |
7533 |
|
} |
7534 |
|
if( !(caltrk->ncalib_event[ipkt]==0 && caltrk->cal_flag[ipkt]==0) ){ |
7535 |
|
if(IsDebug())cout <<endl<<" *** FAILURE *** (data DSPn "<<caltrk->DSPnumber[ipkt]<<")"; |
7536 |
|
validate = 0; |
7537 |
|
} |
7538 |
|
}else{ |
7539 |
|
// validate=0; |
7540 |
|
if(IsDebug())cout <<endl<<" *** DSPn *** ("<< caltrk->DSPnumber[ipkt] <<" @pkt "<<ipkt<<")"; |
7541 |
|
} |
7542 |
|
} |
7543 |
|
|
7544 |
RunHeaderEvent *run = 0; |
// ----------------------- |
7545 |
EventHeader *hrun = 0; |
// Check missing packets: |
7546 |
rh->SetBranchAddress("RunHeader", &run); |
// ----------------------- |
7547 |
rh->SetBranchAddress("Header", &hrun); |
// Readout order: |
7548 |
rh->GetEntry(irun); |
// ------------------ |
7549 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
// DSP packet board |
7550 |
|
// ------------------ |
7551 |
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
// 12 0 1 |
7552 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
// 10 1 1 |
7553 |
return 0; // :-( |
// 8 2 1 |
7554 |
} |
// 4 3 1 |
7555 |
|
// 6 4 1 |
7556 |
if( !run->RM_ACQ_AFTER_CALIB ){ |
// 2 5 1 |
7557 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
// ------------------ |
7558 |
return 0; // :-( |
// 11 0 2 |
7559 |
} |
// 9 1 2 |
7560 |
|
// 7 2 2 |
7561 |
|
// 3 3 2 |
7562 |
|
// 5 4 2 |
7563 |
|
// 1 5 2 |
7564 |
|
// ------------------ |
7565 |
|
// ------------------------------------------------- |
7566 |
|
// Check if it is first or second calibration packet |
7567 |
|
// ------------------------------------------------- |
7568 |
|
UInt_t build=0; |
7569 |
|
UInt_t base=0; |
7570 |
|
UInt_t mask=0; |
7571 |
|
if(classname.Contains("CalibTrk1Event")){ |
7572 |
|
base=12; |
7573 |
|
mask=0x03F000; |
7574 |
|
} |
7575 |
|
if(classname.Contains("CalibTrk2Event")){ |
7576 |
|
base=18; |
7577 |
|
mask=0xFC0000; |
7578 |
|
} |
7579 |
|
// ---------------------------------------------------- |
7580 |
|
// Count number of valid packets and set build variable |
7581 |
|
// ---------------------------------------------------- |
7582 |
|
if(IsDebug())cout <<endl<< " DSP: "; |
7583 |
|
Int_t npkts=0; |
7584 |
|
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
7585 |
|
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
7586 |
|
if(IsDebug())cout <<" "<<caltrk->DSPnumber[ipkt]; |
7587 |
|
npkts++; |
7588 |
|
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
7589 |
|
// cout << caltrk->DSPnumber[ipkt] |
7590 |
|
}; |
7591 |
|
} |
7592 |
|
if(IsDebug())cout << " ==> "<< hex << build << dec; |
7593 |
|
// ---------------------------------------------------- |
7594 |
|
// If the number of valid packets is 6, ok exit... |
7595 |
|
// ---------------------------------------------------- |
7596 |
|
if( npkts==6 ){ |
7597 |
|
return validate; // exit |
7598 |
|
} |
7599 |
|
//////////////////////////////////////////////////////// |
7600 |
|
// ...otherwise there might be some missing packets |
7601 |
|
// |
7602 |
|
// In this case check the acq configuration |
7603 |
|
// (some DSPs might be excluded from acquisition) |
7604 |
|
//////////////////////////////////////////////////////// |
7605 |
|
|
7606 |
|
if(!eh || !file || (file&&file->IsZombie()) ){ |
7607 |
|
if ( IsDebug() )cout << " *** MISSING VIEW *** eh="<<eh<<" file="<<file<<" cannot validate"<<endl; |
7608 |
|
return (0); |
7609 |
|
} |
7610 |
|
|
7611 |
|
// ----------------------------------------------- |
7612 |
|
// retrieve the first run header after calib |
7613 |
|
// ----------------------------------------------- |
7614 |
|
|
7615 |
|
PacketType *pctp; |
7616 |
|
EventCounter *cod; |
7617 |
|
cod = eh->GetCounter(); |
7618 |
|
Int_t irun = cod->Get(pctp->RunHeader); |
7619 |
|
TTree *rh=(TTree*)file->Get("RunHeader"); |
7620 |
|
if ( !rh || rh->IsZombie() ) throw -17; |
7621 |
|
if( rh->GetEntries() <= irun ){ |
7622 |
|
if ( IsDebug() ) cout << " *** MISSING-PKT *** no runs after calib (1) -- cannot validate :-( "<<endl; |
7623 |
|
return 0; // :-( |
7624 |
|
} |
7625 |
|
RunHeaderEvent *run = 0; |
7626 |
|
EventHeader *hrun = 0; |
7627 |
|
rh->SetBranchAddress("RunHeader", &run); |
7628 |
|
rh->SetBranchAddress("Header", &hrun); |
7629 |
|
rh->GetEntry(irun); |
7630 |
|
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
7631 |
|
if ( IsDebug() ) cout << " *** MISSING-PKT *** no runs after calib (2) -- cannot validate :-( "<<endl; |
7632 |
|
return 0; // :-( |
7633 |
|
} |
7634 |
|
|
7635 |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
7636 |
if( dtime > timeaftercalib ){ |
if( dtime > timeaftercalib ){ |
7637 |
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; |
7638 |
return 0; // :-( |
return 0; // :-( |
7639 |
} |
} |
|
|
|
7640 |
|
|
7641 |
|
if ( IsDebug() ) cout <<endl<< " ACQ_BUILD_INFO ==> "<<hex<<(run->ACQ_BUILD_INFO & mask)<<dec; |
7642 |
|
|
7643 |
|
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
7644 |
|
validate=0; // :-( |
7645 |
|
cout <<endl<< " *** MISSING-PKT *** packet mismatch: ACQ_BUILD_INFO="<<hex<<(run->ACQ_BUILD_INFO&mask)<<" != "<<build<<dec; |
7646 |
|
}; |
7647 |
|
|
7648 |
|
return validate; |
7649 |
|
|
|
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; // :-) |
|
7650 |
|
|
7651 |
} |
} |
7652 |
|
|