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 ){ |
189 |
chboot = (UInt_t)atoll(row2->GetField(5)); |
chboot = (UInt_t)atoll(row2->GetField(5)); |
190 |
// |
// |
191 |
if ( !chboot ){ |
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(""); |
qu.str(""); |
198 |
// 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;"; |
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;"; |
|
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] |
|
199 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
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()); |
result3 = conn->Query(qu.str().c_str()); |
203 |
if ( result3 ){ |
if ( result3 ){ |
204 |
row3 = result3->Next(); |
row3 = result3->Next(); |
205 |
if ( row3 && result3->GetRowCount() == 1 ){ |
if ( row3 ){ |
206 |
chboot = (UInt_t)atoll(row3->GetField(0)); |
chbootA = (UInt_t)atoll(row3->GetField(0)); |
207 |
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
if ( debug ) printf(" Found boot_number A = %u \n",chbootA); |
208 |
} else { |
}; |
209 |
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
}; |
210 |
throw -29; |
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-"<< 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] |
230 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
231 |
|
result3 = conn->Query(qu.str().c_str()); |
232 |
|
if ( result3 ){ |
233 |
|
row3 = result3->Next(); |
234 |
|
if ( row3 && result3->GetRowCount() == 1 ){ |
235 |
|
chboot = (UInt_t)atoll(row3->GetField(0)); |
236 |
|
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
237 |
|
} else { |
238 |
|
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
239 |
|
throw -29; |
240 |
|
}; |
241 |
}; |
}; |
242 |
}; |
}; |
243 |
}; |
}; |
899 |
// if ( nevent < jump ) jump = int(nevent/10); |
// if ( nevent < jump ) jump = int(nevent/10); |
900 |
// if ( !jump ) jump = 1; |
// if ( !jump ) jump = 1; |
901 |
// |
// |
902 |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) && nevent > deltapkt ){ |
|
903 |
|
if ( ((PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt)) && nevent > deltapkt ){ |
904 |
// |
// |
905 |
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
if ( IsDebug() ) printf(" starting jump %i \n",jump); |
906 |
// 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)); |
4278 |
UInt_t totime = 0; |
UInt_t totime = 0; |
4279 |
UInt_t obt = 0; |
UInt_t obt = 0; |
4280 |
UInt_t pkt = 0; |
UInt_t pkt = 0; |
4281 |
|
Float_t totped = 0.; |
4282 |
// |
// |
4283 |
tr = (TTree*)file->Get("CalibCalPed"); |
tr = (TTree*)file->Get("CalibCalPed"); |
4284 |
if ( !tr || tr->IsZombie() ) throw -21; |
if ( !tr || tr->IsZombie() ) throw -21; |
4296 |
if ( calibCalPed->cstwerr[section] ){ |
if ( calibCalPed->cstwerr[section] ){ |
4297 |
valid = 1; |
valid = 1; |
4298 |
if ( calibCalPed->cperror[section] ) valid = 0; |
if ( calibCalPed->cperror[section] ) valid = 0; |
4299 |
|
// |
4300 |
|
// 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.] |
4301 |
|
// |
4302 |
|
totped = 0.; |
4303 |
|
Int_t ns = 0; |
4304 |
|
if ( section == 2 ) ns = 3; |
4305 |
|
if ( section == 3 ) ns = 1; |
4306 |
|
if ( section == 1 ) ns = 2; |
4307 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4308 |
|
totped += fabs(calibCalPed->calped[ns][0][ss]); |
4309 |
|
} |
4310 |
|
if ( totped < 1. ){ |
4311 |
|
if ( IsDebug() ) printf(" Section %i totped %f - No calibration data! Calorimeter power problems? \n",section,totped); |
4312 |
|
valid = 0; |
4313 |
|
}; |
4314 |
|
// |
4315 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4316 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4317 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4479 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
4480 |
nevents = tr->GetEntries(); |
nevents = tr->GetEntries(); |
4481 |
// |
// |
4482 |
|
Float_t totpul = 0.; |
4483 |
|
// |
4484 |
if ( nevents > 0 ){ |
if ( nevents > 0 ){ |
4485 |
// |
// |
4486 |
for (UInt_t i=0; i < nevents; i++){ |
for (UInt_t i=0; i < nevents; i++){ |
4490 |
if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ |
if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ |
4491 |
valid = 1; |
valid = 1; |
4492 |
if ( cp1->pperror[section] ) valid = 0; |
if ( cp1->pperror[section] ) valid = 0; |
4493 |
|
// |
4494 |
|
// 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.] |
4495 |
|
// |
4496 |
|
totpul = 0.; |
4497 |
|
Int_t ns = 0; |
4498 |
|
if ( section == 2 ) ns = 3; |
4499 |
|
if ( section == 3 ) ns = 1; |
4500 |
|
if ( section == 1 ) ns = 2; |
4501 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4502 |
|
totpul += cp1->calpuls[ns][0][ss]; |
4503 |
|
} |
4504 |
|
if ( totpul >= 3145632. ){ |
4505 |
|
if ( IsDebug() ) printf(" PULSE1 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); |
4506 |
|
valid = 0; |
4507 |
|
}; |
4508 |
|
// |
4509 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4510 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4511 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |
4663 |
if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ |
if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ |
4664 |
valid = 1; |
valid = 1; |
4665 |
if ( cp2->pperror[section] ) valid = 0; |
if ( cp2->pperror[section] ) valid = 0; |
4666 |
|
// |
4667 |
|
// 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.] |
4668 |
|
// |
4669 |
|
totpul = 0.; |
4670 |
|
Int_t ns = 0; |
4671 |
|
if ( section == 2 ) ns = 3; |
4672 |
|
if ( section == 3 ) ns = 1; |
4673 |
|
if ( section == 1 ) ns = 2; |
4674 |
|
for (UInt_t ss=0; ss<96; ss++){ |
4675 |
|
totpul += cp2->calpuls[ns][0][ss]; |
4676 |
|
} |
4677 |
|
if ( totpul >= 3145632. ){ |
4678 |
|
if ( IsDebug() ) printf(" PULSE2 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); |
4679 |
|
valid = 0; |
4680 |
|
}; |
4681 |
|
// |
4682 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
4683 |
obt = ph->GetOrbitalTime(); |
obt = ph->GetOrbitalTime(); |
4684 |
pkt = ph->GetCounter(); |
pkt = ph->GetCounter(); |