Ignore:
Timestamp:
01/10/06 13:44:29 (19 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.