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

Diff of /chewbacca/YodaProfiler/src/PamelaDBOperations.cpp

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

revision 1.16 by mocchiut, Fri Dec 12 10:49:54 2008 UTC revision 1.20 by mocchiut, Tue Dec 23 20:43:10 2008 UTC
# Line 135  void PamelaDBOperations::OpenL0File(TStr Line 135  void PamelaDBOperations::OpenL0File(TStr
135        stringstream qu;        stringstream qu;
136        TSQLResult *result = 0;        TSQLResult *result = 0;
137        TSQLResult *result2 = 0;        TSQLResult *result2 = 0;
138          TSQLResult *result3 = 0;
139        TSQLRow    *row    = 0;            TSQLRow    *row    = 0;    
140        TSQLRow    *row2    = 0;            TSQLRow    *row2    = 0;    
141          TSQLRow    *row3    = 0;    
142        TString chpath;        TString chpath;
143        TString chfile;        TString chfile;
144        UInt_t ridn = 0;        UInt_t ridn = 0;
# Line 161  void PamelaDBOperations::OpenL0File(TStr Line 163  void PamelaDBOperations::OpenL0File(TStr
163        };        };
164        delete result;        delete result;
165        qu.str("");        qu.str("");
166        qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL from ROOT_TABLE where ID_N=" << ridn << ";";        qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,REAL_TIME_INIT from ROOT_TABLE where ID_N=" << ridn << ";";
167        if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());        if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
168        result2 = conn->Query(qu.str().c_str());        result2 = conn->Query(qu.str().c_str());
169        if ( result2 ){        if ( result2 ){
# Line 178  void PamelaDBOperations::OpenL0File(TStr Line 180  void PamelaDBOperations::OpenL0File(TStr
180            chresursts = (UInt_t)atoll(row2->GetField(4));            chresursts = (UInt_t)atoll(row2->GetField(4));
181            chboot = (UInt_t)atoll(row2->GetField(5));            chboot = (UInt_t)atoll(row2->GetField(5));
182            //            //
183              if ( !chboot ){
184                qu.str("");
185                qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND (REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;";
186                if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
187                result3 = conn->Query(qu.str().c_str());
188                if ( result3 ){
189                  row3 = result3->Next();
190                  if ( row3 && result3->GetRowCount() == 1 ){
191                    chboot = (UInt_t)atoll(row3->GetField(0));
192                    if ( debug ) printf(" Found boot_number = %u \n",chboot);
193                  } else {
194                    if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n");
195                    throw -29;
196                  };
197                };
198              };
199              //
200            chpktinit = (UInt_t)atoll(row2->GetField(6));            chpktinit = (UInt_t)atoll(row2->GetField(6));
201            chpktfinal = (UInt_t)atoll(row2->GetField(7));            chpktfinal = (UInt_t)atoll(row2->GetField(7));
202            chobtinit = (UInt_t)atoll(row2->GetField(8));            chobtinit = (UInt_t)atoll(row2->GetField(8));
# Line 1607  Int_t PamelaDBOperations::insertPamelaGL Line 1626  Int_t PamelaDBOperations::insertPamelaGL
1626      if ( !row ){      if ( !row ){
1627        oss.str("");        oss.str("");
1628        oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "        oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
1629            << dworbit << " order by FROM_ORBIT desc limit 1;";            << dworbit << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;";
1630        if ( IsDebug() ) printf(" %s \n",oss.str().c_str());        if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
1631        result = conn->Query(oss.str().c_str());        result = conn->Query(oss.str().c_str());
1632        if ( !result ) throw -10;        if ( !result ) throw -10;
# Line 2248  Int_t PamelaDBOperations::insertPamelaRU Line 2267  Int_t PamelaDBOperations::insertPamelaRU
2267          ptht = cod->Get(pctp->RunHeader) - 1;          ptht = cod->Get(pctp->RunHeader) - 1;
2268          //      evbeft = cod->Get(pctp->Physics);          //      evbeft = cod->Get(pctp->Physics);
2269          tcod = (UInt_t)cod->Get(pctp->Physics);          tcod = (UInt_t)cod->Get(pctp->Physics);
2270          //      if ( !tcod ) tcod = 1;    // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT          if ( !tcod ) tcod = 1;    // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2271          evbeft = TMath::Min(upperentry,(tcod-1));          evbeft = TMath::Min(upperentry,(tcod-1));
2272          if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics));          if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics));
2273          //          //
# Line 2287  Int_t PamelaDBOperations::insertPamelaRU Line 2306  Int_t PamelaDBOperations::insertPamelaRU
2306            obth = phh->GetOrbitalTime();            obth = phh->GetOrbitalTime();
2307            cod = ehh->GetCounter();            cod = ehh->GetCounter();
2308            tcod = (UInt_t)cod->Get(pctp->Physics);            tcod = (UInt_t)cod->Get(pctp->Physics);
2309            //      if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT            if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2310            evbefh = TMath::Max(chminentry,(tcod-1));            evbefh = TMath::Max(chminentry,(tcod-1));
2311            //            //
2312            if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){            if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){
# Line 2349  Int_t PamelaDBOperations::insertPamelaRU Line 2368  Int_t PamelaDBOperations::insertPamelaRU
2368                cod = ehh->GetCounter();                cod = ehh->GetCounter();
2369                //            evbeft = cod->Get(pctp->Physics);                //            evbeft = cod->Get(pctp->Physics);
2370                tcod = (UInt_t)cod->Get(pctp->Physics);                tcod = (UInt_t)cod->Get(pctp->Physics);
2371                //              if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT                if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT
2372                evbeft = TMath::Min(upperentry,(tcod-1));                evbeft = TMath::Min(upperentry,(tcod-1));
2373                rh->GetEntry(pth);                rh->GetEntry(pth);
2374                phh = ehh->GetPscuHeader();                phh = ehh->GetPscuHeader();

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.23