Ignore:
Timestamp:
08/24/04 14:51:17 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
4 edited

Legend:

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

    r4695 r4722  
    186186    : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fTimeExtractor(NULL),
    187187      fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay),
    188       fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE)
     188      fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE), fOverwrite(kFALSE)
    189189{
    190190
     
    12471247}
    12481248
     1249// --------------------------------------------------------------------------
     1250//
     1251// MJCalibration allows to setup several option by a resource file:
     1252//   MJCalibration.OutputPath: path
     1253//   MJCalibration.InputPath: path
     1254//   MJCalibration.Display: full, datacheck, normal
     1255//   MJCalibration.RelTimeCalibration: yes,no
     1256//   MJCalibration.Datacheck: yes,no
     1257//   MJCalibration.Debug: yes,no
     1258//   MJCalibration.UseBlindPixel: yes,no
     1259//   MJCalibration.UsePINDiode: yes,no
     1260//
     1261// For more details see the class description and the corresponding Getters
     1262//
    12491263void MJCalibration::CheckEnv()
    12501264{
     
    12771291    SetUseBlindPixel(fEnv->GetValue("MJCalibration.UseBlindPixel", IsUseBlindPixel()));
    12781292    SetUsePINDiode(fEnv->GetValue("MJCalibration.UsePINDiode", IsUsePINDiode()));
     1293
     1294    SetOverwrite(fEnv->GetValue("MJPedestal.AllowOverwrite", fOverwrite));
     1295    SetInputPath(fEnv->GetValue("MJPedestal.InputPath", fInputPath));
    12791296}
    12801297
     
    14151432    MDirIter iter;
    14161433    if (fSequence)
    1417         fSequence->SetupCalRuns(iter);
     1434    {
     1435        if (fSequence->SetupCalRuns(iter, fInputPath)==0)
     1436        {
     1437            *fLog << err << "ERROR - No input files of sequence found!" << endl;
     1438            return kFALSE;
     1439        }
     1440    }
    14181441
    14191442    if (fDataCheck)
     
    16661689// --------------------------------------------------------------------------
    16671690//
     1691// Set the path from which the sequence files are read
     1692//
     1693void MJCalibration::SetInputPath(const char *path)
     1694{
     1695    fInputPath = path;
     1696    if (fInputPath.EndsWith("/"))
     1697        fInputPath = fInputPath(0, fInputPath.Length()-1);
     1698}
     1699
     1700// --------------------------------------------------------------------------
     1701//
    16681702// Set the useage of the Blind Pixel device
    16691703//
     
    17021736    *fLog << inf << "Writing to file: " << oname << endl;
    17031737
    1704     TFile file(oname, "RECREATE");
     1738    TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCalibration", 9);
     1739    if (!file.IsOpen())
     1740    {
     1741        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
     1742        return kFALSE;
     1743    }
    17051744
    17061745    *fLog << inf << " - MStatusDisplay..." << flush;
  • trunk/MagicSoft/Mars/mjobs/MJPedestal.cc

    r4695 r4722  
    9191MJPedestal::MJPedestal(const char *name, const char *title)
    9292    : fEnv(0), fRuns(0), fSequence(0), fExtractor(NULL), fDisplayType(kNormalDisplay),
    93       fDataCheck(kFALSE), fUseData(kFALSE), fMaxEvents(0)
     93      fDataCheck(kFALSE), fUseData(kFALSE), fOverwrite(kFALSE), fMaxEvents(0)
    9494{
    9595    fName  = name  ? name  : "MJPedestal";
     
    451451    *fLog << inf << "Writing to file: " << oname << endl;
    452452
    453     TFile file(oname, "RECREATE");
     453    TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJPedestal", 9);
     454    if (!file.IsOpen())
     455    {
     456        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
     457        return kFALSE;
     458    }
    454459
    455460    if (fDisplay && fDisplay->Write()<=0)
     
    481486}
    482487
     488// --------------------------------------------------------------------------
     489//
     490// Set the path from which the sequence files are read
     491//
     492void MJPedestal::SetInputPath(const char *path)
     493{
     494    fInputPath = path;
     495    if (fInputPath.EndsWith("/"))
     496        fInputPath = fInputPath(0, fInputPath.Length()-1);
     497}
     498
    483499void MJPedestal::SetEnv(const char *env)
    484500{
     
    496512}
    497513
     514// --------------------------------------------------------------------------
     515//
     516// MJPedestsl allows to setup several option by a resource file:
     517//   MJPedestal.OutputPath: path
     518//   MJPedestal.MaxEvents: 1000
     519//   MJPedestal.AllowOverwrite: yes, no
     520//   MJPedestal.UseData: yes, no (use DatRuns from sequence instead of PedRuns)
     521//
     522// For more details see the class description and the corresponding Getters
     523//
    498524void MJPedestal::CheckEnv()
    499525{
     
    508534    }
    509535
    510     fMaxEvents = fEnv->GetValue("MJPedestal.MaxEvents", fMaxEvents);
    511     fUseData   = fEnv->GetValue("MJPedestal.UseData",   fUseData);
     536    SetMaxEvents(fEnv->GetValue("MJPedestal.MaxEvents", fMaxEvents));
     537    SetOverwrite(fEnv->GetValue("MJPedestal.AllowOverwrite", fOverwrite));
     538
     539    fUseData = fEnv->GetValue("MJPedestal.UseData", fUseData);
    512540}
    513541
     
    548576    MDirIter iter;
    549577    if (fSequence)
    550         fUseData ? fSequence->SetupDatRuns(iter) : fSequence->SetupPedRuns(iter);
     578    {
     579        const Int_t n = fUseData ? fSequence->SetupDatRuns(iter, fInputPath) : fSequence->SetupPedRuns(iter, fInputPath);
     580        if (n==0)
     581        {
     582            *fLog << err << "ERROR - No input files of sequence found!" << endl;
     583            return kFALSE;
     584        }
     585    }
    551586
    552587    if (fDataCheck)
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r4695 r4722  
    2727//  MSequence
    2828//
     29//  This class describes a sequence. For sequences see:
     30//    http://magic.astro.uni-wuerzburg.de/mars/db/queryseq.html
     31//
     32//  A sequence is a collection of runs which should be used together.
     33//
    2934/////////////////////////////////////////////////////////////////////////////
    3035#include "MSequence.h"
     
    3439#include <TEnv.h>
    3540#include <TRegexp.h>
     41#include <TSystem.h> // TSystem::ExpandPath
    3642
    3743#include "MLog.h"
     
    4450using namespace std;
    4551
     52// --------------------------------------------------------------------------
     53//
     54// Copy the run numbers from the TString runs into the TArrayI data
     55//
    4656void MSequence::Split(TString &runs, TArrayI &data) const
    4757{
     
    6373}
    6474
    65 void MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const
     75Int_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const
    6676{
    6777    TString d(path);
    6878
    6979    // Setup path
    70     if (!path)
     80    if (d.IsNull())
    7181    {
    7282        d  = Form("/data/MAGIC/Period%03d/rootdata/", fPeriod);
    7383        d += fNight.GetStringFmt("%Y_%m_%d");
    7484    }
     85
     86    Int_t num = 0;
    7587
    7688    for (int i=0; i<arr.GetSize(); i++)
     
    8395
    8496        // Add Path/File to TIter
    85         iter.AddDirectory(d, n, 0);
    86     }
    87 }
    88 
     97        num += iter.AddDirectory(d, n, 0);
     98    }
     99    return num;
     100}
     101
     102// --------------------------------------------------------------------------
     103//
     104// Read the file fname as setup file for the sequence.
     105//
    89106MSequence::MSequence(const char *fname)
    90107{
     
    96113    TString str;
    97114
    98     fSequence  = env.GetValue("Sequence", -1);
    99     fLastRun   = env.GetValue("LastRun", -1);
     115    fSequence  = env.GetValue("Sequence",  -1);
     116    fLastRun   = env.GetValue("LastRun",   -1);
    100117    fNumEvents = env.GetValue("NumEvents", -1);
    101     fPeriod    = env.GetValue("Period", -1);
     118    fPeriod    = env.GetValue("Period",    -1);
    102119
    103120    str = env.GetValue("Start", "");
     
    122139}
    123140
     141// --------------------------------------------------------------------------
     142//
     143// Print the contents of the sequence
     144//
    124145void MSequence::Print(Option_t *o) const
    125146{
    126147    gLog << all;
     148    if (!IsValid())
     149    {
     150        gLog << "Sequence: " << fName << " <invalid>" << endl;
     151        return;
     152    }
    127153    gLog << "Sequence:     " << fSequence << endl;
    128154    gLog << "Period:       " << fPeriod << endl;
     
    153179}
    154180
    155 void MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
    156 {
    157     SetupRuns(iter, fPedRuns, path);
    158 }
    159 
    160 void MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
    161 {
    162     SetupRuns(iter, fDatRuns, path);
    163 }
    164 
    165 void MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
    166 {
    167     SetupRuns(iter, fRuns, path);
    168 }
    169 
    170 void MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
    171 {
    172     SetupRuns(iter, fCalRuns, path);
    173 }
     181// --------------------------------------------------------------------------
     182//
     183// Add all ped runs from the sequence to MDirIter.
     184// If path==0 the standard path of the data-center is assumed.
     185// If you have the runs locally use path="."
     186// Return the number of files added.
     187//
     188Int_t MSequence::SetupPedRuns(MDirIter &iter, const char *path) const
     189{
     190    return SetupRuns(iter, fPedRuns, path);
     191}
     192
     193// --------------------------------------------------------------------------
     194//
     195// Add all data runs from the sequence to MDirIter.
     196// If path==0 the standard path of the data-center is assumed.
     197// If you have the runs locally use path="."
     198// Return the number of files added.
     199//
     200Int_t MSequence::SetupDatRuns(MDirIter &iter, const char *path) const
     201{
     202    return SetupRuns(iter, fDatRuns, path);
     203}
     204
     205// --------------------------------------------------------------------------
     206//
     207// Add all runs from the sequence to MDirIter.
     208// If path==0 the standard path of the data-center is assumed.
     209// If you have the runs locally use path="."
     210// Return the number of files added.
     211//
     212Int_t MSequence::SetupAllRuns(MDirIter &iter, const char *path) const
     213{
     214    return SetupRuns(iter, fRuns, path);
     215}
     216
     217// --------------------------------------------------------------------------
     218//
     219// Add all calibration runs from the sequence to MDirIter.
     220// If path==0 the standard path of the data-center is assumed.
     221// If you have the runs locally use path="."
     222// Return the number of files added.
     223//
     224Int_t MSequence::SetupCalRuns(MDirIter &iter, const char *path) const
     225{
     226    return SetupRuns(iter, fCalRuns, path);
     227}
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r4716 r4722  
    3636
    3737    void Split(TString &runs, TArrayI &data) const;
    38     void SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const;
     38    Int_t SetupRuns(MDirIter &iter, const TArrayI &arr, const char *path) const;
    3939
    4040public:
     
    4545    Bool_t IsValid() const { return fSequence!=(UInt_t)-1; }
    4646
    47     void SetupPedRuns(MDirIter &iter, const char *path=0) const;
    48     void SetupDatRuns(MDirIter &iter, const char *path=0) const;
    49     void SetupAllRuns(MDirIter &iter, const char *path=0) const;
    50     void SetupCalRuns(MDirIter &iter, const char *path=0) const;
     47    Int_t SetupPedRuns(MDirIter &iter, const char *path=0) const;
     48    Int_t SetupDatRuns(MDirIter &iter, const char *path=0) const;
     49    Int_t SetupAllRuns(MDirIter &iter, const char *path=0) const;
     50    Int_t SetupCalRuns(MDirIter &iter, const char *path=0) const;
    5151
    5252    // Getter
Note: See TracChangeset for help on using the changeset viewer.