--- YodaProfiler/src/PamelaDBOperations.cpp 2007/04/30 08:16:19 1.31 +++ YodaProfiler/src/PamelaDBOperations.cpp 2007/08/30 15:04:44 1.46 @@ -400,15 +400,15 @@ upperobt = OBT(obtlast); upperentry = nevent-1; // - if ( IsDebug() ) printf(" First entries are: OBT %i pkt_num %i \n",obtfirst,pktfirst); + if ( IsDebug() ) printf(" First entries are: OBT %u pkt_num %u \n",obtfirst,pktfirst); // if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry); // - if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ) return(1); + if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ) return(32); // - if ( !nevent ) return(2); + if ( !nevent ) return(64); // - if ( nevent < 2 ) return(4); + if ( nevent < 2 ) return(128); if ( nevent < jump ) jump = 1; // if ( nevent < jump ) jump = int(nevent/10); // if ( !jump ) jump = 1; @@ -447,7 +447,7 @@ if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){ zomp = i + jump + 1; if ( zomp > nevent-2 ) zomp = nevent - 2; - if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %lld pktlast %i upperobt %lld obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i); + if ( IsDebug() ) printf(" .-. jump %i zomp %i upperpkt %lld pktlast %u upperobt %lld obtlast %u last entry is %i \n",jump,zomp,upperpkt,pktlast,upperobt,obtlast,i); break; }; // @@ -867,7 +867,7 @@ return((Long64_t)pkt_num+16777215LL); }; // - if ( pkt_num > ppktfirst*2 && pkt_num > (16777214/2) ){ + if ( pkt_num > ((Long64_t)ppktfirst*2) && pkt_num > (16777214/2) ){ if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL); return((Long64_t)pkt_num-16777215LL); }; @@ -882,14 +882,15 @@ */ Long64_t PamelaDBOperations::OBT(UInt_t obt){ // - if ( IsDebug() ) printf(" obt conversion: ob is %u obtfirst is %u (numeric_limits::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits::max()/2)); + if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits::max()/2)); // if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits::max()/2) ){ - if ( IsDebug() ) printf(" rise up obt %lld \n",(obt+numeric_limits::max())); + if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)(obt+numeric_limits::max())); return((Long64_t)(obt+numeric_limits::max())); }; // - if ( obt > (pobtfirst*2) && obt > (numeric_limits::max()/2) ){ + if ( obt > ((Long64_t)pobtfirst*2) && obt > (numeric_limits::max()/2) ){ + if ( IsDebug() ) printf(" pobtfirst*2 %lld \n",((Long64_t)pobtfirst*2)); if ( IsDebug() ) printf(" rise down pktnum %lld \n", (Long64_t)obt-(Long64_t)numeric_limits::max()); return((Long64_t)obt-(Long64_t)numeric_limits::max()); }; @@ -1034,6 +1035,9 @@ TSQLResult *result = 0; TSQLRow *row = 0; UInt_t t0 = 0; + Int_t signal = 0; + // + signal = this->SetUpperLimits(); // stringstream oss; // @@ -1086,7 +1090,6 @@ }; // TTree *T = 0; - Int_t signal = 0; // UInt_t nevent = 0; UInt_t recEntries = 0; @@ -1495,7 +1498,7 @@ stringstream oss; oss.str(""); // - signal = this->SetUpperLimits(); + // signal = this->SetUpperLimits(); // // loop on runheader and runtrailer events // @@ -1513,6 +1516,13 @@ rt->SetBranchAddress("RunTrailer", &runt); rt->SetBranchAddress("Header", &eht); // + TTree *T = (TTree*)file->Get("Physics"); + if ( !T || T->IsZombie() ) throw -16; + EventHeader *eh = 0; + T->SetBranchAddress("Header", &eh); + // + if ( !(rh->GetEntries()) && !(rt->GetEntries()) && !(T->GetEntries()) ) return(16); + // UInt_t obtt = 0; UInt_t obth = 0; UInt_t pktt = 0; @@ -1546,14 +1556,14 @@ // if ( !ptt && !(ptht+1) ){ // - if ( IsDebug() ) printf(" Piece of run at the beginning of the file %i %i %i \n",ptht,pth,ptt); + if ( IsDebug() ) printf(" Piece of run at the beginning of the file %u %u %u \n",ptht,pth,ptt); // this->HandleRunFragments(true,false,0,(evbeft-1)); // // } else if ( pth == ptht ){ // - if ( IsDebug() ) printf(" Missing header %i %i %i\n",ptht,pth,ptt); + if ( IsDebug() ) printf(" Missing header %u %u %u\n",ptht,pth,ptt); // if ( (ptt-1) < 0 ) throw -15; // should never arrive here! rt->GetEntry(ptt-1); @@ -1562,14 +1572,14 @@ rt->GetEntry(ptt); pht = eht->GetPscuHeader(); // - if ( IsDebug() ) printf(" Try to find the beginning of a run which has only the runtrailer %i %i %i \n",ptht,pth,ptt); - if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt); + if ( IsDebug() ) printf(" Try to find the beginning of a run which has only the runtrailer %u %u %u \n",ptht,pth,ptt); + if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt); // this->HandleMissingHoT(true,false,evbefh,evbeft-1); // } else { // - if ( IsDebug() ) printf(" Could be a good run, we have a runheader followed by a runtrailer %i %i %i\n",ptht,pth,ptt); + if ( IsDebug() ) printf(" Could be a good run, we have a runheader followed by a runtrailer %u %u %u\n",ptht,pth,ptt); // rh->GetEntry(ptht); phh = ehh->GetPscuHeader(); @@ -1577,7 +1587,7 @@ obth = phh->GetOrbitalTime(); cod = ehh->GetCounter(); evbefh = cod->Get(pctp->Physics); - if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt); + if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt); // // handle this run // @@ -1587,17 +1597,25 @@ // if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){ // - if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER \n"); - // - this->HandleRunFragments(true,true,0,(evbefh-1)); + if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER evbefh = %u \n",evbefh); // + if ( evbefh == 0 ) { + // + signal = 8; + if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n"); + // + } else { + // + this->HandleRunFragments(true,true,0,(evbefh-1)); + // + }; }; // // if ( (ptht - pth) > 1 ){ // if ( IsDebug() ) printf(" Missing runtrailers! \n"); - if ( IsDebug() ) printf(" Attention there is a jump in the runheader counter %i %i %i \n",ptht,pth,ptt); + if ( IsDebug() ) printf(" Attention there is a jump in the runheader counter %u %u %u \n",ptht,pth,ptt); // is not the consecutive header while ( pth != ptht ){ // @@ -1618,8 +1636,8 @@ obth = phh->GetOrbitalTime(); evbefh = cod->Get(pctp->Physics); // - if ( IsDebug() ) printf(" Try to find the end of a run which has only the runheader %i %i %i \n",ptht,pth,ptt); - if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt); + if ( IsDebug() ) printf(" Try to find the end of a run which has only the runheader %u %u %u \n",ptht,pth,ptt); + if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt); // this->HandleMissingHoT(false,true,evbefh,evbeft-1); // @@ -1628,7 +1646,7 @@ } else if ( !(ptht - pth) ){ // if ( IsDebug() ) printf(" Missing runheader! \n"); - if ( IsDebug() ) printf(" Attention! the runheader counter did not changed %i %i %i \n",ptht,pth,ptt); + if ( IsDebug() ) printf(" Attention! the runheader counter did not changed %u %u %u \n",ptht,pth,ptt); if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n"); // } else { @@ -1649,9 +1667,9 @@ obth = phh->GetOrbitalTime(); cod = ehh->GetCounter(); evbefh = cod->Get(pctp->Physics); - if ( IsDebug() ) printf(" Piece of run at the end of file %i %i %i \n",pkth,obth,obtt); - if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i %i %i \n",ptht,pth,ptt); - if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i \n",rhev); + if ( IsDebug() ) printf(" Piece of run at the end of file %u %u %u \n",pkth,obth,obtt); + if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u %u %u \n",ptht,pth,ptt); + if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u \n",rhev); // this->HandleRunFragments(false,true,evbefh,upperentry); } else { @@ -1699,6 +1717,8 @@ // ( runhead_time <= _our_runhead_time && runtrail_time >= _our_runtrail_time) && // ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) && // ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) ) + // || + // ( runhead_time = _our_runhead_time && runtrail_time = _our_runtrail_time && nevents > 100 ) // ) // oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE " @@ -1714,7 +1734,10 @@ << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " - << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; + << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") OR " + << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " // these two lines in a certain way disable the patch below... + << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100)" // + << " ));"; // if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); result = conn->Query(oss.str().c_str()); @@ -1736,7 +1759,8 @@ // // the run has already been inserted // - // return(true); //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here + if ( signal && IsDebug() ) printf(" The run has already been inserted \n"); + return(true); //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here // // PATCH! // we keep the processing run if (in order of growing importance) 1) we have the runtrailer while the old run doesn't have it 2) we have the runheader @@ -2051,7 +2075,7 @@ ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); - if ( IsDebug() ) printf(" Check overlapping events: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); + if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); TTree *T= 0; T = (TTree*)file->Get("Physics"); if ( !T || T->IsZombie() ) throw -16; @@ -2065,7 +2089,7 @@ bobt = OBT(ph->GetOrbitalTime()); firstev++; }; - if ( IsDebug() ) printf(" Check overlapping events done: %i %i %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); + if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); // glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); @@ -2248,7 +2272,7 @@ ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT()); UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT()); ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT()); - if ( IsDebug() ) printf(" Check overlapping events: %i %i %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); + if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); TTree *T= 0; T = (TTree*)file->Get("Physics"); if ( !T || T->IsZombie() ) throw -16; @@ -2262,7 +2286,7 @@ aobt = OBT(ph->GetOrbitalTime()); lastev--; }; - if ( IsDebug() ) printf(" Check overlapping events done: %i %i %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); // glrun->SetEV_TO(lastev); glrun->SetNEVENTS(lastev-firstev+1); @@ -2869,7 +2893,7 @@ fromtime = this->GetAbsTime(ph->GetOrbitalTime()); if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){ // - if ( IsDebug() ) printf(" Calo calibration for section %i at time %i obt %i pkt %i \n",section,fromtime,obt,pkt); + if ( IsDebug() ) printf(" Calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt); // // check if the calibration has already been inserted // @@ -2914,7 +2938,7 @@ // if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section); if ( fromtime < 1150871000 ){ //1150866904 - if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); + if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime); fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode }; // @@ -2976,7 +3000,7 @@ // } else { // - if ( IsDebug() ) printf(" Repeated calo calibration for section %i at time %i obt %i pkt %i \n",section,fromtime,obt,pkt); + if ( IsDebug() ) printf(" Repeated calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt); // }; // @@ -3194,7 +3218,7 @@ // if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){ // - if ( IsDebug() ) printf(" Trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1); + if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); // valid = ValidateTrkCalib( caltrk1, eh1 ); if ( IsDebug() ) cout << " pkt1 validation --> "<PKT(pkt2) == this->PKT(pkt1)+1 ){ // - if ( IsDebug() ) printf(" The trk calibration2 at obt %i pkt %i t2 is %i is good \n",obt2,pkt2,t2); + if ( IsDebug() ) printf(" The trk calibration2 at obt %u pkt %u t2 is %u is good \n",obt2,pkt2,t2); // UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 ); if ( IsDebug() ) cout << " pkt2 validation --> "< pret2+1 ){ // @@ -3286,7 +3310,7 @@ // // Check for missing calibtrk2 // - if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %i pkt %i t2 is %i\n",obt2,pkt2,t2); + if ( IsDebug() ) printf(" Missing the trk calibration2! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); t2 = pret2; // // handle missing calib2 @@ -3300,7 +3324,7 @@ // } else { // - if ( IsDebug() ) printf(" Repetead trk calibration1 at time %i obt %i pkt %i \n",fromtime,obt1,pkt1); + if ( IsDebug() ) printf(" Repetead trk calibration1 at time %u obt %u pkt %u \n",fromtime,obt1,pkt1); // }; // @@ -3325,7 +3349,7 @@ valid = 0; if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ // - if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %i pkt %i t2 is %i\n",obt2,pkt2,t2); + if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u\n",obt2,pkt2,t2); // this->HandleTRK_CALIB(false,true); // @@ -3379,7 +3403,7 @@ fromtime = this->GetAbsTime(ph->GetOrbitalTime()); if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){ // - if ( IsDebug() ) printf(" S4 calibration at time %i obt %i pkt %i \n",fromtime,obt,pkt); + if ( IsDebug() ) printf(" S4 calibration at time %u obt %u pkt %u \n",fromtime,obt,pkt); // // check if the calibration has already been inserted // @@ -3422,7 +3446,7 @@ // if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n"); if ( fromtime < 1150871000 ){ - if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); + if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime); fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode }; // @@ -3481,7 +3505,7 @@ // } else { // - if ( IsDebug() ) printf(" Repetead S4 calibration at time %i obt %i pkt %i \n",fromtime,obt,pkt); + if ( IsDebug() ) printf(" Repeated S4 calibration at time %u obt %u pkt %u \n",fromtime,obt,pkt); // }; // @@ -3692,7 +3716,7 @@ row = result->Next(); t_stop = (UInt_t)atoll(row->GetField(4)); }; - if ( IsDebug() ) printf("Validation interval: from time %i - to time %i \n\n",t_stop,t_start); + if ( IsDebug() ) printf("Validation interval: from time %u - to time %u \n\n",t_stop,t_start); // -------------------------------------------------------------- // now retrieves runs to be validated // -------------------------------------------------------------- @@ -3863,7 +3887,7 @@ }else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max); }; - if ( IsDebug() ) printf("%i Run %i \n",nrow,this_run->ID); + if ( IsDebug() ) printf("%i Run %u \n",nrow,this_run->ID); nrow++; }; @@ -3892,7 +3916,7 @@ // which should be equal to the time between ascending-nodes. //============================================================== if ( t2 - trkcalib->FROM_TIME > 5700) { - if ( IsDebug() )printf("Long time between calib and run start %i :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); + if ( IsDebug() )printf("Long time between calib and run start %u :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); //============================================================== // there might be a missing calibration, due to: // - MM full @@ -3913,7 +3937,7 @@ // it is enough to say that there are no missing calibrations //============================================================== // the long time interval bewteen runs might be due to download - if ( IsDebug() )printf("Short time between calib and run start %i :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); + if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); return(false); }; @@ -4229,7 +4253,7 @@ }; }; }; - if ( IsDebug() ) printf(" %i runs have been unvalidated \n",unv); + if ( IsDebug() ) printf(" %u runs have been unvalidated \n",unv); }; /** @@ -4260,7 +4284,7 @@ if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n"); while ( Row ){ delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN"); - if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0))); + if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0))); drun++; Row = pResult->Next(); }; @@ -4281,12 +4305,12 @@ } else { if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n"); while ( Row ){ - if ( IsDebug() ) printf(" restore run %i \n",(UInt_t)atoll(Row->GetField(1))); + if ( IsDebug() ) printf(" restore run %u \n",(UInt_t)atoll(Row->GetField(1))); delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS"); - if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(1))); + if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(1))); delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN"); if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){ - if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0))); + if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0))); delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN"); }; drun++; @@ -4312,7 +4336,7 @@ } else { if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n"); while ( Row ){ - if ( IsDebug() ) printf(" del run idtrash %i \n",(UInt_t)atoll(Row->GetField(0))); + if ( IsDebug() ) printf(" del run idtrash %u \n",(UInt_t)atoll(Row->GetField(0))); myquery.str(""); myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";"; conn->Query(myquery.str().c_str()); @@ -4321,7 +4345,7 @@ }; }; // - if ( IsDebug() ) printf(" Deleted %i run(s) from GL_RUN_TRASH table \n",drun); + if ( IsDebug() ) printf(" Deleted %u run(s) from GL_RUN_TRASH table \n",drun); // // // @@ -4339,7 +4363,7 @@ } else { if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n"); while ( Row ){ - if ( IsDebug() ) printf(" del run %i \n",(UInt_t)atoll(Row->GetField(0))); + if ( IsDebug() ) printf(" del run %u \n",(UInt_t)atoll(Row->GetField(0))); myquery.str(""); myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";"; conn->Query(myquery.str().c_str()); @@ -4348,7 +4372,7 @@ }; }; // - if ( IsDebug() ) printf(" Deleted %i run(s) from GL_RUN_FRAGMENTS table \n",drun); + if ( IsDebug() ) printf(" Deleted %u run(s) from GL_RUN_FRAGMENTS table \n",drun); // // // @@ -4660,8 +4684,10 @@ TSQLRow *row = 0; TSQLResult *result2 = 0; TSQLRow *row2 = 0; + TSQLResult *result3 = 0; + TSQLRow *row3 = 0; oss.str(""); - oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN order by RUNHEADER_TIME asc;"; + oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME,NEVENTS FROM GL_RUN order by RUNHEADER_TIME asc;"; // oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 order by RUNHEADER_TIME asc;"; result = conn->Query(oss.str().c_str()); // @@ -4675,6 +4701,86 @@ thisrht = (UInt_t)atoll(row->GetField(2)); thisrtt = (UInt_t)atoll(row->GetField(3)); // + if ( (UInt_t)atoll(row->GetField(4)) > 1 ){ + // + // + // + oss.str(""); + oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" + << thisid << " AND RUNHEADER_TIME=" + << thisrht << " AND RUNTRAILER_TIME!=" + << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;"; + result3 = conn->Query(oss.str().c_str()); + if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + // + while ( row3 ){ + // + // 2 runs with same runheader + // + printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0))); + row3 = result3->Next(); + }; + }; + // + oss.str(""); + oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" + << thisid << " AND RUNHEADER_TIME!=" + << thisrht << " AND RUNTRAILER_TIME=" + << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;"; + result3 = conn->Query(oss.str().c_str()); + if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + // + while ( row3 ){ + // + // 2 runs with same runtrailer + // + printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0))); + row3 = result3->Next(); + }; + }; + // + oss.str(""); + oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" + << thisid << " AND RUNHEADER_TIME>" + << thisrht << " AND RUNTRAILER_TIME<" + << thisrtt << " order by RUNHEADER_TIME asc;"; + result3 = conn->Query(oss.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + // + while ( row3 ){ + // + // run contained in the checked one + // + printf(" CHECK n.6 RUN %u CONTAINS RUN %u \n",thisid,(UInt_t)atoll(row3->GetField(0))); + row3 = result3->Next(); + }; + }; + // + oss.str(""); + oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!=" + << thisid << " AND RUNHEADER_TIME=" + << thisrht << " AND RUNTRAILER_TIME=" + << thisrtt << " AND ID_RUN_FRAG!=" + << thisid << " order by RUNHEADER_TIME asc;"; + result3 = conn->Query(oss.str().c_str()); + if ( result3 ){ + row3 = result3->Next(); + // + while ( row3 ){ + // + // duplicated run + // + printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0))); + row3 = result3->Next(); + }; + }; + }; + // // if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){ // if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){ if ( (thisrht < prevrtt) && (thisrht != prevrht) ){ @@ -4706,7 +4812,7 @@ oss.str(""); oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";"; result2 = conn->Query(oss.str().c_str()); - if ( !result2 ) throw -4;; + if ( !result2 ) throw -4; row2 = result2->Next(); prevf = (TString)row2->GetField(0); oss.str("");