Changeset 7983


Ignore:
Timestamp:
09/28/06 10:36:56 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7982 r7983  
    4343   * ganymed_onoff.rc, ganymed_wobble.rc:
    4444     - updated with comments how to use random forest
     45
     46   * datacenter/macros/buildsequenceentries.C:
     47     - updated with a completely redesigned algorithm and completly
     48       redisigned code
     49
     50   * datacenter/macros/writesequencefile.C:
     51     - the new simplified version doesn't take the number of pedestal
     52       events anymore into account.
    4553
    4654
  • trunk/MagicSoft/Mars/NEWS

    r7981 r7983  
    22
    33 *** Version  <cvs>
     4
     5   - general: The algorithm to build seqeunces has been redesigned
     6     completly. It is now more flexible in terms of a resource file
     7     resources/sequences.rc which can be used to partly overwrite
     8     the default algorithm and defined the important part of the
     9     algorithm. It also takes correctly into account several ways
     10     of taking wobble-data. Currently the new algorithm doesn't take
     11     the number of pedestal events anymore into account (so a sequence
     12     could have much less than 1000 pedestal events and data runs are
     13     no-more used instead)
    414
    515   - general: a lot of small changes to make the code compatible with
  • trunk/MagicSoft/Mars/datacenter/macros/writesequencefile.C

    r7528 r7983  
    4646#include <fstream>
    4747
    48 #include <MSQLServer.h>
    4948#include <TSQLRow.h>
    5049#include <TSQLResult.h>
     
    5453#include <TRegexp.h>
    5554
    56 #include <MAstro.h>
    57 #include <MTime.h>
    58 #include <MDirIter.h>
     55#include "MAstro.h"
     56#include "MTime.h"
     57#include "MDirIter.h"
     58
     59#include "MSQLServer.h"
    5960
    6061using namespace std;
    6162
    62 Bool_t GetAllRuns(MSQLServer &serv, ofstream &fout, TString query)
     63Bool_t GetRuns(MSQLServer &serv, ofstream &fout, TString query, TString name)
    6364{
    6465    TSQLResult *res = serv.Query(query);
     
    6667        return kFALSE;
    6768
     69    Int_t cnt=0;
     70
     71    fout << name << ":";
    6872    TSQLRow *row=0;
    69 
    70     Int_t cnt = 0;
    71 
    72     fout << "Runs:";
    7373    while ((row = res->Next()))
    7474    {
     
    8282    if (cnt==0)
    8383    {
    84         cout << "ERROR - No runs belonging to this sequence found." << endl;
    85         return kFALSE;
    86     }
    87 
    88     return kTRUE;
    89 }
    90 
    91 Bool_t GetCalRuns(MSQLServer &serv, ofstream &fout, TString query, MTime *t)
    92 {
    93     TSQLResult *res = serv.Query(query);
    94     if (!res)
    95         return kFALSE;
    96 
    97     Int_t first = 0;
    98     Int_t cnt   = 0;
    99 
    100     fout << "CalRuns:";
    101     TSQLRow *row=0;
    102     while ((row = res->Next()))
    103         if ((*row)[1][0]=='4')
    104         {
    105             fout << " " << (*row)[0];
    106             cnt++;
    107 
    108             if (!first)
    109             {
    110                 t[0].SetSqlDateTime((*row)[2]);
    111                 first = 1;
    112             }
    113             t[1].SetSqlDateTime((*row)[3]);
    114         }
    115     fout << endl;
    116 
    117     delete res;
    118 
    119     if (cnt==0)
    120     {
    121         cout << "ERROR - No calibration runs belonging to this sequence found." << endl;
    122         return kFALSE;
    123     }
    124 
    125     return kTRUE;
    126 }
    127 
    128 Bool_t GetPedRuns(MSQLServer &serv, ofstream &fout, TString query, MTime *t)
    129 {
    130     Int_t cnt = 0;
    131 
    132     fout << "PedRuns:";
    133 
    134     Int_t tot = 0;
    135 
    136     while (tot<1000)
    137     {
    138         TSQLResult *res = serv.Query(query);
    139         if (!res)
    140             return kFALSE;
    141 
    142         Int_t idx = 0;
    143         Int_t n = 0;
    144         Double_t diff = 1e35;
    145         MTime start, stop;
    146 
    147         TSQLRow *row=0;
    148         while ((row=res->Next()))
    149         {
    150             if ((*row)[1][0]=='3' || (cnt>1 && idx==0 && (*row)[1][0]=='2'))
    151             {
    152                 MTime t0, t1;
    153                 t0.SetSqlDateTime((*row)[2]);
    154                 t1.SetSqlDateTime((*row)[3]);
    155 
    156                 if ((Double_t)t[0]-(Double_t)t1<diff && t[0]>t1)
    157                 {
    158                     diff = (Double_t)t[0]-(Double_t)t1;
    159                     idx = atoi((*row)[0]);
    160                     n = atoi((*row)[4]);
    161                     start = t0;
    162                     stop = t1;
    163                 }
    164                 if ((Double_t)t0-(Double_t)t[1]<diff && t0>t[1])
    165                 {
    166                     diff = (Double_t)t0-(Double_t)t[1];
    167                     idx = atoi((*row)[0]);
    168                     n = atoi((*row)[4]);
    169                     start = t0;
    170                     stop = t1;
    171                 }
    172             }
    173         }
    174 
    175         tot += n;
    176         if (idx!=0)
    177             fout << " " << idx;
    178         cnt ++;
    179 
    180         delete res;
    181 
    182         if (start<t[0])
    183             t[0] = start;
    184         if (stop>t[1])
    185             t[1] = stop;
    186     }
    187 
    188     fout << endl;
    189 
    190     if (cnt==0)
    191     {
    192         cout << "ERROR - No pedestal (data) runs belonging to this sequence found." << endl;
    193         return kFALSE;
    194     }
    195 
    196     return kTRUE;
    197 }
    198 
    199 Bool_t GetDatRuns(MSQLServer &serv, ofstream &fout, TString query)
    200 {
    201     TSQLResult *res = serv.Query(query);
    202     if (!res)
    203         return kFALSE;
    204 
    205     Int_t cnt=0;
    206 
    207     fout << "DatRuns:";
    208     TSQLRow *row=0;
    209     while ((row = res->Next()))
    210         if ((*row)[1][0]=='2')
    211         {
    212             fout << " " << (*row)[0];
    213             cnt++;
    214         }
    215     fout << endl;
    216 
    217     delete res;
    218 
    219     if (cnt==0)
    220     {
    221         cout << "ERROR - No data runs belonging to this sequence found." << endl;
     84        cout << "ERROR - No " << name << " belonging to this sequence found." << endl;
    22285        return kFALSE;
    22386    }
     
    297160    TString query(Form("SELECT fRunNumber, fRunTypeKEY, fRunStart, fRunStop, fNumEvents"
    298161                       " FROM RunData WHERE fSequenceFirst=%s AND fExcludedFDAKEY=1"
    299                        " ORDER BY fRunNumber",
     162                       " AND fRunTypeKEY %%s ORDER BY fRunNumber",
    300163                       data[0]));
    301164
     165
     166    TString queryA(Form(query.Data(), "BETWEEN 2 AND 4"));
     167    TString queryC(Form(query.Data(), "BETWEEN 4 AND 4"));
     168    TString queryD(Form(query.Data(), "BETWEEN 2 AND 2"));
     169    TString queryP(Form(query.Data(), "BETWEEN 3 AND 3"));
     170
    302171    //write runs into sequence file
    303     if (!GetAllRuns(serv, fout, query))
    304         return kFALSE;
    305 
    306     fout << endl;
    307 
    308     MTime t[2];
    309     if (!GetCalRuns(serv, fout, query, t))
    310         return kFALSE;
    311     if (!GetPedRuns(serv, fout, query, t))
    312         return kFALSE;
    313     if (!GetDatRuns(serv, fout, query))
     172    if (!GetRuns(serv, fout, queryA, "Runs"))
     173        return kFALSE;
     174
     175    fout << endl;
     176
     177    if (!GetRuns(serv, fout, queryC, "CalRuns"))
     178        return kFALSE;
     179    if (!GetRuns(serv, fout, queryP, "PedRuns"))
     180        return kFALSE;
     181    if (!GetRuns(serv, fout, queryD, "DatRuns"))
    314182        return kFALSE;
    315183
Note: See TracChangeset for help on using the changeset viewer.