Ignore:
Timestamp:
08/25/04 13:20:16 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r4723 r4729  
    9090//
    9191MJPedestal::MJPedestal(const char *name, const char *title)
    92     : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
    93       fDataCheck(kFALSE), fUseData(kFALSE), fOverwrite(kFALSE), fMaxEvents(0)
     92    : fRuns(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
     93      fDataCheck(kFALSE), fUseData(kFALSE)
    9494{
    9595    fName  = name  ? name  : "MJPedestal";
     
    9797}
    9898
    99 MJPedestal::~MJPedestal()
    100 {
    101     if (fEnv)
    102         delete fEnv;
    103 }
    104 
    10599const char* MJPedestal::GetOutputFile() const
    106100{
    107     if (fSequence)
    108         return Form("%s/calped%06d.root", (const char*)fOutputPath, fSequence->GetSequence());
     101    if (fSequence.IsValid())
     102        return Form("%s/calped%06d.root", (const char*)fPathOut, fSequence.GetSequence());
    109103
    110104    if (!fRuns)
    111105        return "";
    112106
    113     return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
     107    return Form("%s/%s-F0.root", (const char*)fPathOut, (const char*)fRuns->GetRunsAsFileName());
    114108}
    115109
     
    160154    TString title = fDisplay->GetTitle();
    161155    title += "--  Pedestal ";
    162     if (fSequence)
    163         title += fSequence->GetName();
     156    if (fSequence.IsValid())
     157        title += fSequence.GetName();
    164158    else
    165159        if (fRuns)  // FIXME: What to do if an environmentfile was used?
     
    468462Bool_t MJPedestal::WriteResult()
    469463{
    470     if (fOutputPath.IsNull())
     464    if (fPathOut.IsNull())
    471465        return kTRUE;
    472466
     
    503497}
    504498
    505 void MJPedestal::SetOutputPath(const char *path)
    506 {
    507     fOutputPath = path;
    508     if (fOutputPath.EndsWith("/"))
    509         fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
    510 }
    511 
    512 // --------------------------------------------------------------------------
    513 //
    514 // Set the path from which the sequence files are read
    515 //
    516 void MJPedestal::SetInputPath(const char *path)
    517 {
    518     fInputPath = path;
    519     if (fInputPath.EndsWith("/"))
    520         fInputPath = fInputPath(0, fInputPath.Length()-1);
    521 }
    522 
    523 void MJPedestal::SetEnv(const char *env)
    524 {
    525     if (fEnv)
    526         delete fEnv;
    527     fEnv = new TEnv(env);
    528 }
    529 
    530499Bool_t MJPedestal::Process()
    531500{
     
    536505}
    537506
    538 // --------------------------------------------------------------------------
    539 //
    540 // MJPedestsl allows to setup several option by a resource file:
    541 //   MJPedestal.OutputPath: path
    542 //   MJPedestal.MaxEvents: 1000
    543 //   MJPedestal.AllowOverwrite: yes, no
    544 //   MJPedestal.UseData: yes, no (use DatRuns from sequence instead of PedRuns)
    545 //
    546 // For more details see the class description and the corresponding Getters
    547 //
    548 void MJPedestal::CheckEnv()
    549 {
    550     if (!fEnv)
    551         return;
    552 
    553     TString e1 = fEnv->GetValue(Form("%s.OutputPath", fName.Data()), "");
    554     if (!e1.IsNull())
    555     {
    556         e1.ReplaceAll("\015", "");
    557         SetOutputPath(e1);
    558     }
    559 
    560     SetMaxEvents(fEnv->GetValue(Form("%s.MaxEvents", fName.Data()), fMaxEvents));
    561     SetOverwrite(fEnv->GetValue(Form("%s.AllowOverwrite", fName.Data()), fOverwrite));
    562 
    563     fUseData = fEnv->GetValue(Form("%s.UseData", fName.Data()), fUseData);
    564 }
    565 
    566507Bool_t MJPedestal::ProcessFile()
    567508{
    568     if (!fRuns && !fEnv && !fSequence)
    569     {
    570         *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl;
    571         return kFALSE;
    572     }
    573     if (!fSequence && fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
    574     {
    575         *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
    576         return kFALSE;
    577     }
     509    if (!fSequence.IsValid())
     510    {
     511        if (!fRuns)
     512        {
     513            *fLog << err << "Neither AddRuns nor SetSequence nor SetEnv was called... abort." << endl;
     514            return kFALSE;
     515        }
     516        if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
     517        {
     518            *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
     519            return kFALSE;
     520        }
     521    }
     522
     523    //if (!CheckEnv())
     524    //    return kFALSE;
     525
     526    CheckEnv();
     527
     528    // --------------------------------------------------------------------------------
    578529
    579530    *fLog << inf;
    580531    fLog->Separator(GetDescriptor());
    581532    *fLog << "Calculate MPedestalCam from Runs ";
    582     if (fSequence)
    583         *fLog << fSequence->GetName() << endl;
     533    if (fSequence.IsValid())
     534        *fLog << fSequence.GetName() << endl;
    584535    else
    585536        if (fRuns)
    586537            *fLog << fRuns->GetRunsAsString() << endl;
    587538        else
    588             *fLog << "in " << fEnv->GetName() << endl;
     539            *fLog << "in Resource File." << endl;
    589540    *fLog << endl;
    590541
    591     CheckEnv();
     542    // --------------------------------------------------------------------------------
    592543
    593544    MParList  plist;
     
    600551
    601552    MDirIter iter;
    602     if (fSequence)
    603     {
    604         const Int_t n = fUseData ? fSequence->SetupDatRuns(iter, fInputPath) : fSequence->SetupPedRuns(iter, fInputPath);
    605         if (n==0)
     553    if (fSequence.IsValid())
     554    {
     555        const Int_t n0 = fUseData ? fSequence.SetupDatRuns(iter, fPathData) : fSequence.SetupPedRuns(iter, fPathData);
     556        const Int_t n1 = fUseData ? fSequence.GetNumDatRuns() : fSequence.GetNumPedRuns();
     557        if (n0==0)
    606558        {
    607559            *fLog << err << "ERROR - No input files of sequence found!" << endl;
    608560            return kFALSE;
    609561        }
     562        if (n0!=n1)
     563        {
     564            *fLog << err << "ERROR - Number of files found (" << n0 << ") doesn't match number of files in sequence (" << n1 << ")" << endl;
     565            return kFALSE;
     566        }
    610567    }
    611568
    612569    if (fDataCheck)
    613570    {
    614         if (fRuns || fSequence)
    615             rawread.AddFiles(fSequence ? iter : *fRuns);
     571        if (fRuns || fSequence.IsValid())
     572            rawread.AddFiles(fSequence.IsValid() ? iter : *fRuns);
    616573        tlist.AddToList(&rawread);
    617574    }
     
    619576    {
    620577        read.DisableAutoScheme();
    621         if (fRuns || fSequence)
    622             read.AddFiles(fSequence ? iter : *fRuns);
     578        if (fRuns || fSequence.IsValid())
     579            read.AddFiles(fSequence.IsValid() ? iter : *fRuns);
    623580        tlist.AddToList(&read);
    624581    }
    625     // Enable logging to file
    626     //*fLog.SetOutputFile(lname, kTRUE);
    627582
    628583    // Setup Tasklist
     
    662617    evtloop.SetDisplay(fDisplay);
    663618    evtloop.SetLogStream(fLog);
    664     if (fEnv)
    665         evtloop.ReadEnv(*fEnv);
     619    if (GetEnv())
     620        evtloop.ReadEnv(*GetEnv());
    666621
    667622    //    if (!WriteEventloop(evtloop))
Note: See TracChangeset for help on using the changeset viewer.