--- chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2009/01/13 13:38:15 1.23 +++ chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2009/12/28 08:39:24 1.30 @@ -88,12 +88,12 @@ // glrun = new GL_RUN(); // - if ( !chewbacca ){ - if ( !boot ) SetNOBOOT(false); - SetTsync(tsync,gpamela); - SetBOOTnumber(boot,gpamela); - SetObt0(obt0); - }; + // if ( !chewbacca ){ + // if ( !boot ) SetNOBOOT(false); + // SetTsync(tsync,gpamela); + // SetBOOTnumber(boot,gpamela); + // SetObt0(obt0); + // }; // SetTLEPath(tlefilename); // @@ -126,6 +126,12 @@ // // SETTERS // +void PamelaDBOperations::NotChewbacca(UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t gpamela){ + if ( !boot ) SetNOBOOT(false); + SetTsync(tsync,gpamela); + SetBOOTnumber(boot,gpamela); + SetObt0(obt0); +}; void PamelaDBOperations::OpenL0File(TString filerootname){ if( INSERT_ROOT ){ @@ -183,19 +189,55 @@ chboot = (UInt_t)atoll(row2->GetField(5)); // if ( !chboot ){ + if ( debug ) printf(" mmm... no BOOT number determined by chewbacca, try to find it looking at DB \n"); + // + // new feature: check in ROOT_TABLE (timewise) the previous and the next BOOT number != 0 , if it is the same we know this one! + // if it is different roll back to the old behaviour + // qu.str(""); - // 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 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] + 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;"; if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); + UInt_t chbootA = 0; + UInt_t chbootB = 1; result3 = conn->Query(qu.str().c_str()); if ( result3 ){ row3 = result3->Next(); - if ( row3 && result3->GetRowCount() == 1 ){ - chboot = (UInt_t)atoll(row3->GetField(0)); - if ( debug ) printf(" Found boot_number = %u \n",chboot); - } else { - if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); - throw -29; + if ( row3 ){ + chbootA = (UInt_t)atoll(row3->GetField(0)); + if ( debug ) printf(" Found boot_number A = %u \n",chbootA); + }; + }; + delete result3; + qu.str(""); + 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;"; + if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); + result3 = conn->Query(qu.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + if ( row3 ){ + chbootB = (UInt_t)atoll(row3->GetField(0)); + if ( debug ) printf(" Found boot_number B = %u \n",chbootB); + }; + }; + if ( chbootA == chbootB ){ + chboot = chbootA; + if ( debug ) printf(" Found boot_number! it is %u \n",chboot); + } else { + qu.str(""); + // 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 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] + 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] + if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); + result3 = conn->Query(qu.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + if ( row3 && result3->GetRowCount() == 1 ){ + chboot = (UInt_t)atoll(row3->GetField(0)); + if ( debug ) printf(" Found boot_number = %u \n",chboot); + } else { + if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); + throw -29; + }; }; }; }; @@ -427,7 +469,7 @@ if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); return; }; - TString dwo = 0; + TString dwo = ""; for (Int_t i = 0; i<5; i++){ dwo.Append(name[i],1); }; @@ -857,7 +899,8 @@ // if ( nevent < jump ) jump = int(nevent/10); // if ( !jump ) jump = 1; // - if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst)) deltapkt ){ + + if ( ((PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst)) deltapkt ){ // if ( IsDebug() ) printf(" starting jump %i \n",jump); // 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)); @@ -4235,6 +4278,7 @@ UInt_t totime = 0; UInt_t obt = 0; UInt_t pkt = 0; + Float_t totped = 0.; // tr = (TTree*)file->Get("CalibCalPed"); if ( !tr || tr->IsZombie() ) throw -21; @@ -4252,6 +4296,22 @@ if ( calibCalPed->cstwerr[section] ){ valid = 1; if ( calibCalPed->cperror[section] ) valid = 0; + // + // 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.] + // + totped = 0.; + Int_t ns = 0; + if ( section == 2 ) ns = 3; + if ( section == 3 ) ns = 1; + if ( section == 1 ) ns = 2; + for (UInt_t ss=0; ss<96; ss++){ + totped += fabs(calibCalPed->calped[ns][0][ss]); + } + if ( totped < 1. ){ + if ( IsDebug() ) printf(" Section %i totped %f - No calibration data! Calorimeter power problems? \n",section,totped); + valid = 0; + }; + // ph = eh->GetPscuHeader(); obt = ph->GetOrbitalTime(); pkt = ph->GetCounter(); @@ -4419,6 +4479,8 @@ tr->SetBranchAddress("Header", &eh); nevents = tr->GetEntries(); // + Float_t totpul = 0.; + // if ( nevents > 0 ){ // for (UInt_t i=0; i < nevents; i++){ @@ -4428,6 +4490,22 @@ if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){ valid = 1; if ( cp1->pperror[section] ) valid = 0; + // + // 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.] + // + totpul = 0.; + Int_t ns = 0; + if ( section == 2 ) ns = 3; + if ( section == 3 ) ns = 1; + if ( section == 1 ) ns = 2; + for (UInt_t ss=0; ss<96; ss++){ + totpul += cp1->calpuls[ns][0][ss]; + } + if ( totpul >= 3145632. ){ + if ( IsDebug() ) printf(" PULSE1 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); + valid = 0; + }; + // ph = eh->GetPscuHeader(); obt = ph->GetOrbitalTime(); pkt = ph->GetCounter(); @@ -4585,6 +4663,22 @@ if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){ valid = 1; if ( cp2->pperror[section] ) valid = 0; + // + // 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.] + // + totpul = 0.; + Int_t ns = 0; + if ( section == 2 ) ns = 3; + if ( section == 3 ) ns = 1; + if ( section == 1 ) ns = 2; + for (UInt_t ss=0; ss<96; ss++){ + totpul += cp2->calpuls[ns][0][ss]; + } + if ( totpul >= 3145632. ){ + if ( IsDebug() ) printf(" PULSE2 Section %i totpul %f - No calibration data! Calorimeter power problems? \n",section,totpul); + valid = 0; + }; + // ph = eh->GetPscuHeader(); obt = ph->GetOrbitalTime(); pkt = ph->GetCounter();