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, Bool_t keepenv){ |
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; |
88 |
// |
// |
89 |
glrun = new GL_RUN(); |
glrun = new GL_RUN(); |
90 |
// |
// |
91 |
if ( !chewbacca ){ |
// if ( !chewbacca ){ |
92 |
if ( !boot ) SetNOBOOT(false); |
// if ( !boot ) SetNOBOOT(false); |
93 |
SetTsync(tsync,gpamela); |
// SetTsync(tsync,gpamela); |
94 |
SetBOOTnumber(boot,gpamela); |
// SetBOOTnumber(boot,gpamela); |
95 |
SetObt0(obt0); |
// SetObt0(obt0); |
96 |
}; |
// }; |
97 |
// |
// |
98 |
SetTLEPath(tlefilename); |
SetTLEPath(tlefilename); |
99 |
// |
// |
126 |
// |
// |
127 |
// SETTERS |
// SETTERS |
128 |
// |
// |
129 |
|
void PamelaDBOperations::NotChewbacca(UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t gpamela){ |
130 |
|
if ( !boot ) SetNOBOOT(false); |
131 |
|
SetTsync(tsync,gpamela); |
132 |
|
SetBOOTnumber(boot,gpamela); |
133 |
|
SetObt0(obt0); |
134 |
|
}; |
135 |
|
|
136 |
void PamelaDBOperations::OpenL0File(TString filerootname){ |
void PamelaDBOperations::OpenL0File(TString filerootname){ |
137 |
if( INSERT_ROOT ){ |
if( INSERT_ROOT ){ |
142 |
stringstream qu; |
stringstream qu; |
143 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
144 |
TSQLResult *result2 = 0; |
TSQLResult *result2 = 0; |
145 |
|
TSQLResult *result3 = 0; |
146 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
147 |
TSQLRow *row2 = 0; |
TSQLRow *row2 = 0; |
148 |
|
TSQLRow *row3 = 0; |
149 |
TString chpath; |
TString chpath; |
150 |
TString chfile; |
TString chfile; |
151 |
UInt_t ridn = 0; |
UInt_t ridn = 0; |
152 |
qu.str(""); |
qu.str(""); |
153 |
qu << "SELECT ROOT_ID_N,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,INSERTED_BY from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
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 << ";"; |
154 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
155 |
result = conn->Query(qu.str().c_str()); |
result = conn->Query(qu.str().c_str()); |
156 |
if ( result ){ |
if ( result ){ |
162 |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
163 |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
164 |
chiby = (TString)(row->GetField(5)); |
chiby = (TString)(row->GetField(5)); |
165 |
|
chrtinit = (UInt_t)atoll(row->GetField(6)); |
166 |
} else { |
} else { |
167 |
throw -84; |
throw -84; |
168 |
}; |
}; |
171 |
}; |
}; |
172 |
delete result; |
delete result; |
173 |
qu.str(""); |
qu.str(""); |
174 |
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 << ";"; |
175 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
176 |
result2 = conn->Query(qu.str().c_str()); |
result2 = conn->Query(qu.str().c_str()); |
177 |
if ( result2 ){ |
if ( result2 ){ |
188 |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
189 |
chboot = (UInt_t)atoll(row2->GetField(5)); |
chboot = (UInt_t)atoll(row2->GetField(5)); |
190 |
// |
// |
191 |
|
if ( !chboot ){ |
192 |
|
if ( debug ) printf(" mmm... no BOOT number determined by chewbacca, try to find it looking at DB \n"); |
193 |
|
// |
194 |
|
// new feature: check in ROOT_TABLE (timewise) the previous and the next BOOT number != 0 , if it is the same we know this one! |
195 |
|
// if it is different roll back to the old behaviour |
196 |
|
// |
197 |
|
qu.str(""); |
198 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND REAL_TIME_INIT>"<< row2->GetField(10) <<" order by REAL_TIME_INIT asc limit 1;"; |
199 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
200 |
|
UInt_t chbootA = 0; |
201 |
|
UInt_t chbootB = 1; |
202 |
|
result3 = conn->Query(qu.str().c_str()); |
203 |
|
if ( result3 ){ |
204 |
|
row3 = result3->Next(); |
205 |
|
if ( row3 ){ |
206 |
|
chbootA = (UInt_t)atoll(row3->GetField(0)); |
207 |
|
if ( debug ) printf(" Found boot_number A = %u \n",chbootA); |
208 |
|
}; |
209 |
|
}; |
210 |
|
delete result3; |
211 |
|
qu.str(""); |
212 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND REAL_TIME_INIT<"<< row2->GetField(10) <<" order by REAL_TIME_INIT desc limit 1;"; |
213 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
214 |
|
result3 = conn->Query(qu.str().c_str()); |
215 |
|
if ( result3 ){ |
216 |
|
row3 = result3->Next(); |
217 |
|
if ( row3 ){ |
218 |
|
chbootB = (UInt_t)atoll(row3->GetField(0)); |
219 |
|
if ( debug ) printf(" Found boot_number B = %u \n",chbootB); |
220 |
|
}; |
221 |
|
}; |
222 |
|
if ( chbootA == chbootB ){ |
223 |
|
chboot = chbootA; |
224 |
|
if ( debug ) printf(" Found boot_number! it is %u \n",chboot); |
225 |
|
} else { |
226 |
|
qu.str(""); |
227 |
|
// 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;"; |
228 |
|
// 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] |
229 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< (float)chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< atof(row2->GetField(10)) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] // 10RED MYSQL operators BUG: |
230 |
|
/* |
231 |
|
|
232 |
|
mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203.; |
233 |
|
+--------------------------------------------------+ |
234 |
|
| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203. | |
235 |
|
+--------------------------------------------------+ |
236 |
|
| -16557 | |
237 |
|
+--------------------------------------------------+ |
238 |
|
1 row in set (0.06 sec) |
239 |
|
|
240 |
|
mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203; |
241 |
|
+-------------------------------------------------+ |
242 |
|
| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203 | |
243 |
|
+-------------------------------------------------+ |
244 |
|
| 18446744073709535059 | |
245 |
|
+-------------------------------------------------+ |
246 |
|
1 row in set (0.02 sec) |
247 |
|
|
248 |
|
*/ |
249 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
250 |
|
result3 = conn->Query(qu.str().c_str()); |
251 |
|
if ( result3 ){ |
252 |
|
row3 = result3->Next(); |
253 |
|
if ( row3 && result3->GetRowCount() == 1 ){ |
254 |
|
chboot = (UInt_t)atoll(row3->GetField(0)); |
255 |
|
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
256 |
|
} else { |
257 |
|
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
258 |
|
throw -29; |
259 |
|
}; |
260 |
|
}; |
261 |
|
}; |
262 |
|
}; |
263 |
|
// |
264 |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
265 |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
266 |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
488 |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
489 |
return; |
return; |
490 |
}; |
}; |
491 |
TString dwo = 0; |
TString dwo = ""; |
492 |
for (Int_t i = 0; i<5; i++){ |
for (Int_t i = 0; i<5; i++){ |
493 |
dwo.Append(name[i],1); |
dwo.Append(name[i],1); |
494 |
}; |
}; |
882 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
883 |
pktlast = ph->GetCounter(); |
pktlast = ph->GetCounter(); |
884 |
nevent = upperentry - chminentry; |
nevent = upperentry - chminentry; |
885 |
|
if ( ((Int_t)upperentry - (Int_t)chminentry) < 0 ) nevent = 0; // nevent is UInt_t! 090112 [8RED: error -88] |
886 |
|
if ( IsDebug() ) printf(" Setting nevent to %u - upperentry %i chminentry %i \n",nevent,upperentry,chminentry); |
887 |
// |
// |
888 |
} else { |
} else { |
889 |
upperpkt = PKT(pktlast); |
upperpkt = PKT(pktlast); |
892 |
}; |
}; |
893 |
// |
// |
894 |
if ( chewbacca && nevent < 1 ) { |
if ( chewbacca && nevent < 1 ) { |
895 |
|
if ( IsDebug() ) printf(" chewbacca and no events in the file \n"); |
896 |
pktfirst = chpktmin; |
pktfirst = chpktmin; |
897 |
upperpkt = PKT(chpktmax); |
upperpkt = PKT(chpktmax); |
898 |
pktlast = chpktmax; |
pktlast = chpktmax; |
918 |
// if ( nevent < jump ) jump = int(nevent/10); |
// if ( nevent < jump ) jump = int(nevent/10); |
919 |
// if ( !jump ) jump = 1; |
// if ( !jump ) jump = 1; |
920 |
// |
// |
921 |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) && nevent > deltapkt ){ |
|
922 |
|
if ( ((PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt)) && nevent > deltapkt ){ |
923 |
// |
// |
924 |
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
925 |
// 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)); |
1566 |
glrun->SetRUNTRAILER_PKT(lastPkt); |
glrun->SetRUNTRAILER_PKT(lastPkt); |
1567 |
// |
// |
1568 |
}; |
}; |
1569 |
|
// |
1570 |
|
// ad hoc solution for INF EV_TO [8RED] 090113 |
1571 |
|
// |
1572 |
|
if ( !firstev && lastev == -1 ){ |
1573 |
|
if ( IsDebug() ) printf(" EE firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
1574 |
|
firstev = 1; |
1575 |
|
lastev = 0; |
1576 |
|
}; |
1577 |
glrun->SetEV_FROM((UInt_t)firstev); |
glrun->SetEV_FROM((UInt_t)firstev); |
1578 |
glrun->SetEV_TO((UInt_t)lastev); |
glrun->SetEV_TO((UInt_t)lastev); |
1579 |
glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1); |
glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1); |
1702 |
if ( !row ){ |
if ( !row ){ |
1703 |
oss.str(""); |
oss.str(""); |
1704 |
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< " |
1705 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< dworbit << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;"; |
1706 |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
1707 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1708 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
1749 |
TYPE = 0; |
TYPE = 0; |
1750 |
TSYNC = 0; |
TSYNC = 0; |
1751 |
// |
// |
1752 |
Double_t minimum = 0.; |
// Double_t minimum = 0.; |
1753 |
Double_t maximum = 0.; |
// Double_t maximum = 0.; |
1754 |
Double_t minimum2 = 0.; |
//Double_t minimum2 = 0.; |
1755 |
Double_t maximum2 = 0.; |
Double_t maximum2 = 0.; |
1756 |
// |
// |
1757 |
// |
// |
1759 |
pamela::McmdRecord *mcrc = 0; |
pamela::McmdRecord *mcrc = 0; |
1760 |
TArrayC *mcmddata = 0; |
TArrayC *mcmddata = 0; |
1761 |
// |
// |
1762 |
minimum = numeric_limits<Double_t>::max(); |
// minimum = numeric_limits<Double_t>::max(); |
1763 |
maximum = numeric_limits<Double_t>::min(); |
// maximum = numeric_limits<Double_t>::min(); |
1764 |
minimum2 = numeric_limits<Double_t>::max(); |
// minimum2 = numeric_limits<Double_t>::max(); |
1765 |
maximum2 = numeric_limits<Double_t>::min(); |
maximum2 = numeric_limits<Double_t>::min(); |
1766 |
// |
// |
1767 |
T = (TTree*)file->Get("Mcmd"); |
T = (TTree*)file->Get("Mcmd"); |
2181 |
UInt_t lowerts = tsync-(obt0/1000)-5; |
UInt_t lowerts = tsync-(obt0/1000)-5; |
2182 |
if ( chewbacca ){ |
if ( chewbacca ){ |
2183 |
oss.str(""); |
oss.str(""); |
2184 |
oss << "select BOOT_NUMBER from ROOT_TABLE where LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)<" |
oss << "select BOOT_NUMBER from ROOT_TABLE where CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG |
2185 |
<< upperts |
<< upperts |
2186 |
<< " AND LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)>" |
<< " AND CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG |
2187 |
<< lowerts |
<< lowerts |
2188 |
<< " AND BOOT_NUMBER>1;"; |
<< " AND BOOT_NUMBER>1;"; |
2189 |
} else { |
} else { |
2190 |
oss.str(""); |
oss.str(""); |
2191 |
oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where TIMESYNC-(OBT0/1000)<" |
oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG |
2192 |
<< upperts |
<< upperts |
2193 |
<< " AND TIMESYNC-(OBT0/1000)>" |
<< " AND CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG |
2194 |
<< lowerts |
<< lowerts |
2195 |
<< " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;"; |
<< " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;"; |
2196 |
}; |
}; |
2289 |
// |
// |
2290 |
// no runtrailers in the file! |
// no runtrailers in the file! |
2291 |
// |
// |
2292 |
if ( !rtev ){ |
if ( IsDebug() ) printf(" Start rtev %i rhev %i nrtev %i nrhev %i \n",rtev,rhev,nrtev,nrhev); |
2293 |
if ( !rhev ){ |
if ( !rtev || (chewbacca && !nrtev) ){ |
2294 |
|
if ( IsDebug() ) printf(" No runtrailers \n"); |
2295 |
|
if ( !rhev || (chewbacca && !nrhev) ){ |
2296 |
if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); |
if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); |
2297 |
if ( !(upperentry-chminentry) ){ |
if ( !(upperentry-chminentry) ){ |
2298 |
if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) |
if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) |
2329 |
// |
// |
2330 |
} else { |
} else { |
2331 |
// |
// |
2332 |
|
if ( IsDebug() ) printf(" We have runtrailers \n"); |
2333 |
Int_t conptt = -1; |
Int_t conptt = -1; |
2334 |
for (Int_t ptt=0; ptt<rtev; ptt++){ |
for (Int_t ptt=0; ptt<rtev; ptt++){ |
2335 |
// |
// |
2346 |
ptht = cod->Get(pctp->RunHeader) - 1; |
ptht = cod->Get(pctp->RunHeader) - 1; |
2347 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2348 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2349 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2350 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2351 |
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)); |
2352 |
// |
// |
2385 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
2386 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2387 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2388 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2389 |
evbefh = TMath::Max(chminentry,(tcod-1)); |
evbefh = TMath::Max(chminentry,(tcod-1)); |
2390 |
// |
// |
2391 |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
2447 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2448 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2449 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2450 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2451 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2452 |
rh->GetEntry(pth); |
rh->GetEntry(pth); |
2453 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
2489 |
// if ( conptt+1 == (nrtev+nrtbef )){ |
// if ( conptt+1 == (nrtev+nrtbef )){ |
2490 |
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
2491 |
ptht++; |
ptht++; |
2492 |
if ( ptht < rhev ){ |
if ( ptht < rhev ){ |
2493 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
2494 |
//pth++; |
//pth++; |
2495 |
//if ( pth < rhev ){ |
//if ( pth < rhev ){ |
2517 |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
2518 |
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); |
2519 |
// |
// |
2520 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
// if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
2521 |
|
if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here! |
2522 |
// rt->GetEntry(ptt-1); |
// rt->GetEntry(ptt-1); |
2523 |
rt->GetEntry(rtev-1); |
rt->GetEntry(rtev-1); |
2524 |
cod = eht->GetCounter(); |
cod = eht->GetCounter(); |
2753 |
// |
// |
2754 |
// 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 |
2755 |
// |
// |
2756 |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
if ( firstev != (lastev+1) ){ // could be a problem sometimes (?) |
2757 |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
2758 |
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
2759 |
|
}; |
2760 |
// |
// |
2761 |
|
if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev); |
2762 |
this->FillClass(mishead,mistrail,firstev,lastev); |
this->FillClass(mishead,mistrail,firstev,lastev); |
2763 |
|
if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev); |
2764 |
// |
// |
2765 |
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"); |
2766 |
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()); |
2802 |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
2803 |
// |
// |
2804 |
} else { |
} else { |
2805 |
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); |
2806 |
if ( PEDANTIC ) throw -69; |
if ( !RELAXED ){ |
2807 |
return; |
if ( PEDANTIC ) throw -69; |
2808 |
|
return; |
2809 |
|
} else { |
2810 |
|
glrun->SetID((UInt_t)atoll(row->GetField(0))); |
2811 |
|
glrun->SetID_RUN_FRAG(0); |
2812 |
|
}; |
2813 |
}; |
}; |
2814 |
// |
// |
2815 |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
2860 |
// |
// |
2861 |
found = false; // default value |
found = false; // default value |
2862 |
// |
// |
2863 |
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"); |
2864 |
// |
// |
2865 |
// 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: |
2866 |
// |
// |
2876 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
2877 |
// |
// |
2878 |
found = true; |
found = true; |
2879 |
|
if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev); |
2880 |
// |
// |
2881 |
} else { |
} else { |
2882 |
// |
// |
2942 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " ID="<<row->GetField(0)<<";"; |
2943 |
// |
// |
2944 |
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 |
2945 |
|
if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev); |
2946 |
// |
// |
2947 |
// merge infos |
// merge infos |
2948 |
// |
// |
2973 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
2974 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
2975 |
// |
// |
2976 |
|
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
2977 |
|
// |
2978 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
2979 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
2980 |
// |
// |
3067 |
// |
// |
3068 |
found = false; // default value |
found = false; // default value |
3069 |
// |
// |
3070 |
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"); |
3071 |
// |
// |
3072 |
// 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: |
3073 |
// |
// |
3167 |
apkt = PKT(ph->GetCounter()); |
apkt = PKT(ph->GetCounter()); |
3168 |
aobt = OBT(ph->GetOrbitalTime()); |
aobt = OBT(ph->GetOrbitalTime()); |
3169 |
lastev--; |
lastev--; |
3170 |
if ( PEDANTIC ) throw -72; |
if ( PEDANTIC && !RELAXED) throw -72; |
3171 |
}; |
}; |
3172 |
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); |
3173 |
// |
// |
3235 |
// 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? |
3236 |
// |
// |
3237 |
oss.str(""); |
oss.str(""); |
3238 |
oss << " SELECT ID FROM GL_RUN WHERE " |
oss << " SELECT ID,ID_ROOT_L0 FROM GL_RUN WHERE " |
3239 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
3240 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
3241 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
3258 |
row = result->Next(); |
row = result->Next(); |
3259 |
// |
// |
3260 |
if ( row ){ |
if ( row ){ |
3261 |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
// |
3262 |
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 |
3263 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
3264 |
|
// |
3265 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
3266 |
|
// 093012 [8RED (-70): RUN ALREADY INSERTED] try to be more general... the run has not been instered yet if the runheader-trailer PKT interval is not covered by already inserted runs, NOTICE: we must look in the GL_RUN_TRASH table! |
3267 |
|
// |
3268 |
|
Bool_t OK = false; |
3269 |
|
UInt_t IDRL2A = 0; |
3270 |
|
UInt_t IDRL2B = 0; |
3271 |
|
if ( chewbacca ){ |
3272 |
|
if ( result->GetRowCount() >= 2 ){ |
3273 |
|
// |
3274 |
|
if ( IsDebug() ) printf(" RH---| gap |---RT case, number of pieces in the GL_RUN table: %i \n",result->GetRowCount()); |
3275 |
|
OK = true; |
3276 |
|
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3277 |
|
// |
3278 |
|
while ( row ){ |
3279 |
|
// |
3280 |
|
TSQLResult *trresult = 0; |
3281 |
|
TSQLRow *trrow = 0; |
3282 |
|
// |
3283 |
|
stringstream tross; |
3284 |
|
tross.str(""); |
3285 |
|
// |
3286 |
|
tross << " SELECT RUNHEADER_PKT, RUNTRAILER_PKT FROM GL_RUN_TRASH where ID=" << row->GetField(0) << ";"; |
3287 |
|
if ( IsDebug() ) printf(" check in the gl_run_trash table for pkt intervals: query is \n %s \n",tross.str().c_str()); |
3288 |
|
trresult = conn->Query(tross.str().c_str()); |
3289 |
|
if ( !trresult ) throw -4; |
3290 |
|
trrow = trresult->Next(); |
3291 |
|
if ( !trrow || trresult->GetRowCount() != 1 ){ |
3292 |
|
OK = false; |
3293 |
|
if ( IsDebug() ) printf(" OPS! no such run (or multiple runs!) in GL_RUN_TRASH table, something wrong is going on! \n"); |
3294 |
|
break; |
3295 |
|
}; |
3296 |
|
// |
3297 |
|
UInt_t pktH = (UInt_t)atoll(row->GetField(0)); |
3298 |
|
UInt_t pktT = (UInt_t)atoll(row->GetField(1)); |
3299 |
|
delete trresult; |
3300 |
|
if ( |
3301 |
|
(PKT(pktH) >= PKT(glrun->GetRUNHEADER_PKT()) && PKT(pktH) <= PKT(glrun->GetRUNTRAILER_PKT())) || |
3302 |
|
(PKT(pktT) >= PKT(glrun->GetRUNHEADER_PKT()) && PKT(pktT) <= PKT(glrun->GetRUNTRAILER_PKT())) || |
3303 |
|
(PKT(pktH) <= PKT(glrun->GetRUNTRAILER_PKT()) && PKT(pktT) >= PKT(glrun->GetRUNTRAILER_PKT())) ){ |
3304 |
|
OK = false; |
3305 |
|
if ( IsDebug() ) printf(" The run is overlapping with already inserted ones!! \n"); |
3306 |
|
break; |
3307 |
|
}; |
3308 |
|
//PKT(glrun->GetRUNHEADER_PKT()) PKT(glrun->GetRUNTRAILER_PKT()) |
3309 |
|
row = result->Next(); |
3310 |
|
}; |
3311 |
|
|
3312 |
|
// if ( result->GetRowCount() == 2 ) { |
3313 |
|
// IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3314 |
|
// UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
3315 |
|
// row = result->Next(); |
3316 |
|
// IDRL2B = (UInt_t)atoll(row->GetField(0)); |
3317 |
|
// UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
3318 |
|
// if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
3319 |
|
// // if ( IDRL0A == IDRL0B ){ //091230 why this condition???? RH could be in a file and RT in another one... |
3320 |
|
// if ( true ){ |
3321 |
|
// TSQLResult *result2 = 0; |
3322 |
|
// TSQLRow *row2 = 0; |
3323 |
|
// oss.str(""); |
3324 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
3325 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3326 |
|
// result2 = conn->Query(oss.str().c_str()); |
3327 |
|
// // |
3328 |
|
// if ( !result2 ) throw -4; |
3329 |
|
// // |
3330 |
|
// row2 = result2->Next(); |
3331 |
|
// // |
3332 |
|
// if ( row2 ){ |
3333 |
|
// UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
3334 |
|
// delete result2; |
3335 |
|
// oss.str(""); |
3336 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
3337 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3338 |
|
// result2 = conn->Query(oss.str().c_str()); |
3339 |
|
// // |
3340 |
|
// if ( !result2 ) throw -4; |
3341 |
|
// // |
3342 |
|
// row2 = result2->Next(); |
3343 |
|
// // |
3344 |
|
// if ( row2 ){ |
3345 |
|
// UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
3346 |
|
// // |
3347 |
|
// 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); |
3348 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
3349 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3350 |
|
// OK = true; |
3351 |
|
// }; |
3352 |
|
// }; |
3353 |
|
// }; |
3354 |
|
// }; |
3355 |
|
// }; |
3356 |
|
}; |
3357 |
|
}; |
3358 |
|
if ( OK ){ |
3359 |
|
// |
3360 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table // we arrive here ONLY with internal pieces of runs, never runheader or runtrailer by definition |
3361 |
|
// |
3362 |
|
// 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 ) |
3363 |
|
// |
3364 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3365 |
|
// |
3366 |
|
GL_RUN *glA = new GL_RUN(); |
3367 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
3368 |
|
// |
3369 |
|
glrun->SetRUNHEADER_TIME(glA->GetRUNHEADER_TIME()); |
3370 |
|
glrun->SetRUNHEADER_OBT(glA->GetRUNHEADER_OBT()); |
3371 |
|
glrun->SetRUNHEADER_PKT(glA->GetRUNHEADER_PKT()); |
3372 |
|
// |
3373 |
|
glrun->SetRUNTRAILER_TIME(glA->GetRUNTRAILER_TIME()); |
3374 |
|
glrun->SetRUNTRAILER_OBT(glA->GetRUNTRAILER_OBT()); |
3375 |
|
glrun->SetRUNTRAILER_PKT(glA->GetRUNTRAILER_PKT()); |
3376 |
|
// |
3377 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) glrun->SetPHYSENDRUN_MASK_S3S2S12(glA->GetPHYSENDRUN_MASK_S3S2S12()); |
3378 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) glrun->SetPHYSENDRUN_MASK_S11CRC(glA->GetPHYSENDRUN_MASK_S11CRC()); |
3379 |
|
// |
3380 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3381 |
|
// |
3382 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
3383 |
|
// |
3384 |
|
glrun->SetCOMPILATIONTIMESTAMP(glA->GetCOMPILATIONTIMESTAMP()); |
3385 |
|
glrun->SetFAV_WRK_SCHEDULE(glA->GetFAV_WRK_SCHEDULE()); |
3386 |
|
glrun->SetEFF_WRK_SCHEDULE(glA->GetEFF_WRK_SCHEDULE()); |
3387 |
|
glrun->SetPRH_VAR_TRG_MODE_A(glA->GetPRH_VAR_TRG_MODE_A()); |
3388 |
|
glrun->SetPRH_VAR_TRG_MODE_B(glA->GetPRH_VAR_TRG_MODE_B()); |
3389 |
|
glrun->SetACQ_BUILD_INFO(glA->GetACQ_BUILD_INFO()); |
3390 |
|
glrun->SetACQ_VAR_INFO(glA->GetACQ_VAR_INFO()); |
3391 |
|
glrun->SetRM_ACQ_AFTER_CALIB(glA->GetRM_ACQ_AFTER_CALIB()); |
3392 |
|
glrun->SetRM_ACQ_SETTING_MODE(glA->GetRM_ACQ_SETTING_MODE()); |
3393 |
|
glrun->SetTRK_CALIB_USED(glA->GetTRK_CALIB_USED()); |
3394 |
|
glrun->SetCAL_DSP_MASK(glA->GetCAL_DSP_MASK()); |
3395 |
|
glrun->SetLAST_TIMESYNC(glA->GetLAST_TIMESYNC()); |
3396 |
|
glrun->SetOBT_TIMESYNC(glA->GetOBT_TIMESYNC()); |
3397 |
|
// |
3398 |
|
}; |
3399 |
|
// |
3400 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3401 |
|
// |
3402 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
3403 |
|
// |
3404 |
|
glrun->SetPKT_COUNTER(glA->GetPKT_COUNTER()); |
3405 |
|
glrun->SetPKT_READY_COUNTER(glA->GetPKT_READY_COUNTER()); |
3406 |
|
}; |
3407 |
|
// |
3408 |
|
// update runheader ROOT_ID_FRAG |
3409 |
|
// |
3410 |
|
oss.str(""); |
3411 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
3412 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3413 |
|
conn->Query(oss.str().c_str()); |
3414 |
|
// |
3415 |
|
oss.str(""); |
3416 |
|
oss << "SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG = " << IDRL2A << ";"; |
3417 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3418 |
|
TSQLResult *tsresult = 0; |
3419 |
|
TSQLRow *tsrow = 0; |
3420 |
|
tsresult=conn->Query(oss.str().c_str()); |
3421 |
|
if ( !tsresult ) throw -4; |
3422 |
|
tsrow = tsresult->Next(); |
3423 |
|
if ( !tsrow || tsresult->GetRowCount() != 1 ) throw -4; |
3424 |
|
IDRL2B = (UInt_t)atoll(tsrow->GetField(0)); |
3425 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
3426 |
|
// |
3427 |
|
// fill the new run in GL_RUN |
3428 |
|
// |
3429 |
|
glrun->Fill_GL_RUN(conn); |
3430 |
|
// |
3431 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3432 |
|
delete glA; |
3433 |
|
// |
3434 |
|
} else { |
3435 |
|
// // |
3436 |
|
// // this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
3437 |
|
// // |
3438 |
|
// // 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 ) |
3439 |
|
// // |
3440 |
|
// GL_RUN *glA = new GL_RUN(); |
3441 |
|
// glA->Query_GL_RUN(IDRL2A,conn); |
3442 |
|
// // |
3443 |
|
// if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3444 |
|
// // |
3445 |
|
// // the first piece contains a good runheader we can update all the other runs with correct infos! |
3446 |
|
// // |
3447 |
|
// oss.str(""); |
3448 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3449 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
3450 |
|
// << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3451 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
3452 |
|
// << " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
3453 |
|
// << " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
3454 |
|
// << " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
3455 |
|
// << " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
3456 |
|
// << " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
3457 |
|
// << " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
3458 |
|
// << " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
3459 |
|
// << " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
3460 |
|
// << " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
3461 |
|
// << " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
3462 |
|
// << " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
3463 |
|
// << " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
3464 |
|
// // |
3465 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3466 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
3467 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3468 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
3469 |
|
// // |
3470 |
|
// oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
3471 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
3472 |
|
// if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
3473 |
|
// conn->Query(oss.str().c_str()); |
3474 |
|
// // |
3475 |
|
// } else { |
3476 |
|
// // |
3477 |
|
// // sig no runheader, let set anyway what is possible... |
3478 |
|
// // |
3479 |
|
// oss.str(""); |
3480 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3481 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
3482 |
|
// // |
3483 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3484 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
3485 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3486 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
3487 |
|
// // |
3488 |
|
// oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3489 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
3490 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
3491 |
|
// if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
3492 |
|
// conn->Query(oss.str().c_str()); |
3493 |
|
// }; |
3494 |
|
// // |
3495 |
|
// // update runheader ROOT_ID_FRAG |
3496 |
|
// // |
3497 |
|
// oss.str(""); |
3498 |
|
// oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
3499 |
|
// if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3500 |
|
// conn->Query(oss.str().c_str()); |
3501 |
|
// // |
3502 |
|
// // now let's look for runtrailer if any in the last run |
3503 |
|
// // |
3504 |
|
// glA->Query_GL_RUN(IDRL2B,conn); |
3505 |
|
// // |
3506 |
|
// if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3507 |
|
// // |
3508 |
|
// // the first piece contains a good runtrailer we can update all the other runs with correct infos! |
3509 |
|
// // |
3510 |
|
// oss.str(""); |
3511 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3512 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3513 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
3514 |
|
// << " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
3515 |
|
// << " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
3516 |
|
// // |
3517 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3518 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3519 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
3520 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3521 |
|
// // |
3522 |
|
// oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
3523 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
3524 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
3525 |
|
// conn->Query(oss.str().c_str()); |
3526 |
|
// // |
3527 |
|
// } else { |
3528 |
|
// // |
3529 |
|
// // sig no runtrailer, let set anyway what is possible... |
3530 |
|
// // |
3531 |
|
// oss.str(""); |
3532 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3533 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3534 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
3535 |
|
// // |
3536 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3537 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3538 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
3539 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3540 |
|
// // |
3541 |
|
// oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
3542 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
3543 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
3544 |
|
// conn->Query(oss.str().c_str()); |
3545 |
|
// }; |
3546 |
|
// // |
3547 |
|
// UInt_t myi = glrun->GetID(); |
3548 |
|
// oss.str(""); |
3549 |
|
// oss << " ID= "<< myi; |
3550 |
|
// // |
3551 |
|
// glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
3552 |
|
// // |
3553 |
|
// // fill the new run in GL_RUN |
3554 |
|
// // |
3555 |
|
// glrun->SetID_RUN_FRAG(IDRL2B); |
3556 |
|
// glrun->Fill_GL_RUN(conn); |
3557 |
|
// glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3558 |
|
// delete glA; |
3559 |
|
// // |
3560 |
|
// } else { |
3561 |
|
// |
3562 |
|
// is just a repetition |
3563 |
|
// |
3564 |
|
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
3565 |
|
if ( PEDANTIC ) throw -70; |
3566 |
|
}; |
3567 |
|
// |
3568 |
} else { |
} else { |
3569 |
if ( NoFrag() ){ |
if ( NoFrag() ){ |
3570 |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
3601 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
3602 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
3603 |
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... |
3604 |
}; |
}; |
3605 |
// |
// |
3606 |
}; |
}; |
3607 |
// |
// |
3617 |
// |
// |
3618 |
EventCounter *code=0; |
EventCounter *code=0; |
3619 |
// |
// |
3620 |
UInt_t nevent = 0; |
// UInt_t nevent = 0; |
3621 |
UInt_t checkfirst = 0; |
UInt_t checkfirst = 0; |
3622 |
UInt_t checklast = 0; |
UInt_t checklast = 0; |
3623 |
UInt_t firstentry = 0; |
UInt_t firstentry = 0; |
3639 |
EventHeader *eh = 0; |
EventHeader *eh = 0; |
3640 |
PscuHeader *ph = 0; |
PscuHeader *ph = 0; |
3641 |
T->SetBranchAddress("Header", &eh); |
T->SetBranchAddress("Header", &eh); |
3642 |
nevent = T->GetEntries(); |
// nevent = T->GetEntries(); |
3643 |
// |
// |
3644 |
// |
// |
3645 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
3646 |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
3647 |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
3648 |
|
firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files |
3649 |
// return true is correct |
// return true is correct |
3650 |
return(true); |
return(true); |
3651 |
// |
// |
3901 |
// |
// |
3902 |
found = false; // default value |
found = false; // default value |
3903 |
// |
// |
3904 |
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"); |
3905 |
// |
// |
3906 |
// 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: |
3907 |
// |
// |
4160 |
EventCounter *code=0; |
EventCounter *code=0; |
4161 |
UInt_t firstev = 0; |
UInt_t firstev = 0; |
4162 |
UInt_t lastev = 0; |
UInt_t lastev = 0; |
4163 |
UInt_t nevent = 0; |
// UInt_t nevent = 0; |
4164 |
UInt_t checkfirst = 0; |
UInt_t checkfirst = 0; |
4165 |
UInt_t checklast = 0; |
UInt_t checklast = 0; |
4166 |
UInt_t firstentry = 0; |
UInt_t firstentry = 0; |
4185 |
EventHeader *eh = 0; |
EventHeader *eh = 0; |
4186 |
PscuHeader *ph = 0; |
PscuHeader *ph = 0; |
4187 |
T->SetBranchAddress("Header", &eh); |
T->SetBranchAddress("Header", &eh); |
4188 |
nevent = T->GetEntries(); |
// nevent = T->GetEntries(); |
4189 |
// |
// |
4190 |
codt = eht->GetCounter(); |
codt = eht->GetCounter(); |
4191 |
codh = ehh->GetCounter(); |
codh = ehh->GetCounter(); |
4419 |
UInt_t totime = 0; |
UInt_t totime = 0; |
4420 |
UInt_t obt = 0; |
UInt_t obt = 0; |
4421 |
UInt_t pkt = 0; |
UInt_t pkt = 0; |
4422 |
|
Float_t totped = 0.; |
4423 |
// |
// |
4424 |
tr = (TTree*)file->Get("CalibCalPed"); |
tr = (TTree*)file->Get("CalibCalPed"); |
4425 |
if ( !tr || tr->IsZombie() ) throw -21; |
if ( !tr || tr->IsZombie() ) throw -21; |
4437 |
if ( calibCalPed->cstwerr[section] ){ |
if ( calibCalPed->cstwerr[section] ){ |
4438 |
valid = 1; |
valid = 1; |
4439 |
if ( calibCalPed->cperror[section] ) valid = 0; |
if ( calibCalPed->cperror[section] ) valid = 0; |
4440 |
|
// |
4441 |
|
// 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.] |
4442 |
|
// |
4443 |
|
totped = 0.; |
4444 |
|
Int_t ns = 0; |
4445 |
|
if ( section == 2 ) ns = 3; |
4446 |
|
if ( section == 3 ) ns = 1; |
4447 |
|
if ( section == 1 ) ns = 2; |
4448 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4449 |
|
totped += fabs(calibCalPed->calped[ns][0][ss]); |
4450 |
|
} |
4451 |
|
if ( totped < 1. ){ |
4452 |
|
if ( IsDebug() ) printf(" Section %i totped %f - No calibration data! Calorimeter power problems? \n",section,totped); |
4453 |
|
valid = 0; |
4454 |
|
}; |
4455 |
|
// |
4456 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4457 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4458 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4620 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
4621 |
nevents = tr->GetEntries(); |
nevents = tr->GetEntries(); |
4622 |
// |
// |
4623 |
|
Float_t totpul = 0.; |
4624 |
|
// |
4625 |
if ( nevents > 0 ){ |
if ( nevents > 0 ){ |
4626 |
// |
// |
4627 |
for (UInt_t i=0; i < nevents; i++){ |
for (UInt_t i=0; i < nevents; i++){ |
4631 |
if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ |
if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ |
4632 |
valid = 1; |
valid = 1; |
4633 |
if ( cp1->pperror[section] ) valid = 0; |
if ( cp1->pperror[section] ) valid = 0; |
4634 |
|
// |
4635 |
|
// 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.] |
4636 |
|
// |
4637 |
|
totpul = 0.; |
4638 |
|
Int_t ns = 0; |
4639 |
|
if ( section == 2 ) ns = 3; |
4640 |
|
if ( section == 3 ) ns = 1; |
4641 |
|
if ( section == 1 ) ns = 2; |
4642 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4643 |
|
totpul += cp1->calpuls[ns][0][ss]; |
4644 |
|
} |
4645 |
|
if ( totpul >= 3145632. ){ |
4646 |
|
if ( IsDebug() ) printf(" PULSE1 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); |
4647 |
|
valid = 0; |
4648 |
|
}; |
4649 |
|
// |
4650 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4651 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4652 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4804 |
if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ |
if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ |
4805 |
valid = 1; |
valid = 1; |
4806 |
if ( cp2->pperror[section] ) valid = 0; |
if ( cp2->pperror[section] ) valid = 0; |
4807 |
|
// |
4808 |
|
// 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.] |
4809 |
|
// |
4810 |
|
totpul = 0.; |
4811 |
|
Int_t ns = 0; |
4812 |
|
if ( section == 2 ) ns = 3; |
4813 |
|
if ( section == 3 ) ns = 1; |
4814 |
|
if ( section == 1 ) ns = 2; |
4815 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4816 |
|
totpul += cp2->calpuls[ns][0][ss]; |
4817 |
|
} |
4818 |
|
if ( totpul >= 3145632. ){ |
4819 |
|
if ( IsDebug() ) printf(" PULSE2 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); |
4820 |
|
valid = 0; |
4821 |
|
}; |
4822 |
|
// |
4823 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4824 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4825 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
5185 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
5186 |
row = result->Next(); |
row = result->Next(); |
5187 |
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
5188 |
|
// |
5189 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5190 |
// |
// |
5191 |
}; |
}; |
5192 |
|
|
5468 |
|
|
5469 |
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
5470 |
|
|
5471 |
TSQLResult *result = 0; |
TSQLResult *rresult = 0; // 10RED bug, result is re-used inside result looop... |
5472 |
|
TSQLResult *result = 0; // 10RED bug, result is re-used inside result looop... |
5473 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
5474 |
// |
// |
5475 |
stringstream oss; |
stringstream oss; |
5499 |
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
5500 |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5501 |
|
|
5502 |
result = conn->Query(oss.str().c_str()); |
rresult = conn->Query(oss.str().c_str()); |
5503 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
5504 |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5505 |
|
|
5508 |
// ----------------------------------- |
// ----------------------------------- |
5509 |
UInt_t nn=0; |
UInt_t nn=0; |
5510 |
do { |
do { |
5511 |
row = result->Next(); |
row = rresult->Next(); |
5512 |
if(!row)break; |
if(!row)break; |
5513 |
|
|
5514 |
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5547 |
TString path = ""; |
TString path = ""; |
5548 |
TString name = ""; |
TString name = ""; |
5549 |
TString raw = ""; |
TString raw = ""; |
5550 |
UInt_t obt0 = 0; |
// UInt_t obt0 = 0; |
5551 |
UInt_t timesync = 0; |
// UInt_t timesync = 0; |
5552 |
UInt_t boot_number = 0; |
// UInt_t boot_number = 0; |
5553 |
bool FOUND = false; |
bool FOUND = false; |
5554 |
|
|
5555 |
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5622 |
path = (TString)row2->GetField(0); |
path = (TString)row2->GetField(0); |
5623 |
name = (TString)row2->GetField(1); |
name = (TString)row2->GetField(1); |
5624 |
raw = (TString)row2->GetField(5); |
raw = (TString)row2->GetField(5); |
5625 |
obt0 = (UInt_t)atoll(row2->GetField(2)); |
// obt0 = (UInt_t)atoll(row2->GetField(2)); |
5626 |
timesync = (UInt_t)atoll(row2->GetField(3)); |
// timesync = (UInt_t)atoll(row2->GetField(3)); |
5627 |
boot_number = (UInt_t)atoll(row2->GetField(4)); |
// boot_number = (UInt_t)atoll(row2->GetField(4)); |
5628 |
|
|
5629 |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
5630 |
// cout << path <<endl; |
// cout << path <<endl; |
5688 |
if(FOUND)break; |
if(FOUND)break; |
5689 |
|
|
5690 |
}while(1);//endl loop over root table entries |
}while(1);//endl loop over root table entries |
5691 |
|
|
5692 |
|
delete result2; // 10RED potential memory leak |
5693 |
if(FOUND)break; |
if(FOUND)break; |
5694 |
|
|
5695 |
}//end loop over tables |
}//end loop over tables |
5696 |
|
|
5697 |
if(FOUND){ |
if(FOUND){ |
5698 |
|
|
5699 |
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
|
|
|
|
//////////////////////////////////////////// |
|
|
// insert a new entry in GL_TRK_CALIB and |
|
|
// modify the time-tag of the previous one |
|
|
//////////////////////////////////////////// |
|
5700 |
|
|
5701 |
// --------------------------------------------------------------------- |
//////////////////////////////////////////// |
5702 |
// step 1: insert a new raw file in GL_RAW |
// insert a new entry in GL_TRK_CALIB and |
5703 |
// --------------------------------------------------------------------- |
// modify the time-tag of the previous one |
5704 |
// |
//////////////////////////////////////////// |
5705 |
// check if the raw file already exist |
|
5706 |
// |
// --------------------------------------------------------------------- |
5707 |
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 |
// step 1: insert a new raw file in GL_RAW |
5708 |
// oss.str(""); |
// --------------------------------------------------------------------- |
5709 |
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
// |
5710 |
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
// check if the raw file already exist |
5711 |
|
// |
5712 |
|
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 |
5713 |
|
// oss.str(""); |
5714 |
|
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
5715 |
|
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5716 |
|
|
5717 |
// result = conn->Query(oss.str().c_str()); |
// result = conn->Query(oss.str().c_str()); |
5718 |
// if ( !result ) throw -4;; |
// if ( !result ) throw -4;; |
5719 |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5720 |
// if( result->GetRowCount() == 0){ |
// if( result->GetRowCount() == 0){ |
5721 |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
5722 |
// // - - - - - - - - - - - |
// // - - - - - - - - - - - |
5723 |
// // insert new raw file |
// // insert new raw file |
5724 |
// // - - - - - - - - - - - |
// // - - - - - - - - - - - |
5725 |
// GL_RAW glraw = GL_RAW(); |
// GL_RAW glraw = GL_RAW(); |
5726 |
// glraw.PATH = gSystem->DirName(raw.Data()); |
// glraw.PATH = gSystem->DirName(raw.Data()); |
5727 |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
5728 |
// glraw.BOOT_NUMBER = boot_number; |
// glraw.BOOT_NUMBER = boot_number; |
5729 |
// // |
// // |
5730 |
// insertPamelaRawFile( &glraw ); |
// insertPamelaRawFile( &glraw ); |
5731 |
// // |
// // |
5732 |
// id_raw = glraw.ID; |
// id_raw = glraw.ID; |
5733 |
// }else{ |
// }else{ |
5734 |
// row = result->Next(); |
// row = result->Next(); |
5735 |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
5736 |
// } |
// } |
5737 |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
5738 |
|
|
5739 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5740 |
// step 1(bis): retrieve the timesync id associated to the file |
// step 1(bis): retrieve the timesync id associated to the file |
5741 |
// (NB, uso lo stesso associato al file iniziale) |
// (NB, uso lo stesso associato al file iniziale) |
5742 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5743 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
5744 |
oss.str(""); |
oss.str(""); |
5745 |
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
5746 |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
5747 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
5748 |
if ( !result ) throw -3; |
if ( !result ) throw -3; |
5749 |
row = result->Next(); |
row = result->Next(); |
5750 |
if ( !row ) throw -3; |
if ( !row ) throw -3; |
5751 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
5752 |
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
5753 |
|
|
5754 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5755 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5756 |
// step 2: insert a new root file in GL_ROOT |
// step 2: insert a new root file in GL_ROOT |
5757 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5799 |
} |
} |
5800 |
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
5801 |
|
|
5802 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5803 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5804 |
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
5805 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5812 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
5813 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
5814 |
|
|
5815 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5816 |
|
|
5817 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5818 |
// step 4: insert the new calibration: |
// step 4: insert the new calibration: |
5819 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5843 |
}while(1);//end loop over calibrations |
}while(1);//end loop over calibrations |
5844 |
|
|
5845 |
|
|
5846 |
if( result )delete result; |
if( rresult )delete rresult; // 10RED bug |
5847 |
if( row )delete row; |
if( row )delete row; |
5848 |
|
|
5849 |
|
|
6144 |
memset(myid,0,500*sizeof(UInt_t)); |
memset(myid,0,500*sizeof(UInt_t)); |
6145 |
// |
// |
6146 |
oss.str(""); |
oss.str(""); |
6147 |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "'order BY RUNHEADER_TIME asc;"; |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; |
6148 |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
6149 |
nresult = conn->Query(oss.str().c_str()); |
nresult = conn->Query(oss.str().c_str()); |
6150 |
// |
// |
6175 |
while ( anr ){ |
while ( anr ){ |
6176 |
// |
// |
6177 |
oss.str(""); |
oss.str(""); |
6178 |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< (float)mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; // 10RED MYSQL OPERATOR BUG |
6179 |
if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str()); |
6180 |
// |
// |
6181 |
nresult1 = conn->Query(oss.str().c_str()); |
nresult1 = conn->Query(oss.str().c_str()); |
6265 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
6266 |
// |
// |
6267 |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
6268 |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT()<< ";"; |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT(); |
6269 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
6270 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
6271 |
}; |
}; |
6272 |
}; |
}; |
6315 |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
6316 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6317 |
// |
// |
6318 |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< ";"; |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT(); |
6319 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
6320 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
6321 |
}; |
}; |
6322 |
}; |
}; |
6367 |
row2 = result2->Next(); |
row2 = result2->Next(); |
6368 |
// |
// |
6369 |
if ( row2 ){ |
if ( row2 ){ |
6370 |
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"); |
6371 |
if ( PEDANTIC ) throw -83; |
if ( PEDANTIC ) throw -83; |
6372 |
row2->Close(); |
row2->Close(); |
6373 |
}; |
}; |
6444 |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
6445 |
// |
// |
6446 |
oss.str(""); |
oss.str(""); |
6447 |
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 " |
6448 |
<< " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND (" |
<< " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND (" |
6449 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
6450 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
6502 |
moved++; |
moved++; |
6503 |
// |
// |
6504 |
} else { |
} else { |
6505 |
if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n"); |
|
6506 |
if ( PEDANTIC ) throw -83; |
// questa parte mah mah mah... da controllare |
6507 |
|
|
6508 |
|
// |
6509 |
|
// 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 |
6510 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
6511 |
|
// |
6512 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
6513 |
|
// |
6514 |
|
Bool_t OK = false; |
6515 |
|
UInt_t IDRL2A = 0; |
6516 |
|
UInt_t IDRL2B = 0; |
6517 |
|
if ( result2->GetRowCount() == 2 ){ |
6518 |
|
IDRL2A = (UInt_t)atoll(row2->GetField(0)); |
6519 |
|
UInt_t IDRL0A = (UInt_t)atoll(row2->GetField(4)); |
6520 |
|
row2 = result2->Next(); |
6521 |
|
IDRL2B = (UInt_t)atoll(row2->GetField(0)); |
6522 |
|
UInt_t IDRL0B = (UInt_t)atoll(row2->GetField(4)); |
6523 |
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
6524 |
|
// if ( IDRL0A == IDRL0B ){ |
6525 |
|
// TSQLResult *result2a = 0; |
6526 |
|
// TSQLRow *row2a = 0; |
6527 |
|
// oss.str(""); |
6528 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
6529 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
6530 |
|
// result2a = conn->Query(oss.str().c_str()); |
6531 |
|
// // |
6532 |
|
// if ( !result2a ) throw -4; |
6533 |
|
// // |
6534 |
|
// row2a = result2a->Next(); |
6535 |
|
// // |
6536 |
|
// if ( row2a ){ |
6537 |
|
// UInt_t PKA = (UInt_t)atoll(row2a->GetField(0)); |
6538 |
|
// delete result2a; |
6539 |
|
// oss.str(""); |
6540 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
6541 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
6542 |
|
// result2a = conn->Query(oss.str().c_str()); |
6543 |
|
// // |
6544 |
|
// if ( !result2a ) throw -4; |
6545 |
|
// // |
6546 |
|
// row2a = result2a->Next(); |
6547 |
|
// // |
6548 |
|
// if ( row2a ){ |
6549 |
|
// UInt_t PKB = (UInt_t)atoll(row2a->GetField(0)); |
6550 |
|
// // |
6551 |
|
// 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); |
6552 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
6553 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
6554 |
|
OK = true; |
6555 |
|
// }; |
6556 |
|
// }; |
6557 |
|
// }; |
6558 |
|
// }; |
6559 |
|
}; |
6560 |
|
if ( OK ){ |
6561 |
|
// |
6562 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
6563 |
|
// |
6564 |
|
// 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 ) |
6565 |
|
// |
6566 |
|
GL_RUN *glA = new GL_RUN(); |
6567 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
6568 |
|
// |
6569 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
6570 |
|
// |
6571 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
6572 |
|
// |
6573 |
|
oss.str(""); |
6574 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6575 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
6576 |
|
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
6577 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
6578 |
|
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
6579 |
|
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
6580 |
|
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
6581 |
|
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
6582 |
|
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
6583 |
|
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
6584 |
|
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
6585 |
|
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
6586 |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
6587 |
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
6588 |
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
6589 |
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
6590 |
|
// |
6591 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
6592 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
6593 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
6594 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
6595 |
|
// |
6596 |
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
6597 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
6598 |
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
6599 |
|
conn->Query(oss.str().c_str()); |
6600 |
|
// |
6601 |
|
} else { |
6602 |
|
// |
6603 |
|
// sig no runheader, let set anyway what is possible... |
6604 |
|
// |
6605 |
|
oss.str(""); |
6606 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6607 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
6608 |
|
// |
6609 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
6610 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
6611 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
6612 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
6613 |
|
// |
6614 |
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
6615 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
6616 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
6617 |
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
6618 |
|
conn->Query(oss.str().c_str()); |
6619 |
|
}; |
6620 |
|
// |
6621 |
|
// update runheader ROOT_ID_FRAG |
6622 |
|
// |
6623 |
|
oss.str(""); |
6624 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
6625 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
6626 |
|
conn->Query(oss.str().c_str()); |
6627 |
|
// |
6628 |
|
// now let's look for runtrailer if any in the last run |
6629 |
|
// |
6630 |
|
glA->Query_GL_RUN(IDRL2B,conn); |
6631 |
|
// |
6632 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
6633 |
|
// |
6634 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
6635 |
|
// |
6636 |
|
oss.str(""); |
6637 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6638 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
6639 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
6640 |
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
6641 |
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
6642 |
|
// |
6643 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
6644 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
6645 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
6646 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6647 |
|
// |
6648 |
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
6649 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
6650 |
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
6651 |
|
conn->Query(oss.str().c_str()); |
6652 |
|
// |
6653 |
|
} else { |
6654 |
|
// |
6655 |
|
// sig no runtrailer, let set anyway what is possible... |
6656 |
|
// |
6657 |
|
oss.str(""); |
6658 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
6659 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
6660 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
6661 |
|
// |
6662 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
6663 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
6664 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
6665 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6666 |
|
// |
6667 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
6668 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
6669 |
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
6670 |
|
conn->Query(oss.str().c_str()); |
6671 |
|
}; |
6672 |
|
// |
6673 |
|
UInt_t myi = glrun->GetID(); |
6674 |
|
oss.str(""); |
6675 |
|
oss << " ID= "<< myi; |
6676 |
|
// |
6677 |
|
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
6678 |
|
// |
6679 |
|
// fill the new run in GL_RUN |
6680 |
|
// |
6681 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
6682 |
|
glrun->Fill_GL_RUN(conn); |
6683 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
6684 |
|
delete glA; |
6685 |
|
moved++; |
6686 |
|
// |
6687 |
|
} else { |
6688 |
|
// |
6689 |
|
// is just a repetition |
6690 |
|
// |
6691 |
|
if ( IsDebug() ) printf(" The run %u is already present in the GL_RUN table...\n",glrun->GetID()); |
6692 |
|
// printf(" CCCCCCCCICCCCCCCCCCCCIOOOOOOOOOO si muove Ciccio! %u \n",glrun->GetID()); |
6693 |
|
// if ( PEDANTIC && glrun->GetID() != 61563 ) throw -83; |
6694 |
|
if ( PEDANTIC ) throw -83; |
6695 |
|
}; |
6696 |
|
// if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! ...\n"); |
6697 |
|
// if ( PEDANTIC ) throw -83; |
6698 |
}; |
}; |
6699 |
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)); |
6700 |
// |
// |