Ignore:
Timestamp:
08/25/04 17:30:31 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
8 edited

Legend:

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

    r4729 r4732  
    148148
    149149    TObject *o = file.Get("ExtractSignal");
    150     if (!o)
    151     {
    152         *fLog << err << dbginf << "ERROR - Unable to read ExtractSignal from file " << fname << endl;
    153         return kFALSE;
    154     }
    155     if (!o->InheritsFrom(MExtractor::Class()))
     150//    if (!o)
     151//    {
     152//        *fLog << err << dbginf << "ERROR - Unable to read ExtractSignal from file " << fname << endl;
     153//        return kFALSE;
     154//    }
     155    if (o && !o->InheritsFrom(MExtractor::Class()))
    156156    {
    157157        *fLog << err << dbginf << "ERROR - ExtractSignal read from " << fname << " doesn't inherit from MExtractor!" << endl;
    158158        return kFALSE;
    159159    }
    160     ext1 = (MTask*)o->Clone();
     160    ext1 = o ? (MTask*)o->Clone() : NULL;
    161161
    162162    o = file.Get("ExtractTime");
    163     if (!o)
    164     {
    165         *fLog << err << dbginf << "ERROR - Unable to read ExtractTime from file " << fname << endl;
    166         return kFALSE;
    167     }
    168     if (!o->InheritsFrom(MExtractor::Class()))
     163//    if (!o)
     164//    {
     165//        *fLog << err << dbginf << "ERROR - Unable to read ExtractTime from file " << fname << endl;
     166//        return kFALSE;
     167//    }
     168    if (o && !o->InheritsFrom(MExtractor::Class()))
    169169    {
    170170        *fLog << err << dbginf << "ERROR - ExtractTime read from " << fname << " doesn't inherit from MExtractor!" << endl;
    171171        return kFALSE;
    172172    }
    173     ext2 = (MTask*)o->Clone();
     173    ext2 = o ? (MTask*)o->Clone() : NULL;
     174
     175    if (!ext1 && !ext2)
     176    {
     177        *fLog << err << dbginf << "ERROR - Neither ExtractSignal nor ExrtractTime found in " << fname << "!" << endl;
     178        return kFALSE;
     179    }
    174180
    175181    return kTRUE;
     
    226232
    227233    *fLog << all;
    228     *fLog << "Extractors read from file" << endl;
    229     *fLog << "=========================" << endl;
    230     extractor1->Print();
    231     *fLog << endl;
    232     extractor2->Print();
    233     *fLog << endl;
     234    if (extractor1)
     235    {
     236        *fLog << underline << "Signal Extractor found in calibration file" << endl;
     237        extractor1->Print();
     238        *fLog << endl;
     239    }
     240    else
     241        *fLog << inf << "No Signal Extractor: ExtractSignal in file." << endl;
     242
     243    if (extractor2)
     244    {
     245        *fLog << underline << "Time Extractor found in calibration file" << endl;
     246        extractor2->Print();
     247        *fLog << endl;
     248    }
     249    else
     250        *fLog << inf << "No Time Extractor: ExtractTime in file." << endl;
    234251
    235252    // This is necessary for the case in which it is not in the files
     
    302319    tlist.AddToList(&pedlo);
    303320    tlist.AddToList(&fill0);
    304     tlist.AddToList(&taskenv1);
    305     tlist.AddToList(&taskenv2);
     321    if (extractor1)
     322        tlist.AddToList(&taskenv1);
     323    if (extractor2)
     324        tlist.AddToList(&taskenv2);
    306325    tlist.AddToList(&fill1);
    307326    tlist.AddToList(&calib);
     
    320339    evtloop.SetDisplay(fDisplay);
    321340    evtloop.SetLogStream(fLog);
    322     if (GetEnv())
    323         evtloop.ReadEnv(*GetEnv());
     341    if (!SetupEnv(evtloop))
     342        return kFALSE;
    324343
    325344    // Execute first analysis
  • trunk/MagicSoft/Mars/mjobs/MJCalibration.cc

    r4729 r4732  
    248248    TString title = fDisplay->GetTitle();
    249249    title += "--  Calibration ";
    250     title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : fRuns->GetRunsAsString();
     250    title += fSequence.IsValid() ? Form("calib%06d", fSequence.GetSequence()) : (const char*)fRuns->GetRunsAsString();
    251251    title += "  --";
    252252    fDisplay->SetTitle(title);
     
    12471247Bool_t MJCalibration::CheckEnv()
    12481248{
    1249     if (!MJob::CheckEnv())
    1250         return kFALSE;
    1251 
    12521249    TString col = GetEnv("Color", "");
    12531250    if (!col.IsNull())
     
    12691266    SetUsePINDiode(GetEnv("UsePINDiode", IsUsePINDiode()));
    12701267
    1271     return kTRUE;
     1268    return MJob::CheckEnv();
    12721269}
    12731270
     
    15571554    evtloop.SetDisplay(fDisplay);
    15581555    evtloop.SetLogStream(fLog);
    1559     if (GetEnv())
    1560         evtloop.ReadEnv(*GetEnv());
    1561 
    1562     //if (!WriteEventloop(evtloop))
    1563     //    return kFALSE;
     1556    if (!SetupEnv(evtloop))
     1557        return kFALSE;
     1558
     1559    if (!taskenv.GetTask() && !taskenv2.GetTask())
     1560    {
     1561        *fLog << err << "ERROR - Neither ExtractSignal nor ExtractTime initializedor both '<dummy>'." << endl;
     1562        return kFALSE;
     1563    }
    15641564
    15651565    if (!WriteTasks(taskenv.GetTask(), taskenv2.GetTask()))
     
    17381738    }
    17391739
    1740     if (t1->Write()<=0)
     1740    if (t1 && t1->Write()<=0)
    17411741    {
    17421742        *fLog << err << "Unable to write " << t1->GetName() << " to " << oname << endl;
    17431743        return kFALSE;
    17441744    }
    1745     if (t2->Write()<=0)
     1745    if (t2 && t2->Write()<=0)
    17461746    {
    17471747        *fLog << err << "Unable to write " << t2->GetName() << " to " << oname << endl;
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r4729 r4732  
    460460}
    461461*/
     462
     463Bool_t MJPedestal::CheckEnv()
     464{
     465    if (HasEnv("DataCheckDisplay"))
     466        fDisplayType = GetEnv("DataCheckDisplay", kFALSE) ? kDataCheckDisplay : kNormalDisplay;
     467
     468    SetDataCheck(GetEnv("DataCheck", fDataCheck));
     469    SetOverwrite(GetEnv("Overwrite", fOverwrite));
     470
     471    return MJob::CheckEnv();
     472}
     473
    462474Bool_t MJPedestal::WriteResult()
    463475{
     
    617629    evtloop.SetDisplay(fDisplay);
    618630    evtloop.SetLogStream(fLog);
    619     if (GetEnv())
    620         evtloop.ReadEnv(*GetEnv());
     631    if (!SetupEnv(evtloop))
     632        return kFALSE;
    621633
    622634    //    if (!WriteEventloop(evtloop))
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.h

    r4729 r4732  
    6161    void   DisplayOutliers(TH1D *hist) const;
    6262    void   FixDataCheckHist(TH1D *hist) const;
     63
     64    Bool_t CheckEnv();
    6365   
    6466public:
     
    7880    void SetInput(MRunIter *iter) { fRuns = iter; }
    7981
    80     void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; SetDataCheckDisplay(); }
     82    void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; b ? SetDataCheckDisplay() : SetNormalDisplay(); }
    8183
    8284    void SetDataCheckDisplay() { fDisplayType = kDataCheckDisplay; }
  • trunk/MagicSoft/Mars/mjobs/MJob.cc

    r4729 r4732  
    3737#include "MLog.h"
    3838#include "MLogManip.h"
     39
     40#include "MEvtLoop.h"
    3941
    4042ClassImp(MJob);
     
    7779    fEnv = new TEnv(env);
    7880
    79     fPrefixEnv = prefix;
     81    fEnvPrefix = prefix;
    8082    if (!prefix)
    81         fPrefixEnv = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName;
     83        fEnvPrefix = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName;
    8284
    83     if (fPrefixEnv.EndsWith("."))
    84         fPrefixEnv.Remove(fPrefixEnv.Length()-1);
     85    if (fEnvPrefix.EndsWith("."))
     86        fEnvPrefix.Remove(fEnvPrefix.Length()-1);
    8587
    8688    return kTRUE;
     
    118120Int_t MJob::GetEnv(const char *name, Int_t dflt) const
    119121{
    120     return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
     122    return GetEnvValue(*fEnv, fEnvPrefix, name, dflt); //    return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);
    121123}
    122124
    123125Double_t MJob::GetEnv(const char *name, Double_t dflt) const
    124126{
    125     return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
     127    return GetEnvValue(*fEnv, fEnvPrefix, name, dflt); //    return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);
    126128}
    127129
    128130const char *MJob::GetEnv(const char *name, const char *dflt) const
    129131{
    130     return fEnv->GetValue(Form("%s%s", fPrefixEnv.Data(), name), dflt);
     132    return GetEnvValue(*fEnv, fEnvPrefix, name, dflt); //fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);
    131133}
    132134
    133135Bool_t MJob::HasEnv(const char *name) const
    134136{
    135     return fEnv->Lookup(Form("%s%s", fPrefixEnv.Data(), name));
     137    return IsEnvDefined(*fEnv, fEnvPrefix, name, fEnvDebug);//fEnv->Lookup(Form("%s%s", fEnvPrefix.Data(), name));
    136138}
    137139
    138140Bool_t MJob::CheckEnv()
    139141{
    140     if (!fEnv)
    141     {
    142         *fLog << warn << "WARNING - " << GetDescriptor() << " CheckEnv called without further SetEnv!" << endl;
    143         return kFALSE;
    144     }
    145 
    146142    TString p;
    147143    p = GetEnv("PathOut", "");
     
    162158    return kTRUE;
    163159}
     160
     161Bool_t MJob::SetupEnv(MEvtLoop &loop) const
     162{
     163    if (!fEnv)
     164        return kTRUE;
     165
     166    return loop.ReadEnv(*fEnv, fEnvPrefix, fEnvDebug) ? kTRUE : kFALSE;
     167}
  • trunk/MagicSoft/Mars/mjobs/MJob.h

    r4729 r4732  
    77
    88class TEnv;
     9class MEvtLoop;
    910
    1011class MJob : public MParContainer
     
    1415
    1516    TEnv     *fEnv;           // Resource file
    16     TString   fPrefixEnv;     // Prefix for resources
     17    TString   fEnvPrefix;     // Prefix for resources
     18    Bool_t    fEnvDebug;      // Debug setup of resources
    1719
    1820protected:
     
    2729    MSequence fSequence;      // Sequence
    2830
    29     virtual Bool_t CheckEnv();
    30 
    31     TEnv       *GetEnv() const { return fEnv; }
    3231    Int_t       GetEnv(const char *name, Int_t dflt) const;
    3332    Double_t    GetEnv(const char *name, Double_t dflt) const;
    3433    const char *GetEnv(const char *name, const char *dflt) const;
    3534    Bool_t      HasEnv(const char *name) const;
     35
     36    Bool_t SetupEnv(MEvtLoop &loop) const;
     37    virtual Bool_t CheckEnv();
    3638
    3739public:
     
    4547    void   SetOverwrite(Bool_t b=kTRUE) { fOverwrite=b; }
    4648    Bool_t SetEnv(const char *env, const char *prefix=0);
     49    void   SetEnvDebug(Bool_t b=kTRUE) { fEnvDebug=b; }
    4750
    4851    void   SetMaxEvents(Int_t max) { fMaxEvents = max; }
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r4729 r4732  
    7373}
    7474
    75 Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const
     75Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, Bool_t raw) const
    7676{
    7777    TString d(path);
     
    8080    if (d.IsNull())
    8181    {
    82         d  = Form("/data/MAGIC/Period%03d/rootdata/", fPeriod);
     82        d  = Form("/data/MAGIC/Period%03d/", fPeriod);
     83        d += raw ? "rawdata/" : "rootdata/";
    8384        d += fNight.GetStringFmt("%Y_%m_%d");
    8485    }
     
    9091        // Create file name
    9192        n =  fNight.GetStringFmt("%Y%m%d_");
    92         n += Form("%05d_*_E.root", arr[i]);
     93        n += Form("%05d_*_E", arr[i]);
     94        n += raw ? ".raw" : ".root";
    9395
    9496        // Add Path/File to TIter
     
    182184// If path==0 the standard path of the data-center is assumed.
    183185// If you have the runs locally use path="."
    184 // Return the number of files added.
    185 //
    186 Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
    187 {
    188     return SetupRuns(iter, fPedRuns, path);
     186// Using raw=kTRUE you get correspodning raw-files setup.
     187// Return the number of files added.
     188//
     189Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const
     190{
     191    return SetupRuns(iter, fPedRuns, path, raw);
    189192}
    190193
     
    194197// If path==0 the standard path of the data-center is assumed.
    195198// If you have the runs locally use path="."
    196 // Return the number of files added.
    197 //
    198 Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
    199 {
    200     return SetupRuns(iter, fDatRuns, path);
     199// Using raw=kTRUE you get correspodning raw-files setup.
     200// Return the number of files added.
     201//
     202Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const
     203{
     204    return SetupRuns(iter, fDatRuns, path, raw);
    201205}
    202206
     
    206210// If path==0 the standard path of the data-center is assumed.
    207211// If you have the runs locally use path="."
    208 // Return the number of files added.
    209 //
    210 Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
    211 {
    212     return SetupRuns(iter, fRuns, path);
     212// Using raw=kTRUE you get correspodning raw-files setup.
     213// Return the number of files added.
     214//
     215Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const
     216{
     217    return SetupRuns(iter, fRuns, path, raw);
    213218}
    214219
     
    218223// If path==0 the standard path of the data-center is assumed.
    219224// If you have the runs locally use path="."
    220 // Return the number of files added.
    221 //
    222 Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
    223 {
    224     return SetupRuns(iter, fCalRuns, path);
    225 }
     225// Using raw=kTRUE you get correspodning raw-files setup.
     226// Return the number of files added.
     227//
     228Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const
     229{
     230    return SetupRuns(iter, fCalRuns, path, raw);
     231}
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r4729 r4732  
    3636
    3737    void Split(TString &runs, TArrayI &data) const;
    38     Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const;
     38    Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path, Bool_t raw=kFALSE) const;
    3939
    4040public:
     
    5353    Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
    5454
    55     Int_t SetupPedRuns(MDirIter &iter, const char *path=0) const;
    56     Int_t SetupDatRuns(MDirIter &iter, const char *path=0) const;
    57     Int_t SetupAllRuns(MDirIter &iter, const char *path=0) const;
    58     Int_t SetupCalRuns(MDirIter &iter, const char *path=0) const;
     55    Int_t SetupPedRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
     56    Int_t SetupDatRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
     57    Int_t SetupAllRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
     58    Int_t SetupCalRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const;
    5959
    6060    Int_t GetNumAllRuns() const { return fRuns.GetSize(); }
Note: See TracChangeset for help on using the changeset viewer.