Ignore:
Timestamp:
07/17/08 16:08:04 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/datacenter/macros
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C

    r8968 r9006  
    159159    UInt_t fMax;
    160160
     161    static UInt_t GetId(const TString &str)
     162    {
     163        const Ssiz_t dot = str.First('.');
     164
     165        const UInt_t run = str.Atoi();
     166        const UInt_t sub = dot<0 ? 0 : atoi(str.Data()+dot+1);
     167
     168        return run*1000+sub;
     169    }
     170
    161171    void Init(const TObjArray &arr, Int_t idx=0)
    162172    {
     
    179189            case 2: fRegexp1  = TPRegexp(Form("^%s$", str.Data())); break;
    180190            case 3: fRegexp2  = TPRegexp(Form("^%s$", str.Data())); break;
    181             case 4: fMin      = str.Atoi();               break;
    182             case 5: fMax      = str.Atoi();               break;
     191            case 4: fMin      = GetId(str);               break;
     192            case 5: fMax      = GetId(str);               break;
    183193            }
    184194        }
    185         //cout << endl;
    186195    }
    187196
     
    257266    TString fPathSequences;
    258267
     268    Int_t fTelescopeNumber;
     269
    259270    TMap  fMap;
    260271    TList fListRegexp;
     
    286297        const TString runtime =
    287298            "SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))), ";
    288             //"SUM(if(TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)<0,"
    289             //" TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart)+24*60*60,"
    290             //" TIME_TO_SEC(fRunStop)-TIME_TO_SEC(fRunStart))), ";
    291 
    292         const TString where = Form("(fRunNumber BETWEEN %d AND %d) AND fExcludedFDAKEY=1",
    293                                    from, to);
     299
     300        const TString where = Form("(fRunNumber*1000+fFileNumber BETWEEN %d AND %d) "
     301                                   "AND fTelescopeNumber=%d AND fExcludedFDAKEY=1",
     302                                   from, to, fTelescopeNumber);
    294303
    295304        TString query;
     
    359368        }
    360369
    361         const TString set = Form("fSequenceFirst=%d ", from);
     370        const TString set = Form("fSequenceFirst=%d, fTelescopeNumber=%d ", from/1000, fTelescopeNumber);
    362371
    363372        TString query1;
    364373        query1 += set;
    365         query1 += Form(",fSequenceLast=%d,",                   to);
     374        query1 += Form(",fSequenceLast=%d,",                   to/1000);
    366375        query1 += Form(" fSourceKEY=%s,",                      (*row)[0]);
    367376        query1 += Form(" fProjectKEY=%s,",                     (*row)[1]);
     
    400409        }
    401410
    402         if (!Insert("SequenceProcessStatus", set))
     411        TString prio = set;
     412        prio += Form(", fPriority=%d ", from/1000);
     413        if (!Insert("SequenceProcessStatus", prio))
    403414        {
    404415            cout << "ERROR - Could not insert Sequence into SequenceProcessStatus." << endl;
     
    458469    Int_t CheckSequence(Int_t runstart, Int_t runstop)
    459470    {
    460         const char *fmt1 = "SELECT fRunNumber FROM RunData WHERE";
    461         const char *fmt2 = "AND fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4) ORDER BY fRunNumber";
    462 
    463         const TString query1 = Form("%s fSequenceFirst=%d %s",            fmt1, runstart, fmt2);
    464         const TString query2 = Form("%s fRunNumber BETWEEN %d AND %d %s", fmt1, runstart, runstop, fmt2);
     471        const char *fmt1 = "SELECT fRunNumber*1000+fFileNumber AS Id FROM RunData WHERE";
     472        const char *fmt2 = "AND fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4) ORDER BY Id";
     473
     474        const TString query1 = Form("%s fTelescopeNumber=%d AND fSequenceFirst=%d %s",    fmt1, fTelescopeNumber, runstart/1000, fTelescopeNumber, fmt2);
     475        const TString query2 = Form("%s fTelescopeNumber=%d AND fRunNumber*1000+fFileNumber BETWEEN %d AND %d %s", fmt1, fTelescopeNumber, runstart, runstop, fmt2);
    465476
    466477        TSQLResult *res1 = Query(query1);
     
    499510        TString query=
    500511            Form("SELECT fSequenceFirst FROM RunData "
    501                  " WHERE fRunNumber BETWEEN %d AND %d AND "
    502                  " fSequenceFirst>0 AND "
     512                 " WHERE fRunNumber*1000+fFileNumber BETWEEN %d AND %d AND "
     513                 " fTelescopeNumber=%d AND fSequenceFirst>0 AND "
    503514                 " fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)"
    504                  " GROUP BY fSequenceFirst", runstart, runstop);
     515                 " GROUP BY fSequenceFirst", fTelescopeNumber, runstart, runstop);
    505516
    506517        TSQLResult *res = Query(query);
     
    554565    Bool_t ReadResources(const char *fname)
    555566    {
    556         TPRegexp regexp("^\\[.*\\]$");
     567        // Check for the section header
     568        TPRegexp regexp("^\\[(Transition|Regexp):?[0-9 ]*\\]$");
     569        // Check if section header contains a number
     570        TPRegexp regnum("[0-9]");
     571        // Check if section header contains the telescope number
     572        TPRegexp regtel(Form("[^0-9]0*%d[^0-9]", fTelescopeNumber));
    557573
    558574        ifstream fin(fname);
     
    579595                continue;
    580596
    581             if (txt[0]=='[' && section!=2)
     597            if (txt[0]=='['/* && section!=2*/)
    582598            {
    583                 //cout << txt << endl;
    584                 section = 0;
    585                 if (txt(regexp)=="[Transition]")
    586                     section = 1;
    587                 if (txt(regexp)=="[Regexp]")
    588                     section = 2;
    589                 continue;
     599                TString sec = txt(regexp);
     600                if (!sec.IsNull())
     601                {
     602                    section = 0;
     603
     604                    // Skip sections with the wrong telescope number
     605                    if (!sec(regnum).IsNull() && !sec(regtel).IsNull())
     606                        continue;
     607
     608                    // Check which section we are in
     609                    if (sec.BeginsWith("[Transition"))
     610                        section = 1;
     611                    if (sec.BeginsWith("[Regexp]"))
     612                        section = 2;
     613                    continue;
     614                }
     615
     616                if (section!=2)
     617                {
     618                    cout << "WARNING - Line starts with [ but we are not in the Regexp section." << endl;
     619                    cout << txt << endl;
     620                    continue;
     621                }
    590622            }
     623
    591624
    592625            TObjArray *arr = txt.Tokenize(" ");
     
    705738    {
    706739        return Form("SELECT RunData.f%sKEY, f%sName FROM RunData "
    707                     "LEFT JOIN %s ON RunData.f%sKEY=%s.f%sKEY "
    708                     "WHERE %s GROUP BY f%sName",
    709                     col, col, col, col, col, col, cond, col);
     740                    "LEFT JOIN %s USING (f%sKEY) WHERE %s GROUP BY f%sName",
     741                    col, col, col, col, cond, col);
    710742    }
    711743
     
    864896        // Request data necessary to split block into sequences
    865897        const TString query=
    866             Form("SELECT fRunNumber, fRunTypeKEY, fRunStart, fRunStop"
     898            Form("SELECT fRunNumber*1000+fFileNumber AS Id, fRunTypeKEY, fRunStart, fRunStop"
    867899                 " FROM RunData "
    868                  " WHERE fRunNumber BETWEEN %d AND %d AND "
     900                 " WHERE fRunNumber*1000+fFileNumber BETWEEN %d AND %d AND "
    869901                 " fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)"
    870                  " ORDER BY fRunNumber", runstart, runstop);
     902                 " ORDER BY Id", runstart, runstop);
    871903
    872904        // Send query
     
    10841116
    10851117public:
    1086     SequenceBuild(TEnv &env) : MSQLMagic(env)
    1087     {
    1088         cout << "buildsequences" << endl;
    1089         cout << "--------------" << endl;
    1090         cout << endl;
    1091         cout << "Connected to " << GetName() << endl;
    1092 
     1118    SequenceBuild(Int_t tel=1, const char *rc="sql.rc") : MSQLMagic(rc), fTelescopeNumber(tel)
     1119    {
    10931120        fListRegexp.SetOwner();
    10941121
     
    10971124            return;
    10981125    }
    1099     SequenceBuild()
     1126
     1127    SequenceBuild(TEnv &env, Int_t tel=1) : MSQLMagic(env), fTelescopeNumber(tel)
     1128    {
     1129        fListRegexp.SetOwner();
     1130
     1131        // FIXME: THIS IS NOT YET HANDLED
     1132        if (ReadResources("resources/sequences.rc"))
     1133            return;
     1134    }
     1135    ~SequenceBuild()
    11001136    {
    11011137        fMap.DeleteAll();
     
    11131149        const TString cond =
    11141150            Form("(fRunStart>ADDDATE(\"%s\", INTERVAL -1 DAY) AND fRunStart<\"%s\") "
    1115                  "AND fExcludedFDAKEY=1 AND fRunTypeKEY BETWEEN 2 AND 4 ",
    1116                  day.Data(), day.Data());
     1151                 "AND fExcludedFDAKEY=1 AND fRunTypeKEY BETWEEN 2 AND 4 "
     1152                 "AND fTelescopeNumber=%d ",
     1153                 day.Data(), day.Data(), fTelescopeNumber);
    11171154
    11181155        //query all sources observed in this night
     
    11281165        // Setup query to get all values from the database,
    11291166        // that are relevant for building sequences
    1130         TString query("SELECT fRunNumber, fRunTypeKEY, ");
     1167        TString query("SELECT fRunNumber*1000+fFileNumber AS Id, fRunTypeKEY, ");
    11311168        query += elts;
    11321169        query += ", ";
     
    11421179                query += mapkey->GetName();
    11431180            }
    1144         query += Form(" FROM RunData WHERE %s ORDER BY fRunNumber", cond.Data());
     1181        query += Form(" FROM RunData WHERE %s ORDER BY Id", cond.Data());
    11451182
    11461183        TSQLResult *res = Query(query);
     
    11761213ClassImp(SequenceBuild);
    11771214
    1178 int buildsequenceentries(TString day, TString datapath, TString sequpath, Bool_t dummy=kTRUE)
     1215int buildsequenceentries(TString day, TString datapath, TString sequpath, Int_t tel=1, Bool_t dummy=kTRUE)
    11791216{
    1180     TEnv env("sql.rc");
    1181 
    1182     SequenceBuild serv(env);
     1217    SequenceBuild serv(tel, "sql.rc");
    11831218    if (!serv.IsConnected())
    11841219    {
     
    11861221        return 0;
    11871222    }
     1223
     1224    cout << "buildsequenceentries" << endl;
     1225    cout << "--------------------" << endl;
     1226    cout << endl;
     1227    cout << "Connected to " << serv.GetName() << endl;
     1228    if (!datapath.IsNull())
     1229        cout << "DataPath:  " << datapath << endl;
     1230    if (!sequpath.IsNull())
     1231        cout << "SeqPath:   " << sequpath << endl;
     1232    cout << "Day:       " << day      << endl;
     1233    cout << "Telescope: " << tel      << endl;
     1234    cout << endl;
    11881235
    11891236    serv.SetIsDummy(dummy);
     
    11961243// Build Sequences for all Nights
    11971244//
    1198 int buildsequenceentries(TString datapath, TString sequpath, Bool_t dummy=kTRUE)
     1245int buildsequenceentries(TString datapath, TString sequpath, Int_t tel=1, Bool_t dummy=kTRUE)
    11991246{
    1200     TEnv env("sql.rc");
    1201 
    1202     SequenceBuild serv(env);
     1247    SequenceBuild serv(tel, "sql.rc");
    12031248    if (!serv.IsConnected())
    12041249    {
     
    12061251        return 0;
    12071252    }
     1253
     1254    cout << "buildsequenceentries" << endl;
     1255    cout << "--------------------" << endl;
     1256    cout << endl;
     1257    cout << "Connected to " << serv.GetName() << endl;
     1258    cout << "DataPath:  " << datapath << endl;
     1259    cout << "SeqPath:   " << sequpath << endl;
     1260    cout << "Telescope: " << tel      << endl;
     1261    cout << endl;
    12081262
    12091263    serv.SetIsDummy(dummy);
     
    12131267}
    12141268
    1215 int buildsequenceentries(Bool_t dummy=kTRUE)
     1269int buildsequenceentries(Int_t tel=1, Bool_t dummy=kTRUE)
    12161270{
    1217     return buildsequenceentries("", "", dummy);
     1271    return buildsequenceentries("", "", tel, dummy);
    12181272}
    12191273
    1220 int buildsequenceentries(TString day, Bool_t dummy=kTRUE)
     1274int buildsequenceentries(TString day, Int_t tel=1, Bool_t dummy=kTRUE)
    12211275{
    1222     return buildsequenceentries(day, "", "", dummy);
     1276    return buildsequenceentries(day, "", "", tel, dummy);
    12231277}
  • trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C

    r7777 r9006  
    5959#include <iostream>
    6060#include <iomanip>
    61 #include <fstream>
    62 
    63 #include <MSQLServer.h>
     61
     62#include <TEnv.h>
     63#include <TSystem.h>
     64
    6465#include <TSQLRow.h>
    6566#include <TSQLResult.h>
    6667
    67 #include <TEnv.h>
    68 #include <TSystem.h>
     68#include "MSQLMagic.h"
    6969
    7070using namespace std;
    7171
    7272//get minimum or maximum runnumber of the runs of a night
    73 int GetRunNumber(MSQLServer &serv, TString date, TString value)
     73int GetRunNumber(MSQLServer &serv, Int_t tel, TString date, TString cmd)
    7474{
    75     TString query(Form("SELECT %s(fRunNumber) FROM RunData ", value.Data()));
     75    TString query;
     76    query  = Form("SELECT %s(fRunNumber) FROM RunData ", cmd.Data());
     77    query += Form("WHERE fTelescopeNumber=%d", tel);
    7678
    7779    if (date!="NULL")
    7880    {
    7981        TString day=date+" 13:00:00";
    80         query+=Form(" WHERE (fRunStart>ADDDATE(\"%s\", INTERVAL -1 DAY) AND fRunStart<\"%s\")",
    81                     day.Data(), day.Data());
    82     }
    83 
    84     cout << "query: " << query << endl;
     82        query += Form(" AND (fRunStart>ADDDATE(\"%s\", INTERVAL -1 DAY) AND fRunStart<\"%s\")",
     83                      day.Data(), day.Data());
     84    }
    8585
    8686    TSQLResult *res = serv.Query(query);
    8787    if (!res)
    8888    {
    89         cout << "Error - could not get run#" << endl;
     89        cout << "ERROR - Could not get " << cmd << " fRunNumber." << endl;
    9090        return -1;
    9191    }
    9292
    9393    TSQLRow *row =res->Next();
    94     cout << (void*)row << endl;
    9594    if (TString((*row)[0]).IsNull())
    9695    {
    97         cout << "No run available for this date" << endl;
     96        cout << "No run available for " << date << endl;
    9897        delete res;
    9998        return 0;
    10099    }
    101100    delete res;
     101
    102102    return atoi((*row)[0]);
    103103}
    104104
    105 //get part of a query (left join of tables)
    106 TString GetJoin(TString table)
     105int doexclusions(Int_t startrun, Int_t stoprun, Int_t tel=1, TString date="NULL", Bool_t dummy=kTRUE)
    107106{
    108     TString query(Form("left join %s ON RunData.f%sKEY=%s.f%sKEY ",
    109                        table.Data(), table.Data(), table.Data(), table.Data()));
    110     return query;
    111 }
    112 
    113 int doexclusions(Int_t startrun, Int_t stoprun, TString date="NULL")
    114 {
    115     TEnv env("sql.rc");
    116     TEnv rc("automatic-exclusions.rc");
    117 
    118     MSQLServer serv(env);
     107    MSQLMagic serv("sql.rc");
    119108    if (!serv.IsConnected())
    120109    {
     
    123112    }
    124113
     114    // Open rc files with exclusions
     115    TEnv rc("resources/exclusions.rc");
     116
     117    // Some information for the user
    125118    cout << "doexclusions" << endl;
    126119    cout << "------------" << endl;
    127120    cout << endl;
    128121    cout << "Connected to " << serv.GetName() << endl;
    129 
    130     //if neither start- nor stoprun is given, the minimum and maximum runnumber
    131     // is queried from the database to do the exclusions for all runs
    132     // if a night is given for all runs of this night
     122    cout << "Date:      " << date << endl;
     123
     124    serv.SetIsDummy(dummy);
     125
     126    // if neither start- nor stoprun is given, the minimum and maximum
     127    // runnumber is queried from the database to do the exclusions for
     128    // all runs if a night is given for all runs of this night
    133129    if (startrun==0 && stoprun==0)
    134130    {
    135         startrun=GetRunNumber(serv, date, "min");
    136         stoprun=GetRunNumber(serv, date, "max");
    137     }
     131        startrun = GetRunNumber(serv, tel, date, "MIN");
     132        stoprun  = GetRunNumber(serv, tel, date, "MAX");
     133    }
     134
     135    cout << "Start Run: " << startrun << endl;
     136    cout << "Stop  Run: " << stoprun  << endl;
     137
    138138    //check format of start- and stoprun
    139139    if (startrun<0 || stoprun<0)
    140140    {
    141         cout << "wrong format of runno" << endl;
     141        cout << "ERROR - Startrun<0 or stoprun<0." << endl;
    142142        return 2;
    143143    }
     144
    144145    //if no run for date is available, GetRunNumber() returns 0
    145146    if (startrun==0 || stoprun==0)
    146147        return 1;
    147148
    148     //get the condition for the runnumber range
    149     TString runcond(Form("AND fRunNumber BETWEEN %d AND %d ", startrun, stoprun));
    150 
    151     //get exclusions-reasons (stored in the table ExcludedFDA) from the database
    152     //the exclusions which can be done automatically are marked with the flag fExcludedFDAAutomatic='yes'
    153     //and with an importance (one run may be excluded for several reasons,
    154     //the reason is chosen according to the importance)
    155     TString query="SELECT fExcludedFDAKEY from ExcludedFDA where fExcludedFDAAutomatic='yes'";
    156     TSQLResult *res = serv.Query(query);
     149    // Get exclusions-reasons (stored in the table ExcludedFDA) from the DB
     150    TSQLResult *res = serv.Query("SELECT fExcludedFDAKEY, fExcludedFDAName "
     151                                 "FROM ExcludedFDA "
     152                                 "ORDER BY fExcludedFDAImportance ASC");
    157153    if (!res)
    158     {
    159         cout << "Error - could not do any automatic excludes." << endl;
    160154        return 2;
    161     }
    162155
    163156    //update the exclusion-reasons for all runs
     
    165158    while ((row = res->Next()))
    166159    {
    167         //read in values from the resource file automatic-exclusions (explanation see above)
    168         TString key=(*row)[0];
    169         TString column=rc.GetValue("key"+key+".Column", "");
    170         TString join1=rc.GetValue("key"+key+".Join1", "");
    171         TString join2=rc.GetValue("key"+key+".Join2", "");
    172         TString border=rc.GetValue("key"+key+".SpecialRunCond", "");
    173 
    174         //get importance of exclusion-reason from database
    175         TString query(Form("SELECT fExcludedFDAImportance from ExcludedFDA where fExcludedFDAKEY=%s ", key.Data()));
    176         TSQLResult *res2 = serv.Query(query);
     160        // check the key (NULL means "No exclusion")
     161        const TString key = (*row)[0];
     162        if (key.IsNull())
     163            continue;
     164
     165        // Get the corresponding condition from the file
     166        const TString cond = rc.GetValue("key"+key, "");
     167        if (cond.IsNull())
     168            continue;
     169
     170        // Get all files to be excluded
     171        TString query2 = "SELECT fRunNumber, fFileNumber FROM RunData ";
     172        query2 += serv.GetJoins("RunData", query2+cond);
     173
     174        query2 += Form("WHERE (%s) ", cond.Data());
     175        query2 += Form("AND fRunNumber BETWEEN %d AND %d ", startrun, stoprun);
     176        query2 += Form("AND fTelescopeNumber=%d", tel);
     177
     178        TSQLResult *res2 = serv.Query(query2);
    177179        if (!res2)
    178         {
    179             cout << "Error - could not get importance." << endl;
    180180            return 2;
    181         }
    182 
    183         TSQLRow *row2=res2->Next();
    184         Int_t newimp=atoi((*row2)[0]);
    185         delete res2;
    186 
    187         //get current importance from database
    188         //for the runs which match the exclusion-reason
    189         query="SELECT fRunNumber, fExcludedFDAImportance ";
    190         if (!column.IsNull())
    191             query+=Form(", %s", column.Data());
    192         if (!join1.IsNull())
    193             query+=Form(", f%sName", join1.Data());
    194         if (!join2.IsNull())
    195             query+=Form(", f%sName", join2.Data());
    196         query +=" FROM RunData ";
    197         query +=GetJoin("ExcludedFDA");
    198         if (!join1.IsNull())
    199             query+=GetJoin(join1.Data());
    200         if (!join2.IsNull())
    201             query+=GetJoin(join2.Data());
    202         query +=Form("WHERE (%s) ", rc.GetValue("key"+key+".Cond", ""));
    203         if (!border.IsNull())
    204             query+=Form(" AND fRunNumber BETWEEN IF(%s>%d, %d, %s) AND IF (%s<%d, %s, %d) ",
    205                         border.Data(), startrun, startrun, border.Data(),
    206                         border.Data(), stoprun, border.Data(), stoprun);
    207         else
    208             query +=runcond;
    209 
    210         cout << query << endl;
    211 
    212         res2 = serv.Query(query);
    213         if (!res2)
    214         {
    215             cout << "Error - no runs to exclude" << endl;
    216             return 2;
    217         }
    218 
    219         //compare new and old importance
    220         //change or keep the exclusion-reason accordingly
     181
     182        // Update exlcusion for file
     183        TSQLRow *row2=0;
    221184        while ((row2 = res2->Next()))
    222185        {
    223             if (TString((*row2)[1]).IsNull() || atoi((*row2)[1])>newimp)
    224             {
    225                 //change exclusion-reason
    226                 TString query(Form("UPDATE RunData SET fExcludedFDAKEY=%s WHERE fRunNumber=%s",
    227                                    key.Data(), (*row2)[0]));
    228                 cout << "QU: " << query << endl;
    229                 TSQLResult *res3 = serv.Query(query);
    230                 if (!res3)
    231                 {
    232                     cout << "Error - could not insert exclusion" << endl;
    233                     return 2;
    234                 }
    235                 delete res3;
    236                 continue;
    237             }
    238             //keep exclusion-reason
    239             cout << "run#: " << (*row2)[0] << " reason for exclusion is still the same" << endl;
     186            TString vars(Form("fExcludedFDAKEY=%s", key.Data()));
     187            TString where(Form("fRunNumber=%s AND fFileNumber=%s", (*row2)[0], (*row2)[1]));
     188
     189            if (serv.Update("RunData", vars, where)==kFALSE)
     190                return 2;
     191
     192            cout << "File M" << tel << ":" << (*row2)[0] << "/" << setw(3) << setfill('0') << (*row2)[1] << " excluded due to: " << (*row)[1] << "." << endl;
    240193        }
     194
    241195        delete res2;
    242196    }
    243197    delete res;
     198
    244199    return 1;
    245200}
    246201
    247202//run doexclusions for one night
    248 int doexclusions(TString date="NULL")
     203int doexclusions(TString date="NULL", Int_t tel=1, Bool_t dummy=kTRUE)
    249204{
    250     return doexclusions(0, 0, date);
     205    return doexclusions(0, 0, tel, date, dummy);
    251206}
  • trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C

    r8996 r9006  
    133133    }
    134134
    135     cout << "  V" << version << " " << flush;
     135    if (version >= 200805190)
     136    {
     137        strng.ReadLine(fin);
     138        if (!strng.BeginsWith("Telescope M"))
     139        {
     140            cout << "WARNING - Line 3 doesn't start with 'Telescope M'." << endl;
     141            cout << strng << endl;
     142        }
     143    }
     144
     145    if (version >= 200411130)
     146    {
     147        strng.ReadLine(fin);
     148        if (strng[0]!='#')
     149        {
     150            cout << "WARNING - '#' expected." << endl;
     151            cout << strng << endl;
     152        }
     153    }
     154
     155    cout << " * V" << version << " " << endl;
    136156
    137157    Int_t cnt=0;
     
    146166            if (strng[0]!='M')
    147167            {
    148                 cout << "First character is not an M." << endl;
     168                cout << "WARNING - First character is not an M." << endl;
    149169                cout << strng << endl;
    150170                strng.ReadLine(fin);
     
    153173            if (strng[1]!='1')
    154174            {
    155                 cout << "Only MAGIC 1 implemented so far." << endl;
     175                cout << "WARNING - Only MAGIC 1 implemented so far." << endl;
    156176                cout << strng << endl;
    157177                strng.ReadLine(fin);
     
    176196        {
    177197            strng.ReadLine(fin);
    178             cout << "Runnumber == 0" << endl;
     198            cout << "WARNING - Runnumber == 0" << endl;
     199            cout << strng << endl;
    179200            continue;
    180201        }
     
    187208        }
    188209
    189         TString where = Form("((fTelescopeNumber=%d AND fFileNumber=%d) OR"
    190                              "(ISNULL(fTelescopeNumber) AND ISNULL(fFileNumber)))",
     210        TString where = Form("fTelescopeNumber=%d AND fFileNumber=%d",
    191211                             telnumber, filenumber);
    192         if (serv.ExistStr("fRunNumber", "RunData", strng, where))
     212        if (serv.ExistStr("fRunNumber", "RunData", Form("%d", runnumber), where))
    193213        {
    194214            // FIXME: Maybe we can implement a switch to update mode?
    195             cout << "Entry M" << telnumber << ":" << runnumber << "/" << filenumber << " already existing... skipped." << endl;
     215            cout << "WARNING - Entry M" << telnumber << ":" << runnumber << "/" << filenumber << " already existing... skipped." << endl;
    196216            strng.ReadLine(fin);
    197217            continue;
     
    569589            return -1;
    570590
    571         TString query2=Form("fRunNumber=%d, fTimingCorrection='1970-01-01 00:00:00', fCompmux='1970-01-01 00:00:00'",
    572                             runnumber);
     591        TString query2=Form("fTelescopeNumber=%d, fRunNumber=%d, fFileNumber=%d, "
     592                            "fPriority=%d, fTimingCorrection='1970-01-01 00:00:00', fCompmux='1970-01-01 00:00:00'",
     593                            telnumber, runnumber, filenumber, runnumber);
    573594        if (testflagkey==3)
    574595            query2+=" , fDataCheckDone='1970-01-01 00:00:00'";
     
    580601
    581602    return cnt;
    582 
    583603}
    584604
    585605// This tool will work from Period017 (2004_05_17) on...
    586 int filldotrun(const TString path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE)
     606int filldotrun(const TString path="/home/lapalma/transfer/ccdata", Bool_t dummy=kTRUE)
    587607{
    588608    MSQLMagic serv("sql.rc");
     
    592612        return 0;
    593613    }
     614
    594615    cout << "filldotrun" << endl;
    595616    cout << "----------" << endl;
     
    617638            break;
    618639
    619         cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;
     640        cout << " * " << name(TRegexp("CC_.*.run", kFALSE)) << endl;
    620641        Int_t n = insert(serv, dummy, name);
    621         cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
     642        cout << "   <" << n << "> " << (dummy?"DUMMY":"") << endl;
    622643
    623644        if (n<0)
Note: See TracChangeset for help on using the changeset viewer.