/[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.21 by mocchiut, Mon Jan 12 18:23:37 2009 UTC revision 1.29 by mocchiut, Wed Dec 23 07:19:32 2009 UTC
# Line 183  void PamelaDBOperations::OpenL0File(TStr Line 183  void PamelaDBOperations::OpenL0File(TStr
183            chboot = (UInt_t)atoll(row2->GetField(5));            chboot = (UInt_t)atoll(row2->GetField(5));
184            //            //
185            if ( !chboot ){            if ( !chboot ){
186                if ( debug ) printf(" mmm... no BOOT number determined by chewbacca, try to find it looking at DB \n");
187                //
188                // new feature: check in ROOT_TABLE (timewise) the previous and the next BOOT number != 0 , if it is the same we know this one!
189                // if it is different roll back to the old behaviour
190                //
191              qu.str("");              qu.str("");
192              //      qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;";              qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND REAL_TIME_INIT>"<< row2->GetField(10) <<" order by REAL_TIME_INIT asc limit 1;";
             qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<20000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29]  
193              if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());              if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
194                UInt_t chbootA = 0;
195                UInt_t chbootB = 1;
196              result3 = conn->Query(qu.str().c_str());              result3 = conn->Query(qu.str().c_str());
197              if ( result3 ){              if ( result3 ){
198                row3 = result3->Next();                row3 = result3->Next();
199                if ( row3 && result3->GetRowCount() == 1 ){                if ( row3 ){
200                  chboot = (UInt_t)atoll(row3->GetField(0));                  chbootA = (UInt_t)atoll(row3->GetField(0));
201                  if ( debug ) printf(" Found boot_number = %u \n",chboot);                  if ( debug ) printf(" Found boot_number A = %u \n",chbootA);
202                } else {                };
203                  if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n");              };
204                  throw -29;              delete result3;
205                qu.str("");
206                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;";
207                if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
208                result3 = conn->Query(qu.str().c_str());
209                if ( result3 ){
210                  row3 = result3->Next();
211                  if ( row3 ){
212                    chbootB = (UInt_t)atoll(row3->GetField(0));
213                    if ( debug ) printf(" Found boot_number B = %u \n",chbootB);
214                  };
215                };
216                if ( chbootA == chbootB ){
217                  chboot = chbootA;
218                  if ( debug ) printf(" Found boot_number! it is %u \n",chboot);
219                } else {        
220                  qu.str("");
221                  //            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;";
222                  //            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]
223                  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]
224                  if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
225                  result3 = conn->Query(qu.str().c_str());
226                  if ( result3 ){
227                    row3 = result3->Next();
228                    if ( row3 && result3->GetRowCount() == 1 ){
229                      chboot = (UInt_t)atoll(row3->GetField(0));
230                      if ( debug ) printf(" Found boot_number = %u \n",chboot);
231                    } else {
232                      if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n");
233                      throw -29;
234                    };
235                };                };
236              };              };
237            };            };
# Line 427  void PamelaDBOperations::SetOrbitNo(UInt Line 463  void PamelaDBOperations::SetOrbitNo(UInt
463        if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data());        if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data());
464        return;        return;
465      };      };
466      TString dwo = 0;      TString dwo = "";
467      for (Int_t i = 0; i<5; i++){      for (Int_t i = 0; i<5; i++){
468        dwo.Append(name[i],1);        dwo.Append(name[i],1);
469      };      };
# Line 857  Int_t PamelaDBOperations::SetUpperLimits Line 893  Int_t PamelaDBOperations::SetUpperLimits
893    //  if ( nevent < jump ) jump = int(nevent/10);    //  if ( nevent < jump ) jump = int(nevent/10);
894    //  if ( !jump ) jump = 1;    //  if ( !jump ) jump = 1;
895    //    //
896    if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) && nevent > deltapkt ){  
897      if ( ((PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt)) && nevent > deltapkt ){
898      //      //
899      if ( IsDebug() ) printf(" starting jump %i \n",jump);      if ( IsDebug() ) printf(" starting jump %i \n",jump);
900      //    if ( IsDebug() ) printf(" (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) %llu < %llu && %llu > %llu \n     OR \n     (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) %llu > %llu && %llu < %llu \n",PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst),PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst));      //    if ( IsDebug() ) printf(" (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) %llu < %llu && %llu > %llu \n     OR \n     (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) %llu > %llu && %llu < %llu \n",PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst),PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst));
# Line 1504  void PamelaDBOperations::FillClass(Bool_ Line 1541  void PamelaDBOperations::FillClass(Bool_
1541      glrun->SetRUNTRAILER_PKT(lastPkt);      glrun->SetRUNTRAILER_PKT(lastPkt);
1542      //          //    
1543    };    };
1544      //
1545      // ad hoc solution for INF EV_TO [8RED] 090113
1546      //
1547      if ( !firstev && lastev == -1 ){
1548        if ( IsDebug() ) printf(" EE firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1);
1549        firstev = 1;
1550        lastev = 0;
1551      };
1552    glrun->SetEV_FROM((UInt_t)firstev);    glrun->SetEV_FROM((UInt_t)firstev);
1553    glrun->SetEV_TO((UInt_t)lastev);    glrun->SetEV_TO((UInt_t)lastev);
1554    glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1);    glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1);
# Line 3363  void PamelaDBOperations::HandleRunFragme Line 3408  void PamelaDBOperations::HandleRunFragme
3408            glrun->SetID_RUN_FRAG(IDRL2B);            glrun->SetID_RUN_FRAG(IDRL2B);
3409            glrun->Fill_GL_RUN(conn);                glrun->Fill_GL_RUN(conn);    
3410            glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS");            glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS");
3411              delete glA;
3412            //            //
3413          } else {          } else {
3414            //            //
# Line 4226  Int_t PamelaDBOperations::insertCALO_CAL Line 4272  Int_t PamelaDBOperations::insertCALO_CAL
4272    UInt_t totime = 0;    UInt_t totime = 0;
4273    UInt_t obt = 0;    UInt_t obt = 0;
4274    UInt_t pkt = 0;    UInt_t pkt = 0;
4275      Float_t totped = 0.;
4276    //    //
4277    tr = (TTree*)file->Get("CalibCalPed");    tr = (TTree*)file->Get("CalibCalPed");
4278    if ( !tr || tr->IsZombie() ) throw -21;    if ( !tr || tr->IsZombie() ) throw -21;
# Line 4243  Int_t PamelaDBOperations::insertCALO_CAL Line 4290  Int_t PamelaDBOperations::insertCALO_CAL
4290        if ( calibCalPed->cstwerr[section] ){        if ( calibCalPed->cstwerr[section] ){
4291          valid = 1;          valid = 1;
4292          if ( calibCalPed->cperror[section] ) valid = 0;          if ( calibCalPed->cperror[section] ) valid = 0;
4293            //
4294            // 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.]
4295            //
4296            totped = 0.;
4297            Int_t ns = 0;
4298            if ( section == 2 ) ns = 3;
4299            if ( section == 3 ) ns = 1;
4300            if ( section == 1 ) ns = 2;
4301            for (UInt_t ss=0; ss<96; ss++){
4302              totped += fabs(calibCalPed->calped[ns][0][ss]);
4303            }
4304            if ( totped < 1. ){
4305              if ( IsDebug() ) printf(" Section %i totped %f -  No calibration data! Calorimeter power problems? \n",section,totped);
4306              valid = 0;
4307            };
4308            //
4309          ph = eh->GetPscuHeader();          ph = eh->GetPscuHeader();
4310          obt = ph->GetOrbitalTime();            obt = ph->GetOrbitalTime();  
4311          pkt = ph->GetCounter();            pkt = ph->GetCounter();  
# Line 4410  Int_t PamelaDBOperations::insertCALOPULS Line 4473  Int_t PamelaDBOperations::insertCALOPULS
4473    tr->SetBranchAddress("Header", &eh);    tr->SetBranchAddress("Header", &eh);
4474    nevents = tr->GetEntries();    nevents = tr->GetEntries();
4475    //    //
4476      Float_t totpul = 0.;
4477      //
4478    if ( nevents > 0 ){    if ( nevents > 0 ){
4479      //      //
4480      for (UInt_t i=0; i < nevents; i++){      for (UInt_t i=0; i < nevents; i++){
# Line 4419  Int_t PamelaDBOperations::insertCALOPULS Line 4484  Int_t PamelaDBOperations::insertCALOPULS
4484          if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){          if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){
4485            valid = 1;            valid = 1;
4486            if ( cp1->pperror[section] ) valid = 0;            if ( cp1->pperror[section] ) valid = 0;
4487              //
4488              // 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.]
4489              //
4490              totpul = 0.;
4491              Int_t ns = 0;
4492              if ( section == 2 ) ns = 3;
4493              if ( section == 3 ) ns = 1;
4494              if ( section == 1 ) ns = 2;
4495              for (UInt_t ss=0; ss<96; ss++){
4496                totpul += cp1->calpuls[ns][0][ss];
4497              }
4498              if ( totpul >= 3145632. ){
4499                if ( IsDebug() ) printf(" PULSE1 Section %i totpul %f -  No calibration data! Calorimeter power problems? \n",section,totpul);
4500                valid = 0;
4501              };
4502              //
4503            ph = eh->GetPscuHeader();            ph = eh->GetPscuHeader();
4504            obt = ph->GetOrbitalTime();              obt = ph->GetOrbitalTime();  
4505            pkt = ph->GetCounter();              pkt = ph->GetCounter();  
# Line 4576  Int_t PamelaDBOperations::insertCALOPULS Line 4657  Int_t PamelaDBOperations::insertCALOPULS
4657          if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){          if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){
4658            valid = 1;            valid = 1;
4659            if ( cp2->pperror[section] ) valid = 0;            if ( cp2->pperror[section] ) valid = 0;
4660              //
4661              // 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.]
4662              //
4663              totpul = 0.;
4664              Int_t ns = 0;
4665              if ( section == 2 ) ns = 3;
4666              if ( section == 3 ) ns = 1;
4667              if ( section == 1 ) ns = 2;
4668              for (UInt_t ss=0; ss<96; ss++){
4669                totpul += cp2->calpuls[ns][0][ss];
4670              }
4671              if ( totpul >= 3145632. ){
4672                if ( IsDebug() ) printf(" PULSE2 Section %i totpul %f -  No calibration data! Calorimeter power problems? \n",section,totpul);
4673                valid = 0;
4674              };
4675              //
4676            ph = eh->GetPscuHeader();            ph = eh->GetPscuHeader();
4677            obt = ph->GetOrbitalTime();              obt = ph->GetOrbitalTime();  
4678            pkt = ph->GetCounter();              pkt = ph->GetCounter();  
# Line 6121  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6218  Int_t PamelaDBOperations::CleanGL_RUN_FR
6218                row2 = result2->Next();                row2 = result2->Next();
6219                //                //
6220                if ( row2 ){                if ( row2 ){
6221                  if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n");                  if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! \n");
6222                  if ( PEDANTIC ) throw -83;                  if ( PEDANTIC ) throw -83;
6223                  row2->Close();                  row2->Close();
6224                };                };
# Line 6198  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6295  Int_t PamelaDBOperations::CleanGL_RUN_FR
6295        glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn);          glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn);  
6296        //        //
6297        oss.str("");        oss.str("");
6298        oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE "        oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER,ID_ROOT_L0 FROM GL_RUN WHERE "
6299            << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND ("            << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND ("
6300            << " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND "            << " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND "
6301            << " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND ("            << " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND ("
# Line 6256  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6353  Int_t PamelaDBOperations::CleanGL_RUN_FR
6353          moved++;          moved++;
6354          //          //
6355        } else {        } else {
6356          if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n");  
6357          if ( PEDANTIC ) throw -83;          // questa parte mah mah mah... da controllare
6358    
6359            //
6360            // we end up here if chewbacca and we have RH---| small gap |---RT, in this case the two pieces are attached and moved to GL_RUN. We are now processing the
6361            // "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number.
6362            //
6363            // 090112 [8RED (-70): RUN ALREADY INSERTED]
6364            //
6365            Bool_t OK = false;
6366            UInt_t IDRL2A = 0;
6367            UInt_t IDRL2B = 0;
6368              if ( result2->GetRowCount() == 2 ){
6369                IDRL2A = (UInt_t)atoll(row2->GetField(0));
6370                UInt_t IDRL0A = (UInt_t)atoll(row2->GetField(4));
6371                row2 = result2->Next();
6372                IDRL2B = (UInt_t)atoll(row2->GetField(0));
6373                UInt_t IDRL0B = (UInt_t)atoll(row2->GetField(4));
6374                if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B);
6375                //      if ( IDRL0A == IDRL0B ){
6376    //            TSQLResult *result2a = 0;
6377    //            TSQLRow    *row2a    = 0;
6378    //            oss.str("");
6379    //            oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;";
6380    //            if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str());
6381    //            result2a = conn->Query(oss.str().c_str());
6382    //            //
6383    //            if ( !result2a ) throw -4;
6384    //            //
6385    //            row2a = result2a->Next();
6386    //            //
6387    //            if ( row2a ){
6388    //              UInt_t PKA = (UInt_t)atoll(row2a->GetField(0));
6389    //              delete result2a;
6390    //              oss.str("");
6391    //              oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;";
6392    //              if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str());
6393    //              result2a = conn->Query(oss.str().c_str());
6394    //              //
6395    //              if ( !result2a ) throw -4;
6396    //              //
6397    //              row2a = result2a->Next();
6398    //              //
6399    //              if ( row2a ){
6400    //                UInt_t PKB = (UInt_t)atoll(row2a->GetField(0));
6401    //                //
6402    //                if ( IsDebug() ) printf(" PKT(PKA) + 1 %llu == runheaderpkt %llu && PKB = runtrailer %llu + 1 %llu \n",PKT(PKA)+1LL, PKT(glrun->GetRUNHEADER_PKT()),PKT(PKB), PKT(glrun->GetRUNTRAILER_PKT())+1LL);
6403    //                if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){
6404    //                  if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n");
6405                        OK = true;
6406                        //            };
6407                        //          };
6408                        //        };                  
6409                        //    };
6410              };      
6411            if ( OK ){
6412              //
6413              // this is the case in which we must insert a piece of run between two fragments in the GL_RUN table
6414              //
6415              // we have to update with runheader/trailer infos our run and we have to change the ROOT_ID_FRAG of the header piece ( 1/2 2/1 must become 1/3 3/2 2/1 )
6416              //
6417              GL_RUN *glA = new GL_RUN();
6418              glA->Query_GL_RUN(IDRL2A,conn);
6419              //
6420              if ( glA->GetACQ_BUILD_INFO() != 0 ){
6421                //
6422                // the first piece contains a good runheader we can update all the other runs with correct infos!
6423                //
6424                oss.str("");
6425                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6426                    << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "
6427                    << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , "
6428                    << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , "
6429                    << " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , "
6430                    << " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , "
6431                    << " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , "
6432                    << " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , "
6433                    << " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , "
6434                    << " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , "
6435                    << " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , "
6436                    << " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , "  
6437                    << " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , "  
6438                    << " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , "  
6439                    << " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , "  
6440                    << " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , ";
6441                //
6442                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() )
6443                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , ";
6444                if ( glA->GetPHYSENDRUN_MASK_S11CRC() )
6445                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , ";
6446                //        
6447                oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC();
6448                oss << " WHERE ID=" << glrun->GetID() << ";";
6449                if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str());
6450                conn->Query(oss.str().c_str());    
6451                //
6452              } else {
6453                //
6454                // sig no runheader, let set anyway what is possible...
6455                //
6456                oss.str("");
6457                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6458                    << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , ";
6459                //
6460                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() )
6461                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , ";
6462                if ( glA->GetPHYSENDRUN_MASK_S11CRC() )
6463                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , ";
6464                //        
6465                oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , "
6466                    << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT();
6467                oss << " WHERE ID=" << glrun->GetID() << ";";
6468                if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str());
6469                conn->Query(oss.str().c_str());    
6470              };
6471              //
6472              // update runheader ROOT_ID_FRAG
6473              //
6474              oss.str("");
6475              oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";";
6476              if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str());
6477              conn->Query(oss.str().c_str());
6478              //
6479              // now let's look for runtrailer if any in the last run
6480              //
6481              glA->Query_GL_RUN(IDRL2B,conn);
6482              //
6483              if ( glA->GetPKT_READY_COUNTER() != 0 ){
6484                //
6485                // the first piece contains a good runtrailer we can update all the other runs with correct infos!
6486                //
6487                oss.str("");
6488                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6489                    << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , "
6490                    << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "
6491                    << " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , "
6492                    << " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , ";
6493                //
6494                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){
6495                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; };
6496                if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) {
6497                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; };
6498                //        
6499                oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER()
6500                    << " WHERE ID=" << glrun->GetID() << ";";
6501                if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str());
6502                conn->Query(oss.str().c_str());    
6503                //
6504              } else {
6505                //
6506                // sig no runtrailer, let set anyway what is possible...
6507                //
6508                oss.str("");
6509                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6510                    << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , "
6511                    << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , ";
6512                  //
6513                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){
6514                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; };
6515                if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){
6516                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; };
6517                //        
6518                oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()
6519                    << " WHERE ID=" << glrun->GetID() << ";";
6520                if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str());
6521                conn->Query(oss.str().c_str());    
6522              };
6523              //
6524              UInt_t myi = glrun->GetID();
6525              oss.str("");
6526              oss << " ID= "<< myi;
6527              //
6528              glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn);  
6529              //
6530              // fill the new run in GL_RUN
6531              //
6532              glrun->SetID_RUN_FRAG(IDRL2B);
6533              glrun->Fill_GL_RUN(conn);    
6534              glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS");
6535              delete glA;
6536              moved++;
6537              //
6538            } else {
6539              //
6540              // is just a repetition
6541              //
6542              if ( IsDebug() ) printf(" The run %u is already present in the GL_RUN table...\n",glrun->GetID());    
6543              //      printf(" CCCCCCCCICCCCCCCCCCCCIOOOOOOOOOO si muove Ciccio! %u \n",glrun->GetID());
6544              //      if ( PEDANTIC && glrun->GetID() != 61563 ) throw -83;
6545              if ( PEDANTIC ) throw -83;
6546            };
6547            //      if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! ...\n");
6548            //      if ( PEDANTIC ) throw -83;
6549        };        };
6550        if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0));              if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0));      
6551        //        //

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.23