/[PAMELA software]/YodaProfiler/src/PamelaDBOperations.cpp
ViewVC logotype

Diff of /YodaProfiler/src/PamelaDBOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by mocchiut, Wed Feb 14 10:55:00 2007 UTC revision 1.48 by mocchiut, Fri Aug 31 08:58:08 2007 UTC
# Line 56  string getTleDatetime(cTle*); Line 56  string getTleDatetime(cTle*);
56   * @param debug        debug flag.   * @param debug        debug flag.
57   * @param tlefilename  ascii file with TLE 3 line elements.   * @param tlefilename  ascii file with TLE 3 line elements.
58   */   */
59  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){  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){
60    //    //
61      STATIC=false;
62      if ( staticp ) STATIC=true;
63    //    //
64    SetConnection(host,user,password);    SetConnection(host,user,password);
65    //    //
# Line 261  void PamelaDBOperations::SetTLEPath(TStr Line 263  void PamelaDBOperations::SetTLEPath(TStr
263    tlefilename = str;    tlefilename = str;
264  };  };
265    
266    TString PamelaDBOperations::GetRawPath(){
267      if ( STATIC ){
268        return((TString)gSystem->DirName(filerawname.Data())+'/');
269      } else {
270        return((TString)gSystem->ExpandPathName("$PAM_RAW")+'/');
271      };
272    };
273    
274    TString PamelaDBOperations::GetRootPath(){
275      if ( STATIC ){
276        return((TString)gSystem->DirName(filerootname.Data())+'/');
277      } else {
278        return((TString)gSystem->ExpandPathName("$PAM_L0")+'/');
279      };
280    };
281    
282  /**  /**
283   * Store the olderthan variable   * Store the olderthan variable
284   * @param olderthan   * @param olderthan
# Line 277  Bool_t PamelaDBOperations::SetID_RAW(){ Line 295  Bool_t PamelaDBOperations::SetID_RAW(){
295    TSQLResult *result = 0;    TSQLResult *result = 0;
296    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
297    oss.str("");    oss.str("");
298    oss << "SELECT ID FROM GL_RAW WHERE "    if ( STATIC ){
299        << " PATH = '" << this->GetRawPath().Data() << "' AND "      oss << "SELECT ID FROM GL_RAW WHERE "
300        << " NAME = '" << this->GetRawFile().Data() << "' ";          << " PATH = '" << this->GetRawPath().Data() << "' AND "
301            << " NAME = '" << this->GetRawFile().Data() << "' ";  
302      } else {
303        oss << "SELECT ID FROM GL_RAW WHERE "
304            << " PATH = '$PAM_RAW' AND "
305            << " NAME = '" << this->GetRawFile().Data() << "' ";  
306      }
307    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
308    if ( result == NULL ) throw -4;    if ( result == NULL ) throw -4;
309    row = result->Next();    row = result->Next();
# Line 377  Int_t PamelaDBOperations::SetUpperLimits Line 400  Int_t PamelaDBOperations::SetUpperLimits
400    upperobt = OBT(obtlast);    upperobt = OBT(obtlast);
401    upperentry = nevent-1;    upperentry = nevent-1;
402    //    //
403    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);
404    //    //
405    if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry);    if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry);
406    //    //
407    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);
408    //    //
409    if ( !nevent ) return(2);    if ( !nevent ) return(64);
410    //    //
411    if ( nevent < 2 ) return(4);    if ( nevent < 2 ) return(128);
412    if ( nevent < jump ) jump = 1;    if ( nevent < jump ) jump = 1;
413    //  if ( nevent < jump ) jump = int(nevent/10);    //  if ( nevent < jump ) jump = int(nevent/10);
414    //  if ( !jump ) jump = 1;    //  if ( !jump ) jump = 1;
# Line 424  Int_t PamelaDBOperations::SetUpperLimits Line 447  Int_t PamelaDBOperations::SetUpperLimits
447          if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){          if ( t_pktlast < upperpkt && t_obtlast < upperobt && t_pktlast < upperpkt2 && t_obtlast < upperobt2 ){
448            zomp = i + jump + 1;            zomp = i + jump + 1;
449            if ( zomp > nevent-2 ) zomp = nevent - 2;            if ( zomp > nevent-2 ) zomp = nevent - 2;
450            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);
451            break;            break;
452          };          };
453          //          //
# Line 844  Long64_t PamelaDBOperations::PKT(UInt_t Line 867  Long64_t PamelaDBOperations::PKT(UInt_t
867      return((Long64_t)pkt_num+16777215LL);      return((Long64_t)pkt_num+16777215LL);
868    };    };
869    //    //
870    if ( pkt_num > ppktfirst*2 && pkt_num > (16777214/2) ){    if ( pkt_num > ((Long64_t)ppktfirst*2) && pkt_num > (16777214/2) ){
871      if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL);      if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL);
872      return((Long64_t)pkt_num-16777215LL);      return((Long64_t)pkt_num-16777215LL);
873    };    };
# Line 859  Long64_t PamelaDBOperations::PKT(UInt_t Line 882  Long64_t PamelaDBOperations::PKT(UInt_t
882   */   */
883  Long64_t PamelaDBOperations::OBT(UInt_t obt){    Long64_t PamelaDBOperations::OBT(UInt_t obt){  
884    //    //
885    if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max()));    if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u  (numeric_limits<UInt_t>::max()/2) is %u  \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2));
886      //
887      if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){
888        if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)(obt+numeric_limits<UInt_t>::max()));
889        return((Long64_t)(obt+numeric_limits<UInt_t>::max()));
890      };
891    //    //
892    if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){    if ( obt > ((Long64_t)pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){
893        if ( IsDebug() ) printf(" pobtfirst*2 %lld \n",((Long64_t)pobtfirst*2));
894        if ( IsDebug() ) printf(" rise down pktnum %lld \n", (Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max());
895      return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max());      return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max());
896    };    };
897    //    //
898      if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)obt);
899    return((Long64_t)obt);    return((Long64_t)obt);
900  };  };
901    
# Line 980  Int_t PamelaDBOperations::insertPamelaRa Line 1011  Int_t PamelaDBOperations::insertPamelaRa
1011    if ( idr ) return(1);    if ( idr ) return(1);
1012    //    //
1013    oss.str("");    oss.str("");
1014    oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('"    if ( STATIC ){
1015        << this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')";      oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('"
1016            << this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')";
1017      } else {
1018        oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')";
1019      };
1020    if ( conn->Query(oss.str().c_str()) == 0 ) throw -4;    if ( conn->Query(oss.str().c_str()) == 0 ) throw -4;
1021    //    //
1022    idr =  this->SetID_RAW();    idr =  this->SetID_RAW();
# Line 1000  Int_t PamelaDBOperations::insertPamelaGL Line 1035  Int_t PamelaDBOperations::insertPamelaGL
1035    TSQLResult *result = 0;    TSQLResult *result = 0;
1036    TSQLRow *row = 0;    TSQLRow *row = 0;
1037    UInt_t t0 = 0;    UInt_t t0 = 0;
1038      Int_t signal = 0;
1039      //
1040      signal = this->SetUpperLimits();
1041    //    //
1042    stringstream   oss;    stringstream   oss;
1043    //      //  
# Line 1052  Int_t PamelaDBOperations::insertPamelaGL Line 1090  Int_t PamelaDBOperations::insertPamelaGL
1090    };    };
1091    //    //
1092    TTree *T = 0;    TTree *T = 0;
   Int_t signal = 0;  
