Changeset 8780 for trunk


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8779 r8780  
    1919                                                 -*-*- END OF LINE -*-*-
    2020
    21  2007/12/03 Stefan Ruegamer
     21 2007/12/10 Thomas Bretz
     22
     23   * mfileio/MReadReports.cc:
     24     - due to a tiny misconception the last event in trees was skipped
     25       simply because no time-stamp for a next event followed...
     26       fixed.
     27
     28   * mhflux/MAlphaFitter.[h,cc]:
     29     - added a new member function FixScale() to fix the scale
     30
     31   * mhflux/MHAlpha.cc:
     32     - replaced the check whether the significance is >1 by a check
     33       whether it is >0. 0 means calculation failed. So all
     34       valid data points are shown. If no significance could
     35       be calculated (negative flux) the data point is omitted.
     36     - fixed a few drawing problems, which sometimes suppressed the
     37       time-histogram even if it contained valid data (this only
     38       affected very very short sequences - with a single time bin)
     39
     40   * mjobs/MDataSet.[h,cc]:
     41     - implemented a possibility to use put the sequence inside the
     42       dataset file
     43     - improved comments
     44     - allow to exclude runs from within the dataset file
     45
     46   * mjobs/MSequence.[h,cc]:
     47     - added a new data member to store excluded runs. This is
     48       needed to be able to store everything correctly later.
     49     - improved comments
     50     - added possibility to exclude previously set runs
     51     - added a few member functions to check which runs are contained
     52     - comment out some currently obsolete member function
     53     - allow to read the resources of a sequence file prefixed
     54       this is used in the new option of MDataSet
     55     - increased class version number accordingly
     56
     57
     58
     59 2007/12/10 Stefan Ruegamer
    2260
    2361   * steps.rc
     
    2866
    2967
     68
     69 2007/12/03 Stefan Ruegamer
    3070
    3171   * datacenter/script/sourcefile
  • trunk/MagicSoft/Mars/NEWS

    r8736 r8780  
    11                                                               -*-*- END -*-*-
    22
    3  *** <cvs>
    4 
     3== <cvs> ==
     4
     5;general
     6* fixed GroupBy options in plot*.C macros
     7* only display KVA points (not the Tuorla points) in plotoptical.C
     8* all programs now allow to add resources to the ones from the resource
     9file or overwrite them from the command line. This can be done like this
     10::ganymed --config=ganymed.rc --rc=Cut1.Param1:0.25 --rc=Cut1.Param3:5.5
     11:if something seems to be wrong you can debug what the program is doing
     12using the option --debug-env=3
     13* increased the diversity of debug levels. That also means that with -v3
     14you get now less output, i.e. only the output which is important for
     15an analysis. To get more output which helps for debugging try 4, 5 and 6.
     16* fixed a problem in the task synchronizing the reading of the reports
     17and the data stream. The effect was that in some circumstances the last
     18events of some trees could have been skipped. Since this is only a
     19very tiny part of the data no severe effect to your analysis results
     20is expected.
     21* Dataset file now allow to include the sequence file directly within
     22the dataset file and also allow to exclude single runs from the dataset.
     23(for more details see Class reference of MDataSet)
     24* Sequence files now allow for excluding runs from the analysis
     25(for more details see Class reference of MSequence)
     26;ganymed/sponde
     27* Now data points are even shown correctly if they have error bars larger
     28than one sigma. Points with null or negative significances are omitted.
     29;sponde
     30*fixed resource files ('''Spectrum''' instead of '''MJSpectrum''')
    531
    632
     
    4874     energy)
    4975
    50    - general: TheRandom Forest training of energy (trainenergy.c) and
     76   - general: The Random Forest training of energy (trainenergy.c) and
    5177     disp (traindisp.C) has been improved by more graphical output to
    5278     judge the result.
     
    125151     as old files read in.
    126152
    127    - callisto: The callibration constants of earlier updates got lost
     153   - callisto: The calibration constants of earlier updates got lost
    128154     somehow. All constants have been updated.
    129155
  • trunk/MagicSoft/Mars/mfileio/MReadReports.cc

    r7838 r8780  
    317317
    318318    fPosEntry.Set(i);
     319    fPosEntry.Reset();
    319320
    320321    // Force that with the next call to Process the required events are read
     
    415416    while (fChains->GetSize())
    416417    {
     418        // Find the next tree to read from checking the time-stamps
     419        // of the next events which would be read
    417420        const Int_t nmin=FindNext();
    418421        if (nmin<0)
     
    422425        }
    423426
    424         TChain *chain = (TChain*)fChains->At(nmin);
    425 
    426         MTask *task = (MTask*)fTrees->GetList()->At(nmin);
    427 
    428         //Int_t before = chain->GetTreeNumber();
    429         if (chain->GetEntry(++fPosEntry[nmin])>0)
    430         {
    431             const Int_t rc = task->CallProcess();
    432             if (rc)
    433                 return rc;
    434         }
    435 
    436         *fLog << dbg << "Removing chain " << chain->GetName() << " from list" << flush;
    437 
    438         delete *GetTime(chain);        // Delete MTime*
    439         *fLog << "." << flush;
    440         delete fChains->Remove(chain); // Remove chain from TList
    441         *fLog << "." << flush;
    442 
    443         // FIXME: Maybe MTaskList should have a member function to
    444         //        reorder the tasks?
    445 
    446         // Move this task to the end of the list so that nmin still
    447         // corresponds to the correct task in the list.
    448         const_cast<TList*>(fTrees->GetList())->Remove(task);
    449         *fLog << "." << flush;
    450         const_cast<TList*>(fTrees->GetList())->AddLast(task);
    451         *fLog << "done." << endl;
    452     }
    453 
    454     return kFALSE;
     427        // Read the event from this tree
     428        MTask *task = static_cast<MTask*>(fTrees->GetList()->At(nmin));
     429        const Int_t rc = task->CallProcess();
     430
     431        // Read the time-stamp of the next event
     432        TChain *chain = static_cast<TChain*>(fChains->At(nmin));
     433        const Int_t cnt = chain->GetEntry(++fPosEntry[nmin]);
     434
     435        // In case there is no further time-stamp of an error reading the
     436        // event we remove this time-stamp from the list of time-stamps to
     437        // be checked for reading the next events, because there is none.
     438        if (cnt<=0 || rc==kFALSE)
     439        {
     440            *fLog << dbg << "Removing chain " << chain->GetName() << " from list" << flush;
     441
     442            delete *GetTime(chain);        // Delete MTime*
     443            *fLog << "." << flush;
     444            delete fChains->Remove(chain); // Remove chain from TList
     445            *fLog << "." << flush;
     446
     447            // FIXME: Maybe MTaskList should have a member function to
     448            //        reorder the tasks?
     449
     450            // Move this task to the end of the list so that nmin still
     451            // corresponds to the correct task in the list.
     452            const_cast<TList*>(fTrees->GetList())->Remove(task);
     453            *fLog << "." << flush;
     454            const_cast<TList*>(fTrees->GetList())->AddLast(task);
     455            *fLog << "done." << endl;
     456        }
     457
     458        // If something else than kFALSE (means: stop reading from this
     459        // tree) has happened we return the return code of the processing
     460        if (rc!=kFALSE)
     461            return rc;
     462    }
     463
     464    return kFALSE;
    455465}
    456466
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc

    r8775 r8780  
    853853            fScaleMode = kUserScale;
    854854        if (txt==(TString)"fixed")
    855         {
    856             fScaleMode = kUserScale;
    857             fScaleUser = fScaleFactor;
    858         }
     855            FixScale();
    859856        rc = kTRUE;
    860857    }
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h

    r8775 r8780  
    165165    void EnableBackgroundFit(Bool_t b=kTRUE) { fFitBackground=b; }
    166166
     167    void FixScale()
     168    {
     169        fScaleMode = kUserScale;
     170        fScaleUser = fScaleFactor;
     171    }
     172
    167173    // Getter
    168174    Double_t GetSignalIntegralMax() const  { return fSigInt; }
  • trunk/MagicSoft/Mars/mhflux/MHAlpha.cc

    r8775 r8780  
    159159    for (int i=1; i<=n; i++)
    160160    {
    161         if (fit.FitEnergy(fHist, fOffData, i))
    162         {
    163             fHEnergy.SetBinContent(i, fit.GetEventsExcess());
    164             if (fit.GetSignificanceExc()>1)
    165                 fHEnergy.SetBinError(i, fit.GetEventsExcess()/fit.GetSignificanceExc());
    166             else
    167                 fHEnergy.SetBinError(i, fit.GetEventsExcess());
    168 
    169             if (fit.GetSignificanceExc()>1)
    170             {
    171                 mean += fit.GetSignificanceExc()*fit.GetSignificanceExc();
    172                 num++;
    173             }
    174         }
     161        if (!fit.FitEnergy(fHist, fOffData, i))
     162            continue;
     163
     164        if (fit.GetSignificanceExc()<=0)
     165            continue;
     166
     167        fHEnergy.SetBinContent(i, fit.GetEventsExcess());
     168        fHEnergy.SetBinError(i, fit.GetEventsExcess()/fit.GetSignificanceExc());
     169
     170        mean += fit.GetSignificanceExc()*fit.GetSignificanceExc();
     171        num++;
    175172    }
    176173    return TMath::Sqrt(mean)/num;
     
    188185    for (int i=1; i<=n; i++)
    189186    {
    190         if (fit.FitTheta(fHist, fOffData, i))
    191         {
    192             fHTheta.SetBinContent(i, fit.GetEventsExcess());
    193             if (fit.GetSignificanceExc()>1)
    194                 fHTheta.SetBinError(i, fit.GetEventsExcess()/fit.GetSignificanceExc());
    195             else
    196                 fHTheta.SetBinError(i, fit.GetEventsExcess());
    197         }
     187        if (!fit.FitTheta(fHist, fOffData, i))
     188            continue;
     189
     190        if (fit.GetSignificanceExc()<=0)
     191            continue;
     192
     193        fHTheta.SetBinContent(i, fit.GetEventsExcess());
     194        fHTheta.SetBinError(i, fit.GetEventsExcess()/fit.GetSignificanceExc());
    198195    }
    199196}
     
    431428    // Fill histogram
    432429    //
    433     fHTime.SetBinContent(n+1, fit.GetEventsExcess());
    434     if (fit.GetSignificanceExc()>1)
     430    if (fit.GetSignificanceExc()>0)
     431    {
     432        fHTime.SetBinContent(n+1, fit.GetEventsExcess());
    435433        fHTime.SetBinError(n+1, fit.GetEventsExcess()/fit.GetSignificanceExc());
    436     else
    437         fHTime.SetBinError(n+1, fit.GetEventsExcess());
     434    }
    438435
    439436    *fLog << all << *fTimeEffOn << ": " << fit.GetEventsExcess() << endl;
     
    735732    AppendPad("variable");
    736733
    737     if (fHEnergy.GetNbinsX()>1)
     734    if (fHEnergy.GetNbinsX()>1 || fHEnergy.GetBinContent(1)>0)
    738735    {
    739736        pad->cd(2);
     
    759756        delete pad->GetPad(2);
    760757
    761     if (fTimeEffOn && fTime || fHTime.GetNbinsX()>1)
     758    if (fTimeEffOn && fTime || fHTime.GetNbinsX()>1 || fHTime.GetBinContent(1)>0)
    762759    {
    763760        pad->cd(3);
     
    771768        delete pad->GetPad(3);
    772769
    773     if (fHTheta.GetNbinsX()>1)
     770    if (fHTheta.GetNbinsX()>1 || fHTheta.GetBinContent(1)>0)
    774771    {
    775772        pad->cd(4);
  • 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.