Ignore:
Timestamp:
10/14/06 19:16:21 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/datacenter
Files:
3 edited

Legend:

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

    r8010 r8065  
    259259    TList fListRegexp;
    260260
    261     /*
    262     TString GetKeyName(TString col, TString key)
    263     {
    264         col(TRegexp("^Elt")) = "";
    265         return QueryNameOfKey(col, key, kFALSE);
    266     }*/
    267 
    268261    Int_t CheckTransition(TSQLResult &res, const TString *keys, TSQLRow &row, Int_t i)
    269262    {
     
    330323        delete res;
    331324
     325        const TString elts = GetELTSource(where);
     326        if (elts.IsNull())
     327            return kFALSE;
     328
     329        const TString eltp = GetELTProject(where);
     330        if (eltp.IsNull())
     331            return kFALSE;
     332
    332333        // ========== Request data of sequence ==========
    333         query = Form("SELECT fSourceKEY, fProjectKEY, "
    334                      " fL1TriggerTableKEY, fL2TriggerTableKEY,"
    335                      " fHvSettingsKEY, fDiscriminatorThresholdTableKEY,"
    336                      " fTriggerDelayTableKEY, fObservationModeKEY "
    337                      " FROM RunData WHERE fRunTypeKEY=2 AND %s"
    338                      " LIMIT 1", where.Data());
     334        query  = "SELECT ";
     335        query += elts;
     336        query += ", ";
     337        query += eltp;
     338        query += ", fL1TriggerTableKEY, fL2TriggerTableKEY,"
     339            " fHvSettingsKEY, fDiscriminatorThresholdTableKEY,"
     340            " fTriggerDelayTableKEY, fObservationModeKEY "
     341            " FROM RunData WHERE fRunTypeKEY=2 AND ";
     342        query += where;
     343        query += " LIMIT 1";
    339344
    340345        res = Query(query);
     
    692697    }
    693698
     699    TString GetELTQuery(const char *col, const char *cond) const
     700    {
     701        return Form("SELECT RunData.f%sKEY, f%sName FROM RunData "
     702                    "LEFT JOIN %s ON RunData.f%sKEY=%s.f%sKEY "
     703                    "WHERE %s GROUP BY f%sName",
     704                    col, col, col, col, col, col, cond, col);
     705    }
     706
     707    TString GetELTSource(const char *cond)
     708    {
     709        //query all sources observed in this night
     710        TSQLResult *resx = Query(GetELTQuery("Source", cond));
     711        if (!resx)
     712            return "";
     713
     714        // In the case there is only a single source
     715        // do not replace the source key by the ELT
     716        if (resx->GetRowCount()==1)
     717            return "fSourceKEY";
     718
     719        TString elts = GetELT("Source", resx, "\\-?W[1-9][ abc]?$");
     720        delete resx;
     721
     722        return elts;
     723    }
     724
     725    TString GetELTProject(const char *cond)
     726    {
     727        //query all project names observed in this night
     728        TSQLResult *resx = Query(GetELTQuery("Project", cond));
     729        if (!resx)
     730            return "";
     731
     732        // In the case there is only a single project
     733        // do not replace the project key by the ELT
     734        if (resx->GetRowCount()==1)
     735            return "fProjectKEY";
     736
     737        TList regexp;
     738        regexp.Add(new TObjString("\\-?W[1-9][abc]?$"));
     739        regexp.Add(new TObjString("\\-W[0-9]\\.[0-9][0-9]\\+[0-9][0-9][0-9]$"));
     740
     741        TString eltp2 = GetELT("Project", resx, regexp);
     742        delete resx;
     743        regexp.Delete();
     744
     745        return eltp2;
     746    }
     747
    694748    Bool_t HasAtLeastOne(TString src, TString chk) const
    695749    {
     
    10421096        fMap.DeleteAll();
    10431097    }
    1044     /*
    1045      SequenceBuild(SequenceBuild &sb) : MSQLServer(sb)
    1046      {
    1047         fPathRawData = sb.fPathRawData;
    1048         fPathSequences = sb.fPathSequences;
    1049     }*/
     1098
    10501099    void SetPathRawData(const char *path) { fPathRawData=path; }
    10511100    void SetPathSequences(const char *path) { fPathSequences=path; }
     
    10591108        const TString cond =
    10601109            Form("(fRunStart>ADDDATE(\"%s\", INTERVAL -1 DAY) AND fRunStart<\"%s\") "
    1061                  "AND fExcludedFDAKEY=1 AND fRunTypeKEY BETWEEN 2 AND 4 "
    1062                  "ORDER BY fRunNumber",
     1110                 "AND fExcludedFDAKEY=1 AND fRunTypeKEY BETWEEN 2 AND 4 ",
    10631111                 day.Data(), day.Data());
    10641112
    1065 
    1066 
    10671113        //query all sources observed in this night
    1068         TString querys(Form("SELECT RunData.fSourceKEY, fSourceName FROM RunData "
    1069                             "LEFT JOIN Source ON RunData.fSourceKEY=Source.fSourceKEY "
    1070                             "WHERE %s", cond.Data()));
    1071         TSQLResult *resx = Query(querys);
    1072         if (!resx)
    1073             return 2;
    1074         TString elts = GetELT("Source", resx, "\\-?W[1-9][ abc]?$");
    1075         delete resx;
     1114        const TString elts = GetELTSource(cond);
     1115        if (elts.IsNull())
     1116            return 2;
    10761117
    10771118        //query all project names observed in this night
    1078         TString queryp(Form("SELECT RunData.fProjectKEY, fProjectName FROM RunData "
    1079                             "LEFT JOIN Project ON RunData.fProjectKEY=Project.fProjectKEY "
    1080                             "WHERE %s", cond.Data()));
    1081         resx = Query(queryp);
    1082         if (!resx)
    1083             return 2;
    1084 
    1085         TList regexp;
    1086         regexp.Add(new TObjString("\\-?W[1-9][abc]?$"));
    1087         regexp.Add(new TObjString("\\-W[0-9]\\.[0-9][0-9]\\+[0-9][0-9][0-9]$"));
    1088         TString eltp2 = GetELT("Project", resx, regexp);
    1089         delete resx;
    1090         regexp.Delete();
     1119        const TString eltp2 = GetELTProject(cond);
     1120        if (elts.IsNull())
     1121            return 2;
    10911122
    10921123        // Setup query to get all values from the database,
     
    11061137                query += mapkey->GetName();
    11071138            }
    1108         query += Form(" FROM RunData WHERE %s", cond.Data());
     1139        query += Form(" FROM RunData WHERE %s ORDER BY fRunNumber", cond.Data());
    11091140
    11101141        TSQLResult *res = Query(query);
  • trunk/MagicSoft/Mars/datacenter/scripts/dbchk

    r8057 r8065  
    66# directory where the sequence files are stored
    77sequencedir=/magic/sequences
     8callistodir=/magic/data/callisto
     9stardir=/magic/data/star
    810# access to the sql database
    911alias mymysql='mysql -s -u MAGIC -h hercules --password=d99swMT!'
     
    1719# Cross check sequences in Sequence and other databases
    1820# added switch which allows to correct for the problems immediatly
     21# unify the checks (especially 1b and 1c)
     22# for the sequences better use 0* instead of 0+ ?
    1923
    2024
    2125# CHECK 1
    22 echo Checking if all sequences in Sequences have a corresponding sequence files
     26echo Checking if all sequence files have a corresponding entry in Sequences
    2327files=`find $sequencedir -type f`
    2428for file in $files
     
    2731   if [ "$sequence" = "" ]
    2832   then
    29       echo No sequence file: $sequence
     33      echo No sequence file: $file
    3034      continue
    3135   fi
     
    3438   if ! [ "$sequence" = "$var" ]
    3539   then
    36       echo Sequence-File $sequence exist but it is not in the db.
     40      echo Sequence-File $sequence exist but it is not in Sequences.
     41      continue
     42   fi
     43done
     44
     45# CHECK 1b (callisto)
     46echo Checking if all sequences in $callistodir have a corresponding sequence in Sequence
     47dirs=`find $callistodir -type d`
     48for dir in $dirs
     49do
     50   sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
     51   if [ "$sequence" = "" ]
     52   then
     53      echo Invalid directory: $dir
     54      continue
     55   fi
     56
     57   var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
     58   if ! [ "$sequence" = "$var" ]
     59   then
     60      echo $dir exists but no corresponding sequence in Sequences.
     61      continue
     62   fi
     63done
     64
     65# CHECK 1c (star)
     66echo Checking if all sequences in $stardir have a corresponding sequence in Sequence
     67dirs=`find $stardir -type d`
     68for dir in $dirs
     69do
     70   sequence=`echo $file | sed -e "s/^.*\/0\+\([0-9]\+\)$/\1/"`
     71   if [ "$sequence" = "" ]
     72   then
     73      echo Invalid directory: $dir
     74      continue
     75   fi
     76
     77   var=`echo SELECT fSequenceFirst FROM $db.Sequences WHERE fSequenceFirst=$sequence | mymysql`
     78   if ! [ "$sequence" = "$var" ]
     79   then
     80      echo $dir exists but no corresponding sequence in Sequences.
    3781      continue
    3882   fi
     
    4084
    4185# CHECK 2
    42 echo Checking if all sequence files have a corresponding entry in Sequences
     86echo Checking if all sequences in Sequences have a corresponding sequence files
    4387sequences=`echo SELECT fSequenceFirst FROM $db.Sequences | mymysql`
    4488for sequence in $sequences
    4589do
    46    var=`find $sequencedir -regex .*/sequence0+${sequence}\.txt$`
     90   var=`find $sequencedir -type f -regex .*/sequence0+${sequence}\.txt$`
    4791   if [ "$var" = "" ]
    4892   then
  • trunk/MagicSoft/Mars/datacenter/scripts/sourcefile

    r7994 r8065  
    114114
    115115
    116 # alias
    117 alias 'intgrep'='grep -E ^\\\(int\\\)[0-9]+$ | sed -e s\/\(int\)\/\/'
     116# alias (we cannot check the beginning of the line due to
     117# color codes in filldotraw.C)
     118alias 'intgrep'='grep -E -o \\\(int\\\)[0-9]+$'
    118119
    119120# in the following the functions, which are needed by several scripts, are
Note: See TracChangeset for help on using the changeset viewer.