Changeset 7215 for trunk/MagicSoft


Ignore:
Timestamp:
07/22/05 20:41:54 (19 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7214 r7215  
    2020
    2121                                                 -*-*- END OF LINE -*-*-
    22  2005/07/12 Daniela Dorner
     22 2005/07/22 Daniela Dorner
    2323
    2424   * sinope.cc:
     
    3636     - small change in all scripts to make it easier to adapt scripts
    3737       for a different user
     38
     39   * datacenter/macros/buildsequenceentries.C:
     40     - implemented new algorithm to build sequences: instead of
     41       checking the conditions of the runs after grouping them together
     42       the condition are taken into account for grouping the runs
     43       Attention: some sequences will change with this new algorithm!
    3844
    3945
  • trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C

    r7183 r7215  
    6262int debug = 0;
    6363
    64 Bool_t DeleteSequences(MSQLServer &serv, TString cond)
    65 {
    66     TString query(Form("SELECT fSequenceFirst FROM Sequences"
    67                        " WHERE %s AND fManuallyChangedKEY=1", cond.Data()));
     64Bool_t DeleteSequence(MSQLServer &serv, Int_t sequ, Bool_t dummy)
     65{
     66    TString query1(Form("DELETE FROM Calibration WHERE fSequenceFirst=%d", sequ));
     67    TString query2(Form("DELETE FROM Star WHERE fSequenceFirst=%d", sequ));
     68    TString query3(Form("DELETE FROM SequenceProcessStatus WHERE fSequenceFirst=%d", sequ));
     69    TString query4(Form("UPDATE RunData SET fSequenceFirst=0 WHERE fSequenceFirst=%d", sequ));
     70    TString query5(Form("DELETE FROM Sequences WHERE fSequenceFirst=%d AND fManuallyChangedKEY=1", sequ));
     71
     72    TString fname(Form("/mnt/stk01/sequences/%04d/sequence%08d.txt", sequ/10000, sequ));
     73    TString command(Form("rm -r /magic/data/callisto/%04d/%08d/", sequ/10000, sequ));
     74    TString command2(Form("rm -r /magic/data/star/%04d/%08d/", sequ/10000, sequ));
     75
     76    if (dummy)
     77    {
     78        cout << "not using dummy=kTRUE the following commands would be executed: " << endl;
     79        cout << "queries: " << endl;
     80        cout << query1 << endl;
     81        cout << query2 << endl;
     82        cout << query3 << endl;
     83        cout << query4 << endl;
     84        cout << query5 << endl;
     85        cout << "removing files:" << endl;
     86        cout << "unlink " << fname << endl;
     87        cout << command << endl;
     88        cout << command2 << endl;
     89        return kTRUE;
     90    }
     91
     92    TSQLResult *res = serv.Query(query1);
     93    if (!res)
     94        return kFALSE;
     95    delete res;
     96
     97    res = serv.Query(query2);
     98    if (!res)
     99        return kFALSE;
     100    delete res;
     101
     102    res = serv.Query(query3);
     103    if (!res)
     104        return kFALSE;
     105    delete res;
     106
     107    res = serv.Query(query4);
     108    if (!res)
     109        return kFALSE;
     110    delete res;
     111
     112    res = serv.Query(query5);
     113    if (!res)
     114        return kFALSE;
     115    delete res;
     116
     117    gSystem->Unlink(fname);
     118
     119    gSystem->Exec(command);
     120    gSystem->Exec(command2);
     121
     122    return kTRUE;
     123}
     124
     125Int_t DoCheck(TSQLResult &res)
     126{
     127    TArrayI data(5);
     128    Int_t n = 0;
     129
     130    TSQLRow *row=0;
     131    while ((row=res.Next()))
     132    {
     133        n++;
     134
     135        if (data[0]==0)
     136        {
     137            for (int i=0; i<data.GetSize(); i++)
     138                data[i] = atoi((*row)[i]);
     139            continue;
     140        }
     141
     142        for (int i=1; i<data.GetSize(); i++)
     143        {
     144            if (data[i] != atoi((*row)[i]))
     145                return i+1;
     146        }
     147    }
     148    return n==0 ? 0 : -1;
     149}
     150
     151Bool_t CheckRuns(MSQLServer &serv, Int_t from, Int_t to, Int_t type)
     152{
     153    TString query("SELECT fRunNumber, fL1TriggerTableKEY, fL2TriggerTableKEY,"
     154                  " fCalibrationScriptKEY, fProjectKEY FROM RunData");
     155    query += Form(" WHERE fRunTypeKEY=%d AND fExcludedFDAKEY=1 AND "
     156                  " (fRunNumber BETWEEN %d AND %d)"
     157                  " ORDER BY fRunNumber", type, from, to);
    68158
    69159    TSQLResult *res = serv.Query(query);
    70160    if (!res)
    71161        return kFALSE;
     162
     163    Int_t rc = DoCheck(*res);
     164    delete res;
     165
     166    switch (rc)
     167    {
     168    case 0: cout << "ERROR - No runs found for check!"             << endl; break;
     169    case 1: cout << "ERROR - fRunNumber doesn't match!"            << endl; break;
     170    case 2: cout << "ERROR - fL1TriggerTableKEY doesn't match!"    << endl; break;
     171    case 3: cout << "ERROR - fL2TriggerTableKEY doesn't match!"    << endl; break;
     172    case 4: cout << "ERROR - fCalibrationScriptKEY doesn't match!" << endl; break;
     173    case 5: cout << "ERROR - fProjectKEY doesn't match!"           << endl; break;
     174    }
     175
     176    return rc<0;
     177}
     178
     179Bool_t CheckSequence(MSQLServer &serv, Int_t from, Int_t to, Bool_t dummy)
     180{
     181    Bool_t rc=kFALSE;
     182
     183    TString query("SELECT fSequenceFirst, count(*) FROM RunData ");
     184    query += Form(" WHERE fExcludedFDAKEY=1 AND (fRunNumber BETWEEN %d AND %d)"
     185                  " GROUP BY fSequenceFirst", from, to);
     186
     187    TSQLResult *res = serv.Query(query);
     188    if (!res)
     189        return kFALSE;
     190
     191    Int_t count=0;
     192    Int_t nor=0;
     193    TArrayI sequences;
    72194
    73195    TSQLRow *row=0;
    74196    while ((row=res->Next()))
    75197    {
    76         query = Form("DELETE FROM Calibration WHERE fSequenceFirst=%s", (*row)[0]);
    77 
    78         TSQLResult *res = serv.Query(query);
    79         if (!res)
    80             return kFALSE;
    81         delete res;
    82 
    83         query = Form("DELETE FROM Star WHERE fSequenceFirst=%s", (*row)[0]);
     198        sequences.Set(count+1);
     199        sequences.AddAt(atoi((*row)[0]), count);
     200//        cout << "sequence:   " << sequences.At(count) << endl;
     201        nor=atoi((*row)[1]);
     202        count++;
     203    }
     204
     205    delete res;
     206
     207    if (sequences.GetSize()>1)
     208    {
     209        for (Int_t i=0;i<sequences.GetSize();i++)
     210        {
     211            rc=kTRUE;
     212            if (sequences.At(i)!=0)
     213            {
     214                cout << "deleting sequence " << sequences.At(i) << "... <" << i << ">" << endl;
     215                if(!DeleteSequence(serv, sequences.At(i), dummy))
     216                   rc=kFALSE;
     217            }
     218        }
     219        return rc;
     220    }
     221
     222    if (sequences.At(0)==0)
     223        return kTRUE;
     224
     225
     226    query="SELECT fRunNumber FROM RunData ";
     227    query += Form(" WHERE fExcludedFDAKEY=1 AND (fRunNumber BETWEEN %d AND %d)"
     228                  " ORDER BY fRunNumber", from, to);
     229
     230    res = serv.Query(query);
     231    if (!res)
     232        return kFALSE;
     233
     234    TArrayI runs;
     235    count=0;
     236    row=0;
     237    while ((row=res->Next()))
     238    {
     239        runs.Set(count+1);
     240        runs.AddAt(atoi((*row)[0]), count);
     241        count++;
     242    }
     243
     244    delete res;
     245
     246
     247    if (nor==runs.GetSize() && sequences.GetSize()==1)
     248    {
     249        query="SELECT fRunNumber FROM RunData ";
     250        query += Form(" WHERE fSequenceFirst=%d ", sequences.At(0));
    84251
    85252        res = serv.Query(query);
    86253        if (!res)
    87254            return kFALSE;
     255
     256        TArrayI oldruns;
     257        count=0;
     258        row=0;
     259        while ((row=res->Next()))
     260        {
     261            oldruns.Set(count+1);
     262            oldruns.AddAt(atoi((*row)[0]), count);
     263            count++;
     264        }
     265
     266        if (runs.GetSize()!=oldruns.GetSize())
     267        {
     268            cout << "different sequsizes -> deleting sequence " << sequences.At(0) << endl;
     269            return DeleteSequence(serv, sequences.At(0), dummy);
     270        }
     271
     272        for (Int_t i=0; i<runs.GetSize(); i++)
     273        {
     274            if (runs.At(i)==oldruns.At(i))
     275                continue;
     276            cout << "different runs -> deleting sequence " << sequences.At(0) << endl;
     277            return DeleteSequence(serv, sequences.At(0), dummy);
     278        }
     279
    88280        delete res;
    89 
    90         query = Form("DELETE FROM SequenceProcessStatus WHERE fSequenceFirst=%s", (*row)[0]);
    91 
    92         res = serv.Query(query);
    93         if (!res)
    94             return kFALSE;
    95         delete res;
    96 
    97         Int_t sequno=atoi((*row)[0]);
    98         TString fname(Form("/mnt/stk01/sequences/%04d/sequence%08d.txt", sequno/10000, sequno));
    99         gSystem->Unlink(fname);
    100 
    101         query = Form("UPDATE RunData SET fSequenceFirst=0 WHERE fSequenceFirst=%s", (*row)[0]);
    102 
    103         res = serv.Query(query);
    104         if (!res)
    105             return kFALSE;
    106         delete res;
    107 
    108     }
    109     delete res;
    110 
    111     query = Form("DELETE FROM Sequences WHERE %s AND fManuallyChangedKEY=1", cond.Data());
    112     res = serv.Query(query);
    113     if (!res)
    114         return kFALSE;
    115 
    116     delete res;
    117 
    118     return kTRUE;
    119 }
    120 
    121 Int_t CheckOverlap(MSQLServer &serv, Int_t from, Int_t to)
    122 {
    123     TString query(Form("SELECT fSequenceFirst FROM Sequences WHERE"
    124                        " (%d BETWEEN fSequenceFirst AND fSequenceLast) OR "
    125                        " (%d BETWEEN fSequenceFirst AND fSequenceLast)", from, to));
    126 
    127     TSQLResult *res = serv.Query(query);
    128     if (!res)
    129         return -1;
    130 
    131     TSQLRow *row = res->Next();
    132 
    133     Int_t rc = row ? kFALSE : kTRUE;
    134     if (rc==kFALSE)
    135         cout << "Sorry - the sequence from " << from << " to " << to << " overlaps with sequence #" << (*row)[0] << endl;
    136 
    137     delete res;
    138 
     281    }
     282
     283    cout << "same sequence -> nothing to do..." << endl;
    139284    return rc;
    140285}
    141286
    142 Int_t DoCheck(TSQLResult &res, Int_t from, Int_t to)
    143 {
    144     TSQLRow *row=0;
    145 
    146     TArrayI data(9);
    147 
    148     Int_t n = 0;
    149 
    150     while ((row=res.Next()))
    151     {
    152         n++;
    153 
    154         if (data[0]==0)
    155         {
    156             for (int i=0; i<data.GetSize(); i++)
    157                 data[i] = atoi((*row)[i]);
    158             continue;
    159         }
    160 
    161         for (int i=1; i<data.GetSize(); i++)
    162         {
    163             if (data[i] != atoi((*row)[i]))
    164                 return i+1;
    165         }
    166     }
    167     return n==0 ? 0 : -1;
    168 }
    169 
    170 Bool_t CheckSequence(MSQLServer &serv, Int_t from, Int_t to, Int_t src, Int_t type)
    171 {
    172     TString query("SELECT fRunNumber, fL1TriggerTableKEY, fL2TriggerTableKEY,"
    173                   " fProjectKEY, fHvSettingsKEY, fDiscriminatorThresholdTableKEY,"
    174                   " fTriggerDelayTableKEY, fLightConditionsKEY, fTestFlagKEY"
    175                   " FROM RunData");
    176     query += Form(" WHERE fRunTypeKEY=%d AND fSourceKEY=%d AND fExcludedFDAKEY=1 AND (fRunNumber BETWEEN %d AND %d)"
    177                   " ORDER BY fRunNumber", type, src, from, to);
    178 
    179     TSQLResult *res = serv.Query(query);
    180     if (!res)
    181         return kFALSE;
    182 
    183     Int_t rc = DoCheck(*res, from, to);
    184     delete res;
    185 
    186     switch (rc)
    187     {
    188     case 0: cout << "ERROR - No runs found for check!"                        << endl; break;
    189     case 1: cout << "ERROR - fRunNumber doesn't match!"                       << endl; break;
    190     case 2: cout << "ERROR - fL1TriggerTableKEY doesn't match!"                 << endl; break;
    191     case 3: cout << "ERROR - fL2TriggerTableKEY doesn't match!"                 << endl; break;
    192     case 4: cout << "ERROR - fProjectKEY doesn't match!"                      << endl; break;
    193     case 5: cout << "ERROR - fHvSettingsKEY doesn't match!"                   << endl; break;
    194     case 6: cout << "ERROR - fDiscriminatorThresholdTableKEY doesn't match!"  << endl; break;
    195     case 7: cout << "ERROR - fTriggerDelayTableKEY doesn't match!"            << endl; break;
    196     case 8: cout << "ERROR - fLightConditionsKEY doesn't match!"              << endl; break;
    197     case 9: cout << "ERROR - fTestFlagKEY doesn't match!"                     << endl; break;
    198     }
    199 
    200     return rc<0;
    201 }
    202 
    203 Bool_t InsertSequence(MSQLServer &serv, Int_t from, Int_t to, Int_t src, Bool_t dummy)
    204 {
    205     Int_t rc = dummy ? kTRUE : CheckOverlap(serv, from, to);
    206     if (rc<=0)
    207         return kFALSE;
     287Bool_t InsertSequence(MSQLServer &serv, Int_t from, Int_t to)
     288{
    208289
    209290    // ========== Request number of events ==========
     
    214295    query +=      " MIN(fZenithDistance), MAX(fZenithDistance), ";
    215296    query +=      " MIN(fAzimuth), MAX(fAzimuth) ";
    216     query += Form(" FROM RunData"
    217                   " WHERE fRunTypeKEY=2 AND fSourceKEY=%d AND (fRunNumber BETWEEN %d AND %d) AND fExcludedFDAKEY=1",
    218                   src, from, to);
     297    query += Form(" FROM RunData WHERE fRunTypeKEY=2 AND "
     298                  " (fRunNumber BETWEEN %d AND %d) AND fExcludedFDAKEY=1",
     299                  from, to);
    219300
    220301    TSQLResult *res = serv.Query(query);
     
    239320
    240321    // ========== Request start time of sequence ==========
    241     query = Form("SELECT fRunStart FROM RunData WHERE fRunNumber=%d AND fSourceKEY=%d AND fExcludedFDAKEY=1", from, src);
     322    query = Form("SELECT fRunStart FROM RunData WHERE fRunNumber=%d AND fExcludedFDAKEY=1", from);
    242323
    243324    res = serv.Query(query);
     
    257338
    258339    // ========== Request data of sequence ==========
    259     query = Form("SELECT fProjectKEY, fL1TriggerTableKEY, fL1TriggerTableKEY,"
     340    query = Form("SELECT fSourceKEY, fProjectKEY, "
     341                 " fL1TriggerTableKEY, fL1TriggerTableKEY,"
    260342                 " fHvSettingsKEY, fDiscriminatorThresholdTableKEY,"
    261343                 " fTriggerDelayTableKEY, fLightConditionsKEY, fTestFlagKEY"
    262344                 " FROM RunData"
    263                  " WHERE fRunTypeKEY=2 AND fSourceKEY=%d AND fExcludedFDAKEY=1 AND (fRunNumber BETWEEN %d AND %d)"
    264                  " LIMIT 1", src, from, to);
     345                 " WHERE fRunTypeKEY=2 AND fExcludedFDAKEY=1 AND (fRunNumber BETWEEN %d AND %d)"
     346                 " LIMIT 1", from, to);
    265347
    266348    res = serv.Query(query);
     
    275357    }
    276358
    277     TString query1 = Form("INSERT Sequences SET"
    278                           " fSequenceFirst=%d,"
    279                           " fSequenceLast=%d,"
    280                           " fProjectKEY=%s,"
    281                           " fSourceKEY=%d,"
    282                           " fNumEvents=%s,"
    283                           " fRunTime=%s,"
    284                           " fRunStart=\"%s\","
    285                           " fZenithDistanceMin=%s,"
    286                           " fZenithDistanceMax=%s,"
    287                           " fAzimuthMin=%s,"
    288                           " fAzimuthMax=%s,"
    289                           " fL1TriggerTableKEY=%s,"
    290                           " fL2TriggerTableKEY=%s,"
    291                           " fHvSettingsKEY=%s,"
    292                           " fDiscriminatorThresholdTableKEY=%s,"
    293                           " fTriggerDelayTableKEY=%s,"
    294                           " fLightConditionsKEY=%s,"
    295                           " fTestFlagKEY=%s,"
    296                           " fManuallyChangedKEY=1",
    297                           from, to, (*row)[0], src, nevts.Data(),
    298                           secs.Data(), start.Data(), zdmin.Data(),
    299                           zdmax.Data(), azmin.Data(), azmax.Data(),
    300                           (*row)[1], (*row)[2], (*row)[3],
    301                           (*row)[4], (*row)[5], (*row)[6],
    302                           (*row)[7]);
     359    TString query1("INSERT Sequences SET");
     360    query1+=Form(" fSequenceFirst=%d,  fSequenceLast=%d,", from, to);
     361    query1+=Form(" fProjectKEY=%s,", (*row)[0]);
     362    query1+=Form(" fSourceKEY=%s,", (*row)[1]);
     363    query1+=Form(" fNumEvents=%s,", nevts.Data());
     364    query1+=Form(" fRunTime=%s,", secs.Data());
     365    query1+=Form(" fRunStart=\"%s\",", start.Data());
     366    query1+=Form(" fZenithDistanceMin=%s,", zdmin.Data());
     367    query1+=Form(" fZenithDistanceMax=%s,", zdmax.Data());
     368    query1+=Form(" fAzimuthMin=%s,", azmin.Data());
     369    query1+=Form(" fAzimuthMax=%s,", azmax.Data());
     370    query1+=Form(" fL1TriggerTableKEY=%s,", (*row)[2]);
     371    query1+=Form(" fL2TriggerTableKEY=%s,", (*row)[3]);
     372    query1+=Form(" fHvSettingsKEY=%s,", (*row)[4]);
     373    query1+=Form(" fDiscriminatorThresholdTableKEY=%s,", (*row)[5]);
     374    query1+=Form(" fTriggerDelayTableKEY=%s,", (*row)[6]);
     375    query1+=Form(" fLightConditionsKEY=%s,", (*row)[7]);
     376    query1+=Form(" fTestFlagKEY=%s, fManuallyChangedKEY=1", (*row)[8]);
     377
    303378
    304379    TString query2 = Form("UPDATE RunData SET fSequenceFirst=%d WHERE"
     
    306381                          "  (fRunTypeKEY BETWEEN  2 AND  4) AND"
    307382                          "  fSourceKEY=%d AND fHvSettingsKEY=%s AND fExcludedFDAKEY=1",
    308                           from, from, to, src, (*row)[3]);
    309 
    310     TString query3 = Form("INSERT SequenceProcessStatus SET fSequenceFirst=%d ",
    311                           from);
    312     delete res;
    313 
    314     if (dummy)
    315         return kTRUE;
     383                          from, from, to, (*row)[1], (*row)[4]);
     384
     385    TString query3 = Form("INSERT SequenceProcessStatus SET fSequenceFirst=%d ", from);
     386
     387    delete res;
    316388
    317389    res = serv.Query(query1);
     
    333405}
    334406
    335 Bool_t NewSequence(MSQLServer &serv, Int_t from, Int_t to, Int_t src, Bool_t dummy)
     407Bool_t NewSequence(MSQLServer &serv, Int_t from, Int_t to, Bool_t dummy)
    336408{
    337409    cout << "Found Sequence (" << from << ", " << to << ") ... checking runs..." << flush;
    338410
    339     if (!CheckSequence(serv, from, to, src, 2))
     411    if (!CheckRuns(serv, from, to, 2))
    340412    {
    341413        cout << "Warning - Found inconsistency in data-runs (" << from << ", " << to << ")" << endl;
     
    344416        return kTRUE;
    345417    }
    346     if (!CheckSequence(serv, from, to, src, 3))
     418    if (!CheckRuns(serv, from, to, 3))
    347419    {
    348420        cout << "Warning - Found inconsistency in ped-runs (" << from << ", " << to << ")" << endl;
     
    354426    cout << "ok." << endl;
    355427
    356     Bool_t rc = InsertSequence(serv, from, to, src, dummy);
     428
     429    cout << "checking Sequence..." << endl;
     430
     431    if (!CheckSequence(serv, from, to, dummy))
     432    {
     433        cout << " inserting sequence not necessary" << endl;
     434        return kTRUE;
     435    }
     436
     437
     438    if (dummy)
     439        return kTRUE;
     440
     441    Bool_t rc = InsertSequence(serv, from, to);
    357442    if (!rc)
    358443        cout << "InsertSequence failed!" << endl;
     
    361446}
    362447
    363 Bool_t GetSources(MSQLServer &serv, TString cond, TArrayI &srcs)
    364 {
    365     TString query(Form("SELECT fSourceKEY"
    366                        " FROM RunData"
    367                        " WHERE %s AND fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4) GROUP BY fSourceKEY",
    368                        cond.Data())
    369                  ); //DATE(fStartTime)=\"2004-05-19\"");
    370 
    371     TSQLResult *res = serv.Query(query);
    372     if (!res)
    373         return kFALSE;
    374 
    375     srcs.Set(res->GetRowCount());
    376 
    377     cout << "Found " << srcs.GetSize() << " sources." << endl << endl;
    378 
    379     TSQLRow *row=0;
    380     Int_t i=0;
    381     while ((row=res->Next()))
    382         srcs[i++] = atoi((*row)[0]);
    383 
    384     delete res;
    385     return kTRUE;
    386 }
    387 
    388 Bool_t Process(MSQLServer &serv, TString cond, Int_t src, Bool_t dummy)
    389 {
    390     if (debug)
    391         cout << "Processing Source: " << src << endl;
     448Bool_t Process(MSQLServer &serv, Int_t from, Int_t to, Bool_t dummy)
     449{
    392450
    393451    TString query(Form("SELECT fRunNumber, fRunTypeKEY, fRunStart, fRunStop"
    394452                       " FROM RunData"
    395                        " WHERE %s AND fSourceKEY=%d AND fExcludedFDAKEY=1 AND"
    396                        " (fRunTypeKEY BETWEEN 2 AND 4)"
    397                        " ORDER BY fRunNumber", cond.Data(), src)
    398                  ); //DATE(fStartTime)=\"2004-05-19\"");
     453                       " WHERE fRunNumber BETWEEN %d AND %d AND "
     454                       " fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)"
     455                       " ORDER BY fRunNumber", from, to));
    399456
    400457    TSQLResult *res = serv.Query(query);
     
    532589            if (n!=-1)
    533590            {
    534                 if (!NewSequence(serv, start, last, src, dummy))
     591                if (!NewSequence(serv, start, last, dummy))
    535592                {
    536593                    rc = kFALSE;
     
    548605    if (n!=-1 && start!=last)
    549606    {
    550         if (!NewSequence(serv, start, last, src, dummy))
     607        if (!NewSequence(serv, start, last, dummy))
    551608            rc = kFALSE;
    552609    }
     
    558615}
    559616
    560 // This tool will work from Period017 (2004_05_17) on...
     617
     618
    561619int buildsequenceentries(TString day, Bool_t dummy=kTRUE)
    562620{
     
    581639                            day.Data(), day.Data()));
    582640
    583     if (!dummy && !DeleteSequences(serv, cond))
     641    TString query(Form("SELECT fRunNumber, fSourceKEY, fProjectKEY, fHvSettingsKEY,  fLightConditionsKEY, fDiscriminatorThresholdTableKEY, fTriggerDelayTableKEY FROM RunData WHERE %s AND fExcludedFDAKEY=1 order by fRunNumber", cond.Data()));
     642
     643    TSQLResult *res = serv.Query(query);
     644    if (!res)
    584645        return 0;
    585646
     647    TString keys[6]= { "NULL", "NULL", "NULL", "NULL", "NULL", "NULL" };
     648    TString stop     = "NULL";
     649    TString runstart = "NULL";
     650    TString runstop  = "NULL";
     651    Int_t count = 0;
     652    TExMap blocks;
     653    Int_t runbegin;
     654    Int_t runend;
     655
     656    TSQLRow *row=0;
     657    while ((row=res->Next()))
     658    {
     659        if (count==0)
     660        {
     661            for (Int_t i=1 ; i<7 ; i++)
     662                keys[i-1]=(*row)[i];
     663            runstart=(*row)[0];
     664        }
     665
     666        for (Int_t i=1 ; i<7 ; i++)
     667        {
     668            runbegin=atoi(runstart.Data());
     669            runend=atoi(runstop.Data());
     670            if (i==2 && runbegin>20100 && runend<45100)
     671                continue;
     672
     673            TString value=(*row)[i];
     674            TString key=keys[i-1];
     675            if (!value.CompareTo(key))
     676                continue;
     677
     678            keys[i-1]=value;
     679            //hier einfuellen
     680            blocks.Add((ULong_t)blocks.GetSize(), (Long_t)runbegin, (Long_t)runend);
     681            runstart=(*row)[0];
     682            for (Int_t i=1 ; i<7 ; i++)
     683                keys[i-1]=(*row)[i];
     684            break;
     685        }
     686        runstop=(*row)[0];
     687        count++;
     688    }
     689
     690    //und hier einfuellen (letzter wert)
     691    runbegin=atoi(runstart.Data());
     692    runend=atoi(runstop.Data());
     693    blocks.Add((ULong_t)blocks.GetSize(), (Long_t)runbegin, (Long_t)runend);
     694
     695
    586696    Bool_t rc = kTRUE;
    587697
    588     // get all sources for this day
    589     TArrayI src;
    590     GetSources(serv, cond, src);
    591     // find and build the sequences for the day for each source
    592     for (int i=0; i<src.GetSize(); i++)
    593         if (!Process(serv, cond, src[i], dummy))
     698    Long_t key, val;
     699    TExMapIter nblocks(&blocks);
     700    while (nblocks.Next(key, val))
     701    {
     702        Int_t runstart2 = (Int_t)key;
     703        Int_t runstop2 = (Int_t)val;
     704        cout << endl << "datablock from " << runstart2 << " to " << runstop2 << endl;
     705
     706        if (!Process(serv, runstart2, runstop2, dummy))
    594707            rc = kFALSE;
    595708
     709    }
    596710    return rc ? 1 : 0;
    597711}
     712
    598713
    599714int buildsequenceentries()
     
    610725    TString query="SELECT fDate FROM SequenceBuildStatus";
    611726
    612     cout << "Q: " << query << endl;
    613 
    614727    TSQLResult *res = serv.Query(query);
    615728    if (!res)
Note: See TracChangeset for help on using the changeset viewer.