/[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.35 by mocchiut, Mon Apr 30 09:16:49 2007 UTC revision 1.52 by mocchiut, Thu Oct 25 13:23:37 2007 UTC
# Line 24  Line 24 
24  #include <RunHeaderEvent.h>  #include <RunHeaderEvent.h>
25  #include <RunTrailerEvent.h>  #include <RunTrailerEvent.h>
26  #include <CalibCalPedEvent.h>  #include <CalibCalPedEvent.h>
27    #include <CalibCalPulse1Event.h>
28    #include <CalibCalPulse2Event.h>
29  #include <CalibS4Event.h>  #include <CalibS4Event.h>
30  #include <CalibTrk1Event.h>  #include <CalibTrk1Event.h>
31  #include <CalibTrk2Event.h>  #include <CalibTrk2Event.h>
# Line 56  string getTleDatetime(cTle*); Line 58  string getTleDatetime(cTle*);
58   * @param debug        debug flag.   * @param debug        debug flag.
59   * @param tlefilename  ascii file with TLE 3 line elements.   * @param tlefilename  ascii file with TLE 3 line elements.
60   */   */
61  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){  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, Bool_t gpamela){
62    //    //
63    STATIC=false;    STATIC=false;
64    if ( staticp ) STATIC=true;    if ( staticp ) STATIC=true;
# Line 68  PamelaDBOperations::PamelaDBOperations(T Line 70  PamelaDBOperations::PamelaDBOperations(T
70    glrun = new GL_RUN();    glrun = new GL_RUN();
71    //    //
72    if ( !boot ) SetNOBOOT(false);    if ( !boot ) SetNOBOOT(false);
73    SetBOOTnumber(boot);    SetTsync(tsync,gpamela);
74    SetTsync(tsync);    SetBOOTnumber(boot,gpamela);
75    SetObt0(obt0);    SetObt0(obt0);
76    //    //
77    SetTLEPath(tlefilename);    SetTLEPath(tlefilename);
# Line 179  void PamelaDBOperations::SetNoFrag(Bool_ Line 181  void PamelaDBOperations::SetNoFrag(Bool_
181   * @param boot    BOOT number of the RAW file   * @param boot    BOOT number of the RAW file
182   */   */
183  void PamelaDBOperations::SetBOOTnumber(UInt_t boot){  void PamelaDBOperations::SetBOOTnumber(UInt_t boot){
184      this->SetBOOTnumber(boot,false);
185    };
186    
187    /**
188     * Store the BOOT number of the RAW file.
189     * @param boot    BOOT number of the RAW file
190     */
191    void PamelaDBOperations::SetBOOTnumber(UInt_t boot, Bool_t gpamela){
192    BOOTNO=boot;    BOOTNO=boot;
193      if ( gpamela ){
194        stringstream oss;
195        TSQLResult *result = 0;
196        TSQLRow    *row    = 0;    
197        if ( !boot ){
198          //
199          BOOTNO = 1;
200          //
201          // look in the DB for the last timesync and the last run
202          //
203          oss.str("");
204          oss << "SELECT BOOT_NUMBER FROM GL_RUN order by RUNHEADER_TIME desc limit 1;";
205          result = conn->Query(oss.str().c_str());
206          if ( result ){
207            row = result->Next();
208            if ( row ){
209              BOOTNO = (UInt_t)atoll(row->GetField(0)) + 1;
210            };
211          };
212        };
213      };
214  };  };
215    
216  /**  /**
# Line 187  void PamelaDBOperations::SetBOOTnumber(U Line 218  void PamelaDBOperations::SetBOOTnumber(U
218   * @param boot    time sync   * @param boot    time sync
219   */   */
220  void PamelaDBOperations::SetTsync(UInt_t ts){  void PamelaDBOperations::SetTsync(UInt_t ts){
221      this->SetTsync(ts,false);
222    };
223    
224    /**
225     * Store the time sync of the RAW file.
226     * @param boot    time sync
227     */
228    void PamelaDBOperations::SetTsync(UInt_t ts, Bool_t gpamela){
229      //
230      // if not gpamela or given tsync file set ts
231      //
232    tsync=ts;    tsync=ts;
233      if ( gpamela ){
234        stringstream oss;
235        TSQLResult *result = 0;
236        TSQLRow    *row    = 0;    
237        TSQLResult *result2 = 0;
238        TSQLRow    *row2    = 0;    
239        if ( !ts ){
240          //
241          tsync = 1;
242          //
243          // look in the DB for the last timesync and the last run
244          //
245          oss.str("");
246          oss << "SELECT TIMESYNC FROM GL_TIMESYNC order by TIMESYNC desc limit 1;";
247          result = conn->Query(oss.str().c_str());
248          if ( result ){
249            row = result->Next();
250            if ( row ){
251              tsync = (UInt_t)atoll(row->GetField(0)) + 1;
252              oss.str("");
253              oss << "SELECT (RUNTRAILER_TIME-RUNHEADER_TIME) FROM GL_RUN order by RUNHEADER_TIME desc limit 1;";
254              result2 = conn->Query(oss.str().c_str());
255              if ( result2 ){
256                row2 = result2->Next();
257                if ( row2 ){
258                  tsync += (UInt_t)atoll(row2->GetField(0));
259                };
260              }
261            };
262          };
263        };
264      };
265  };  };
266    
267  /**  /**
# Line 1036  Int_t PamelaDBOperations::insertPamelaGL Line 1110  Int_t PamelaDBOperations::insertPamelaGL
1110    TSQLRow *row = 0;    TSQLRow *row = 0;
1111    UInt_t t0 = 0;    UInt_t t0 = 0;
1112    Int_t signal = 0;    Int_t signal = 0;
1113      UInt_t idresof = 0;
1114    //    //
1115    signal = this->SetUpperLimits();    signal = this->SetUpperLimits();
1116    //    //
# Line 1044  Int_t PamelaDBOperations::insertPamelaGL Line 1119  Int_t PamelaDBOperations::insertPamelaGL
1119    if ( this->GetID_RAW() == 0 )  throw -11;    if ( this->GetID_RAW() == 0 )  throw -11;
1120    //    //
1121    oss.str("");    oss.str("");
1122    oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"    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 SPECIAL_FILE='"
1123        << this->GetRawFile().Data() << "';";        << this->GetRawFile().Data() << "';";
1124    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
1125    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
# Line 1053  Int_t PamelaDBOperations::insertPamelaGL Line 1128  Int_t PamelaDBOperations::insertPamelaGL
1128    //    //
1129    if ( !row ){    if ( !row ){
1130      oss.str("");      oss.str("");
1131      oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) 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< "
1132          << dworbit << " order by FROM_ORBIT desc limit 1;";          << dworbit << " order by FROM_ORBIT desc limit 1;";
1133      if ( IsDebug() ) printf(" %s \n",oss.str().c_str());      if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
1134      result = conn->Query(oss.str().c_str());      result = conn->Query(oss.str().c_str());
# Line 1062  Int_t PamelaDBOperations::insertPamelaGL Line 1137  Int_t PamelaDBOperations::insertPamelaGL
1137      if ( !row ) throw -10;      if ( !row ) throw -10;
1138    };    };
1139    //    //
1140      idresof = (UInt_t)atoll(row->GetField(6));
1141      //
1142    TTimeStamp tu = TTimeStamp((UInt_t)atoi(row->GetField(0)),(UInt_t)atoi(row->GetField(1)),(UInt_t)atoi(row->GetField(2)),(UInt_t)atoi(row->GetField(3)),(UInt_t)atoi(row->GetField(4)),(UInt_t)atoi(row->GetField(5)),0,true,0);    TTimeStamp tu = TTimeStamp((UInt_t)atoi(row->GetField(0)),(UInt_t)atoi(row->GetField(1)),(UInt_t)atoi(row->GetField(2)),(UInt_t)atoi(row->GetField(3)),(UInt_t)atoi(row->GetField(4)),(UInt_t)atoi(row->GetField(5)),0,true,0);
1143    t0 = (UInt_t)tu.GetSec();    t0 = (UInt_t)tu.GetSec();
1144    if ( IsDebug() ) printf(" t0 is %u ti is %s %s %s %s %s %s\n",t0,row->GetField(0),row->GetField(1),row->GetField(2),row->GetField(3),row->GetField(4),row->GetField(5));    if ( IsDebug() ) printf(" t0 is %u ti is %s %s %s %s %s %s %s\n",t0,row->GetField(0),row->GetField(1),row->GetField(2),row->GetField(3),row->GetField(4),row->GetField(5),row->GetField(6));
1145    //    //
1146    /*    /*
1147     * Verify that the TIMESYNC have been not already processed     * Verify that the TIMESYNC have been not already processed
# Line 1270  Int_t PamelaDBOperations::insertPamelaGL Line 1347  Int_t PamelaDBOperations::insertPamelaGL
1347    if ( !existsts ) throw -3;    if ( !existsts ) throw -3;
1348    //    //
1349    oss.str("");    oss.str("");
1350    oss << "INSERT INTO GL_TIMESYNC (ID_RAW,TYPE,OBT0,TIMESYNC) VALUES ('"    oss << "INSERT INTO GL_TIMESYNC (ID_RAW,TYPE,OBT0,TIMESYNC,ID_RESURS_OFFSET) VALUES ('"
1351        << this->GetID_RAW() << "','"//224'"        << this->GetID_RAW() << "','"//224'"
1352        << dec << (UInt_t)TYPE << "','"        << dec << (UInt_t)TYPE << "','"
1353        << dec << (UInt_t)OBT << "','"        << dec << (UInt_t)OBT << "','"
1354        << dec << (UInt_t)TSYNC << "');";        << dec << (UInt_t)TSYNC << "','"
1355          << dec << (UInt_t)idresof << "');";
1356    conn->Query(oss.str().c_str());    conn->Query(oss.str().c_str());
1357    if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str());    if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str());
1358      if ( conn->GetErrorCode() ){
1359        printf(" OK, you got an error because the database structure you are using is not up to date\n Using backward compability code, hence you can continue safetly \n");
1360        oss.str("");
1361        oss << "INSERT INTO GL_TIMESYNC (ID_RAW,TYPE,OBT0,TIMESYNC) VALUES ('"
1362            << this->GetID_RAW() << "','"//224'"
1363            << dec << (UInt_t)TYPE << "','"
1364            << dec << (UInt_t)OBT << "','"
1365            << dec << (UInt_t)TSYNC << "');";
1366        conn->Query(oss.str().c_str());
1367        if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str());
1368      };
1369    //    //
1370    if ( IsDebug() ) printf(" found a timesync t0 is %u \n",t0);    if ( IsDebug() ) printf(" found a timesync t0 is %u \n",t0);
1371      //
1372    toffset = (UInt_t)TSYNC - (UInt_t)(this->OBT(OBT)/1000) + t0;    toffset = (UInt_t)TSYNC - (UInt_t)(this->OBT(OBT)/1000) + t0;
1373    //    //
1374    tsync = TSYNC;    tsync = TSYNC;
# Line 1516  Int_t PamelaDBOperations::insertPamelaRU Line 1606  Int_t PamelaDBOperations::insertPamelaRU
1606    rt->SetBranchAddress("RunTrailer", &runt);    rt->SetBranchAddress("RunTrailer", &runt);
1607    rt->SetBranchAddress("Header", &eht);    rt->SetBranchAddress("Header", &eht);
1608    //    //
1609      TTree *T = (TTree*)file->Get("Physics");
1610      if ( !T || T->IsZombie() ) throw -16;
1611      EventHeader *eh = 0;
1612      T->SetBranchAddress("Header", &eh);
1613      //
1614      if ( !(rh->GetEntries()) && !(rt->GetEntries()) && !(T->GetEntries()) ) return(16);
1615      //
1616    UInt_t obtt = 0;    UInt_t obtt = 0;
1617    UInt_t obth = 0;    UInt_t obth = 0;
1618    UInt_t pktt = 0;    UInt_t pktt = 0;
# Line 1590  Int_t PamelaDBOperations::insertPamelaRU Line 1687  Int_t PamelaDBOperations::insertPamelaRU
1687          //          //
1688          if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){          if ( PKT(pkth)>PKT(pktfirst) && OBT(obth)>OBT(obtfirst) && !ptt ){
1689            //            //
1690            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));  
1691            //            //
1692              if ( evbefh == 0 ) {
1693                //
1694                signal = 8;
1695                if ( IsDebug() ) printf(" Not supported yet: run with no events, no runtrailer, no runheader \n");
1696                //
1697              } else {
1698                //
1699                this->HandleRunFragments(true,true,0,(evbefh-1));
1700                //
1701              };
1702          };          };
1703          //          //
1704          //          //
# Line 1702  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1807  Bool_t PamelaDBOperations::IsRunAlreadyI
1807    //                                  ( runhead_time <= _our_runhead_time &&  runtrail_time >= _our_runtrail_time) &&    //                                  ( runhead_time <= _our_runhead_time &&  runtrail_time >= _our_runtrail_time) &&
1808    //                                  ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) &&    //                                  ( runhead_obt <= _our_runheadobt || runhead_pkt <= _our_runheadpkt ) &&
1809    //                                  ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) )    //                                  ( runtrail_obt <= _our_runtrailobt || runtrail_pkt <= _our_runtrailpkt ) )
1810      //                                  ||
1811      //                                  ( runhead_time = _our_runhead_time &&  runtrail_time = _our_runtrail_time && nevents > 100 )
1812      //                                  )
1813      //                                  ||
1814      //                                  ( runhead_time = _our_runhead_time &&  runtrail_time > _our_runtrail_time && nevents > 100 )
1815      //                                  )
1816      //                                  ||
1817      //                                  ( runhead_time < _our_runhead_time &&  runtrail_time = _our_runtrail_time && nevents > 100 )
1818    //                                  )    //                                  )
1819    //    //
1820    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 1717  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1830  Bool_t PamelaDBOperations::IsRunAlreadyI
1830        << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR "        << " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR "
1831        << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND ("        << " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND ("
1832        << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR "        << " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR "
1833        << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));";        << " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") OR "
1834          << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //  these two lines in a certain way disable the patch below...
1835          << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR"    //
1836          << " (RUNHEADER_TIME=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //
1837          << " RUNTRAILER_TIME>" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100) OR"    //
1838          << " (RUNHEADER_TIME<" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND "                //
1839          << " RUNTRAILER_TIME=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND NEVENTS>100)"    //
1840          << " ));";
1841    //    //
1842    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());
1843    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
# Line 1739  Bool_t PamelaDBOperations::IsRunAlreadyI Line 1859  Bool_t PamelaDBOperations::IsRunAlreadyI
1859      //      //
1860      // the run has already been inserted      // the run has already been inserted
1861      //      //
1862      //    return(true);  //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here      if ( signal && IsDebug() ) printf(" The run has already been inserted \n");    
1863        return(true);  //<<<<<<<<<<<<<<<<<<<<<<<< patch follows, uncomment here
1864      //      //
1865      // PATCH!      // PATCH!
1866      // 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 2990  Int_t PamelaDBOperations::insertCALO_CAL Line 3111  Int_t PamelaDBOperations::insertCALO_CAL
3111    return(0);    return(0);
3112  };  };
3113    
3114    
3115    /**
3116     * Scan calorimeter calibrations packets, fill the GL_CALO_CALIB table
3117     */
3118    Int_t PamelaDBOperations::insertCALOPULSE_CALIB(){
3119      //
3120      TSQLResult *result = 0;
3121      TSQLRow    *row    = 0;
3122      //
3123      stringstream oss;
3124      oss.str("");
3125      //
3126      oss << " DESCRIBE GL_CALOPULSE_CALIB;";
3127      if ( IsDebug() ) printf(" Check if the GL_CALOPULSE_CALIB table exists: query is \n %s \n",oss.str().c_str());
3128      result = conn->Query(oss.str().c_str());
3129      //
3130      if ( conn->GetErrorCode() ){
3131        if ( IsDebug() ) printf(" The GL_CALOPULSE_CALIB table does not exists! \n");
3132        throw -30;
3133      };
3134      //
3135      // CaloPulse1
3136      //
3137      CalibCalPulse1Event *cp1 = 0;
3138      TTree *tr = 0;
3139      EventHeader *eh = 0;
3140      PscuHeader *ph = 0;
3141      //
3142      UInt_t nevents = 0;
3143      UInt_t fromtime = 0;
3144      UInt_t totime = 0;
3145      UInt_t obt = 0;
3146      UInt_t pkt = 0;
3147      //
3148      tr = (TTree*)file->Get("CalibCalPulse1");
3149      if ( !tr || tr->IsZombie() ) throw -31;
3150      //
3151      tr->SetBranchAddress("CalibCalPulse1", &cp1);
3152      tr->SetBranchAddress("Header", &eh);
3153      nevents = tr->GetEntries();
3154      //
3155      if ( nevents > 0 ){
3156        //
3157        for (UInt_t i=0; i < nevents; i++){
3158          tr->GetEntry(i);
3159          for (UInt_t section = 0; section < 4; section++){
3160            //
3161            if ( cp1->pstwerr[section] && cp1->unpackError == 0 ){
3162              valid = 1;
3163              if ( cp1->pperror[section] ) valid = 0;
3164              ph = eh->GetPscuHeader();
3165              obt = ph->GetOrbitalTime();  
3166              pkt = ph->GetCounter();  
3167              fromtime = this->GetAbsTime(ph->GetOrbitalTime());  
3168              if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){
3169                //
3170                if ( IsDebug() ) printf(" Calo pulse1 calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt);
3171                //
3172                // check if the calibration has already been inserted
3173                //
3174                oss.str("");
3175                oss << " SELECT ID FROM GL_CALOPULSE_CALIB WHERE "
3176                    << " SECTION = "<< section << " AND "
3177                    << " PULSE_AMPLITUDE = 0 AND "
3178                    << " BOOT_NUMBER = "<< this->GetBOOTnumber() << " AND "
3179                    << " OBT = "<< obt << " AND "
3180                    << " PKT = "<< pkt << ";";
3181                //
3182                if ( IsDebug() ) printf(" Check if the calo pulse1 calibration has already been inserted: query is \n %s \n",oss.str().c_str());
3183                result = conn->Query(oss.str().c_str());
3184                //
3185                if ( !result ) throw -4;
3186                //
3187                row = result->Next();
3188                //
3189                if ( row ){
3190                  //
3191                  if ( IsDebug() ) printf(" Calo pulse1 calibration already inserted in the DB\n");
3192                  //
3193                } else {
3194                  //
3195                  // we have to insert a new calibration, check where to place it
3196                  //
3197                  oss.str("");
3198                  oss << " SELECT ID,TO_TIME FROM GL_CALOPULSE_CALIB WHERE "
3199                      << " SECTION = "<< section << " AND "
3200                      << " PULSE_AMPLITUDE = 0 AND "
3201                      << " SECTION = "<< section << " AND "
3202                      << " FROM_TIME < "<< fromtime << " AND "
3203                      << " TO_TIME > "<< fromtime << ";";
3204                  //
3205                  if ( IsDebug() ) printf(" Check where to place the pulse1 calo calibration: query is \n %s \n",oss.str().c_str());
3206                  result = conn->Query(oss.str().c_str());
3207                  //
3208                  if ( !result ) throw -4;
3209                  //
3210                  row = result->Next();
3211                  //
3212                  if ( !row ){
3213                    //
3214                    // no calibrations in the db contain our calibration
3215                    //
3216                    if ( IsDebug() ) printf(" Pulse1 calibration with fromtime lower than others to be inserted in the DB for section %i \n",section);
3217                    if ( fromtime < 1150871000 ){ //1150866904
3218                      if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime);
3219                      fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode
3220                    };
3221                    //
3222                    oss.str("");
3223                    oss << " SELECT FROM_TIME FROM GL_CALOPULSE_CALIB WHERE "
3224                        << " PULSE_AMPLITUDE = 0 AND "
3225                        << " SECTION = "<< section << " AND "
3226                        << " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;";
3227                    //
3228                    if ( IsDebug() ) printf(" Check the upper limit for pulse1 calibration: query is \n %s \n",oss.str().c_str());
3229                    result = conn->Query(oss.str().c_str());
3230                    //
3231                    if ( !result ) throw -4;
3232                    //
3233                    row = result->Next();
3234                    if ( !row ){
3235                      totime = numeric_limits<UInt_t>::max();
3236                    } else {
3237                      totime = (UInt_t)atoll(row->GetField(0));
3238                    };
3239                    //
3240                  } else {
3241                    //
3242                    // determine upper and lower limits and make space for the new calibration
3243                    //
3244                    totime = (UInt_t)atoll(row->GetField(1));
3245                    //
3246                    oss.str("");
3247                    oss << " UPDATE GL_CALOPULSE_CALIB SET "  
3248                        << " TO_TIME = "<< fromtime << " WHERE "  // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[
3249                        << " ID = "<< row->GetField(0) << ";";
3250                    //
3251                    if ( IsDebug() ) printf(" Make space for the new pulse1 calibration: query is \n %s \n",oss.str().c_str());
3252                    result = conn->Query(oss.str().c_str());
3253                    //
3254                    if ( !result ) throw -4;
3255                    //
3256                  };
3257                  //
3258                  oss.str("");
3259                  oss << " INSERT INTO GL_CALOPULSE_CALIB (ID,ID_ROOT_L0,EV_ROOT,FROM_TIME,TO_TIME,SECTION,PULSED_STRIP,PULSE_AMPLITUDE,OBT,PKT,BOOT_NUMBER,VALIDATION) "
3260                      << " VALUES (NULL,' "
3261                      << idroot << "','"
3262                      << i << "','"
3263                      << fromtime << "','"
3264                      << totime << "','"
3265                      << section << "',NULL,'0','"
3266                      << obt << "','"
3267                      << pkt << "','"
3268                      << this->GetBOOTnumber() << "','"
3269                      << valid << "');";
3270                  //
3271                  if ( IsDebug() ) printf(" Insert the new pulse1 calibration: query is \n %s \n",oss.str().c_str());
3272                  //
3273                  result = conn->Query(oss.str().c_str());
3274                  //
3275                  if ( !result ) throw -4;
3276                  //
3277                };
3278                //
3279              } else {
3280                //
3281                if ( IsDebug() ) printf(" Repeated pulse1 calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt);
3282                //
3283              };      
3284              //      
3285            };
3286          };
3287        };
3288      };
3289      //
3290      // CaloPulse2
3291      //
3292      tr->Reset();
3293      CalibCalPulse2Event *cp2 = 0;
3294      tr = 0;
3295      //
3296      nevents = 0;
3297      fromtime = 0;
3298      totime = 0;
3299      obt = 0;
3300      pkt = 0;
3301      //
3302      tr = (TTree*)file->Get("CalibCalPulse2");
3303      if ( !tr || tr->IsZombie() ) throw -32;
3304      //
3305      tr->SetBranchAddress("CalibCalPulse2", &cp2);
3306      tr->SetBranchAddress("Header", &eh);
3307      nevents = tr->GetEntries();
3308      //
3309      if ( nevents > 0 ){
3310        //
3311        for (UInt_t i=0; i < nevents; i++){
3312          tr->GetEntry(i);
3313          for (UInt_t section = 0; section < 4; section++){
3314            //
3315            if ( cp2->pstwerr[section] && cp2->unpackError == 0 ){
3316              valid = 1;
3317              if ( cp2->pperror[section] ) valid = 0;
3318              ph = eh->GetPscuHeader();
3319              obt = ph->GetOrbitalTime();  
3320              pkt = ph->GetCounter();  
3321              fromtime = this->GetAbsTime(ph->GetOrbitalTime());  
3322              if ( this->PKT(pkt) >= this->PKT(pktfirst) && this->OBT(obt) >= this->OBT(obtfirst) ){
3323                //
3324                if ( IsDebug() ) printf(" Calo pulse2 calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt);
3325                //
3326                // check if the calibration has already been inserted
3327                //
3328                oss.str("");
3329                oss << " SELECT ID FROM GL_CALOPULSE_CALIB WHERE "
3330                    << " SECTION = "<< section << " AND "
3331                    << " PULSE_AMPLITUDE != 0 AND "
3332                    << " BOOT_NUMBER = "<< this->GetBOOTnumber() << " AND "
3333                    << " OBT = "<< obt << " AND "
3334                    << " PKT = "<< pkt << ";";
3335                //
3336                if ( IsDebug() ) printf(" Check if the calo pulse2 calibration has already been inserted: query is \n %s \n",oss.str().c_str());
3337                result = conn->Query(oss.str().c_str());
3338                //
3339                if ( !result ) throw -4;
3340                //
3341                row = result->Next();
3342                //
3343                if ( row ){
3344                  //
3345                  if ( IsDebug() ) printf(" Calo pulse2 calibration already inserted in the DB\n");
3346                  //
3347                } else {
3348                  //
3349                  // we have to insert a new calibration
3350                  //
3351                  //
3352                  // Determine the amplitude of the pulse
3353                  //
3354                  UInt_t pampli = 1;
3355                  UInt_t pstrip = 0;
3356                  UInt_t se = 0;
3357                  if ( section == 1 ) se = 2;
3358                  if ( section == 2 ) se = 3;
3359                  if ( section == 3 ) se = 1;
3360                  for (Int_t ii=0;ii<16;ii++){
3361                    if ( cp2->calpuls[se][0][ii] > 10000. ){
3362                      pampli = 2;
3363                      pstrip = ii;
3364                    };
3365                  };
3366                  if ( pampli == 1 ){
3367                    Bool_t found = false;
3368                    Float_t delta=0.;
3369                    UInt_t cstr = 0;
3370                    while ( !found && cstr < 16 ){
3371                      for (Int_t ii=0;ii<16;ii++){
3372                        delta = cp2->calpuls[se][0][ii] - cp2->calpuls[se][0][cstr];
3373                        if ( IsDebug() ) printf(" cstr is %u ii is %i delta is %f \n",cstr,ii,delta);
3374                        if ( delta > 500. ){
3375                          pampli = 1;
3376                          pstrip = ii;
3377                          found = true;
3378                          if ( IsDebug() ) printf(" FOUND cstr is %u ii is %i delta is %f \n",cstr,ii,delta);
3379                        };
3380                      };
3381                      cstr++;
3382                    };
3383                    if ( !found ) pstrip = 100;
3384                  };
3385                  if ( IsDebug() ) printf(" The amplitude of the pulser is %u (where 1 = low pulse, 2 = high pulse), pulsed strip is %u \n",pampli,pstrip);
3386                  //
3387                  // we have to insert a new calibration, check where to place it
3388                  //
3389                  oss.str("");
3390                  oss << " SELECT ID,TO_TIME FROM GL_CALOPULSE_CALIB WHERE "
3391                      << " SECTION = "<< section << " AND "
3392                      << " PULSE_AMPLITUDE = " << pampli << " AND "
3393                      << " SECTION = "<< section << " AND "
3394                      << " FROM_TIME < "<< fromtime << " AND "
3395                      << " TO_TIME > "<< fromtime << ";";
3396                  //
3397                  if ( IsDebug() ) printf(" Check where to place the pulse2 calo calibration: query is \n %s \n",oss.str().c_str());
3398                  result = conn->Query(oss.str().c_str());
3399                  //
3400                  if ( !result ) throw -4;
3401                  //
3402                  row = result->Next();
3403                  //
3404                  if ( !row ){
3405                    //
3406                    // no calibrations in the db contain our calibration
3407                    //
3408                    if ( IsDebug() ) printf(" Pulse2 calibration with fromtime lower than others to be inserted in the DB for section %i \n",section);
3409                    if ( fromtime < 1150871000 ){ //1150866904
3410                      if ( IsDebug() ) printf(" First PAMELA flight calibration at time %u \n",fromtime);
3411                      fromtime = 0;// the first flight calibration was taken at about  1156429100 s, this line allow to analyze first runs in raw mode
3412                    };
3413                    //
3414                    oss.str("");
3415                    oss << " SELECT FROM_TIME FROM GL_CALOPULSE_CALIB WHERE "
3416                        << " PULSE_AMPLITUDE = " << pampli << " AND "
3417                        << " SECTION = "<< section << " AND "
3418                        << " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;";
3419                    //
3420                    if ( IsDebug() ) printf(" Check the upper limit for pulse2 calibration: query is \n %s \n",oss.str().c_str());
3421                    result = conn->Query(oss.str().c_str());
3422                    //
3423                    if ( !result ) throw -4;
3424                    //
3425                    row = result->Next();
3426                    if ( !row ){
3427                      totime = numeric_limits<UInt_t>::max();
3428                    } else {
3429                      totime = (UInt_t)atoll(row->GetField(0));
3430                    };
3431                    //
3432                  } else {
3433                    //
3434                    // determine upper and lower limits and make space for the new calibration
3435                    //
3436                    totime = (UInt_t)atoll(row->GetField(1));
3437                    //
3438                    oss.str("");
3439                    oss << " UPDATE GL_CALOPULSE_CALIB SET "  
3440                        << " TO_TIME = "<< fromtime << " WHERE "  // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[
3441                        << " ID = "<< row->GetField(0) << ";";
3442                    //
3443                    if ( IsDebug() ) printf(" Make space for the new pulse2 calibration: query is \n %s \n",oss.str().c_str());
3444                    result = conn->Query(oss.str().c_str());
3445                    //
3446                    if ( !result ) throw -4;
3447                    //
3448                  };
3449                  //
3450                  // Fill the DB
3451                  //
3452                  oss.str("");
3453                  //              oss << " INSERT INTO GL_CALOPULSE_CALIB (ID,ID_ROOT_L0,EV_ROOT,FROM_TIME,TO_TIME,SECTION,OBT,PKT,BOOT_NUMBER,VALIDATION) "
3454                  oss << " INSERT INTO GL_CALOPULSE_CALIB (ID,ID_ROOT_L0,EV_ROOT,FROM_TIME,TO_TIME,SECTION,PULSED_STRIP,PULSE_AMPLITUDE,OBT,PKT,BOOT_NUMBER,VALIDATION) "
3455                      << " VALUES (NULL,' "
3456                      << idroot << "','"
3457                      << i << "','"
3458                      << fromtime << "','"
3459                      << totime << "','"
3460                      << section << "','"
3461                      << pstrip << "','"
3462                      << pampli << "','"
3463                      << obt << "','"
3464                      << pkt << "','"
3465                      << this->GetBOOTnumber() << "','"
3466                      << valid << "');";
3467                  //
3468                  if ( IsDebug() ) printf(" Insert the new pulse2 calibration: query is \n %s \n",oss.str().c_str());
3469                  //
3470                  result = conn->Query(oss.str().c_str());
3471                  //
3472                  if ( !result ) throw -4;
3473                  //
3474                };
3475                //
3476              } else {
3477                //
3478                if ( IsDebug() ) printf(" Repeated pulse2 calo calibration for section %i at time %u obt %u pkt %u \n",section,fromtime,obt,pkt);
3479                //
3480              };      
3481              //      
3482            };
3483          };
3484        };
3485      };
3486      //
3487      return(0);
3488    };
3489    
3490  /**  /**
3491   * Fill the GL_TRK_CALIB table   * Fill the GL_TRK_CALIB table
3492   */   */
# Line 4421  void PamelaDBOperations::RemoveCALIBS(){ Line 4918  void PamelaDBOperations::RemoveCALIBS(){
4918        //        //
4919      };      };
4920    };    };
4921      Bool_t OLDDB = false;
4922      for (Int_t section = 0; section < 4; section++){
4923        myquery.str("");
4924        myquery << " SELECT MIN(FROM_TIME),MAX(TO_TIME) FROM GL_CALOPULSE_CALIB WHERE ID_ROOT_L0="<< this->GetID_ROOT() <<" AND ";
4925        myquery << " SECTION=" << section << ";";
4926        //
4927        pResult = conn->Query(myquery.str().c_str());
4928        //
4929        if ( conn->GetErrorCode() ){
4930          printf(" Section %i : warning, old databse structure no GL_CALOPULSE_CALIB table!\n",section);
4931          OLDDB=true;
4932        } else {
4933          Row = pResult->Next();      
4934          if( !Row->GetField(0) || !Row->GetField(1) ){
4935            //
4936            if ( IsDebug() ) printf(" NO PULSE CALO CALIBRATION SECTION %i ASSOCIATED TO THIS FILE! \n",section);
4937            //
4938          } else {
4939            //
4940            myquery.str("");
4941            myquery << " UPDATE GL_CALOPULSE_CALIB SET TO_TIME=" << Row->GetField(1);
4942            myquery << " WHERE TO_TIME="<< Row->GetField(0) << " AND ";
4943            myquery << " SECTION=" << section << ";";
4944            //
4945            pResult = conn->Query(myquery.str().c_str());
4946            //
4947            if( !pResult ){
4948              //
4949              if ( IsDebug() ) printf(" ERROR DELETING CALO PULSE CALIBRATIONS \n");
4950              //
4951              throw -4;
4952              //
4953            };
4954            //
4955          };
4956        };
4957      };
4958    myquery.str("");    myquery.str("");
4959    myquery << " DELETE FROM GL_CALO_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT();    myquery << " DELETE FROM GL_CALO_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT() << ";";
4960    //    //
4961    pResult = conn->Query(myquery.str().c_str());    pResult = conn->Query(myquery.str().c_str());
4962    //    //
# Line 4434  void PamelaDBOperations::RemoveCALIBS(){ Line 4968  void PamelaDBOperations::RemoveCALIBS(){
4968      //      //
4969    };    };
4970    //    //
4971      myquery.str("");
4972      myquery << " DELETE FROM GL_CALOPULSE_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT() << ";";
4973      //
4974      pResult = conn->Query(myquery.str().c_str());
4975      if ( IsDebug() ) printf(" Delete from GL_CALOPULSE_CALIB query is %s \n",myquery.str().c_str());
4976      if ( !OLDDB ){
4977        //
4978        if( !pResult ){
4979          //
4980          if ( IsDebug() ) printf(" ERROR DELETING PULSE CALO CALIBRATIONS \n");
4981          //
4982          throw -4;
4983          //
4984        };
4985      };
4986      //
4987    // Tracker    // Tracker
4988    //    //
4989    myquery.str("");    myquery.str("");
# Line 4463  void PamelaDBOperations::RemoveCALIBS(){ Line 5013  void PamelaDBOperations::RemoveCALIBS(){
5013      };      };
5014      //      //
5015      myquery.str("");      myquery.str("");
5016      myquery << " DELETE FROM GL_TRK_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT();      myquery << " DELETE FROM GL_TRK_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT() << ";";
5017      //      //
5018      pResult = conn->Query(myquery.str().c_str());      pResult = conn->Query(myquery.str().c_str());
5019      //      //
# Line 4506  void PamelaDBOperations::RemoveCALIBS(){ Line 5056  void PamelaDBOperations::RemoveCALIBS(){
5056      };      };
5057      //      //
5058      myquery.str("");      myquery.str("");
5059      myquery << " DELETE FROM GL_S4_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT();      myquery << " DELETE FROM GL_S4_CALIB WHERE ID_ROOT_L0=" << this->GetID_ROOT() << ";";
5060      //      //
5061      pResult = conn->Query(myquery.str().c_str());      pResult = conn->Query(myquery.str().c_str());
5062      //      //
# Line 4663  UInt_t PamelaDBOperations::Check(){ Line 5213  UInt_t PamelaDBOperations::Check(){
5213    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
5214    TSQLResult *result2 = 0;    TSQLResult *result2 = 0;
5215    TSQLRow    *row2    = 0;    TSQLRow    *row2    = 0;
5216      TSQLResult *result3 = 0;
5217      TSQLRow    *row3    = 0;
5218    oss.str("");    oss.str("");
5219    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;";
5220    //  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;";
5221    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
5222    //    //
5223    if ( !result ) throw -4;;    if ( !result ) throw -4;;
5224    //    //
5225    row = result->Next();    row = result->Next();
5226      UInt_t nid = 0;
5227    //    //
5228    while ( row ){    while ( row ){
5229        nid++;
5230        if ( !(nid%1000) && nid ) printf(" %iK run scanned \n",nid/1000);
5231      thisid = (UInt_t)atoll(row->GetField(0));      thisid = (UInt_t)atoll(row->GetField(0));
5232      thisl0id = (UInt_t)atoll(row->GetField(1));      thisl0id = (UInt_t)atoll(row->GetField(1));
5233      thisrht = (UInt_t)atoll(row->GetField(2));      thisrht = (UInt_t)atoll(row->GetField(2));
5234      thisrtt = (UInt_t)atoll(row->GetField(3));      thisrtt = (UInt_t)atoll(row->GetField(3));
5235      //      //
5236        if ( (UInt_t)atoll(row->GetField(4)) > 1 ){
5237          //
5238          //
5239          //
5240          oss.str("");
5241          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
5242              << thisid << " AND ( RUNHEADER_TIME="
5243              << thisrht << " OR RUNTRAILER_TIME="
5244              << thisrtt << " ) AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
5245          result3 = conn->Query(oss.str().c_str());
5246          if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
5247          if ( result3 ){
5248            //
5249            oss.str("");
5250            oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
5251                << thisid << " AND RUNHEADER_TIME="
5252                << thisrht << " AND RUNTRAILER_TIME!="
5253                << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
5254            result3 = conn->Query(oss.str().c_str());
5255            if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
5256            if ( result3 ){
5257              row3 = result3->Next();
5258              //
5259              while ( row3 ){
5260                //
5261                // 2 runs with same runheader
5262                //
5263                printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0)));  
5264                row3 = result3->Next();
5265              };
5266            };
5267            //
5268            oss.str("");
5269            oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
5270                << thisid << " AND RUNHEADER_TIME!="
5271                << thisrht << " AND RUNTRAILER_TIME="
5272                << thisrtt << " AND NEVENTS!=0 AND NEVENTS!=1 order by RUNHEADER_TIME asc;";
5273            result3 = conn->Query(oss.str().c_str());
5274            if ( IsDebug() ) printf(" query is %s \n",oss.str().c_str());
5275            if ( result3 ){
5276              row3 = result3->Next();
5277              //
5278              while ( row3 ){
5279                //
5280                // 2 runs with same runtrailer
5281                //
5282                printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0)));
5283                row3 = result3->Next();
5284              };
5285            };
5286            //
5287            oss.str("");
5288            oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
5289                << thisid << " AND RUNHEADER_TIME="
5290                << thisrht << " AND RUNTRAILER_TIME="
5291                << thisrtt << " AND ID_RUN_FRAG!="
5292                << thisid << " order by RUNHEADER_TIME asc;";
5293            result3 = conn->Query(oss.str().c_str());
5294            if ( result3 ){
5295              row3 = result3->Next();
5296              //
5297              while ( row3 ){
5298                //
5299                // duplicated run
5300                //
5301                printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0)));
5302                row3 = result3->Next();
5303              };
5304            };
5305          };
5306          //
5307          oss.str("");
5308          oss << "SELECT ID,ID_ROOT_L0,RUNHEADER_TIME,RUNTRAILER_TIME FROM GL_RUN WHERE ID!="
5309              << thisid << " AND RUNHEADER_TIME>"
5310              << thisrht << " AND RUNTRAILER_TIME<"
5311              << thisrtt << " order by RUNHEADER_TIME asc;";
5312          result3 = conn->Query(oss.str().c_str());
5313          if ( result3 ){
5314            row3 = result3->Next();
5315            //
5316            while ( row3 ){
5317              //
5318              // run contained in the checked one
5319              //
5320              printf(" CHECK n.6 RUN %u CONTAINS RUN %u  \n",thisid,(UInt_t)atoll(row3->GetField(0)));
5321              row3 = result3->Next();
5322            };
5323          };
5324          //
5325        };
5326        //
5327      //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){      //    if ( thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt && !(!prevrht && !prevrtt &&!previd) ){
5328      //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){      //    if ( (thisrht < prevrtt || thisrtt < prevrht || thisrht > thisrtt) && (thisrht != prevrht) ){
5329      if ( (thisrht < prevrtt) && (thisrht != prevrht) ){      if ( (thisrht < prevrtt) && (thisrht != prevrht) ){
5330        if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);        if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);
5331        printf(" CHECK n.1 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid);        printf(" CHECK n.1 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-prevrtt),previd,thisid);
5332        TString prevf = "";        TString prevf = "";
5333        TString thisf = "";        TString thisf = "";
5334        oss.str("");        oss.str("");
# Line 4703  UInt_t PamelaDBOperations::Check(){ Line 5349  UInt_t PamelaDBOperations::Check(){
5349      //      //
5350      if ( (thisrtt < prevrht) && (thisrht != prevrht) ){      if ( (thisrtt < prevrht) && (thisrht != prevrht) ){
5351        if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);        if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);
5352        printf(" CHECK n.2 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid);        printf(" CHECK n.2 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrtt-prevrht),previd,thisid);
5353        TString prevf = "";        TString prevf = "";
5354        TString thisf = "";        TString thisf = "";
5355        oss.str("");        oss.str("");
5356        oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";        oss << "SELECT NAME FROM GL_ROOT where ID=" << (UInt_t)prevl0id <<";";
5357        result2 = conn->Query(oss.str().c_str());        result2 = conn->Query(oss.str().c_str());
5358        if ( !result2 ) throw -4;;        if ( !result2 ) throw -4;
5359        row2 = result2->Next();        row2 = result2->Next();
5360        prevf = (TString)row2->GetField(0);        prevf = (TString)row2->GetField(0);
5361        oss.str("");        oss.str("");
# Line 4724  UInt_t PamelaDBOperations::Check(){ Line 5370  UInt_t PamelaDBOperations::Check(){
5370      //      //
5371      if ( (thisrht > thisrtt) && (thisrht != prevrht) ){      if ( (thisrht > thisrtt) && (thisrht != prevrht) ){
5372        if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);        if ( IsDebug() ) printf(" IDprev %u ID %u    prevrht %u prevrtt %u  thisrht %u thisrtt %u \n",previd,thisid,prevrht,prevrtt,thisrht,thisrtt);
5373        printf(" CHECK n.3 TIME SCREW of %u s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid);        printf(" CHECK n.3 TIME SCREW of %i s AROUND RUNs %u and %u \n",(thisrht-thisrtt),previd,thisid);
5374        TString prevf = "";        TString prevf = "";
5375        TString thisf = "";        TString thisf = "";
5376        oss.str("");        oss.str("");

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.52

  ViewVC Help
Powered by ViewVC 1.1.23