Ignore:
Timestamp:
01/11/07 14:56:24 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
6 edited

Legend:

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

    r8221 r8244  
    8787#include "MRead.h"
    8888#include "MJob.h"
     89#include "MEnv.h"
    8990#include "MAstro.h"
    9091#include "MDirIter.h"
     
    155156// The entries are sorted by filename.
    156157//
    157 void MDataSet::ResolveSequences(TEnv &env, const TArrayI &num, TList &list, const TString &sequences, const TString &data) const
    158 {
     158void MDataSet::ResolveSequences(TEnv &env, const TArrayI &num, TList &list) const
     159{
     160    TString sequences = fPathSequences;
     161    TString data      = fPathDataFiles;
     162
    159163    for (int i=0; i<num.GetSize(); i++)
    160164    {
     
    168172            dir = Form("%s%04d/%08d", data.Data(), num[i]/10000, num[i]);
    169173
    170         gSystem->ExpandPathName(name);
    171         gSystem->ExpandPathName(dir);
    172 
    173         if (gSystem->AccessPathName(name, kFileExists))
    174             gLog << warn << "WARNING - Sequence file '" << name << "' doesn't exist." << endl;
    175 
    176         if (gSystem->AccessPathName(dir, kFileExists))
    177             gLog << warn << "WARNING - Directory '" << dir << "' doesn't exist." << endl;
    178 
    179         list.Add(new TNamed(name, dir));
     174        // FIXME: The sequence number from the sequence file is assigned!!!
     175        MSequence *seq = new MSequence(name, dir);
     176
     177        if (seq->IsValid() && seq->GetSequence()!=(UInt_t)num[i])
     178            *fLog << warn << "WARNING - Sequence number " << num[i] << " in dataset file doesn't match sequence number " << seq->GetSequence() << " in sequence file!" << endl;
     179
     180        list.Add(seq);
    180181    }
    181182
     
    204205        gLog << err << "ERROR - Dataset file " << expname << " not accessible!" << endl;
    205206
    206     TEnv env(expname);
     207    MEnv env(expname);
    207208    delete [] expname;
    208209
     
    218219    SetupDefaultPath(data,      fgPathDataFiles);
    219220
    220     ResolveSequences(env, fNumSequencesOn,  fSequencesOn,  sequences, data);
    221     ResolveSequences(env, fNumSequencesOff, fSequencesOff, sequences, data);
     221    fPathSequences = sequences;
     222    fPathDataFiles = data;
     223
     224    ResolveSequences(env, fNumSequencesOn,  fSequencesOn);
     225    ResolveSequences(env, fNumSequencesOff, fSequencesOff);
    222226
    223227    fNameSource   = env.GetValue("SourceName", "");
     
    228232    fNameSource = fNameSource.Strip(TString::kBoth);
    229233    fCatalog    = fCatalog.Strip(TString::kBoth);
     234
     235    if (env.GetNumUntouched()>0)
     236    {
     237        gLog << warn << "WARNING - At least one resource in the dataset-file has not been touched!" << endl;
     238        env.PrintUntouched();
     239    }
    230240}
    231241
     
    234244// Return '+' if both can be accessed, '-' otherwise.
    235245//
    236 void MDataSet::PrintFile(const TObject &obj)
     246void MDataSet::PrintFile(const MSequence &seq)
    237247{
    238248    const Char_t access =
    239         !gSystem->AccessPathName(obj.GetName(), kFileExists) &&
    240         !gSystem->AccessPathName(obj.GetTitle(), kFileExists) ? '+' : '-';
    241 
    242     gLog << " " << access << " " << obj.GetName() << " <" << obj.GetTitle() << ">" << endl;
     249        !gSystem->AccessPathName(seq.GetFileName(), kFileExists) &&
     250        !gSystem->AccessPathName(seq.GetDataPath(), kFileExists) ? '+' : '-';
     251
     252    gLog << "#  " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;
    243253}
    244254
     
    272282    gLog << "Comment: " << fComment << endl;
    273283
     284    if (fSequencesOn.GetEntries()>0)
     285        gLog << endl;
     286
     287    TIter NextOn(&fSequencesOn);
     288    TIter NextOff(&fSequencesOff);
     289    MSequence *seq=0;
     290    while ((seq=(MSequence*)NextOn()))
     291    {
     292        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".File: " << seq->GetFileName() << endl;
     293        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".Dir:  " << seq->GetDataPath() << endl;
     294    }
     295    if (fSequencesOff.GetEntries()>0)
     296        gLog << endl;
     297    while ((seq=(MSequence*)NextOff()))
     298    {
     299        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".File: " << seq->GetFileName() << endl;
     300        gLog << "Sequence" << Form("%08d", seq->GetSequence()) << ".Dir:  " << seq->GetDataPath() << endl;
     301    }
     302
    274303    if (TString(o).Contains("files", TString::kIgnoreCase))
    275304    {
    276         TObject *obj=0;
    277 
    278305        gLog << endl;
    279         gLog << "On-Data Files:" << endl;
    280         TIter NextOn(&fSequencesOn);
    281         while ((obj=NextOn()))
    282             PrintFile(*obj);
     306        gLog << "# On-Data Files:" << endl;
     307        NextOn.Reset();
     308        while ((seq=(MSequence*)NextOn()))
     309            PrintFile(*seq);
    283310
    284311        gLog << endl;
    285         gLog << "Off-Data Files:" << endl;
    286         TIter NextOff(&fSequencesOff);
    287         while ((obj=NextOff()))
    288             PrintFile(*obj);
     312        gLog << "# Off-Data Files:" << endl;
     313        NextOff.Reset();
     314        while ((seq=(MSequence*)NextOff()))
     315            PrintFile(*seq);
    289316
    290317        return;
     
    300327{
    301328    TIter Next(const_cast<TList*>(&list));
    302     TObject *o=0;
    303 
    304     while ((o=Next()))
    305     {
    306         MSequence seq(o->GetName());
    307         if (!seq.IsValid())
     329
     330    MSequence *seq=0;
     331    while ((seq=(MSequence*)Next()))
     332    {
     333        if (!seq->IsValid())
    308334        {
    309             gLog << warn;
    310             gLog << "WARNING - MDataSet::AddSequencesFromList: Sequence invalid!" << endl;
    311             gLog << "  + File: " << o->GetName() << endl;
    312             gLog << "  + Dir:  " << o->GetTitle() << endl;
     335            gLog << err;
     336            gLog << "ERROR - MDataSet::AddSequencesFromList: Sequence invalid!" << endl;
     337            gLog << "  + File: " << seq->GetFileName() << endl;
     338            gLog << "  + Dir:  " << seq->GetDataPath() << endl;
    313339            return kFALSE;
    314340        }
    315341
    316         const TString dir(o->GetTitle());
    317         if (seq.SetupDatRuns(files, MSequence::kImages, dir.IsNull() ? 0 : dir.Data())<=0)
     342        if (seq->SetupDatRuns(files, MSequence::kImages)<=0)
    318343            return kFALSE;
    319344    }
  • trunk/MagicSoft/Mars/mjobs/MDataSet.h

    r7492 r8244  
    1414class MRead;
    1515class MDirIter;
     16class MSequence;
    1617class MPointingPos;
    1718
     
    2425
    2526    UInt_t  fNumAnalysis;     // Analysis number (artificial)
     27
     28    TString fPathSequences;
     29    TString fPathDataFiles;
    2630
    2731    TArrayI fNumSequencesOn;  // number of on-sequences
     
    3943
    4044    void Split(TString &runs, TArrayI &data) const;
    41     void ResolveSequences(TEnv &env, const TArrayI &num, TList &list, const TString &sequences, const TString &data) const;
    42     static void PrintFile(const TObject &obj);
     45    void ResolveSequences(TEnv &env, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const;
     46    static void PrintFile(const MSequence &obj);
    4347
    4448    void ReplaceDir(TList &list, const TString &old, const TString &news) const;
  • trunk/MagicSoft/Mars/mjobs/MJCut.cc

    r8222 r8244  
    6262#include "MWriteRootFile.h"
    6363
     64// Filter
     65//#include "MFDataMember.h"
     66
    6467// Fit signal environment
    6568#include "../mhflux/MAlphaFitter.h"
     
    270273// analysis number num, see GetOutputFile()
    271274//
    272 Bool_t MJCut::WriteResult(const MParList &plist, UInt_t num) const
     275Bool_t MJCut::WriteResult(const MParList &plist, const MDataSet &set) const
    273276{
    274277    TObjArray arr;
     
    286289        arr.Add((TObject*)(&halpha->GetAlphaFitter()));
    287290
     291    // Save also the dataset
     292    arr.Add(const_cast<MDataSet*>(&set));
     293
     294    const Int_t num = set.GetNumAnalysis();
    288295    const TString fname(fNameOutput.IsNull() ? Form("ganymed%08d.root", num) : fNameOutput.Data());
    289296
     
    577584
    578585    // Initialize default binnings
    579     MBinning bins1(18,  0,     90,    "BinningAlpha", "lin");
    580     MBinning bins2(15, 10,     1e6 ,  "BinningSize",  "log");
    581     MBinning bins3(67, -0.005, 0.665, "BinningTheta", "asin");
     586    MBinning bins1( 18,  0,     90,    "BinningAlpha",  "lin");
     587    MBinning bins2( 15, 10,     1e6 ,  "BinningSize",   "log");
     588    MBinning bins3( 67, -0.005, 0.665, "BinningTheta",  "asin");
     589    //MBinning binsT(150,  0,     150,   "BinningDeltaT", "lin");
    582590    MBinning bins4("BinningFalseSource");
    583591    MBinning bins5("BinningWidth");
     
    597605    plist.AddToList(&bins9);
    598606    plist.AddToList(&bins0);
    599     //plist.AddToList(&binsa);
     607    //plist.AddToList(&binsT);
    600608
    601609    // --------------------------------------------------------------------------------
     
    662670    MFillH fill6a("MHImgParOffPost [MHImagePar]",    "MImagePar",    "FillImgParPost");
    663671    MFillH fill7a("MHNewParOffPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
     672    //MFillH fill9a("MHEffOffTime    [MHEffectiveOnTime]", "MTime",        "FillEffOnTime");
    664673    fill1a.SetNameTab("PreCut");
    665674    fill2a.SetNameTab("PostCut");
     
    669678    fill6a.SetNameTab("ImgPar");
    670679    fill7a.SetNameTab("NewPar");
     680    //fill9a.SetNameTab("EffOffT");
     681
     682    //MFDataMember fbin("Bin.fVal", '>', 0);
     683    //fill9a.SetFilter(&fbin);
    671684
    672685    MPrint print2("MEffectiveOnTime");
     
    722735    }
    723736    if (!fWriteOnly)
     737    {
    724738        tlist2.AddToList(&falpha);
     739        /* if (!fIsMonteCarlo)
     740        {
     741            tlist2.AddToList(&fbin);
     742            tlist2.AddToList(&fill9a);
     743        } */
     744    }
    725745    tlist2.AddToList(&cont3);
    726746    if (write1)
     
    810830    MFillH fill6b("MHImgParOnPost [MHImagePar]",    "MImagePar",    "FillImgParPost");
    811831    MFillH fill7b("MHNewParOnPost [MHNewImagePar]", "MNewImagePar", "FillNewParPost");
     832    //MFillH fill9b("MHEffOnTime    [MHEffectiveOnTime]", "MTime",        "FillEffOnTime");
    812833    fill1b.SetNameTab("PreCut");
    813834    fill2b.SetNameTab("PostCut");
     
    817838    fill6b.SetNameTab("ImgPar");
    818839    fill7b.SetNameTab("NewPar");
     840    //fill9b.SetNameTab("EffOnT");
    819841    fill1b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
    820842    fill2b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
     
    824846    fill6b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
    825847    fill7b.SetDrawOption(set.HasOffSequences()||fIsWobble?"same":"");
     848
     849    //fill9b.SetFilter(&fbin);
    826850
    827851    /*
     
    891915        }
    892916        tlist2.Replace(&falpha2);
     917        //if (!fIsMonteCarlo)
     918        //    tlist2.Replace(&fill9b);
    893919        if (!fIsWobble || !fNameHist.IsNull())
    894920            tlist2.Replace(&ffs2);
     
    925951    // FIXME: Perform fit and plot energy dependant alpha plots
    926952    // and fit result to new tabs!
    927     if (!WriteResult(plist, set.GetNumAnalysis()))
     953    if (!WriteResult(plist, set))
    928954        return kFALSE;
    929955
  • trunk/MagicSoft/Mars/mjobs/MJCut.h

    r7753 r8244  
    4242    void     SetupWriter(MWriteRootFile *write, const char *name) const;
    4343    Bool_t   WriteTasks(UInt_t num, TObjArray &cont) const;
    44     Bool_t   WriteResult(const MParList &plist, UInt_t num) const;
     44    Bool_t   WriteResult(const MParList &plist, const MDataSet &set) const;
    4545    MHAlpha *CreateNewHist(MParList &plist, const char *name="") const;
    4646    MH      *CreateNewHistFS(MParList &plist, const char *name="") const;
  • trunk/MagicSoft/Mars/mjobs/MJStar.cc

    r8220 r8244  
    136136    fLog->Separator(GetDescriptor());
    137137    *fLog << "Calculate image parameters of sequence ";
    138     *fLog << fSequence.GetName() << endl;
     138    *fLog << fSequence.GetFileName() << endl;
    139139    *fLog << endl;
    140140
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r8224 r8244  
    130130#include "MLogManip.h"
    131131
     132#include "MEnv.h"
    132133#include "MJob.h"
    133134#include "MAstro.h"
     
    202203{
    203204    TString d(path);
     205    if (d.IsNull())
     206        d = fDataPath;
    204207
    205208    const Bool_t def = d.IsNull();
     
    207210    // For this particular case we assume that the files are added one by
    208211    // one without wildcards.
    209     const Int_t n0  = iter.GetNumEntries();
     212    const Int_t n0 = iter.GetNumEntries();
    210213
    211214    // Setup path
     
    291294        }
    292295
     296        // Check existance and accessibility of file
     297        MDirIter file(d, n, 0);
     298        TString name = file();
     299        gSystem->ExpandPathName(name);
     300        if (gSystem->AccessPathName(name, kFileExists))
     301        {
     302            *fLog << err;
     303            *fLog << "ERROR - File " << d << n << " not accessible!" << endl;
     304            return 0;
     305        }
     306        if (!file().IsNull())
     307        {
     308            *fLog << err;
     309            *fLog << "ERROR - Searching for file " << d << n << " gave more than one result!" << endl;
     310            return 0;
     311        }
     312
    293313        // Add Path/File to TIter
    294314        iter.AddDirectory(d, n, 0);
     
    358378MSequence::LightCondition_t MSequence::ReadLightCondition(TEnv &env) const
    359379{
    360     TString str = env.GetValue("LightCondition", "n/a");
     380    TString str = env.GetValue("LightConditions", "n/a");
    361381    if (!str.CompareTo("n/a", TString::kIgnoreCase))
    362382        return kNA;
    363     if (!str.CompareTo("NoMoon", TString::kIgnoreCase))
     383    if (!str.CompareTo("No_Moon", TString::kIgnoreCase))
    364384        return kNoMoon;
    365385    if (!str.CompareTo("Twilight", TString::kIgnoreCase))
     
    370390        return kDay;
    371391
    372     gLog << warn << "MSequence: LightCondition-tag not n/a, nomoon, twilight, moon or day." << endl;
     392    gLog << warn;
     393    gLog << "WARNING - in " << fFileName << ":" << endl;
     394    gLog << "          LightCondition-tag is '" << str << "' but must be n/a, no_moon, twilight, moon or day." << endl;
    373395    return kNA;
    374396}
     
    378400// Read the file fname as setup file for the sequence.
    379401//
    380 MSequence::MSequence(const char *fname)
     402MSequence::MSequence(const char *fname, const char *path)
    381403{
    382404    fName  = fname;
    383 
    384     const char *expname = gSystem->ExpandPathName(fname);
    385 
    386     fTitle = Form("Sequence contained in file %s", expname);
    387 
    388     const Bool_t access = !gSystem->AccessPathName(expname, kFileExists);
    389     if (!access)
    390         gLog << err << "ERROR - Dataset file " << expname << " not accessible!" << endl;
    391 
    392     TEnv env(expname);
    393     delete [] expname;
    394 
    395     TString str;
    396 
    397     fSequence  = env.GetValue("Sequence",  -1);
     405    fTitle = path;
     406
     407    fFileName = fname;
     408    fDataPath = path;
     409
     410    gSystem->ExpandPathName(fName);
     411    gSystem->ExpandPathName(fTitle);
     412
     413    const Bool_t rc1 = gSystem->AccessPathName(fName, kFileExists);
     414    const Bool_t rc2 = gSystem->AccessPathName(fTitle, kFileExists);
     415
     416    if (rc1)
     417        gLog << err << "ERROR - Sequence file '" << fName << "' doesn't exist." << endl;
     418    if (rc2)
     419        gLog << err << "ERROR - Directory '" << fTitle << "' doesn't exist." << endl;
     420
     421    MEnv env(fName);
     422
     423    fSequence  = env.GetValue("Sequence", -1);
     424    if (rc1 || rc2)
     425        fSequence = (UInt_t)-1;
     426
    398427    fLastRun   = env.GetValue("LastRun",   -1);
    399428    fNumEvents = env.GetValue("NumEvents", -1);
     
    402431    fLightCondition = ReadLightCondition(env);
    403432
     433    TString str;
    404434    str = env.GetValue("Start", "");
    405435    fStart.SetSqlDateTime(str);
     
    426456    GetFileNames(env, fPedRuns);
    427457    GetFileNames(env, fDatRuns);
     458
     459    // Dummies:
     460    env.GetValue("ZdMin", 0);
     461    env.GetValue("ZdMax", 0);
     462    env.GetValue("L1TriggerTable", 0);
     463    env.GetValue("L2TriggerTable", 0);
     464
     465    if (env.GetNumUntouched()>0)
     466    {
     467        gLog << warn << "WARNING - At least one resource in the dataset-file has not been touched!" << endl;
     468        env.PrintUntouched();
     469    }
    428470}
    429471
     
    437479    if (!IsValid())
    438480    {
    439         gLog << "Sequence: " << fName << " <invalid>" << endl;
     481        gLog << "Sequence: " << fFileName << " <invalid>" << endl;
    440482        return;
    441483    }
     
    475517        gLog << " " << fDatRuns[i];
    476518    gLog << endl;
     519
     520    if (!fDataPath.IsNull())
     521        gLog << endl << "DataPath: " << fDataPath << endl;
    477522}
    478523
     
    480525//
    481526// Add all ped runs from the sequence to MDirIter.
    482 // If path==0 the standard path of the data-center is assumed.
     527// If path==0 fDataPath is used instead. If it is also empty
     528// the standard path of the data-center is assumed.
    483529// If you have the runs locally use path="."
    484530// Using raw=kTRUE you get correspodning raw-files setup.
    485531// Return the number of files added.
     532//
    486533UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
    487534{
     
    492539//
    493540// Add all data runs from the sequence to MDirIter.
    494 // If path==0 the standard path of the data-center is assumed.
     541// If path==0 fDataPath is used instead. If it is also empty
     542// the standard path of the data-center is assumed.
    495543// If you have the runs locally use path="."
    496544// Using raw=kTRUE you get correspodning raw-files setup.
     
    505553//
    506554// Add all runs from the sequence to MDirIter.
    507 // If path==0 the standard path of the data-center is assumed.
     555// If path==0 fDataPath is used instead. If it is also empty
     556// the standard path of the data-center is assumed.
    508557// If you have the runs locally use path="."
    509558// Using raw=kTRUE you get correspodning raw-files setup.
     
    518567//
    519568// Add all calibration runs from the sequence to MDirIter.
    520 // If path==0 the standard path of the data-center is assumed.
     569// If path==0 fDataPath is used instead. If it is also empty
     570// the standard path of the data-center is assumed.
    521571// If you have the runs locally use path="."
    522572// Using raw=kTRUE you get correspodning raw-files setup.
     
    531581//
    532582// Add all data runs from the sequence to MDirIter.
    533 // If path==0 the standard path of the data-center is assumed.
     583// If path==0 fDataPath is used instead. If it is also empty
     584// the standard path of the data-center is assumed.
    534585// If you have the runs locally use path="."
    535586// Using raw=kTRUE you get correspodning raw-files setup.
Note: See TracChangeset for help on using the changeset viewer.