Ignore:
Timestamp:
12/10/07 17:45:36 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mjobs/MDataSet.cc

    r8744 r8780  
    3131//  Such an input file looks like:
    3232//
    33 //     crab.seq:
     33//     crab.txt:
    3434//     ---------
    3535//       AnalysisNumber: 1
     
    3737//       Name: SecondCrab
    3838//
    39 //       SequencesOn: 35222 35229
     39//       SequencesOn:  35222 35229
    4040//       SequencesOff: 36817
    4141//
     
    4949//       Sequence00036817.Dir: /data2/wuerzburg/Crab-Analyse/images/036817
    5050//
     51//       Sequence00036817.Exclude: 36818 36819
     52//
    5153//       WobbleMode: No
    5254//       MonteCarlo: No
     
    5557//       Catalog: /magic/datacenter/setup/magic_favorites_dc.edb
    5658//
     59//
     60// Reading the file is based on TEnv. For more details see also
     61// the class reference of TEnv.
     62//
     63//
    5764// AnalysisNumber: The analysis number is an artifical number used to name
    58 // the output files automatically if the names are not overwritten in the
    59 // corresponding programs.
     65//  the output files automatically if the names are not overwritten in the
     66//  corresponding programs.
    6067//
    6168// SequencePath: In case it is not specified the datacenter default path is
    62 // used. If it is given it is the place at which the sequence files
    63 // are searched, if not overwritten by either a program command line
    64 // option (aka. a argument to the constructor) or a resource for
    65 // an individual sequence file. Note, that the four digits high-level
    66 // directories to sort the sequences are added to the given path.
     69//  used. If it is given it is the place at which the sequence files
     70//  are searched, if not overwritten by either a program command line
     71//  option (aka. a argument to the constructor) or a resource for
     72//  an individual sequence file. Note, that the four digits high-level
     73//  directories to sort the sequences are added to the given path.
    6774//
    6875// DataPath: In case it is not specified the datacenter default path is
    69 // used. If it is given it is the place at which the data files
    70 // are searched, if not overwritten by either a program command line
    71 // option (aka. a argument to the constructor) or a resource for
    72 // an individual data path.  Note, that the four digits high-level
    73 // directories to sort the sequences are added to the given path.
     76//  used. If it is given it is the place at which the data files
     77//  are searched, if not overwritten by either a program command line
     78//  option (aka. a argument to the constructor) or a resource for
     79//  an individual data path.  Note, that the four digits high-level
     80//  directories to sort the sequences are added to the given path.
    7481//
    7582// SequencesOn/Off: The sequence number are used to concatenate the filenames
    76 // of the sequences using the file structure used in the datacenter. Each
    77 // sequence can be added to the on and off data at the same time but only
    78 // once.
    79 //
    80 // If you have different file names you can overwrite the default file names
    81 // using Sequence%08d.File (make sure you have 8 digits!)
    82 //
    83 // In standard coditions (datacenter file system) paths are concatenated
    84 // by using the information in the sequence files (date, etc). You can
    85 // overwrite the directories in which the sequence-files (eg I-files) are
    86 // stored using Sequence%08d.Dir (make sure you have 8 digits!)
     83//  of the sequences using the file structure used in the datacenter. Each
     84//  sequence can be added to the on and off data at the same time but only
     85//  once.
     86//
     87//  If you have different file names you can overwrite the default file names
     88//  using Sequence%08d.File (make sure you have 8 digits!)
     89//
     90//  If the file name is given as "-", e.g.
     91//       Sequence00035222.File: -
     92//  the current dataset file is read as sequence file. In this case all
     93//  resources defined for a sequence file should be prefixed by
     94//  "Sequence%08d."; if not prefixed the default without the prefix
     95//  is looked up. Be aware that the "Sequence" resource for sequence-files
     96//  (for more details see MSequence) is ignored and the already defined
     97//  number is used instead and thus should be identical to the sequence
     98//  number - which normally is not necessary.
     99//
     100//  In standard coditions (datacenter file system) paths are concatenated
     101//  by using the information in the sequence files (date, etc). You can
     102//  overwrite the directories in which the sequence-files (eg I-files) are
     103//  stored using Sequence%08d.Dir (make sure you have 8 digits!)
     104//
     105//  Using the resource Sequence%08d.Exclude you can exclude a list of
     106//  runs from a sequence.
    87107//
    88108// WobbleMode: This is just a flag which is passed to the program
    89 // end eveluated (or not) by the individual program, which takes this
    90 // dataset as an input. For example this is necessary in ganymed to do
    91 // some wobble mode special setup. If no resource is given (or it is
    92 // set to "auto") wobble mode if set if the datset contains no off-
    93 // sequences.
     109//  end eveluated (or not) by the individual program, which takes this
     110//  dataset as an input. For example this is necessary in ganymed to do
     111//  some wobble mode special setup. If no resource is given (or it is
     112//  set to "auto") wobble mode if set if the datset contains no off-
     113//  sequences.
    94114//
    95115// MonetCarlo: This is just a flag which is passed to the program
    96 // end eveluated (or not) by the individual program, which takes this
    97 // dataset as an input. For example this tells ganymed to skip some
    98 // parts accessing time stamps which are not available in the MCs.
     116//  end eveluated (or not) by the individual program, which takes this
     117//  dataset as an input. For example this tells ganymed to skip some
     118//  parts accessing time stamps which are not available in the MCs.
    99119//
    100120// SequencePath/DataPath: This determined were the sequences and data-files
    101 // are stored. The priorities are as follows:
    102 //  0) Build in default path:          /magic/sequences   /magic/data/star
    103 //  1) Def.path from dataset file:       SequencePath         DataPath
    104 //  2) Indiv.path from dataset file:  12345.SequencePath   12345.DataPath
    105 //  3) Path from command line:            Argument in the constructors
    106 //  4) Path for an indiv. dataset:         Sequences00022555.File/Dir
     121//  are stored. The priorities are as follows:
     122//   0) Build in default path:          /magic/sequences   /magic/data/star
     123//   1) Def.path from dataset file:       SequencePath         DataPath
     124//   2) Indiv.path from dataset file:  12345.SequencePath   12345.DataPath
     125//   3) Path from command line:            Argument in the constructors
     126//   4) Path for an indiv. dataset:         Sequences00022555.File/Dir
    107127//
    108128// Catalog: This is the xephem-style file from the central control
    109 // containing the observed sky positions.
     129//  containing the observed sky positions.
    110130//
    111131// SourceName: The source name, as defined in the catalog, of the object
    112 // the data corresponds to.
     132//  the data corresponds to.
    113133//
    114134// Name: A name is stored for your convinience
     
    261281    for (int i=0; i<num.GetSize(); i++)
    262282    {
    263         TString name = GetEnvValue2(env, prefix, Form("Sequence%08d.File", num[i]), "");
    264         TString dir  = GetEnvValue2(env, prefix, Form("Sequence%08d.Dir",  num[i]), "");
     283        const TString seqid = Form("Sequence%08d", num[i]);
     284
     285        TString name = GetEnvValue2(env, prefix, Form("%s.File",    seqid.Data()), "");
     286        TString dir  = GetEnvValue2(env, prefix, Form("%s.Dir",     seqid.Data()), "");
     287        TString excl = GetEnvValue2(env, prefix, Form("%s.Exclude", seqid.Data()), "");
    265288
    266289        // Set default sequence file and dir name
     
    270293            dir = Form("%s%04d/%08d", data.Data(), num[i]/10000, num[i]);
    271294
     295        // Check if sequence information is contained in Dataset file
     296        const Bool_t useds = name=="-";
     297
    272298        // FIXME: The sequence number from the sequence file is assigned!!!
    273         MSequence *seq = new MSequence(name, dir);
     299        MSequence *seq = new MSequence(useds?fName:name, dir, num[i]);
     300        seq->ExcludeRuns(excl);
    274301
    275302        if (seq->IsValid() && seq->GetSequence()!=(UInt_t)num[i])
     
    436463
    437464    gLog << "#  " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;
     465}
     466
     467// --------------------------------------------------------------------------
     468//
     469// Helper to print a seqeunce in Print()
     470//
     471void MDataSet::PrintSeq(const MSequence &seq) const
     472{
     473    const Bool_t useds = seq.GetFileName()==fName;
     474
     475    gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".File:   " << (useds?"-":seq.GetFileName()) << endl;
     476    gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir:    " << seq.GetDataPath() << endl;
     477    if (!useds && seq.GetNumExclRuns()>0)
     478        gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
     479
     480    if (useds)
     481    {
     482        gLog << endl;
     483        seq.Print("prefixed");
     484        gLog << endl << "# ---" << endl;
     485    }
    438486}
    439487
     
    478526        gLog << endl;
    479527
     528    // FIXME: If file==fName --> print Sequence0000.content
     529
    480530    TIter NextOn(&fSequencesOn);
    481531    TIter NextOff(&fSequencesOff);
    482532    MSequence *seq=0;
    483533    while ((seq=(MSequence*)NextOn()))
    484     {
    485         gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".File: " << seq->GetFileName() << endl;
    486         gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".Dir:  " << seq->GetDataPath() << endl;
    487     }
     534        PrintSeq(*seq);
    488535    if (fSequencesOff.GetEntries()>0)
    489536        gLog << endl;
    490537    while ((seq=(MSequence*)NextOff()))
    491     {
    492         gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".File: " << seq->GetFileName() << endl;
    493         gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".Dir:  " << seq->GetDataPath() << endl;
    494     }
     538        PrintSeq(*seq);
    495539
    496540    if (TString(o).Contains("files", TString::kIgnoreCase))
  • trunk/MagicSoft/Mars/mjobs/MDataSet.h

    r8724 r8780  
    4646    Bool_t GetWobbleMode(const TEnv &env, const TString &prefix) const;
    4747    static void PrintFile(const MSequence &obj);
     48    void PrintSeq(const MSequence &seq) const;
    4849
    4950    // Directory and file handling
     
    138139    const TList &GetSequencesOff() const { return fSequencesOff; }
    139140
     141    const TArrayI &GetSequencesNumOn() const  { return fNumSequencesOn; }
     142    const TArrayI &GetSequencesNumOff() const { return fNumSequencesOff; }
     143
    140144    Bool_t AddFiles(MRead &read) const;
    141145    Bool_t AddFilesOn(MRead &read) const;
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r8744 r8780  
    1818!   Author(s): Thomas Bretz, 8/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2004
     20!   Copyright: MAGIC Software Development, 2004-2007
    2121!
    2222!
     
    2828//
    2929//  This class describes a sequence. For sequences see:
    30 //    http://magic.astro.uni-wuerzburg.de/mars/db/queryseq.html
     30//    http://db.astro.uni-wuerzburg.de
    3131//
    3232//  A sequence is a collection of runs which should be used together.
    3333//  Any run can be contained only once.
    3434//
    35 //  Here is an example how a file describing a sequence could look like:
     35//  Here is an example how a file describing a sequence could look like.
     36//
     37//  Reading the file is based on TEnv. For more details see also
     38//  the class reference of TEnv.
    3639//
    3740// ===========================================================================
     
    4043//  ------------
    4144//
    42 //   # Sequence number (identifier)
     45//   # Sequence number (identifier) - necessary if the path
     46//   # contains the sequence number, e.g. image files
    4347//   Sequence:     31015
    44 //   # Observation Period (used to get the path-names)
     48//
     49//   # Observation Period (not needed)
    4550//   Period:       18
    46 //   # Date of sunrise of the observation night
     51//
     52//   # Date of sunrise of the observation night - necessary if the path
     53//   # contains the date, e.g. raw data
    4754//   Night:        2004-06-24
    4855//
    49 //   # Start time of the sequence (first data run)
     56//   # Start time of the sequence (first data run, not needed)
    5057//   Start:        2004-06-24 03:12:42
    51 //   # Run number of last data run in sequence
     58//
     59//   # Run number of last data run in sequence (not needed)
    5260//   LastRun:      31032
    53 //   # Project name of data-runs of sequence
     61//
     62//   # Project name of data-runs of sequence (not needed)
    5463//   Project:      3EG2033+41
    55 //   # Source name of all runs of sequence
     64//
     65//   # Source name of all runs of sequence (not needed)
    5666//   Source:       3EG2033+41
    57 //   # Trigger table of data-runs of sequence
     67//
     68//   # Trigger table of data-runs of sequence (not needed)
    5869//   TriggerTable: L1_4NN:L2_DEFAULT
    59 //   # HV Setting table of data-runs of sequence
     70//
     71//   # HV Setting table of data-runs of sequence (not needed)
    6072//   HvSettings:   HVSettings_FF36q
    61 //   # Total number of data-events in sequence
     73//
     74//   # Total number of data-events in sequence (not needed)
    6275//   NumEvents:    250914
    6376//
    64 //   # List of all runs of this sequence
     77//   # Whether this is MC data or not (necessary in case of MCs if
     78//   # default paths should be used)
     79//   MonteCarlo: Yes
     80//
     81//   # List of all runs of this sequence (not needed)
    6582//   Runs: 31015 31016 31017 31018 31019 31020 31021 31022 31023 31024 31025 31026 31027 31028 31029 31030 31031 31032
    6683//
    67 //   # List of all calibration runs of this sequence
     84//   # List of all calibration runs of this sequence (necessary if accessed)
    6885//   CalRuns: 31015 31016 31017
    69 //   # List of pedestal runs belonging to the calibration runs of this sequence
     86//   # List of pedestal runs belonging to the calibration runs of this sequence (necessary if accessed)
    7087//   PedRuns: 31018
    71 //   # List of all data runs belonging to this sequence
     88//   # List of all data runs belonging to this sequence (necessary)
    7289//   DatRuns: 31019 31020 31022 31023 31024 31025 31027 31028 31030 31032
    7390//
    74 //   # List of run types of all runs
    75 //   31015: C
    76 //   31016: C
    77 //   31017: C
    78 //   31018: P
    79 //   31019: D
    80 //   31020: D
    81 //   31021: P
    82 //   31022: D
    83 //   31023: D
    84 //   31024: D
    85 //   31025: D
    86 //   31026: P
    87 //   31027: D
    88 //   31028: D
    89 //   31029: P
    90 //   31030: D
    91 //   31031: P
    92 //   31032: D
     91//   # Just for fun ;-) (not needed, but helpful)
     92//   Comment: This is a template for a sequence file
    9393//
    9494// ===========================================================================
     
    125125//  Class Version 3:
    126126//   + fComment
     127//
     128//  Class Version 4:
     129//   + fExclRuns
    127130//
    128131/////////////////////////////////////////////////////////////////////////////
     
    253256        d += '/';
    254257
     258    Int_t excluded = 0;
    255259    for (int i=0; i<arr.GetSize(); i++)
    256260    {
     261        if (IsExcluded(arr[i]))
     262        {
     263            excluded++;
     264            continue;
     265        }
     266
    257267        // R. DeLosReyes and T. Bretz
    258268        // Changes to read the DAQ numbering format. Changes takes place
     
    325335    }
    326336
     337    // n0: The previous contents of the iter
     338    // n1: The number of files which have been added to the iter
     339    // n2: The number of files which should have been added from the array
    327340    const Int_t n1 = iter.GetNumEntries()-n0;
    328     const Int_t n2 = arr.GetSize();
     341    const Int_t n2 = arr.GetSize()-excluded;
    329342    if (n1==0)
    330343    {
     
    386399//}
    387400
    388 MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env) const
    389 {
    390     TString str = env.GetValue("LightConditions", "n/a");
     401MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env, const char *prefix) const
     402{
     403    TString str = GetEnvValue2(env, prefix, "LightConditions", "n/a");
    391404    if (!str.CompareTo("n/a", TString::kIgnoreCase))
    392405        return kNA;
     
    410423// Read the file fname as setup file for the sequence.
    411424//
    412 MSequence::MSequence(const char *fname, const char *path)
     425MSequence::MSequence(const char *fname, const char *path, UInt_t seq)
    413426{
    414427    fName  = fname;
     
    431444    MEnv env(fName);
    432445
    433     fSequence  = env.GetValue("Sequence", -1);
     446    fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq);
    434447    if (rc1 || rc2)
    435448        fSequence = (UInt_t)-1;
    436449
    437     fLastRun   = env.GetValue("LastRun",   -1);
    438     fNumEvents = env.GetValue("NumEvents", -1);
    439     fPeriod    = env.GetValue("Period",    -1);
    440 
    441     fLightCondition = ReadLightCondition(env);
     450    const TString prefix = Form("Sequence%08d", fSequence);
     451
     452    fLastRun   = GetEnvValue2(env, prefix, "LastRun",   -1);
     453    fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1);
     454    fPeriod    = GetEnvValue2(env, prefix, "Period",    -1);
     455
     456    fLightCondition = ReadLightCondition(env, prefix);
    442457
    443458    TString str;
    444     str = env.GetValue("Start", "");
     459    str = GetEnvValue2(env, prefix, "Start", "");
    445460    fStart.SetSqlDateTime(str);
    446     str = env.GetValue("Night", "");
     461    str = GetEnvValue2(env, prefix, "Night", "");
    447462    str += " 00:00:00";
    448463    fNight.SetSqlDateTime(str);
    449464
    450     fProject      = env.GetValue("Project", "");
    451     fSource       = env.GetValue("Source", "");
    452     fTriggerTable = env.GetValue("TriggerTable", "");
    453     fHvSettings   = env.GetValue("HvSettings", "");
    454     fMonteCarlo   = env.GetValue("MonteCarlo", kFALSE);
    455     fComment      = env.GetValue("Comment",    "");
    456 
    457     str = env.GetValue("Runs", "");
     465    fProject      = GetEnvValue2(env, prefix, "Project", "");
     466    fSource       = GetEnvValue2(env, prefix, "Source", "");
     467    fTriggerTable = GetEnvValue2(env, prefix, "TriggerTable", "");
     468    fHvSettings   = GetEnvValue2(env, prefix, "HvSettings", "");
     469    fMonteCarlo   = GetEnvValue2(env, prefix, "MonteCarlo", kFALSE);
     470    fComment      = GetEnvValue2(env, prefix, "Comment",    "");
     471
     472    str = GetEnvValue2(env, prefix, "Runs", "");
    458473    Split(str, fRuns);
    459     str = env.GetValue("CalRuns", "");
     474    str = GetEnvValue2(env, prefix, "CalRuns", "");
    460475    Split(str, fCalRuns);
    461     str = env.GetValue("PedRuns", "");
     476    str = GetEnvValue2(env, prefix, "PedRuns", "");
    462477    Split(str, fPedRuns);
    463     str = env.GetValue("DatRuns", "");
     478    str = GetEnvValue2(env, prefix, "DatRuns", "");
    464479    Split(str, fDatRuns);
     480    str = GetEnvValue2(env, prefix, "Exclude", "");
     481    Split(str, fExclRuns);
    465482
    466483  //  GetFileNames(env, fRuns);
     
    470487
    471488    // Dummies:
    472     env.GetValue("ZdMin", 0);
    473     env.GetValue("ZdMax", 0);
    474     env.GetValue("L1TriggerTable", 0);
    475     env.GetValue("L2TriggerTable", 0);
    476 
    477     if (env.GetNumUntouched()>0)
    478     {
    479         gLog << warn << "WARNING - At least one resource in the dataset-file has not been touched!" << endl;
     489    env.Touch("ZdMin");
     490    env.Touch("ZdMax");
     491    env.Touch("L1TriggerTable");
     492    env.Touch("L2TriggerTable");
     493
     494    if (seq<0 && env.GetNumUntouched()>0)
     495    {
     496        gLog << warn << "WARNING - At least one resource in the sequence-file has not been touched!" << endl;
    480497        env.PrintUntouched();
    481498    }
     
    492509}
    493510
    494 
    495511// --------------------------------------------------------------------------
    496512//
     
    499515void MSequence::Print(Option_t *o) const
    500516{
     517    const TString pre = TString(o).Contains("prefixed") ? Form("Sequence%08d.", fSequence) : "";
     518
    501519    gLog << all;
    502520    if (!IsValid())
    503521    {
    504         gLog << "Sequence: " << fFileName << " <invalid>" << endl;
     522        gLog << pre << "Sequence: " << fFileName << " <invalid>" << endl;
    505523        return;
    506524    }
     
    508526    gLog << "# Name: " << GetName() << endl;
    509527    gLog << endl;
    510     gLog << "Sequence:       " << fSequence << endl;
     528    if (pre.IsNull())
     529        gLog << "Sequence:       " << fSequence << endl;
    511530    if (fMonteCarlo)
    512         gLog << "MonteCarlo:     Yes" << endl;
    513     gLog << "Period:         " << fPeriod << endl;
    514     gLog << "Night:          " << fNight << endl << endl;
    515     gLog << "LightCondition: ";
     531        gLog << pre << "MonteCarlo:     Yes" << endl;
     532    gLog << pre <<"Period:         " << fPeriod << endl;
     533    gLog << pre << "Night:          " << fNight << endl << endl;
     534    gLog << pre << "LightCondition: ";
    516535    switch (fLightCondition)
    517536    {
     
    522541    case kDay:      gLog << "Day" << endl;     break;
    523542    }
    524     gLog << "Start:          " << fStart << endl;
    525     gLog << "LastRun:        " << fLastRun << endl;
    526     gLog << "NumEvents:      " << fNumEvents << endl;
    527     gLog << "Project:        " << fProject << endl;
    528     gLog << "Source:         " << fSource << endl;
    529     gLog << "TriggerTable:   " << fTriggerTable << endl;
    530     gLog << "HvSettings:     " << fHvSettings << endl << endl;
    531     gLog << "Runs:";
    532     for (int i=0; i<fRuns.GetSize(); i++)
    533         gLog << " " << fRuns[i];
    534     gLog << endl;
    535     gLog << "CalRuns:";
    536     for (int i=0; i<fCalRuns.GetSize(); i++)
    537         gLog << " " << fCalRuns[i];
    538     gLog << endl;
    539     gLog << "PedRuns:";
    540     for (int i=0; i<fPedRuns.GetSize(); i++)
    541         gLog << " " << fPedRuns[i];
    542     gLog << endl;
    543     gLog << "DatRuns:";
    544     for (int i=0; i<fDatRuns.GetSize(); i++)
    545         gLog << " " << fDatRuns[i];
    546     gLog << endl;
    547 
     543    gLog << pre << "Start:          " << fStart << endl;
     544    gLog << pre << "LastRun:        " << fLastRun << endl;
     545    gLog << pre << "NumEvents:      " << fNumEvents << endl;
     546    gLog << pre << "Project:        " << fProject << endl;
     547    gLog << pre << "Source:         " << fSource << endl;
     548    gLog << pre << "TriggerTable:   " << fTriggerTable << endl;
     549    gLog << pre << "HvSettings:     " << fHvSettings << endl << endl;
     550    if (fRuns.GetSize()>0)
     551    {
     552        gLog << pre << "Runs:";
     553        for (int i=0; i<fRuns.GetSize(); i++)
     554            gLog << " " << fRuns[i];
     555        gLog << endl;
     556    }
     557    if (fCalRuns.GetSize()>0)
     558    {
     559        gLog << pre << "CalRuns:";
     560        for (int i=0; i<fCalRuns.GetSize(); i++)
     561            gLog << " " << fCalRuns[i];
     562        gLog << endl;
     563    }
     564    if (fPedRuns.GetSize()>0)
     565    {
     566        gLog << pre << "PedRuns:";
     567        for (int i=0; i<fPedRuns.GetSize(); i++)
     568            gLog << " " << fPedRuns[i];
     569        gLog << endl;
     570    }
     571    if (fDatRuns.GetSize()>0)
     572    {
     573        gLog << pre << "DatRuns:";
     574        for (int i=0; i<fDatRuns.GetSize(); i++)
     575            gLog << " " << fDatRuns[i];
     576        gLog << endl;
     577    }
     578    if (fExclRuns.GetSize()>0)
     579    {
     580        gLog << pre << "Exclude:";
     581        for (int i=0; i<fExclRuns.GetSize(); i++)
     582            gLog << " " << fExclRuns[i];
     583        gLog << endl;
     584    }
    548585    if (!fDataPath.IsNull())
    549         gLog << endl << "DataPath: " << fDataPath << endl;
    550 
    551     gLog << endl << "Comment: " << fComment << endl;
    552 
     586        gLog << endl << pre << "DataPath: " << fDataPath << endl;
     587
     588    gLog << endl << pre << "Comment: " << fComment << endl;
    553589}
    554590
     
    562598// Return the number of files added.
    563599//
     600// Runs which are in fExlRuns are ignored.
     601//
    564602UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
    565603{
     
    576614// Return the number of files added.
    577615//
     616// Runs which are in fExlRuns are ignored.
     617//
    578618UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const
    579619{
     
    590630// Return the number of files added.
    591631//
     632// Runs which are in fExlRuns are ignored.
     633//
    592634UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const
    593635{
     
    604646// Return the number of files added.
    605647//
     648// Runs which are in fExlRuns are ignored.
     649//
    606650UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const
    607651{
     
    618662// Return the number of files added.
    619663//
     664// Runs which are in fExlRuns are ignored.
     665//
    620666UInt_t MSequence::SetupDatRuns(MDirIter &iter, FileType_t type, const char *path) const
    621667{
     
    653699        fRuns[nall+i] = first+i;
    654700        if (runs)
    655             (*runs)[nrun+i]  = first+i;
     701            (*runs)[nrun+i] = first+i;
    656702    }
    657703    return add;
     704}
     705
     706Bool_t MSequence::IsContained(const TArrayI &arr, UInt_t run) const
     707{
     708    for (int i=0; i<arr.GetSize(); i++)
     709        if (run==(UInt_t)arr[i])
     710            return kTRUE;
     711    return kFALSE;
     712}
     713
     714/*
     715// --------------------------------------------------------------------------
     716//
     717// Check if num is found in arr. If it is found remove it. Copy all
     718// following entries one back and decrease the array size by 1.
     719//
     720void MSequence::ExcludeRun(TArrayI &arr, UInt_t num)
     721{
     722    UInt_t *ptr = (UInt_t*)arr.GetArray();
     723
     724    Int_t i = 0;
     725    for (i=0; i<arr.GetSize(); i++)
     726        if (ptr[i]==num)
     727            break;
     728
     729    if (i==arr.GetSize())
     730        return;
     731
     732    for (; i<arr.GetSize()-1; i++)
     733        ptr[i] = ptr[i+1];
     734
     735    arr.Set(arr.GetSize()-1);
     736}
     737*/
     738
     739// --------------------------------------------------------------------------
     740//
     741// Exclude this run (i.e. add it to fExclRuns)
     742//
     743void MSequence::ExcludeRun(UInt_t num)
     744{
     745    /*
     746     ExcludeRun(fRuns,    num);
     747     ExcludeRun(fCalRuns, num);
     748     ExcludeRun(fPedRuns, num);
     749     ExcludeRun(fDatRuns, num);
     750     */
     751
     752    if (IsExcluded(num))
     753        return;
     754
     755    // set new entry
     756    const Int_t n = fExclRuns.GetSize();
     757    fExclRuns.Set(n+1);
     758    fExclRuns[n] = num;
     759
     760    MJob::SortArray(fExclRuns);
     761}
     762
     763// --------------------------------------------------------------------------
     764//
     765// Exclude all runs which are found in the list, e.g. "100 102 105"
     766//
     767void MSequence::ExcludeRuns(TString runs)
     768{
     769    TArrayI data;
     770    Split(runs, data);
     771
     772    for (int i=0; i<data.GetSize(); i++)
     773        ExcludeRun(data[i]);
     774}
     775
     776const TString MSequence::GetExcludedRuns() const
     777{
     778    TString rc;
     779    for (int i=0; i<fExclRuns.GetSize(); i++)
     780    {
     781        rc += fExclRuns[i];
     782        rc += " ";
     783    }
     784    return rc(0, rc.Length()-1);
    658785}
    659786
     
    698825    return kFALSE;
    699826}
     827
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r8695 r8780  
    5252    TArrayI fDatRuns;
    5353
     54    TArrayI fExclRuns;
     55
    5456    Bool_t fMonteCarlo;
    5557
     
    5860    void Split(TString &runs, TArrayI &data) const;
    5961    //void GetFileNames(TEnv &env, const TArrayI &arr);
    60     LightCondition_t ReadLightCondition(TEnv &env) const;
     62
     63    LightCondition_t ReadLightCondition(TEnv &env, const char *prefix) const;
    6164
    6265    const char *GetFileName(UInt_t num);
     
    6568    UInt_t SetupRuns(MDirIter &iter, const TArrayI &arr, FileType_t type, const char *path=0) const;
    6669    UInt_t AddRuns(UInt_t first, UInt_t last, TArrayI *runs);
     70    void   ExcludeRun(TArrayI &arr, UInt_t num);
     71    Bool_t IsContained(const TArrayI &arr, UInt_t num) const;
    6772
    6873public:
    6974    MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
    7075        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE) { }
    71     MSequence(const char *fname, const char *path="");
     76    MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
    7277    MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart),
    7378        fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod),
     
    8893    Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
    8994    Bool_t IsMonteCarlo() const { return fMonteCarlo; }
     95    Bool_t IsExcluded(UInt_t run) const { return IsContained(fExclRuns, run); }
     96    Bool_t IsContained(UInt_t run) const { return IsContained(fCalRuns, run) || IsContained(fPedRuns, run) || IsContained(fDatRuns, run); }
    9097
    9198    void SetMonteCarlo(Bool_t ismc=kTRUE) { fMonteCarlo=ismc; }
     
    102109    UInt_t SetupCalRuns(MDirIter &iter, FileType_t type, const char *path=0);
    103110   */
     111
    104112    // Getter
    105     UInt_t GetNumAllRuns() const { return fRuns.GetSize(); }
    106     UInt_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
    107     UInt_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
    108     UInt_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
     113//    UInt_t GetNumAllRuns() const { return fRuns.GetSize(); }
     114//    UInt_t GetNumDatRuns() const { return fDatRuns.GetSize(); }
     115//    UInt_t GetNumPedRuns() const { return fPedRuns.GetSize(); }
     116//    UInt_t GetNumCalRuns() const { return fCalRuns.GetSize(); }
     117    UInt_t GetNumExclRuns() const { return fExclRuns.GetSize(); }
    109118
    110119    UInt_t GetSequence() const { return fSequence; }
     
    117126    const UInt_t GetFirstCalRun() const { return fCalRuns[0]; }
    118127    const UInt_t GetLastCalRun() const { return fCalRuns[fCalRuns.GetSize()-1]; }
    119     const TArrayI &GetPedRuns() const { return fPedRuns; }
    120     const TArrayI &GetCalRuns() const { return fCalRuns; }
    121     const TArrayI &GetDatRuns() const { return fDatRuns; }
     128//    const TArrayI &GetDatRuns() const { return fDatRuns; }
     129//    const TArrayI &GetPedRuns() const { return fPedRuns; }
     130//    const TArrayI &GetCalRuns() const { return fCalRuns; }
     131    const TArrayI &GetExclRuns() const { return fExclRuns; }
    122132
    123133    const MTime &GetStart() const { return fStart; }
     
    129139    const TString &GetFileName() const { return fFileName; }
    130140    const TString &GetDataPath() const { return fDataPath; }
     141
     142    const TString GetExcludedRuns() const;
    131143
    132144    // Setter
     
    143155    UInt_t AddDatRuns(UInt_t num) { return AddDatRuns(num, num); }
    144156
     157    void ExcludeRun(UInt_t num);
     158    void ExcludeRuns(TString runs);
     159
    145160    static Bool_t InflatePath(TString &seq, Bool_t ismc=kFALSE);
    146161
    147     ClassDef(MSequence, 3)
     162    ClassDef(MSequence, 4)
    148163};
    149164
Note: See TracChangeset for help on using the changeset viewer.