Ignore:
Timestamp:
01/15/10 09:27:25 (15 years ago)
Author:
snruegam
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r9213 r9539  
    9090#include <TExMap.h>
    9191#include <TArrayI.h>
     92#include <TArrayL.h>
    9293#include <TArrayD.h>
    9394#include <TPRegexp.h>
     
    103104using namespace std;
    104105
    105     /*static*/ UInt_t GetId(const TString str)
     106    /*static*/ ULong_t GetId(const TString str)
    106107    {
    107108        const Ssiz_t dot = str.First('.');
     
    110111        const UInt_t sub = dot<0 ? 0 : atoi(str.Data()+dot+1);
    111112
    112         return run*1000+sub;
     113        return ULong_t(run)*1000+sub;
    113114    }
    114115
     
    119120    TPRegexp fRegexp;
    120121
    121     UInt_t fMin;
    122     UInt_t fMax;
     122    ULong_t fMin;
     123    ULong_t fMax;
    123124
    124125public:
    125126    Rule(TObjArray &arr) :
    126127        fRegexp(arr.GetEntries()>0?Form("^%s", arr[0]->GetName()):""),
    127             fMin(0), fMax((UInt_t)-1)
     128            fMin(0), fMax((ULong_t)-1)
    128129    {
    129130        if (arr.GetEntries()>1)
     
    133134    }
    134135
    135     Ssiz_t Match(const TString &str, Int_t idx, Int_t run=-1)
     136    Ssiz_t Match(const TString &str, Int_t idx, Long_t run=-1)
    136137    {
    137138        if (!IsValid(run))
     
    145146    }
    146147
    147     Bool_t IsValid(UInt_t run) const { return run<0 || (run>=fMin && run<=fMax); }
     148    Bool_t IsValid(ULong_t run) const { return run>=fMin && run<=fMax; }
    148149    ClassDef(Rule, 0)
    149150};
     
    159160    TPRegexp fRegexp2;
    160161
    161     UInt_t fMin;
    162     UInt_t fMax;
     162    ULong_t fMin;
     163    ULong_t fMax;
    163164
    164165    void Init(const TObjArray &arr, Int_t idx=0)
     
    191192    CheckMatch() : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2("") {}
    192193
    193     CheckMatch(const TString &txt) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((UInt_t)-1)
     194    CheckMatch(const TString &txt) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((ULong_t)-1)
    194195    {
    195196        TObjArray *arr = txt.Tokenize(" ");
     
    198199    }
    199200
    200     CheckMatch(TObjArray &arr, Int_t idx=0) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((UInt_t)-1)
     201    CheckMatch(TObjArray &arr, Int_t idx=0) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((ULong_t)-1)
    201202    {
    202203        Init(arr, idx);
    203204    }
    204205
    205     CheckMatch(const char *from, const char *to, Int_t min=0, Int_t max=-1)
     206    CheckMatch(const char *from, const char *to, Long_t min=0, Long_t max=-1)
    206207        : fRunType1(".*"), fRunType2(".*"), fRegexp1(Form("^%s$", from)), fRegexp2(Form("^%s$", to)), fMin(min), fMax(max)
    207208    {
    208209    }
    209210
    210     Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, UInt_t run=0)
     211    Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, ULong_t run=0)
    211212    {
    212213        if (run>0)
     
    234235public:
    235236    CheckList() { SetOwner(); }
    236     Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, Int_t run=-1) const
     237    Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, Long_t run=-1) const
    237238    {
    238239        TIter Next(this);
     
    277278        // (row[i]) and the current run-type (row[1]) matches the attribute
    278279        // of the last run (keys[i] with run-type row[i])
    279         return list->Matches(keys[1], row[1], keys[i], row[i], atoi(row[0]));
    280     }
    281 
    282     Bool_t InsertSequence(Int_t from, Int_t to)
     280        return list->Matches(keys[1], row[1], keys[i], row[i], atol(row[0]));
     281    }
     282
     283    Bool_t InsertSequence(Long_t from, Long_t to)
    283284    {
    284285        cout << "     - Inserting Sequence into database." << endl;
     
    291292            "SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))), ";
    292293
    293         const TString where = Form("(fRunNumber*1000+fFileNumber BETWEEN %d AND %d) "
     294        const TString where = Form("(fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld) "
    294295                                   "AND fTelescopeNumber=%d AND fExcludedFDAKEY=1",
    295296                                   from, to, fTelescopeNumber);
     
    361362        }
    362363
    363         const TString set = Form("fSequenceFirst=%d, fTelescopeNumber=%d ", from/1000, fTelescopeNumber);
     364        const TString set = Form("fSequenceFirst=%ld, fTelescopeNumber=%d ", from/1000, fTelescopeNumber);
    364365
    365366        TString query1;
    366367        query1 += set;
    367         query1 += Form(",fSequenceLast=%d,",                   to/1000);
     368        query1 += Form(",fSequenceLast=%ld,",                   to/1000);
    368369        query1 += Form(" fSourceKEY=%s,",                      (*row)[0]);
    369370        query1 += Form(" fProjectKEY=%s,",                     (*row)[1]);
     
    404405
    405406        TString prio = set;
    406         prio += Form(", fPriority=%d ", from/1000);
     407        prio += Form(", fPriority=%ld ", from/1000);
    407408        if (!Insert("SequenceProcessStatus", prio))
    408409        {
     
    465466    }
    466467
    467     Int_t CheckSequence(Int_t runstart, Int_t runstop)
     468    Int_t CheckSequence(Long_t runstart, Long_t runstop)
    468469    {
    469470        const char *fmt1 = "SELECT fRunNumber*1000+fFileNumber AS Id FROM RunData WHERE";
    470471        const char *fmt2 = "AND fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4) ORDER BY Id";
    471472
    472         const TString query1 = Form("%s fTelescopeNumber=%d AND fSequenceFirst=%d %s",                             fmt1, fTelescopeNumber, runstart/1000,     fmt2);
    473         const TString query2 = Form("%s fTelescopeNumber=%d AND fRunNumber*1000+fFileNumber BETWEEN %d AND %d %s", fmt1, fTelescopeNumber, runstart, runstop, fmt2);
     473        const TString query1 = Form("%s fTelescopeNumber=%d AND fSequenceFirst=%ld %s",                              fmt1, fTelescopeNumber, runstart/1000,     fmt2);
     474        const TString query2 = Form("%s fTelescopeNumber=%d AND fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld %s", fmt1, fTelescopeNumber, runstart, runstop, fmt2);
    474475
    475476        TSQLResult *res1 = Query(query1);
     
    495496                return kFALSE;
    496497
    497             if (atoi((*row1)[0])!=atoi((*row2)[0]))
     498            if (atol((*row1)[0])!=atol((*row2)[0]))
    498499                return kFALSE;
    499500        }
     
    502503    }
    503504
    504     Int_t CreateSequence(Int_t runstart, Int_t runstop)
     505    Int_t CreateSequence(Long_t runstart, Long_t runstop)
    505506    {
    506507        cout << "   * Creating Sequence " << runstart << "-" << runstop << ":" << endl;
     
    508509        TString query=
    509510            Form("SELECT fSequenceFirst FROM RunData "
    510                  " WHERE fRunNumber*1000+fFileNumber BETWEEN %d AND %d AND "
     511                 " WHERE fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld AND "
    511512                 " fTelescopeNumber=%d AND fSequenceFirst>0 AND "
    512513                 " fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)"
     
    794795    }
    795796
    796     TString PrepareString(TSQLResult &res, TArrayI &runs)
     797    TString PrepareString(TSQLResult &res, TArrayL &runs)
    797798    {
    798799        // Number of result rows
     
    810811        while ((row=res.Next()))
    811812        {
    812             runs[idx] = atoi((*row)[0]);          // run number
     813            runs[idx] = atol((*row)[0]);          // run number
    813814
    814815            const TString tstart = ((*row)[2]);   // start time
     
    862863    }
    863864
    864     void PrintResidual(Int_t runstart, Int_t runstop, TString residual, const char *descr)
     865    void PrintResidual(Long_t runstart, Long_t runstop, TString residual, const char *descr)
    865866    {
    866867        residual.ToLower();
     
    891892    }
    892893
    893     Int_t SplitBlock(Int_t runstart, Int_t runstop, const TString &cond)
     894    Int_t SplitBlock(Long_t runstart, Long_t runstop, const TString &cond)
    894895    {
    895896        // Request data necessary to split block into sequences
     
    897898            Form("SELECT fRunNumber*1000+fFileNumber AS Id, fRunTypeKEY, fRunStart, fRunStop"
    898899                 " FROM RunData "
    899                  " WHERE fRunNumber*1000+fFileNumber BETWEEN %d AND %d AND "
     900                 " WHERE fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld AND "
    900901                 /*" fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)"
    901902                  " ORDER BY Id"*/, runstart, runstop);
     
    912913        // Get String containing the sequence of P-,C- and D-Runs
    913914        // and an array with the corresponding run-numbers
    914         TArrayI runs;
     915        TArrayL runs;
    915916        const TString str = PrepareString(*res, runs);
    916917
     
    10351036            // This is the runnumber of the first run in the new block
    10361037            if (runstart<0)
    1037                 runstart=atoi((*row)[0]);
     1038                runstart=atol((*row)[0]);
    10381039
    10391040            // Check which transitions might be allowed for this run and
     
    10851086
    10861087                // This is already the first run of the new block
    1087                 runstart=atoi((*row)[0]);
     1088                runstart=atol((*row)[0]);
    10881089
    10891090                // These are the keys corresponding to the first run
     
    11011102
    11021103            // This is the new runnumber of the last run in this block
    1103             runstop=atoi((*row)[0]);
     1104            runstop=atol((*row)[0]);
    11041105        }
    11051106
Note: See TracChangeset for help on using the changeset viewer.