Changeset 7459


Ignore:
Timestamp:
01/10/06 13:44:29 (19 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7458 r7459  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21  2006/01/10 Daniela Dorner
     22
     23     * datacenter/macros/buildsequenceentries.C, checkfileavail.C,
     24       checkstardone.C, doexclusions.C, fillcalib.C, filldotraw.C,
     25       filldotrbk.C, filldotrun.C, fillganymed.C, fillsignal.C,
     26       fillsinope.C, fillstar.C, findcacofiles.C, getdolist.C,
     27       insertcacofile.C, insertdataset.C, insertdate.C,
     28       insertsequence.C, resetallruns.C, resetcolumn.C, setstatus.C,
     29       setupdb.C, writesequencefile.C:
     30       - updated and added documentation
     31
     32
     33
    2034 2005/12/21 Thomas Bretz
    2135
     
    2842   * mbase/MTime.[h,cc]:
    2943     - added algorithm to calculate week
    30      
     44
    3145
    3246
  • trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C

    r7395 r7459  
    3030//
    3131// to group the runs of one night into sequences, this marco:
    32 // - reads the runinformation of one night from the database
    33 // - group the runs into sets of following runs with the same conditions
    34 // - groups the runs in this sets to sequences such that each run belongs
    35 //   to the nearest (in time) calibration run
    36 // - check if the runs with the same runtype have the same calibration script
    37 //   and the same trigger tables
     32//  - reads the runinformation of one night from the database
     33//  - group the runs into sets of following runs with the same conditions
     34//  - groups the runs in this sets to sequences such that each run belongs
     35//    to the nearest (in time) calibration run
     36//  - check if the runs with the same runtype have the same calibration script
     37//    and the same trigger tables
     38//  if sequence is okay:
     39//  - check if in the range of the runnumbers of this sequence other sequences
     40//    exist in the database
     41//  if there are no sequences, insert the new sequence, else:
     42//  - delete overlaping sequences
     43//  if there's only one sequence in the same runnumber range:
     44//  - check if the new and the old sequence are identical
     45//    if they are identical, do nothing, if not, delete the old sequence and
     46//    insert the new one
     47//
     48// remark: deleting sequences includes the following steps:
     49// - delete entries from the tables Sequences, SequenceProcessStatus,
     50//   Calibration and Star
     51// - updating the sequence number (fSequenceFirst) in the table RunData
     52// - remove the Sequence File, the calibrated data and the image files from
     53//   the disk
     54//
     55// the macro can be executed either for all nights or for one single night
     56// .x buildsequenceentries.C+( "datapath", "sequpath", Bool_t dummy=kTRUE)
     57// .x buildsequenceentries.C+( "night", "datapath", "sequpath")
     58//
     59// the Bool_t dummy:
     60//  kTRUE:  dummy-mode, i.e. nothing is inserted into the database, but the
     61//          commands, that would be executed are returned
     62//  kFALSE: the information is inserted into the database and the files of
     63//          removed sequences is deleted
     64// be careful with this option - for tests use always kTRUE
     65//
     66// TString datapath, TString sequpath:
     67//  datapath: path, where the processed data is stored in the datacenter
     68//  sequpath: path, where the sequence files are stored in the datacenter
     69// the datapath (standard: /magic/data/) and the sequencepath (standard:
     70// /magic/sequences) have to be given, that the sequence file, the
     71// calibrated data and the star files can be removed, when an old sequence
     72// has to be removed from the database
     73//
     74// If nothing failes 1 is returned. In the case of an error 0 is returned.
     75// This is needed for the scripts that execute the macro.
    3876//
    3977/////////////////////////////////////////////////////////////////////////////
     
    63101Bool_t DeleteSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t sequ, Bool_t dummy)
    64102{
     103    //queries to delete information from the database
    65104    TString query1(Form("DELETE FROM Calibration WHERE fSequenceFirst=%d", sequ));
    66105    TString query2(Form("DELETE FROM Star WHERE fSequenceFirst=%d", sequ));
     
    69108    TString query5(Form("DELETE FROM Sequences WHERE fSequenceFirst=%d AND fManuallyChangedKEY=1", sequ));
    70109
     110    //commands to delete files from the disk
    71111    TString fname(Form("%s/%04d/sequence%08d.txt", sequpath.Data(),sequ/10000, sequ));
    72112    TString command(Form("rm -r %s/callisto/%04d/%08d/", datapath.Data(), sequ/10000, sequ));
     
    148188}
    149189
     190
     191//check values, that can be different for different runtypes
    150192Bool_t CheckRuns(MSQLServer &serv, Int_t from, Int_t to, Int_t type)
    151193{
     
    497539}
    498540
     541//
     542// Handling new sequence (checking runs; checking for old sequence; inserting sequence, if everything is okay)
     543//
    499544Bool_t NewSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, TList &sequlist, Bool_t dummy)
    500545{
     
    564609}
    565610
     611//
     612// Build Sequences in range of runs
     613//
    566614Bool_t Process(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to,  TList &sequlist, Bool_t dummy)
    567615{
     
    735783
    736784
     785//
     786// Build Sequences for the night given by TString day
     787//
    737788int buildsequenceentries(TString day, TString datapath, TString sequpath, Bool_t dummy=kTRUE)
    738789{
     
    757808                            day.Data(), day.Data()));
    758809
     810    //get all values from the database, that are relevant for building sequences
    759811    TString query(Form("SELECT fRunNumber, fSourceKEY, fProjectKEY, fHvSettingsKEY,  fLightConditionsKEY, fDiscriminatorThresholdTableKEY, fTriggerDelayTableKEY FROM RunData WHERE %s AND fExcludedFDAKEY=1 order by fRunNumber", cond.Data()));
    760812
     
    763815        return 0;
    764816
     817    //build blocks of runs, which have the same values
     818    //for each block the first and the last run are stored in a TExMap
     819    //the values are checked with the help of an array of TStrings
    765820    TString keys[6]= { "NULL", "NULL", "NULL", "NULL", "NULL", "NULL" };
    766821    TString stop     = "NULL";
     
    795850
    796851            keys[i-1]=value;
    797             //hier einfuellen
     852            //fill values into TExMap
    798853            blocks.Add((ULong_t)blocks.GetSize(), (Long_t)runbegin, (Long_t)runend);
    799854            runstart=(*row)[0];
     
    806861    }
    807862
    808     //und hier einfuellen (letzter wert)
     863    //fill values into TExMap (last value)
    809864    runbegin=atoi(runstart.Data());
    810865    runend=atoi(runstop.Data());
     
    812867
    813868
     869    //get list of current sequence of this night from the database and store it in sequlist
    814870    TList sequlist;
    815871    query=Form("SELECT fSequenceFirst FROM Sequences WHERE fManuallyChangedKEY=1 AND %s order by fSequenceFirst",
    816872               cond.Data());
    817 
    818873//    cout << "Q: " << query << endl;
    819874
     
    833888    Bool_t rc = kTRUE;
    834889
     890    //build sequences in each block of runs
    835891    Long_t key, val;
    836892    TExMapIter nblocks(&blocks);
     
    846902    }
    847903
     904    //newly build or remaining sequences are removed from sequlist while building sequences
     905    //delete sequences that remained in the list
     906    //this is necessary if e.g. all runs of one old sequence have been excluded in the meantime
    848907    TIter Next(&sequlist);
    849908    TObject *obj = 0;
     
    858917}
    859918
    860 
     919//
     920// Build Sequences for all Nights
     921//
    861922int buildsequenceentries(TString datapath, TString sequpath, Bool_t dummy=kTRUE)
    862923{
     
    870931    }
    871932
     933    //get all dates from the database
    872934    TString query="SELECT fDate FROM SequenceBuildStatus";
    873935
     
    876938        return 0;
    877939
     940    //execute buildsequenceentries for all dates
    878941    TString date;
    879942    TSQLRow *row=0;
  • trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C

    r7457 r7459  
    2828// ================
    2929//
     30// check the availability of the files of one sequence:
     31// the script filesondisk has inserted the information (which files are on
     32// disk into the database) and with this macro this information is checked
     33// for the runs of one sequence
     34//
     35// executing the macro:
     36//  .x checkfileavail.C+("sequencefile")
     37// the sequencefile (including path) has to be given, as the macro retrieves
     38// from there the runnumbers
     39//
     40// the macro returns 0, if a file is missing, and 1 if all files are there
     41// the return value is checked by the script, that executes the macro
     42//
     43// this macro is very similar to the macro checkstardone.C
     44//
    3045/////////////////////////////////////////////////////////////////////////////
    3146
     
    4358
    4459
     60//check the value of a column for a run
     61//if a file is not available, the column contains nothing (NULL) - this value is returned
    4562TString GetStatus(MSQLServer &serv, TEnv &rc, TString primary, TString table, TString column)
    4663{
     
    89106    TEnv rc("steps.rc");
    90107
     108    //reading runnumbers from Sequencefile
    91109    TEnv sequ(sequencefile);
    92 
     110    cout << "sequ file: " << sequencefile.Data() << endl;
    93111    TString runs;
    94112    runs = sequ.GetValue("Runs", "");
     
    100118    }
    101119
    102     cout << "sequ file: " << sequencefile.Data() << endl;
     120    //getting runnumbers from database
     121    //(not neccessary anymore -> can be changed)
    103122    TString query(Form("SELECT fRunNumber FROM RunData WHERE fRunNumber in (%s)",
    104123                       runs.Data()));
     
    108127        cout << "Error - no run to check" << endl;
    109128
     129    //check for each run the availability of files from the table RunProcessStatus
     130    //the following columns have to be checked:
     131    //fCCFileAvail, fCaCoFileAvail, fCaCoFileFound, fRawFileAvail, fTimingCorrection
     132    //fTimingCorrection has to be checked, as only rawfiles with correct timing should be calibrated
    110133    TSQLRow *row=0;
    111134    while ((row = res->Next()))
     
    113136        TString runno=(*row)[0];
    114137        cout << "run#: " << runno << endl;
     138        //if one value returns "" (i.e. column is NULL), 0 is returned
    115139        if (GetStatus(serv, rc, runno, "RunProcessStatus", "fCCFileAvail")==""
    116140            || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileAvail")==""
     
    121145            return 0;
    122146    }
     147    //if all values are okay (i.e. files are availabel), 1 is returned
    123148    return 1;
    124149
  • trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C

    r7112 r7459  
    2828// ===============
    2929//
     30// check the availability of the star files for one sequence:
     31// if star has been executed successfully, this information has been inserted
     32// into the database (SequenceProcessStatus) with this macro this information
     33// is checked
     34//
     35// executing the macro:
     36//  .x checkstardone.C+("sequencenumber")
     37//
     38// the macro returns 0, if for the sequence star is not done, and 1 if star
     39// has been done
     40// the return value is checked by the script, that executes the macro
     41//
     42// this macro is very similar to the macro checkfileavail.C
     43//
    3044/////////////////////////////////////////////////////////////////////////////
    3145
     
    4357
    4458
     59//check the value of a column for a sequence
    4560TString GetStatus(MSQLServer &serv, TEnv &rc, TString primary, TString table, TString column)
    4661{
     
    5570    if (!res)
    5671    {
    57         cout << "Error - no run to check" << endl;
     72        cout << "Error - no sequence to check" << endl;
    5873        return "";
    5974    }
     
    8499    TEnv rc("steps.rc");
    85100
     101    //check if fStar not NULL for sequence
    86102    if (GetStatus(serv, rc, datasetno, "SequenceProcessStatus", "fStar")=="")
    87103        return 0;
  • trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C

    r7112 r7459  
    2929// ==============
    3030//
     31// this macro sets the ExcludedFDA flag for runs, that can be excluded
     32// automatically
     33// the information which runs have to be excluded is retrieved from the
     34// resource file automatic-exclusions.rc
     35//
     36// the macro can be executed either for a night or for a range of runnumbers
     37// or for all nights
     38// .x doexclusions.C+("night")
     39// .x doexclusions.C+(startrun,stoprun)
     40// .x doexclusions.C+
     41//
     42// resource file: automatic-exclustions.rc
     43// for each exclusion-reason there is one block of 6 lines in this file:
     44// example for one exclusion-reason:
     45//  #NumEventsSmaller10:                   (name of exclusion)
     46//  key15.Column: fNumEvents               (name of the affected column)
     47//  #key15.Join1:                          (name of column that has to
     48//  #key15.Join2:                                             be joined)
     49//  key15.Cond: fNumEvents between 2 and 9 (condition that fulfils exclusion)
     50//  #key15.SpecialRunCond:                 (special condition, if exclusion
     51//                                          is needed only for certain runs)
     52// if a value is not needed for an exclusion (like the joins and the special
     53// condition in this example), the line is commented out
     54//
    3155/////////////////////////////////////////////////////////////////////////////
    3256#include <iostream>
     
    4367using namespace std;
    4468
     69//get minimum or maximum runnumber of the runs of a night
    4570int GetRunNumber(MSQLServer &serv, TString date, TString value)
    4671{
     
    75100}
    76101
     102//get part of a query (left join of tables)
    77103TString GetJoin(TString table)
    78104{
     
    99125    cout << "Connected to " << serv.GetName() << endl;
    100126
     127    //if neither start- nor stoprun is given, the minimum and maximum runnumber
     128    // is queried from the database to do the exclusions for all runs
     129    // if a night is given for all runs of this night
    101130    if (startrun==0 && stoprun==0)
    102131    {
     
    104133        stoprun=GetRunNumber(serv, date, "max");
    105134    }
     135    //check format of start- and stoprun
    106136    if (startrun<0 || stoprun<0)
    107137    {
     
    112142        return 1;
    113143
     144    //get the condition for the runnumber range
    114145    TString runcond(Form("AND fRunNumber BETWEEN %d AND %d ", startrun, stoprun));
    115146
     147    //get exclusions-reasons (stored in the table ExcludedFDA) from the database
     148    //the exclusions which can be done automatically are marked with the flag fExcludedFDAAutomatic='yes'
     149    //and with an importance (one run may be excluded for several reasons,
     150    //the reason is chosen according to the importance)
    116151    TString query="SELECT fExcludedFDAKEY from ExcludedFDA where fExcludedFDAAutomatic='yes'";
    117152    TSQLResult *res = serv.Query(query);
     
    122157    }
    123158
     159    //update the exclusion-reasons for all runs
    124160    TSQLRow *row=0;
    125161    while ((row = res->Next()))
    126162    {
     163        //read in values from the resource file automatic-exclusions (explanation see above)
    127164        TString key=(*row)[0];
    128165        TString column=rc.GetValue("key"+key+".Column", "");
     
    131168        TString border=rc.GetValue("key"+key+".SpecialRunCond", "");
    132169
     170        //get importance of exclusion-reason from database
    133171        TString query(Form("SELECT fExcludedFDAImportance from ExcludedFDA where fExcludedFDAKEY=%s ", key.Data()));
    134172        TSQLResult *res = serv.Query(query);
     
    143181        delete res;
    144182
     183        //get current importance from database
     184        //for the runs which match the exclusion-reason
    145185        query="SELECT fRunNumber, fExcludedFDAImportance ";
    146186        if (!column.IsNull())
     
    173213        }
    174214
     215        //compare new and old importance
     216        //change or keep the exclusion-reason accordingly
    175217        while ((row2 = res->Next()))
    176218        {
    177219            if (TString((*row2)[1]).IsNull() || atoi((*row2)[1])>newimp)
    178220            {
     221                //change exclusion-reason
    179222                TString query(Form("UPDATE RunData SET fExcludedFDAKEY=%s WHERE fRunNumber=%s",
    180223                                   key.Data(), (*row2)[0]));
     
    189232                continue;
    190233            }
     234            //keep exclusion-reason
    191235            cout << "run#: " << (*row2)[0] << " reason for exclusion is still the same" << endl;
    192236        }
     
    197241}
    198242
     243//run doexclusions for one night
    199244int doexclusions(TString date="NULL")
    200245{
  • trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C

    r7363 r7459  
    3434// From this file the MBadPixelsCam and the MGeomCam is extracted. If
    3535// the geometry isn't found MGeomCamMagic is used as a default.
     36// The bad pixel information and other information, extracted from the status
     37// display, is inserted into the database in the table Calibration, which
     38// stores the results from the calibration.
     39// The corresponding sequence number is extracted from the filename...
     40// FIXME: MSeqeuence should be stored in the calib-file?
    3641//
    3742// Usage:
    38 //   .x fillcalib.C("/data/MAGIC/Period014/calib00000.root", kTRUE)
     43//  .x fillcalib.C("/magic/data/callisto/0004/00047421/calib00047421.root", kTRUE)
    3944//
    4045// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
    4146// switched on and nothing will be written into the database. This is usefull
    4247// for tests.
    43 //
    44 // The corresponding sequence number is extracted from the filename...
    45 // FIXME: MSeqeuence should be stored in the calib-file?
    4648//
    4749// The macro can also be run without ACLiC but this is a lot slower...
     
    106108int Process(MSQLServer &serv, TString fname, Bool_t dummy)
    107109{
     110    //getting number of unsuitable, unreliable and isolated pixel
    108111    MBadPixelsCam badpix;
    109112
     
    234237    cout << "  Mean Conv outer:   " << meanconvouter << endl;
    235238
     239    //inserting or updating the information in the database
    236240    TString query;
    237241    if (!ExistStr(serv, "fSequenceFirst", "Calibration", seq))
  • trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C

    r7325 r7459  
    7272using namespace std;
    7373
     74//get key for a magic number
    7475Int_t MagicNumber(MSQLServer &serv, const MRawRunHeader &h)
    7576{
     
    137138    MRawRunHeader h;
    138139
     140    //read header either from root or from raw file
    139141    if (fname.EndsWith(".root"))
    140142        ReadRoot(fname, &h);
     
    148150    }
    149151
     152    //get key for the magic number
    150153    const Int_t key = MagicNumber(serv, h);
    151154    if (key<0)
     
    204207    cout << endl;
    205208
     209    //get date for the run to build path of the file
    206210    TString query(Form("SELECT DATE_FORMAT(ADDDATE(fRunStart, Interval 13 HOUR), '%%Y/%%m/%%d') FROM RunData WHERE fRunNumber=%d",
    207211                       runno));
     
    239243    }
    240244
     245    //check if there's only one file with this runno
    241246    if (count!=1)
    242247    {
  • trunk/MagicSoft/Mars/datacenter/macros/filldotrbk.C

    r7112 r7459  
    3232//
    3333// Usage:
    34 //   .x filldotrbk.C("/data/MAGIC/Period014", kTRUE)
    35 //
    36 // While the first argument is the directory in which all subdirectories where
    37 // searches for CC_*.rbk files. All these files were analysed and the runbook
     34//   .x filldotrbk.C("/magic/subsystemdata/cc/", kTRUE)
     35//
     36// The first argument is the directory in which all subdirectories are
     37// searched for CC_*.rbk files. All these files are analysed and the runbook
    3838// entries will be put into the DB, eg:
    39 //   "/data/MAGIC"                              would do it for all data
    40 //   "/data/MAGIC/Period019/ccdata"             would do it for one Period
    41 //   "/data/MAGIC/Period019/ccdata/2004_05_17"  would do it for a single day
    42 //   "/data/MAGIC/Period019/ccdata/file.rbk"    would do it for a single file
     39//  "/magic/subsystemdata/cc"                  would do it for all data
     40//  "/magic/subsystemdata/cc/2005"                  for one year
     41//  "/magic/subsystemdata/cc/2005/11"               for one month
     42//  "/magic/subsystemdata/cc/2005/11/11"            for a single day
     43//  "/magic/subsystemdata/cc/2005/11/11/file.rbk"   for a single file
    4344//
    4445// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     
    4647// for tests.
    4748//
    48 // Before an antry is added its existance is checked... if it is added already
    49 // it is ignored.
     49// Before an entry is added, its existance is checked... if it is already
     50// in the database, it is ignored.
    5051//
    5152// The macro can also be run without ACLiC but this is a lot slower...
     
    9697        }
    9798    }
    98 
    9999    delete res;
    100 
    101100    return rc;
    102101}
     
    105104{
    106105
     106    //check if entry is already in database
    107107    if (ExistStr(serv, "fRunBookDate", "RunBook", date))
    108108        return 0;
     
    116116            entry.Remove(i--);
    117117
     118    //insert entry into the database
    118119    TString query("INSERT RunBook (fRunBookDate, fRunBookText) VALUES (\"");
    119120    query += date;
     
    178179        }
    179180*/
     181
     182        //skip run statistics from old runbooks
    180183        if (entry.Contains("MAGIC ELECTRONIC RUNBOOK")   ||
    181184            entry.Contains("DATA RUN STATISTICS")        ||
     
    220223    cout << endl;
    221224
     225    //get all runbook files in path
    222226    if (path.EndsWith(".rbk"))
    223227        return process(serv, dummy, path);
    224228
     229    //fill entries for each runbook file
    225230    MDirIter Next(path, "CC_*.rbk", -1);
    226231    while (1)
  • trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C

    r7394 r7459  
    4646// searches for CC_*.run files. All these files were analysed and the run
    4747// info will be put into the DB, eg:
    48 //   "/data/MAGIC"                              would do it for all data
    49 //   "/data/MAGIC/Period019/ccdata"             would do it for one Period
    50 //   "/data/MAGIC/Period019/ccdata/2004_05_17"  would do it for a single day
    51 //   "/data/MAGIC/Period019/ccdata/file.run"    would do it for a single file
     48//  "/magic/subsystemdata/cc"                  would do it for all data
     49//  "/magic/subsystemdata/cc/2005"                  for one year
     50//  "/magic/subsystemdata/cc/2005/11"               for one month
     51//  "/magic/subsystemdata/cc/2005/11/11"            for a single day
     52//  "/magic/subsystemdata/cc/2005/11/11/file.run"   for a single file
    5253//
    5354// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     
    104105}
    105106
     107//get key for the value
     108// if value is not existing, insert value and get key
    106109Int_t QueryNameKEY(MSQLServer &serv, Bool_t dummy, const char *col, const char *name, Bool_t insert=kTRUE)
    107110{
     
    125128        return -1;
    126129
     130    //insert new value
    127131    query = Form("INSERT %s (f%sName) VALUES (\"%s\");", col, col, name);
    128132
  • trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C

    r7333 r7459  
    3030// This macro is used to read the ganymed-output files.
    3131// These files are automatically called ganymed00000.root.
     32// From MAlphaFitter and the Status Display the results from ganymed are
     33// extracted an inserted into the database, where they are stored in the table
     34// Ganymed.
     35// The dataset number is extracted from the filename.
     36//
     37// Usage:
     38//  .x fillganymed.C("/magic/data/ganymed/0000/0001/ganmymed0001.root", kTRUE)
     39//
     40// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     41// switched on and nothing will be written into the database. This is usefull
     42// for tests.
     43//
     44// Remark: Running it from the commandline looks like this:
     45//   root -q -l -b fillganymed.C+\(\"filename\"\,kFALSE\) 2>&1 | tee file.log
    3246//
    3347// Make sure, that database and password are corretly set in a resource
     
    96110    }
    97111
     112    //get excess, signal, background events and the scale factor from MAlphaFitter
    98113    MAlphaFitter *fit;
    99114    file.GetObject("MAlphaFitter", fit);
     
    113128    TString scale = Form("%5.2f", f);
    114129
     130    //get effective ontime from the status display
    115131    MStatusArray arr;
    116132    if (arr.Read()<=0)
     
    130146    Int_t tm = (Int_t)vstime->Integral();
    131147
     148    //get dataset number from filename
    132149    TString dataset = fname(TRegexp("ganymed[0-9]+[.]root$"));
    133150    if (dataset.IsNull())
     
    135152        cout << "WARNING - Could get dataset# from filename: " << fname << endl;
    136153        return 0;
    137     }
    138154
    139155    Int_t ds = atoi(dataset.Data()+8);
     
    152168
    153169
     170    //build query, insert information into the DB
     171    //if entry is already existing: update query
     172    //else: insert query
    154173    TString query;
    155174    if (!ExistStr(serv, "fDataSetNumber", "Ganymed", ds))
     
    212231    cout << endl;
    213232
     233    //process file
    214234    return Process(serv, fname, dummy);
    215235}
  • trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C

    r7428 r7459  
    3232// signal00000.root.
    3333//
    34 // From this file the Mean PedRms for the inner and outer camera is extracted.
     34// From this file the mean pedrms, the mean signal and the pulse position
     35// for the inner and outer camera is extracted and inserted into the database
     36// in the table Calibration, where the results of callisto are stored.
     37// The sequence number is extracted from the filename.
    3538//
    3639// Usage:
    37 //   .x fillsignal.C("/data/MAGIC/Period014/signal00000.root", kTRUE)
     40//   .x fillsignal.C("/magic/data/callisto/0004/00047421/signal00047421.root", kTRUE)
    3841//
    3942// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     
    171174    rmspul  = TMath::Nint(rmspul*100)/100.;
    172175
     176    //get sequence number from the filename
    173177    TString sequence = fname(TRegexp("signal[0-9]+[.]root$"));
    174178    if (sequence.IsNull())
     
    205209    cout << "  Rms  extracted  PulsePos " << rmsextpulpos    << endl;
    206210
     211    //build query and insert information into the database
     212    // here only a update query is built, as this macro is exexuted after
     213    // the macro fillcalib.C in the script fillcallisto
     214    // and so the table Calibration is always updated
    207215    TString query = Form("UPDATE Calibration SET "
    208216                         " fMeanPedRmsInner=%s,   fMeanPedRmsOuter=%s, "
     
    248256    cout << endl;
    249257
     258    //process file
    250259    return Process(serv, fname, dummy);
    251260}
  • trunk/MagicSoft/Mars/datacenter/macros/fillsinope.C

    r7265 r7459  
    3030//
    3131// This macro is used to read the sinope output files sinope*.txt
     32// For each run sinope is run twice: once for the data events and once for the
     33// calibration events. The pulse position and height is checked. The output is
     34// stored in a sinope*.root and a sinope*.txt file. The files for data events
     35// are marked with -dat and the ones for calibration events with -cal.
     36// From the txt files the result is extracted and inserted into the database
     37// in the table DataCheck, which stores the datacheck results.
     38// As the column names in the database differ only by the addition 'Interlaced'
     39// which is given to columns corresponding to the calibration events, the
     40// files can be processed with the same function.
    3241//
    3342// Usage:
     
    8796    TEnv env(fname);
    8897
     98    //build query
    8999    TString query="UPDATE DataCheck SET ";
    90100
     101    //array with part of column names
    91102    TString values[9] = { "Events" , "HasSignal" , "HasPedestal" , "PositionSignal" , "PositionFWHM" , "PositionAsym" , "HeightSignal" , "HeightFWHM" , "HeightAsym" };
    92103
     104    //get values from the file add them to query
    93105    TString str;
    94106    for (Int_t i=0 ; i<9 ; i++)
     
    118130
    119131    cout << "Q: " << query << endl;
     132    //insert information into db
    120133    TSQLResult *res = serv.Query(query);
    121134    if (!res)
     
    146159    cout << endl;
    147160
     161    //get date of run from database
    148162    TString query(Form("SELECT DATE_FORMAT(ADDDATE(fRunStart, Interval 13 HOUR), '%%Y/%%m/%%d') FROM RunData WHERE fRunNumber=%d",
    149163                       runno));
     
    162176    delete res;
    163177
     178    //insert entry for the run into the database in the table DataCheck, if it is not yet existing
    164179    if (!ExistStr(serv, "fRunNumber", "DataCheck", Form("%d", runno)))
    165180    {
    166181        query=Form("INSERT DataCheck SET fRunNumber=%d", runno);
    167182
    168         cout << "U:" << query << endl;
    169183        res = serv.Query(query);
    170184        if (!res)
     
    175189    }
    176190
     191    //get filenames of sinope output files
    177192    TString fname(Form("%s/sinope/%s/sinope-dat%08d.txt",
    178193                       datapath.Data(), date.Data(), runno));
     
    183198
    184199    Int_t rc=0;
     200    //process dat-file
    185201    rc=Process(serv, fname, runno, kFALSE, dummy);
    186202    if (rc==0)
    187203        return rc;
    188204
     205    //process cal-file
    189206    rc=Process(serv, fnamecal, runno, kTRUE, dummy);
    190207    return rc;
  • trunk/MagicSoft/Mars/datacenter/macros/fillstar.C

    r7405 r7459  
    3030//
    3131// This macro is used to read the star-output files.
    32 // These files are automatically called star00000.root.
     32// These files are automatically called star00000000.root.
     33// From these files the muon parameters (psf, muon number, ratio, muon rate),
     34// the  rate, the number of islands, the effective ontime, the maximum
     35// humidity and a parameter describing the inhomogeneity are extracted from
     36// the status display.
     37// The sequence number is extracted from the filename.
     38//
     39// Usage:
     40//   .x fillstar.C("/magic/data/star/0004/00047421/star00047421.root", kTRUE)
     41//
     42// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     43// switched on and nothing will be written into the database. This is usefull
     44// for tests.
     45//
     46// The macro can also be run without ACLiC but this is a lot slower...
     47//
     48// Remark: Running it from the commandline looks like this:
     49//   root -q -l -b fillstar.C+\(\"filename\"\,kFALSE\) 2>&1 | tee fillstar.log
    3350//
    3451// Make sure, that database and password are corretly set in a resource
  • trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C

    r7232 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // FindCaCoFiles.C
     27// findcacofiles.C
    2828// ===============
     29//
     30// Macro to get from the database the number of the runs, for which no caco
     31// file is available.
     32//
     33// Sometimes the DAQ aborts a run and starts itself a new one. In this cases
     34// there's the camera controll doesn't start a new file, as the command to
     35// start a new run was not sent by the central control. So the caco
     36// information is stored in the previous caco file, which has a different
     37// runnumber. To be able to merpp the information into the calibrated data
     38// file, the runnumber of the file containing the information has to be found.
     39// This is done by a script.
     40// findcacofiles.C produces the input for this script. It queries from the
     41// database, for which runs no caco file with the same runnumber is available
     42// and writes the runnumbers into an txt file.
     43//
     44// Usage:
     45//   .x findcacofiles.C+("date", "logpath")
     46// date and logpath are needed only for the output file
     47//
     48// Make sure, that database and password are corretly set in a resource
     49// file called sql.rc and the resource file is found.
     50//
     51// Returns 0 in case of failure and 1 in case of success.
    2952//
    3053/////////////////////////////////////////////////////////////////////////////
     
    6083    cout << endl;
    6184
     85    //get runnumbers from database
    6286    TString query="SELECT RunProcessStatus.fRunNumber FROM RunProcessStatus ";
    6387    query+=" LEFT JOIN RunData on RunData.fRunNumber=RunProcessStatus.fRunNumber ";
     
    7296    }
    7397
     98    //create output file
    7499    TString filename(Form("%s/findcacofiles-%s.txt", logpath.Data(), date.Data()));
    75100    ofstream fout(filename, ios::app);
     
    80105    }
    81106
     107    //write runnumbers into output file
    82108    TSQLRow *row=0;
    83109    while ((row = res->Next()))
  • trunk/MagicSoft/Mars/datacenter/macros/getdolist.C

    r7324 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // GetDoList.C
     27// getdolist.C
    2828// ===========
     29//
     30// This macro is a key part of the automation concept.
     31// It queries from the database, for which dates/runs/sequences/datasets a
     32// certain step has to be done and writes the todo-files.
     33//
     34// Usage:
     35//  .x getdolist.C+("table", "column", "date", "listpath")
     36// The first and second argument give the table and column in the database
     37// and specify like this the primary (date/run/sequenc/dataset) and the
     38// step.
     39// The third argument specifies the date, for which the macro has to be
     40// executed. This is currently not used in the automatic analysis. It was
     41// forseen to give the possibility to process the data night by night. By
     42// giving date='NULL' the macro is executed for all dates.
     43// The forth argument gives the path, where teh todo-file is stored.
     44//
     45// The macro needs apart from sql.rc the resource file steps.rc
     46// In this files the interdependencies of the analysis steps are given: To
     47// execute a certain step other steps have to be executed first and each
     48// step also influences othere steps - this information is stored in steps.rc
     49//   example:
     50// To execute the calibration, all files have to be available on disk (needs).
     51// And if the calibration is done, fillcallisto and star can be executed
     52// (influences).
     53//
     54// Make sure, that database and password are corretly set in a resource
     55// file called sql.rc and the resource file is found.
     56//
     57// Returns 0 in case of failure and 1 in case of success.
    2958//
    3059/////////////////////////////////////////////////////////////////////////////
     
    6493    TEnv rc("steps.rc");
    6594
     95    //read in needs
    6696    TString needs  = rc.GetValue(table+"."+column+".Needs", "");
    6797    cout << "Needs: " << needs  << endl;
    6898
    6999    TList l;
    70 
    71100    while (!needs.IsNull())
    72101    {
     
    82111    }
    83112
     113    //build query
     114    // this forms a query like e.g.
     115    //SELECT SequenceProcessStatus.fSequenceFirst FROM SequenceProcessStatus
     116    // WHERE ISNULL(fCallisto)
     117    // AND NOT ISNULL(fAllFilesAvail) AND NOT ISNULL(fSequenceFileWritten)
     118    //which would query all sequences for which Callisto has to be done.
    84119    TString query(Form("SELECT %s.%s FROM %s",
    85120                       table.Data(), rc.GetValue(table+".Primary", ""),
    86121                       table.Data()));
    87122
     123    //get joins
     124    //if a date is given, the tables, which contain the information about the
     125    // date (given in step.rc as TimerTable), have to be joined
    88126    if (date!="NULL" && rc.GetValue(table+".TimerTable", "")!="")
    89127        query+=Form(" left join %s on %s.%s=%s.%s ",
     
    99137        query+=Form(" AND NOT ISNULL(%s)", o->GetName());
    100138
     139    //if a date is given another condition is added to the query
    101140    if (date!="NULL")
    102141    {
     
    111150    }
    112151
     152    //to process the newest data first, the results are ordered descending by the primary
    113153    query+=Form(" ORDER BY %s.%s DESC ", table.Data(), rc.GetValue(table+".Primary", ""));
    114154
     155    //this part of the query is needed, if there are more than 512 results and single
     156    //todo files are written, as shell scripts have a limitation for arrays
     157    // this is currently only the case, if runs are processed, i.e. for the table RunProcessStatus
    115158    if (table=="RunProcessStatus")
    116159        query+="LIMIT 0, 500";
     
    126169
    127170
     171    //write todo-file
     172    //depending on the kind of step and primary, this looks different
     173    //for steps, which do not take much time and can thus be executed
     174    // for all data at once (e.g. buildsequenceentries) only one todo
     175    // file is written
     176    //for steps, which take quite long for one primary (e.g. calibration)
     177    // or of which a large number has to be executed (e.g. datacheck)
     178    // one todo-file per primary is written
    128179    TString filename;
    129180    TSQLRow *row=0;
     
    137188        {
    138189            filename=Form("%s/ToDo-%s-%s-%s.txt", listpath.Data(), table.Data(), column.Data(), (*row)[0]);
     190            //remove file, if it is already existing
     191            // this is needed, that the same step is not executed several times
    139192            gSystem->Unlink(filename);
    140193            ofstream fout(filename, ios::app);
  • trunk/MagicSoft/Mars/datacenter/macros/insertcacofile.C

    r7112 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // InsertCaCoFiles.C
     27// insertcacofiles.C
    2828// =================
     29//
     30// Macro to insert runnumber of the caco files, which contain the information
     31// for a run, for which no caco file is available.
     32//
     33// Sometimes the DAQ aborts a run and starts itself a new one. In this cases
     34// there's the camera controll doesn't start a new file, as the command to
     35// start a new run was not sent by the central control. So the caco
     36// information is stored in the previous caco file, which has a different
     37// runnumber. To be able to merpp the information into the calibrated data
     38// file, the runnumber of the file containing the information has to be found.
     39// This is done by a script.
     40// insertcacofiles.C inserts the runnumber of the file, that has been found,
     41// into the column CaCoFileFound.
     42//
     43// Usage:
     44//   .x insertcacofile.C+("runnumber", "newrunnumber")
     45// The first is the runnumber of which the cacofile is missing, the second is
     46// the runnumber of the file in which the information probably can be found.
     47//
     48// Make sure, that database and password are corretly set in a resource
     49// file called sql.rc and the resource file is found.
     50//
     51// Returns 0 in case of failure and 1 in case of success.
    2952//
    3053/////////////////////////////////////////////////////////////////////////////
     
    4265
    4366using namespace std;
    44 
    4567
    4668int insertcacofile(TString runnumber, TString newrunnumber)
     
    6082    cout << endl;
    6183
     84    //get new runnumber
    6285    Int_t newrunno=atoi(newrunnumber.Data());
     86    //build query and insert information
    6387    TString query(Form("UPDATE RunProcessStatus SET fCaCoFileAvail=Now(), fCaCoFileFound=%d WHERE fRunNumber=%s ",
    6488                       newrunno, runnumber.Data()));
  • trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C

    r7336 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // InsertDataset.C
     27// insertdataset.C
    2828// ===============
     29//
     30// This macro inserts datasets into the database.
     31// If a new dataset file has been stored in the dataset directory, the
     32// information file is read by a script and the information is inserted with
     33// this macro into the database in the tables DataSets and
     34// DataSetProcessStatus, where in the information about datasets is stored.
     35//
     36// Usage:
     37//   .x insertdataset.C+("number","source,"wobble","comment",kTRUE)
     38// The first argument is the dataset number, the second is giving the source
     39// name, the third the observation mode (wobble/on-off), the fourth a comment
     40// about the dataset. This arguments are extracted by a script from the
     41// dataset file.
     42// The last argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     43// switched on and nothing will be written into the database. This is usefull
     44// for tests.
     45//
     46// Make sure, that database and password are corretly set in a resource
     47// file called sql.rc and the resource file is found.
     48//
     49// Returns 0 in case of failure and 1 in case of success.
    2950//
    3051/////////////////////////////////////////////////////////////////////////////
     
    5980}
    6081
     82//get key of a name
     83// insert value, if it is not yet existing
    6184Int_t QueryNameKEY(MSQLServer &serv, Bool_t dummy, const char *col, const char *name, Bool_t insert=kTRUE)
    6285{
     
    121144    cout << endl;
    122145
     146    //get source key
    123147    Int_t sourcekey = QueryNameKEY(serv, dummy, "Source", source.Data(), kFALSE);
    124148    if (sourcekey<0)
     
    131155    cout << "no:" << number << endl;
    132156
     157    //if dataset is not yet in database, insert the information
    133158    if (!ExistStr(serv, "fDataSetNumber", "DataSets", number.Data())) // Form("%d", number)
    134159    {
     
    151176        delete res;
    152177
    153 
     178        //add also entry in the table DataSetProcessStatus
    154179        query=Form("INSERT DataSetProcessStatus SET fDataSetNumber='%s', "
    155180                   " fDataSetInserted=Now() ",
  • trunk/MagicSoft/Mars/datacenter/macros/insertdate.C

    r7112 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // InsertDate.C
     27// insertdate.C
    2828// ============
     29//
     30// This macro is inserting a date into the table SequenceBuildStatus.
     31// It is executed by the script copyscript, which copies the slow control
     32// data to the appropriate directory and inserts the information into the
     33// database.
     34//
     35// Usage:
     36//  .x insertdate.C+("date")
     37//
     38// Make sure, that database and password are corretly set in a resource
     39// file called sql.rc and the resource file is found.
     40//
     41// Returns 0 in case of failure and 1 in case of success.
    2942//
    3043/////////////////////////////////////////////////////////////////////////////
     
    7992    cout << endl;
    8093
     94    //insert entry for date into the table SequenceBuildStatus,
     95    // if entry is not yet existing
    8196    if (!ExistStr(serv, "fDate", "SequenceBuildStatus", date))
    8297    {
  • trunk/MagicSoft/Mars/datacenter/macros/insertsequence.C

    r7400 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // InsertSequence.C
     27// insertsequence.C
    2828// ================
     29//
     30// This macro inserts a sequence into the database. It extracts the
     31// information from a sequence file.
     32// This macro is not used by the automatic analysis. It is needed to insert
     33// manually built sequences into the database.
     34//
     35// Usage:
     36//  .x insertsequence.C+("filename", kTRUE)
     37// The first argument is the filename of the manual written sequencefile.
     38// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     39// switched on and nothing will be written into the database. This is usefull
     40// for tests.
     41//
     42// Make sure, that database and password are corretly set in a resource
     43// file called sql.rc and the resource file is found.
     44//
     45// Returns 0 in case of failure and 1 in case of success.
    2946//
    3047/////////////////////////////////////////////////////////////////////////////
     
    125142    cout << endl;
    126143
     144    //get sequence number from file
    127145    TString sequnum;
    128146    sequnum=sequ.GetValue("Sequence", "");
    129147    Int_t seq=atoi(sequnum.Data());
    130148
     149    //get runs from sequence file
    131150    TString runs;
    132151    runs = sequ.GetValue("Runs", "");
     
    138157    }
    139158
     159    //get source key
    140160    TString sourcename = sequ.GetValue("Source", "");
    141161    Int_t sourcekey = QueryNameKEY(serv, dummy, "Source", sourcename.Data());
    142162
     163    //get values for the sequence
    143164    TString query="SELECT max(fRunNumber), min(fRunStart), ";
    144165    query +="sum(time_to_sec(fRunStop)-time_to_sec(fRunStart)), ";
     
    218239    cout << "  l2tt      " << l2tt      << endl;
    219240
     241    //build queries
    220242    TString query1="INSERT Sequences SET fManuallyChangedKEY=2, ";
    221243    query1 +=Form("fSequenceFirst=%d, fSequenceLast=%s, "
     
    232254                  l1tt.Data(), l2tt.Data());
    233255
     256    //the time of the column fSequenceFileWritten is set to 'not to be done'
    234257    TString query2=Form("INSERT SequenceProcessStatus SET "
    235258                        "fSequenceFirst=%d, fSequenceFileWritten='1970-01-01 00:00:00'",
  • trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C

    r7274 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // ResetAllRuns.C
     27// resetallruns.C
    2828// ==============
     29//
     30// This macro resets the values of a column in the table RunProcessStatus. It
     31// is used by the script filesondisk to reset the values for the columns,
     32// which indicate the availability of the files.
     33//
     34// Usage:
     35//   .x resetallrun.C+("filename", "column")
     36// The first argument is giving a file, in which a list of runs can be found
     37// for which the column will be set to Now() by this macro. The second
     38// argument is giving the column, which has to be reset.
     39//
     40// Make sure, that database and password are corretly set in a resource
     41// file called sql.rc and the resource file is found.
     42//
     43// Returns 0 in case of failure and 1 in case of success.
    2944//
    3045/////////////////////////////////////////////////////////////////////////////
     
    5974    cout << endl;
    6075
     76    //reset column to NULL
    6177    TString query(Form("UPDATE RunProcessStatus SET %s=NULL",
    6278                       column.Data()));
     79    //if the column is fCaCoFileAvail, reset also the column fCaCoFileFound
    6380    if (column.Contains("CaCo"))
    6481        query+=", fCaCoFileFound=NULL";
    65 
    6682
    6783    cout << "q: " << query << endl;
     
    7692
    7793
     94    //read in file
    7895    ifstream fin(filename);
    7996    if (!fin)
     
    8299        return 0;
    83100    }
    84 
    85101    while (1)
    86102    {
     103        //get runnumber
    87104        TString runnumber;
    88105        runnumber.ReadLine(fin);
     
    90107            break;
    91108
     109        //build query and set status for this run to Now()
    92110        TString query(Form("UPDATE RunProcessStatus SET %s=Now()", column.Data()));
    93111
  • trunk/MagicSoft/Mars/datacenter/macros/resetcolumn.C

    r7232 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // ResetColumn.C
     27// resetcolumn.C
    2828// =============
    2929//
     
    3434//
    3535// As arguments you have to give the column, the table and from which
    36 // to which Date/Sequence/Run you want to reset the value.
     36// to which Date/Sequence/Run/Dataset you want to reset the value.
    3737//
    3838// The last argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
     
    4040// for tests (i.e. if you want to see if the query is correct).
    4141//
    42 // usage:
     42// Usage:
    4343//   .x resetcolumn.C("fStar","SequenceProcessStatus","45114","49329",kTRUE)
     44//
     45// Make sure, that database and password are corretly set in a resource
     46// file called sql.rc and the resource file is found.
     47//
     48// Returns 0 in case of failure and 1 in case of success.
    4449//
    4550/////////////////////////////////////////////////////////////////////////////
     
    7782
    7883    TEnv rc("steps.rc");
     84    //get steps which are influenced by the step, which is resetted
    7985    TString influences  = rc.GetValue(table+"."+column+".Influences", "");
    8086
     
    97103    }
    98104
     105    //build query and reset columns
    99106    TString query(Form("Update %s SET %s=NULL ", table.Data(), column.Data()));
    100107
     
    112119    }
    113120
    114 
    115121    TSQLResult *res = serv.Query(query);
    116122    if (!res)
  • trunk/MagicSoft/Mars/datacenter/macros/setstatus.C

    r7112 r7459  
    2525/////////////////////////////////////////////////////////////////////////////
    2626//
    27 // SetStatus.C
     27// setstatus.C
    2828// ===========
     29//
     30// This macro is a key part of the automation concept.
     31// It sets the status for dates/runs/sequences/datasets in the database, if a
     32// certain step has been done.
     33//
     34// Usage:
     35//   .x setstatus.C+("primary","table","column","value",kTRUE)
     36// The first argument is the primary (date/run/sequence/dataset), the second
     37// and third argument give the table and column of the step. The fourth
     38// column is giving the value, to which the column has to be set. The last
     39// argument is indicating if the columns of all influenced steps shall be
     40// reset to NULL. The default is kTRUE, which means, that the columns are
     41// reset.
     42//
     43// Make sure, that database and password are corretly set in a resource
     44// file called sql.rc and the resource file is found.
     45//
     46// Returns 0 in case of failure and 1 in case of success.
    2947//
    3048/////////////////////////////////////////////////////////////////////////////
     
    5371    }
    5472
     73    //some columns can't be reseted, this is given in steps.rc
    5574    TString reset=rc.GetValue(table+"."+column+".Reset", "no");
    5675    if (reset.Contains("no"))
     
    6685TString CheckDefault(MSQLServer &serv, TEnv &rc, TString primary, TString table, TString influence)
    6786{
     87    //check if the value in the database is the default
    6888    TString query(Form("SELECT %s FROM %s WHERE %s=%s",
    6989                       influence.Data(), table.Data(),
     
    97117    cout << "set influenes for " << table << "." << column << endl;
    98118
     119    //build query and set step and influences for the step
    99120    TString influences  = rc.GetValue(table+"."+column+".Influences", "");
    100121
     
    115136        TString deflt  = rc.GetValue(influence+".Default", "");
    116137
     138        //for some columns there may be a different default
     139        // in the file steps.rc they are marked with Default: check
     140        // in this case, the value in the database has to be checked
    117141        if (deflt=="check")
    118142            deflt=CheckDefault(serv, rc, primary, table, influence);
    119 
     143        //if it is the default value (1970-01-01 00:00:00), nothing is inserted into the database
    120144        if (deflt=="yes")
    121145            continue;
     
    125149
    126150    query+=Form(" WHERE %s='%s'", rc.GetValue(table+".Primary", ""), primary.Data());
    127 
    128 //    cout << "query: " << query << endl;
    129151
    130152    TSQLResult *res = serv.Query(query);
     
    153175    TEnv rc("steps.rc");
    154176
     177    //if reset is needed and/or can be done, set new values
    155178    return !CheckReset(rc, table, column, value) ? 0 : SetInfluences(serv, rc, primary, table, column, value, resetall);
    156179
  • trunk/MagicSoft/Mars/datacenter/macros/setupdb.C

    r7427 r7459  
     1// This macro is a macro to create the Magic Database.
     2// It is kept up to date, if any changes in the database are made.
     3
    14#include <iomanip.h>
    25/*
  • trunk/MagicSoft/Mars/datacenter/macros/writesequencefile.C

    r7259 r7459  
    2929// ===================
    3030//
    31 // reads the sequence information from the database
    32 // and writes it into a txt file
     31// reads the sequence information from the database and writes it into a
     32// txt file
     33//
     34// Usage:
     35//  .x writesequencefile.C+(sequno,"sequpath")
     36//
     37// Make sure, that database and password are corretly set in a resource
     38// file called sql.rc and the resource file is found.
     39//
     40// Returns 0 in case of failure and 1 in case of success.
    3341//
    3442/////////////////////////////////////////////////////////////////////////////
     
    257265        return kFALSE;
    258266
     267    //create sequence file
    259268    TString fname(Form("%s/%04d/sequence%08d.txt", sequpath.Data(), atoi(data[0])/10000, atoi(data[0])));
    260269    cout << "Creating " << fname << "..." << flush;
     
    267276    }
    268277
     278    //write information into file
    269279    fout << "Sequence:        " << data[0]  << endl;
    270280    fout << "Period:          " << period   << endl;
     
    289299                       data[0]));
    290300
     301    //write runs into sequence file
    291302    if (!GetAllRuns(serv, fout, query))
    292303        return kFALSE;
     
    327338    cout << endl;
    328339
     340    //get sequence information from database
    329341    TString query(Form("SELECT fSequenceFirst, fSequenceLast, fProjectKEY, fSourceKEY,"
    330342                       " fL1TriggerTableKEY, fL2TriggerTableKEY, fHvSettingsKEY, "
Note: See TracChangeset for help on using the changeset viewer.