/[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.22 by mocchiut, Mon Jan 12 20:22:29 2009 UTC revision 1.30 by mocchiut, Mon Dec 28 08:39:24 2009 UTC
# Line 88  PamelaDBOperations::PamelaDBOperations(T Line 88  PamelaDBOperations::PamelaDBOperations(T
88    //    //
89    glrun = new GL_RUN();    glrun = new GL_RUN();
90    //    //
91    if ( !chewbacca ){    //   if ( !chewbacca ){
92      if ( !boot ) SetNOBOOT(false);    //     if ( !boot ) SetNOBOOT(false);
93      SetTsync(tsync,gpamela);    //     SetTsync(tsync,gpamela);
94      SetBOOTnumber(boot,gpamela);    //     SetBOOTnumber(boot,gpamela);
95      SetObt0(obt0);    //     SetObt0(obt0);
96    };    //   };
97    //    //
98    SetTLEPath(tlefilename);    SetTLEPath(tlefilename);
99    //    //
# Line 126  void PamelaDBOperations::Close(){ Line 126  void PamelaDBOperations::Close(){
126  //  //
127  // SETTERS  // SETTERS
128  //  //
129    void PamelaDBOperations::NotChewbacca(UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t gpamela){
130      if ( !boot ) SetNOBOOT(false);
131      SetTsync(tsync,gpamela);
132      SetBOOTnumber(boot,gpamela);
133      SetObt0(obt0);
134    };
135    
136  void PamelaDBOperations::OpenL0File(TString filerootname){  void PamelaDBOperations::OpenL0File(TString filerootname){
137    if( INSERT_ROOT ){    if( INSERT_ROOT ){
# Line 183  void PamelaDBOperations::OpenL0File(TStr Line 189  void PamelaDBOperations::OpenL0File(TStr
189            chboot = (UInt_t)atoll(row2->GetField(5));            chboot = (UInt_t)atoll(row2->GetField(5));
190            //            //
191            if ( !chboot ){            if ( !chboot ){
192                if ( debug ) printf(" mmm... no BOOT number determined by chewbacca, try to find it looking at DB \n");
193                //
194                // new feature: check in ROOT_TABLE (timewise) the previous and the next BOOT number != 0 , if it is the same we know this one!
195                // if it is different roll back to the old behaviour
196                //
197              qu.str("");              qu.str("");
198              //      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 <<")<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]  
199              if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());              if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
200                UInt_t chbootA = 0;
201                UInt_t chbootB = 1;
202              result3 = conn->Query(qu.str().c_str());              result3 = conn->Query(qu.str().c_str());
203              if ( result3 ){              if ( result3 ){
204                row3 = result3->Next();                row3 = result3->Next();
205                if ( row3 && result3->GetRowCount() == 1 ){                if ( row3 ){
206                  chboot = (UInt_t)atoll(row3->GetField(0));                  chbootA = (UInt_t)atoll(row3->GetField(0));
207                  if ( debug ) printf(" Found boot_number = %u \n",chboot);                  if ( debug ) printf(" Found boot_number A = %u \n",chbootA);
208                } else {                };
209                  if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n");              };
210                  throw -29;              delete result3;
211                qu.str("");
212                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;";
213                if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
214                result3 = conn->Query(qu.str().c_str());
215                if ( result3 ){
216                  row3 = result3->Next();
217                  if ( row3 ){
218                    chbootB = (UInt_t)atoll(row3->GetField(0));
219                    if ( debug ) printf(" Found boot_number B = %u \n",chbootB);
220                  };
221                };
222                if ( chbootA == chbootB ){
223                  chboot = chbootA;
224                  if ( debug ) printf(" Found boot_number! it is %u \n",chboot);
225                } else {        
226                  qu.str("");
227                  //            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;";
228                  //            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]
229                  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]
230                  if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str());
231                  result3 = conn->Query(qu.str().c_str());
232                  if ( result3 ){
233                    row3 = result3->Next();
234                    if ( row3 && result3->GetRowCount() == 1 ){
235                      chboot = (UInt_t)atoll(row3->GetField(0));
236                      if ( debug ) printf(" Found boot_number = %u \n",chboot);
237                    } else {
238                      if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n");
239                      throw -29;
240                    };
241                };                };
242              };              };
243            };            };
# Line 427  void PamelaDBOperations::SetOrbitNo(UInt Line 469  void PamelaDBOperations::SetOrbitNo(UInt
469        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());
470        return;        return;
471      };      };
472      TString dwo = 0;      TString dwo = "";
473      for (Int_t i = 0; i<5; i++){      for (Int_t i = 0; i<5; i++){
474        dwo.Append(name[i],1);        dwo.Append(name[i],1);
475      };      };
# Line 857  Int_t PamelaDBOperations::SetUpperLimits Line 899  Int_t PamelaDBOperations::SetUpperLimits
899    //  if ( nevent < jump ) jump = int(nevent/10);    //  if ( nevent < jump ) jump = int(nevent/10);
900    //  if ( !jump ) jump = 1;    //  if ( !jump ) jump = 1;
901    //    //
902    if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt) && nevent > deltapkt ){  
903      if ( ((PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) || (labs(PKT(pktlast)-PKT(pktfirst))<deltapkt && labs(OBT(obtlast)-OBT(obtfirst))<deltaobt)) && nevent > deltapkt ){
904      //      //
905      if ( IsDebug() ) printf(" starting jump %i \n",jump);      if ( IsDebug() ) printf(" starting jump %i \n",jump);
906      //    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 1547  void PamelaDBOperations::FillClass(Bool_
1547      glrun->SetRUNTRAILER_PKT(lastPkt);      glrun->SetRUNTRAILER_PKT(lastPkt);
1548      //          //    
1549    };    };
1550      //
1551      // ad hoc solution for INF EV_TO [8RED] 090113
1552      //
1553      if ( !firstev && lastev == -1 ){
1554        if ( IsDebug() ) printf(" EE firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1);
1555        firstev = 1;
1556        lastev = 0;
1557      };
1558    glrun->SetEV_FROM((UInt_t)firstev);    glrun->SetEV_FROM((UInt_t)firstev);
1559    glrun->SetEV_TO((UInt_t)lastev);    glrun->SetEV_TO((UInt_t)lastev);
1560    glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1);    glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1);
# Line 3363  void PamelaDBOperations::HandleRunFragme Line 3414  void PamelaDBOperations::HandleRunFragme
3414            glrun->SetID_RUN_FRAG(IDRL2B);            glrun->SetID_RUN_FRAG(IDRL2B);
3415            glrun->Fill_GL_RUN(conn);                glrun->Fill_GL_RUN(conn);    
3416            glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS");            glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS");
3417              delete glA;
3418            //            //
3419          } else {          } else {
3420            //            //
# Line 4226  Int_t PamelaDBOperations::insertCALO_CAL Line 4278  Int_t PamelaDBOperations::insertCALO_CAL
4278    UInt_t totime = 0;    UInt_t totime = 0;
4279    UInt_t obt = 0;    UInt_t obt = 0;
4280    UInt_t pkt = 0;    UInt_t pkt = 0;
4281      Float_t totped = 0.;
4282    //    //
4283    tr = (TTree*)file->Get("CalibCalPed");    tr = (TTree*)file->Get("CalibCalPed");
4284    if ( !tr || tr->IsZombie() ) throw -21;    if ( !tr || tr->IsZombie() ) throw -21;
# Line 4243  Int_t PamelaDBOperations::insertCALO_CAL Line 4296  Int_t PamelaDBOperations::insertCALO_CAL
4296        if ( calibCalPed->cstwerr[section] ){        if ( calibCalPed->cstwerr[section] ){
4297          valid = 1;          valid = 1;
4298          if ( calibCalPed->cperror[section] ) valid = 0;          if ( calibCalPed->cperror[section] ) valid = 0;
4299            //
4300            // 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.]
4301            //
4302            totped = 0.;
4303            Int_t ns = 0;
4304            if ( section == 2 ) ns = 3;
4305            if ( section == 3 ) ns = 1;
4306            if ( section == 1 ) ns = 2;
4307            for (UInt_t ss=0; ss<96; ss++){
4308              totped += fabs(calibCalPed->calped[ns][0][ss]);
4309            }
4310            if ( totped < 1. ){
4311              if ( IsDebug() ) printf(" Section %i totped %f -  No calibration data! Calorimeter power problems? \n",section,totped);
4312              valid = 0;
4313            };
4314            //
4315          ph = eh->GetPscuHeader();          ph = eh->GetPscuHeader();
4316          obt = ph->GetOrbitalTime();            obt = ph->GetOrbitalTime();  
4317          pkt = ph->GetCounter();            pkt = ph->GetCounter();  
# Line 4410  Int_t PamelaDBOperations::insertCALOPULS Line 4479  Int_t PamelaDBOperations::insertCALOPULS
4479    tr->SetBranchAddress("Header", &eh);    tr->SetBranchAddress("Header", &eh);
4480    nevents = tr->GetEntries();    nevents = tr->GetEntries();
4481    //    //
4482      Float_t totpul = 0.;
4483      //
4484    if ( nevents > 0 ){    if ( nevents > 0 ){
4485      //      //
4486      for (UInt_t i=0; i < nevents; i++){      for (UInt_t i=0; i < nevents; i++){
# Line 4419  Int_t PamelaDBOperations::insertCALOPULS Line 4490  Int_t PamelaDBOperations::insertCALOPULS
4490          if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){          if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){
4491            valid = 1;            valid = 1;
4492            if ( cp1->pperror[section] ) valid = 0;            if ( cp1->pperror[section] ) valid = 0;
4493              //
4494              // 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.]
4495              //
4496              totpul = 0.;
4497              Int_t ns = 0;
4498              if ( section == 2 ) ns = 3;
4499              if ( section == 3 ) ns = 1;
4500              if ( section == 1 ) ns = 2;
4501              for (UInt_t ss=0; ss<96; ss++){
4502                totpul += cp1->calpuls[ns][0][ss];
4503              }
4504              if ( totpul >= 3145632. ){
4505                if ( IsDebug() ) printf(" PULSE1 Section %i totpul %f -  No calibration data! Calorimeter power problems? \n",section,totpul);
4506                valid = 0;
4507              };
4508              //
4509            ph = eh->GetPscuHeader();            ph = eh->GetPscuHeader();
4510            obt = ph->GetOrbitalTime();              obt = ph->GetOrbitalTime();  
4511            pkt = ph->GetCounter();              pkt = ph->GetCounter();  
# Line 4576  Int_t PamelaDBOperations::insertCALOPULS Line 4663  Int_t PamelaDBOperations::insertCALOPULS
4663          if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){          if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){
4664            valid = 1;            valid = 1;
4665            if ( cp2->pperror[section] ) valid = 0;            if ( cp2->pperror[section] ) valid = 0;
4666              //
4667              // 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.]
4668              //
4669              totpul = 0.;
4670              Int_t ns = 0;
4671              if ( section == 2 ) ns = 3;
4672              if ( section == 3 ) ns = 1;
4673              if ( section == 1 ) ns = 2;
4674              for (UInt_t ss=0; ss<96; ss++){
4675                totpul += cp2->calpuls[ns][0][ss];
4676              }
4677              if ( totpul >= 3145632. ){
4678                if ( IsDebug() ) printf(" PULSE2 Section %i totpul %f -  No calibration data! Calorimeter power problems? \n",section,totpul);
4679                valid = 0;
4680              };
4681              //
4682            ph = eh->GetPscuHeader();            ph = eh->GetPscuHeader();
4683            obt = ph->GetOrbitalTime();              obt = ph->GetOrbitalTime();  
4684            pkt = ph->GetCounter();              pkt = ph->GetCounter();  
# Line 6121  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6224  Int_t PamelaDBOperations::CleanGL_RUN_FR
6224                row2 = result2->Next();                row2 = result2->Next();
6225                //                //
6226                if ( row2 ){                if ( row2 ){
6227                  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");
6228                  if ( PEDANTIC ) throw -83;                  if ( PEDANTIC ) throw -83;
6229                  row2->Close();                  row2->Close();
6230                };                };
# Line 6198  Int_t PamelaDBOperations::CleanGL_RUN_FR Line 6301  Int_t PamelaDBOperations::CleanGL_RUN_FR
6301        glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn);          glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn);  
6302        //        //
6303        oss.str("");        oss.str("");
6304        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 "
6305            << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND ("            << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND ("
6306            << " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND "            << " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND "
6307            << " 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 6359  Int_t PamelaDBOperations::CleanGL_RUN_FR
6359          moved++;          moved++;
6360          //          //
6361        } else {        } else {
6362          if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n");  
6363          if ( PEDANTIC ) throw -83;          // questa parte mah mah mah... da controllare
6364    
6365            //
6366            // 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
6367            // "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number.
6368            //
6369            // 090112 [8RED (-70): RUN ALREADY INSERTED]
6370            //
6371            Bool_t OK = false;
6372            UInt_t IDRL2A = 0;
6373            UInt_t IDRL2B = 0;
6374              if ( result2->GetRowCount() == 2 ){
6375                IDRL2A = (UInt_t)atoll(row2->GetField(0));
6376                UInt_t IDRL0A = (UInt_t)atoll(row2->GetField(4));
6377                row2 = result2->Next();
6378                IDRL2B = (UInt_t)atoll(row2->GetField(0));
6379                UInt_t IDRL0B = (UInt_t)atoll(row2->GetField(4));
6380                if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B);
6381                //      if ( IDRL0A == IDRL0B ){
6382    //            TSQLResult *result2a = 0;
6383    //            TSQLRow    *row2a    = 0;
6384    //            oss.str("");
6385    //            oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;";
6386    //            if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str());
6387    //            result2a = conn->Query(oss.str().c_str());
6388    //            //
6389    //            if ( !result2a ) throw -4;
6390    //            //
6391    //            row2a = result2a->Next();
6392    //            //
6393    //            if ( row2a ){
6394    //              UInt_t PKA = (UInt_t)atoll(row2a->GetField(0));
6395    //              delete result2a;
6396    //              oss.str("");
6397    //              oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;";
6398    //              if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str());
6399    //              result2a = conn->Query(oss.str().c_str());
6400    //              //
6401    //              if ( !result2a ) throw -4;
6402    //              //
6403    //              row2a = result2a->Next();
6404    //              //
6405    //              if ( row2a ){
6406    //                UInt_t PKB = (UInt_t)atoll(row2a->GetField(0));
6407    //                //
6408    //                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);
6409    //                if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){
6410    //                  if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n");
6411                        OK = true;
6412                        //            };
6413                        //          };
6414                        //        };                  
6415                        //    };
6416              };      
6417            if ( OK ){
6418              //
6419              // this is the case in which we must insert a piece of run between two fragments in the GL_RUN table
6420              //
6421              // 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 )
6422              //
6423              GL_RUN *glA = new GL_RUN();
6424              glA->Query_GL_RUN(IDRL2A,conn);
6425              //
6426              if ( glA->GetACQ_BUILD_INFO() != 0 ){
6427                //
6428                // the first piece contains a good runheader we can update all the other runs with correct infos!
6429                //
6430                oss.str("");
6431                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6432                    << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "
6433                    << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , "
6434                    << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , "
6435                    << " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , "
6436                    << " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , "
6437                    << " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , "
6438                    << " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , "
6439                    << " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , "
6440                    << " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , "
6441                    << " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , "
6442                    << " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , "  
6443                    << " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , "  
6444                    << " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , "  
6445                    << " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , "  
6446                    << " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , ";
6447                //
6448                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() )
6449                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , ";
6450                if ( glA->GetPHYSENDRUN_MASK_S11CRC() )
6451                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , ";
6452                //        
6453                oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC();
6454                oss << " WHERE ID=" << glrun->GetID() << ";";
6455                if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str());
6456                conn->Query(oss.str().c_str());    
6457                //
6458              } else {
6459                //
6460                // sig no runheader, let set anyway what is possible...
6461                //
6462                oss.str("");
6463                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6464                    << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , ";
6465                //
6466                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() )
6467                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , ";
6468                if ( glA->GetPHYSENDRUN_MASK_S11CRC() )
6469                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , ";
6470                //        
6471                oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , "
6472                    << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT();
6473                oss << " WHERE ID=" << glrun->GetID() << ";";
6474                if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str());
6475                conn->Query(oss.str().c_str());    
6476              };
6477              //
6478              // update runheader ROOT_ID_FRAG
6479              //
6480              oss.str("");
6481              oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";";
6482              if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str());
6483              conn->Query(oss.str().c_str());
6484              //
6485              // now let's look for runtrailer if any in the last run
6486              //
6487              glA->Query_GL_RUN(IDRL2B,conn);
6488              //
6489              if ( glA->GetPKT_READY_COUNTER() != 0 ){
6490                //
6491                // the first piece contains a good runtrailer we can update all the other runs with correct infos!
6492                //
6493                oss.str("");
6494                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6495                    << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , "
6496                    << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "
6497                    << " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , "
6498                    << " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , ";
6499                //
6500                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){
6501                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; };
6502                if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) {
6503                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; };
6504                //        
6505                oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER()
6506                    << " WHERE ID=" << glrun->GetID() << ";";
6507                if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str());
6508                conn->Query(oss.str().c_str());    
6509                //
6510              } else {
6511                //
6512                // sig no runtrailer, let set anyway what is possible...
6513                //
6514                oss.str("");
6515                oss << "UPDATE GL_RUN_FRAGMENTS SET "
6516                    << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , "
6517                    << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , ";
6518                  //
6519                if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){
6520                  oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; };
6521                if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){
6522                  oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; };
6523                //        
6524                oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()
6525                    << " WHERE ID=" << glrun->GetID() << ";";
6526                if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str());
6527                conn->Query(oss.str().c_str());    
6528              };
6529              //
6530              UInt_t myi = glrun->GetID();
6531              oss.str("");
6532              oss << " ID= "<< myi;
6533              //
6534              glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn);  
6535              //
6536              // fill the new run in GL_RUN
6537              //
6538              glrun->SetID_RUN_FRAG(IDRL2B);
6539              glrun->Fill_GL_RUN(conn);    
6540              glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS");
6541              delete glA;
6542              moved++;
6543              //
6544            } else {
6545              //
6546              // is just a repetition
6547              //
6548              if ( IsDebug() ) printf(" The run %u is already present in the GL_RUN table...\n",glrun->GetID());    
6549              //      printf(" CCCCCCCCICCCCCCCCCCCCIOOOOOOOOOO si muove Ciccio! %u \n",glrun->GetID());
6550              //      if ( PEDANTIC && glrun->GetID() != 61563 ) throw -83;
6551              if ( PEDANTIC ) throw -83;
6552            };
6553            //      if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! ...\n");
6554            //      if ( PEDANTIC ) throw -83;
6555        };        };
6556        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));      
6557        //        //

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.23