1093    //    //
1094    UInt_t nevent = 0;    UInt_t nevent = 0;
1095    UInt_t recEntries = 0;    UInt_t recEntries = 0;
# Line 1262  Int_t PamelaDBOperations::insertPamelaRo Line 1299  Int_t PamelaDBOperations::insertPamelaRo
1299    UInt_t idtimesync = 0;    UInt_t idtimesync = 0;
1300    //    //
1301    oss.str("");    oss.str("");
1302    oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW "    if ( STATIC ){
1303        << " LEFT JOIN GL_ROOT "      oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW "
1304        << " ON GL_RAW.ID = GL_ROOT.ID_RAW "          << " LEFT JOIN GL_ROOT "
1305        << " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND "          << " ON GL_RAW.ID = GL_ROOT.ID_RAW "
1306        << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID ";          << " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND "
1307            << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID ";
1308      } else {
1309        oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW "
1310            << " LEFT JOIN GL_ROOT "
1311            << " ON GL_RAW.ID = GL_ROOT.ID_RAW "
1312            << " WHERE GL_RAW.PATH = '$PAM_RAW' AND "
1313            << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID ";
1314      };
1315    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
1316    //    //
1317    if ( !result ) throw -12;    if ( !result ) throw -12;
# Line 1293  Int_t PamelaDBOperations::insertPamelaRo Line 1338  Int_t PamelaDBOperations::insertPamelaRo
1338    idtimesync = (UInt_t)atoll(row->GetField(0));    idtimesync = (UInt_t)atoll(row->GetField(0));
1339    //    //
1340    oss.str("");    oss.str("");
1341    oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('"    if ( STATIC ){
1342        << this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')";      oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('"
1343            << this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')";
1344      } else {
1345        oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('"
1346            << this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')";
1347      };
1348    //    //
1349    if (conn->Query(oss.str().c_str()) == 0) throw -4;    if (conn->Query(oss.str().c_str()) == 0) throw -4;
1350    //    //
# Line 1321  Int_t PamelaDBOperations::assignBOOT_NUM Line 1371  Int_t PamelaDBOperations::assignBOOT_NUM
1371    TSQLResult *result = 0;    TSQLResult *result = 0;
1372    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
1373    oss.str("");    oss.str("");
1374    oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE "    if ( STATIC ){
1375        << " PATH = '" << this->GetRawPath().Data() << "' AND "      oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE "
1376        << " NAME = '" << this->GetRawFile().Data() << "' ";          << " PATH = '" << this->GetRawPath().Data() << "' AND "
1377            << " NAME = '" << this->GetRawFile().Data() << "' ";
1378      } else {
1379        oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE "
1380            << " PATH = '$PAM_RAW' AND "
1381            << " NAME = '" << this->GetRawFile().Data() << "' ";
1382      };
1383    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
1384    //    //
1385    if ( !result ) throw -4;;    if ( !result ) throw -4;;
# Line 1442  Int_t PamelaDBOperations::insertPamelaRU Line 1498  Int_t PamelaDBOperations::insertPamelaRU
1498    stringstream oss;    stringstream oss;
1499    oss.str("");    oss.str("");
1500    //    //
1501    signal = this->SetUpperLimits();    //  signal = this->SetUpperLimits();
1502    //    //
1503    // loop on runheader and runtrailer events    // loop on runheader and runtrailer events
1504    //    //
# Line 1460  Int_t PamelaDBOperations::insertPamelaRU Line 1516  Int_t PamelaDBOperations::insertPamelaRU
1516    rt->SetBranchAddress("RunTrailer", &runt);    rt->SetBranchAddress("RunTrailer", &runt);
1517    rt->SetBranchAddress("Header", &eht);    rt->SetBranchAddress("Header", &eht);
1518    //    //
1519      TTree *T = (TTree*)file->Get("Physics");
1520      if ( !T || T->IsZombie() ) throw -16;
1521      EventHeader *eh = 0;
1522      T->SetBranchAddress("Header", &eh);
1523      //
1524      if ( !(rh->GetEntries()) && !(rt->GetEntries()) && !(T->GetEntries()) ) return(16);
1525      //
1526    UInt_t obtt = 0;    UInt_t obtt = 0;
1527    UInt_t obth = 0;    UInt_t obth = 0;
1528    UInt_t pktt = 0;    UInt_t pktt = 0;
# Line 1493  Int_t PamelaDBOperations::insertPamelaRU Line 1556  Int_t PamelaDBOperations::insertPamelaRU
1556        //        //
1557        if ( !ptt &&  !(ptht+1) ){        if ( !ptt &&  !(ptht+1) ){
1558          //          //
1559          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);
1560          //          //
1561          this->HandleRunFragments(true,false,0,(evbeft-1));          this->HandleRunFragments(true,false,0,(evbeft-1));
1562          //          //
1563          //          //
1564        } else if ( pth == ptht ){        } else if ( pth == ptht ){
1565          //          //
1566          if ( IsDebug() ) printf(" Missing header %i %i %i\n",ptht,pth,ptt);          if ( IsDebug() ) printf(" Missing header %u %u %u\n",ptht,pth,ptt);
1567          //          //
1568          if ( (ptt-1) < 0 ) throw -15; // should never arrive here!          if ( (ptt-1) < 0 ) throw -15; // should never arrive here!
1569          rt->GetEntry(ptt-1);          rt->GetEntry(ptt-1);
# Line 1509  Int_t PamelaDBOperations::insertPamelaRU Line 1572  Int_t PamelaDBOperations::insertPamelaRU
1572          rt->GetEntry(ptt);          rt->GetEntry(ptt);
1573          pht = eht->GetPscuHeader();          pht = eht->GetPscuHeader();
1574          //          //
1575          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(" Try to find the beginning of a run which has only the runtrailer   %u %u %u \n",ptht,pth,ptt);
1576          if ( IsDebug() ) printf(" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  %i %i %i \n",pkth,obth,obtt);          if ( IsDebug() ) printf(" '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  %u %u %u \n",pkth,obth,obtt);
1577          //          //
1578          this->HandleMissingHoT(true,false,evbefh,evbeft-1);          this->HandleMissingHoT(true,false,evbefh,evbeft-1);
1579          //          //
1580        } else {        } else {
1581          //          //
1582          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);
1583          //          //
1584          rh->GetEntry(ptht);          rh->GetEntry(ptht);
1585          phh = ehh->GetPscuHeader();          phh = ehh->GetPscuHeader();
# Line 1524  Int_t PamelaDBOperations::insertPamelaRU Line 1587  Int_t PamelaDBOperations::insertPamelaRU
1587          obth = phh->GetOrbitalTime();          obth = phh->GetOrbitalTime();
1588          cod = ehh->GetCounter();          cod = ehh->GetCounter();
1589          evbefh = cod->Get(pctp->Physics);          evbefh = cod->Get(pctp->Physics);
1590          if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt);          if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt);
1591          //          //
1592          // handle this run          // handle this run
1593          //          //
# Line 1534  Int_t PamelaDBOperations::insertPamelaRU Line 1597  Int_t PamelaDBOperations::insertPamelaRU
1597          //          //
1598          if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){          if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){
1599            //            //
1600            if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER \n");            if ( IsDebug() ) printf(" Piece of run at the beginning of the file WITH NO RUNTRAILER evbefh = %u \n",evbefh);        
           //  
           this->HandleRunFragments(true,true,0,(evbefh-1));  
1601            //            //
1602              if ( evbefh == 0 ) {
1603                //
1604                signal = 8;
1605                if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n");
1606                //
1607              } else {
1608                //
1609                this->HandleRunFragments(true,true,0,(evbefh-1));
1610                //
1611              };
1612          };          };
1613          //          //
1614          //          //
1615          if ( (ptht - pth) > 1 ){          if ( (ptht - pth) > 1 ){
1616            //            //
1617            if ( IsDebug() ) printf(" Missing runtrailers! \n");            if ( IsDebug() ) printf(" Missing runtrailers! \n");
1618            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);
1619            // is not the consecutive header            // is not the consecutive header
1620            while ( pth != ptht ){                      while ( pth != ptht ){          
1621              //              //
# Line 1565  Int_t PamelaDBOperations::insertPamelaRU Line 1636  Int_t PamelaDBOperations::insertPamelaRU
1636              obth = phh->GetOrbitalTime();              obth = phh->GetOrbitalTime();
1637              evbefh = cod->Get(pctp->Physics);              evbefh = cod->Get(pctp->Physics);
1638              //              //
1639              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(" Try to find the end of a run which has only the runheader   %u %u %u \n",ptht,pth,ptt);
1640              if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %i %i %i \n",pkth,obth,obtt);              if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' %u %u %u \n",pkth,obth,obtt);
1641              //              //
1642              this->HandleMissingHoT(false,true,evbefh,evbeft-1);              this->HandleMissingHoT(false,true,evbefh,evbeft-1);
1643              //              //
# Line 1575  Int_t PamelaDBOperations::insertPamelaRU Line 1646  Int_t PamelaDBOperations::insertPamelaRU
1646          } else if ( !(ptht - pth) ){          } else if ( !(ptht - pth) ){
1647            //            //
1648            if ( IsDebug() ) printf(" Missing runheader! \n");            if ( IsDebug() ) printf(" Missing runheader! \n");
1649            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);
1650            if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n");            if ( IsDebug() ) printf(" The run should have already been handled by HandleRun() \n");
1651            //            //
1652          } else {          } else {
# Line 1596  Int_t PamelaDBOperations::insertPamelaRU Line 1667  Int_t PamelaDBOperations::insertPamelaRU
1667            obth = phh->GetOrbitalTime();            obth = phh->GetOrbitalTime();
1668            cod = ehh->GetCounter();            cod = ehh->GetCounter();
1669            evbefh = cod->Get(pctp->Physics);            evbefh = cod->Get(pctp->Physics);
1670            if ( IsDebug() ) printf(" Piece of run at the end of file %i %i %i \n",pkth,obth,obtt);            if ( IsDebug() ) printf(" Piece of run at the end of file %u %u %u \n",pkth,obth,obtt);
1671            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i %i %i \n",ptht,pth,ptt);            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u %u %u \n",ptht,pth,ptt);
1672            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %i \n",rhev);            if ( IsDebug() ) printf(" ''''''''''''''''''''''''''''''' %u \n",rhev);
1673            //            //
1674            this->HandleRunFragments(false,true,evbefh,upperentry);            this->HandleRunFragments(false,true,evbefh,upperentry);
1675          } else {          } else {
# Line 1646  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1717  Bool_t PamelaDBOperations::IsRunAlreadyI
1717    //                                  ( runhead_time <= _our_runhead_time &&  runtrail_time >= _our_runtrail_time) &&    //                                  ( runhead_time <= _our_runhead_time &&  runtrail_time >= _our_runtrail_time) &&
1718    //                                  ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) &&    //                                  ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) &&
1719    //                                  ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) )    //                                  ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) )
1720      //                                  ||
1721      //                                  ( runhead_time = _our_runhead_time &&  runtrail_time = _our_runtrail_time && nevents > 100 )
1722      //                                  )
1723      //                                  ||
1724      //                                  ( runhead_time = _our_runhead_time &&  runtrail_time > _our_runtrail_time && nevents > 100 )
1725      //                                  )
1726      //                                  ||
1727      //                                  ( runhead_time < _our_runhead_time &&  runtrail_time = _our_runtrail_time && nevents > 100 )
1728    //                                  )    //                                  )
1729    //    //
1730    oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE "    oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE "
# Line 1661  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1740  Bool_t PamelaDBOperations::IsRunAlreadyI
1740        << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR "        << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR "
1741        << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND ("        << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND ("
1742        << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR "        << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR "
1743        << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));";        << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") OR "
1744          << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //  these two lines in a certain way disable the patch below...
1745          << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR"    //
1746          << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //
1747          << " RUNTRAILER_TIME>" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR"    //
1748          << " (RUNHEADER_TIME<" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //
1749          << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100)"    //
1750          << " ));";
1751    //    //
1752    if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str());
1753    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
# Line 1683  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1769  Bool_t PamelaDBOperations::IsRunAlreadyI
1769      //      //
1770      // the run has already been inserted      // the run has already been inserted
1771      //      //
1772      //    return(true);  //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here      if ( signal && IsDebug() ) printf(" The run has already been inserted \n");    
1773        return(true);  //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here
1774      //      //
1775      // PATCH!      // PATCH!
1776      // 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      // 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
# Line 1998  void PamelaDBOperations::HandleRunFragme Line 2085  void PamelaDBOperations::HandleRunFragme
2085        ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT());        ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT());
2086        UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT());        UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT());
2087        ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT());        ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT());
2088        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);
2089        TTree *T= 0;        TTree *T= 0;
2090        T = (TTree*)file->Get("Physics");        T = (TTree*)file->Get("Physics");
2091        if ( !T || T->IsZombie() ) throw -16;        if ( !T || T->IsZombie() ) throw -16;
# Line 2012  void PamelaDBOperations::HandleRunFragme Line 2099  void PamelaDBOperations::HandleRunFragme
2099          bobt = OBT(ph->GetOrbitalTime());                bobt = OBT(ph->GetOrbitalTime());      
2100          firstev++;          firstev++;
2101        };        };
2102        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);
2103        //        //
2104        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());        glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER());
2105        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());        glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER());
# Line 2195  void PamelaDBOperations::HandleRunFragme Line 2282  void PamelaDBOperations::HandleRunFragme
2282        ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT());        ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT());
2283        UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT());        UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT());
2284        ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT());        ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT());
2285        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);
2286        TTree *T= 0;        TTree *T= 0;
2287        T = (TTree*)file->Get("Physics");        T = (TTree*)file->Get("Physics");
2288        if ( !T || T->IsZombie() ) throw -16;        if ( !T || T->IsZombie() ) throw -16;
# Line 2209  void PamelaDBOperations::HandleRunFragme Line 2296  void PamelaDBOperations::HandleRunFragme
2296          aobt = OBT(ph->GetOrbitalTime());                aobt = OBT(ph->GetOrbitalTime());      
2297          lastev--;          lastev--;
2298        };        };
2299        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);
2300        //        //
2301        glrun->SetEV_TO(lastev);        glrun->SetEV_TO(lastev);
2302        glrun->SetNEVENTS(lastev-firstev+1);        glrun->SetNEVENTS(lastev-firstev+1);
# Line 2816  Int_t PamelaDBOperations::insertCALO_CAL Line 2903  Int_t PamelaDBOperations::insertCALO_CAL
2903          fromtime = this->GetAbsTime(ph->GetOrbitalTime());            fromtime = this->GetAbsTime(ph->GetOrbitalTime());  
2904          if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){          if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){
2905            //            //
2906            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);
2907            //            //
2908            // check if the calibration has already been inserted            // check if the calibration has already been inserted
2909            //            //
# Line 2861  Int_t PamelaDBOperations::insertCALO_CAL Line 2948  Int_t PamelaDBOperations::insertCALO_CAL
2948                //                //
2949                if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section);                if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section);
2950                if ( fromtime < 1150871000 ){ //1150866904                if ( fromtime < 1150871000 ){ //1150866904
2951                  if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);                  if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime);
2952                  fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode                  fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode
2953                };                };
2954                //                //
# Line 2923  Int_t PamelaDBOperations::insertCALO_CAL Line 3010  Int_t PamelaDBOperations::insertCALO_CAL
3010            //            //
3011          } else {          } else {
3012            //            //
3013            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);
3014            //            //
3015          };                };      
3016          //                //      
# Line 3141  Int_t PamelaDBOperations::insertTRK_CALI Line 3228  Int_t PamelaDBOperations::insertTRK_CALI
3228      //      //
3229      if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){      if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->OBT(obt1) >= this->OBT(obtfirst) ){
3230        //        //
3231        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);
3232        //              //      
3233        valid = ValidateTrkCalib( caltrk1, eh1 );        valid = ValidateTrkCalib( caltrk1, eh1 );
3234        if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl;        if ( IsDebug() ) cout << " pkt1 validation --> "<<valid<<endl;
# Line 3184  Int_t PamelaDBOperations::insertTRK_CALI Line 3271  Int_t PamelaDBOperations::insertTRK_CALI
3271          //          //
3272        };        };
3273        //        //
3274        if ( IsDebug() ) printf(" Found trk calibration2 at obt %i pkt %i t2 is %i \n",obt2,pkt2,t2);        if ( IsDebug() ) printf(" Found trk calibration2 at obt %u pkt %u t2 is %u \n",obt2,pkt2,t2);
3275        //        //
3276        // The calibration is good        // The calibration is good
3277        //        //
3278        if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){        if ( this->PKT(pkt2) == this->PKT(pkt1)+1 ){
3279          //          //
3280          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);
3281          //          //
3282          UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 );          UInt_t valid2 = ValidateTrkCalib( caltrk2, eh2 );
3283          if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl;          if ( IsDebug() ) cout << " pkt2 validation --> "<<valid2<<endl;
# Line 3204  Int_t PamelaDBOperations::insertTRK_CALI Line 3291  Int_t PamelaDBOperations::insertTRK_CALI
3291          //          //
3292          if ( t2 != pret2+1 ){          if ( t2 != pret2+1 ){
3293            //            //
3294            if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %i pkt %i t2 is %i pret2 is %i \n",obt2,pkt2,t2,pret2);            if ( IsDebug() ) printf(" Missing the trk calibration1! Next one at obt %u pkt %u t2 is %u pret2 is %u \n",obt2,pkt2,t2,pret2);
3295            //            //
3296            while ( t2 > pret2+1 ){            while ( t2 > pret2+1 ){
3297              //              //
# Line 3233  Int_t PamelaDBOperations::insertTRK_CALI Line 3320  Int_t PamelaDBOperations::insertTRK_CALI
3320          //          //
3321          // Check for missing calibtrk2          // Check for missing calibtrk2
3322          //          //
3323          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);
3324          t2 = pret2;          t2 = pret2;
3325          //          //
3326          // handle missing calib2          // handle missing calib2
# Line 3247  Int_t PamelaDBOperations::insertTRK_CALI Line 3334  Int_t PamelaDBOperations::insertTRK_CALI
3334        //        //
3335      } else {      } else {
3336        //        //
3337        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);
3338        //        //
3339      };      };
3340      //          //    
# Line 3272  Int_t PamelaDBOperations::insertTRK_CALI Line 3359  Int_t PamelaDBOperations::insertTRK_CALI
3359      valid = 0;      valid = 0;
3360      if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){      if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){
3361        //        //
3362        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);
3363        //        //
3364        this->HandleTRK_CALIB(false,true);        this->HandleTRK_CALIB(false,true);
3365        //        //
# Line 3326  Int_t PamelaDBOperations::insertS4_CALIB Line 3413  Int_t PamelaDBOperations::insertS4_CALIB
3413      fromtime = this->GetAbsTime(ph->GetOrbitalTime());        fromtime = this->GetAbsTime(ph->GetOrbitalTime());  
3414      if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){      if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){
3415        //        //
3416        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);
3417        //        //
3418        // check if the calibration has already been inserted        // check if the calibration has already been inserted
3419        //        //
# Line 3369  Int_t PamelaDBOperations::insertS4_CALIB Line 3456  Int_t PamelaDBOperations::insertS4_CALIB
3456            //            //
3457            if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n");            if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n");
3458            if ( fromtime < 1150871000 ){              if ( fromtime < 1150871000 ){  
3459              if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime);              if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime);
3460              fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode              fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode
3461            };            };
3462            //            //
# Line 3428  Int_t PamelaDBOperations::insertS4_CALIB Line 3515  Int_t PamelaDBOperations::insertS4_CALIB
3515        //        //
3516      } else {      } else {
3517        //        //
3518        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);
3519        //        //
3520      };            };      
3521      //            //      
# Line 3639  Int_t PamelaDBOperations::ValidateRuns(T Line 3726  Int_t PamelaDBOperations::ValidateRuns(T
3726        row = result->Next();        row = result->Next();
3727        t_stop = (UInt_t)atoll(row->GetField(4));        t_stop = (UInt_t)atoll(row->GetField(4));
3728      };      };
3729      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);
3730      // --------------------------------------------------------------      // --------------------------------------------------------------
3731      // now retrieves runs to be validated      // now retrieves runs to be validated
3732      // --------------------------------------------------------------      // --------------------------------------------------------------
# Line 3810  Int_t PamelaDBOperations::ValidateRuns(T Line 3897  Int_t PamelaDBOperations::ValidateRuns(T
3897                    }else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max);                    }else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max);
3898            };            };
3899                        
3900            if ( IsDebug() ) printf("%i Run %i \n",nrow,this_run->ID);            if ( IsDebug() ) printf("%i Run %u \n",nrow,this_run->ID);
3901            nrow++;            nrow++;
3902                        
3903    };    };
# Line 3839  Bool_t PamelaDBOperations::MissingTRK_CA Line 3926  Bool_t PamelaDBOperations::MissingTRK_CA
3926          // which should be equal to the time between ascending-nodes.          // which should be equal to the time between ascending-nodes.
3927          //==============================================================          //==============================================================
3928          if ( t2 - trkcalib->FROM_TIME > 5700) {          if ( t2 - trkcalib->FROM_TIME > 5700) {
3929                  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);
3930          //==============================================================          //==============================================================
3931          // there might be a missing calibration, due to:          // there might be a missing calibration, due to:
3932          // - MM full          // - MM full
# Line 3860  Bool_t PamelaDBOperations::MissingTRK_CA Line 3947  Bool_t PamelaDBOperations::MissingTRK_CA
3947          // it is enough to say that there are no missing calibrations          // it is enough to say that there are no missing calibrations
3948          //==============================================================          //==============================================================
3949          // the long time interval bewteen runs might be due to download          // the long time interval bewteen runs might be due to download
3950          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);
3951          return(false);          return(false);
3952                    
3953  };  };
# Line 4176  void PamelaDBOperations::ValidationOFF() Line 4263  void PamelaDBOperations::ValidationOFF()
4263        };        };
4264      };      };
4265    };    };
4266    if ( IsDebug() ) printf(" %i runs have been unvalidated \n",unv);    if ( IsDebug() ) printf(" %u runs have been unvalidated \n",unv);
4267  };  };
4268    
4269  /**  /**
# Line 4207  void PamelaDBOperations::RemoveRUNS(){ Line 4294  void PamelaDBOperations::RemoveRUNS(){
4294      if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n");          if ( IsDebug() ) printf(" Deleting run from GL_RUN table \n");    
4295      while ( Row ){      while ( Row ){
4296        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");
4297        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)));
4298        drun++;        drun++;
4299        Row = pResult->Next();            Row = pResult->Next();    
4300      };      };
# Line 4228  void PamelaDBOperations::RemoveRUNS(){ Line 4315  void PamelaDBOperations::RemoveRUNS(){
4315    } else {    } else {
4316      if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n");          if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN table \n");    
4317      while ( Row ){      while ( Row ){
4318        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)));
4319        delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS");        delrun->RestoreRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN_FRAGMENTS");
4320        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)));
4321        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN");        delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(1)),"GL_RUN");
4322        if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){        if ( (UInt_t)atoll(Row->GetField(1)) != (UInt_t)atoll(Row->GetField(0)) ){
4323          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)));
4324          delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");          delrun->DeleteRun(conn,(UInt_t)atoll(Row->GetField(0)),"GL_RUN");
4325        };        };
4326        drun++;        drun++;
# Line 4259  void PamelaDBOperations::RemoveRUNS(){ Line 4346  void PamelaDBOperations::RemoveRUNS(){
4346    } else {    } else {
4347      if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n");          if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_TRASH table \n");    
4348      while ( Row ){      while ( Row ){
4349        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)));
4350        myquery.str("");        myquery.str("");
4351        myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";";              myquery << " DELETE FROM GL_RUN_TRASH where ID_TRASH=" << Row->GetField(0) <<";";      
4352        conn->Query(myquery.str().c_str());        conn->Query(myquery.str().c_str());
# Line 4268  void PamelaDBOperations::RemoveRUNS(){ Line 4355  void PamelaDBOperations::RemoveRUNS(){
4355      };      };
4356    };    };
4357    //      //  
4358    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);    
4359    //    //
4360    //    //
4361    //    //
# Line 4286  void PamelaDBOperations::RemoveRUNS(){ Line 4373  void PamelaDBOperations::RemoveRUNS(){
4373    } else {    } else {
4374      if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n");          if ( IsDebug() ) printf(" Deleting run fragments from GL_RUN_FRAGMENTS table \n");    
4375      while ( Row ){      while ( Row ){
4376        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)));
4377        myquery.str("");        myquery.str("");
4378        myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";";        myquery << " DELETE FROM GL_RUN_FRAGMENTS where ID=" << Row->GetField(0) <<";";
4379        conn->Query(myquery.str().c_str());        conn->Query(myquery.str().c_str());
# Line 4295  void PamelaDBOperations::RemoveRUNS(){ Line 4382  void PamelaDBOperations::RemoveRUNS(){
4382      };      };
4383    };    };
4384    //      //  
4385    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);    
4386    //    //
4387    //    //
4388    //    //
# Line 4607  UInt_t PamelaDBOperations::Check(){ Line 4694  UInt_t PamelaDBOperations::Check(){
4694    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
4695    TSQLResult *result2 = 0;    TSQLResult *result2 = 0;
4696    TSQLRow    *row2    = 0;    TSQLRow    *row2    = 0;
4697      TSQLResult *result3 = 0;
4698      TSQLRow    *row3    = 0;
4699    oss.str("");    oss.str("");
4700    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;";
4701    //  oss << "SELECT ID,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN where ID>10170 and ID<10190 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;";
4702    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
4703    //    //
# Line 4622  UInt_t PamelaDBOperations::Check(){ Line 4711  UInt_t PamelaDBOperations::Check(){
4711      thisrht = (UInt_t)atoll(row->GetField(2));      thisrht = (UInt_t)atoll(row->GetField(2));
4712      thisrtt = (UInt_t)atoll(row->GetField(3));      thisrtt = (UInt_t)atoll(row->GetField(3));
4713      //      //
4714        if ( (UInt_t)atoll(row->GetField(4)) > 1 ){
4715          //
4716          //
4717          //
4718          oss.str("");
4719          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4720              << thisid << " AND RUNHEADER_TIME="
4721              << thisrht << " AND RUNTRAILER_TIME!="
4722              << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
4723          result3 = conn->Query(oss.str().c_str());
4724          if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
4725          if ( result3 ){
4726            row3 = result3->Next();
4727            //
4728            while ( row3 ){
4729              //
4730              // 2 runs with same runheader
4731              //
4732              printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0)));    
4733              row3 = result3->Next();
4734            };
4735          };
4736          //
4737          oss.str("");
4738          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4739              << thisid << " AND RUNHEADER_TIME!="
4740              << thisrht << " AND RUNTRAILER_TIME="
4741              << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
4742          result3 = conn->Query(oss.str().c_str());
4743          if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
4744          if ( result3 ){
4745            row3 = result3->Next();
4746            //
4747            while ( row3 ){
4748              //
4749              // 2 runs with same runtrailer
4750              //
4751              printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0)));
4752              row3 = result3->Next();
4753            };
4754          };
4755          //
4756          oss.str("");
4757          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4758              << thisid << " AND RUNHEADER_TIME>"
4759              << thisrht << " AND RUNTRAILER_TIME<"
4760              << thisrtt << " order by RUNHEADER_TIME asc;";
4761          result3 = conn->Query(oss.str().c_str());
4762          if ( result3 ){
4763            row3 = result3->Next();
4764            //
4765            while ( row3 ){
4766              //
4767              // run contained in the checked one
4768              //
4769              printf(" CHECK n.6 RUN %u CONTAINS RUN %u  \n",thisid,(UInt_t)atoll(row3->GetField(0)));
4770              row3 = result3->Next();
4771            };
4772          };
4773          //
4774          oss.str("");
4775          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
4776              << thisid << " AND RUNHEADER_TIME="
4777              << thisrht << " AND RUNTRAILER_TIME="
4778              << thisrtt << " AND ID_RUN_FRAG!="
4779              << thisid << " order by RUNHEADER_TIME asc;";
4780          result3 = conn->Query(oss.str().c_str());
4781          if ( result3 ){
4782            row3 = result3->Next();
4783            //
4784            while ( row3 ){
4785              //
4786              // duplicated run
4787              //
4788              printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0)));
4789              row3 = result3->Next();
4790            };
4791          };
4792        };
4793        //
4794      //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){      //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){
4795      //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){      //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){
4796      if ( (thisrht < prevrtt) && (thisrht != prevrht) ){      if ( (thisrht < prevrtt) && (thisrht != prevrht) ){
# Line 4653  UInt_t PamelaDBOperations::Check(){ Line 4822  UInt_t PamelaDBOperations::Check(){
4822        oss.str("");        oss.str("");
4823        oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";        oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";
4824        result2 = conn->Query(oss.str().c_str());        result2 = conn->Query(oss.str().c_str());
4825        if ( !result2 ) throw -4;;        if ( !result2 ) throw -4;
4826        row2 = result2->Next();        row2 = result2->Next();
4827        prevf = (TString)row2->GetField(0);        prevf = (TString)row2->GetField(0);
4828        oss.str("");        oss.str("");

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.48

  ViewVC Help
Powered by ViewVC 1.1.23