Ignore:
Timestamp:
05/10/09 11:52:17 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mjobs
Files:
4 edited

Legend:

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

    r9428 r9441  
    6262
    6363#include "MArgs.h"
    64 //#include "MDirIter.h"
     64#include "MDirIter.h"
    6565#include "MParList.h"
    6666#include "MTaskList.h"
     
    126126//
    127127MJSimulation::MJSimulation(const char *name, const char *title)
    128     : fForceMode(kFALSE), fCamera(kTRUE) ,fForceTrigger(kFALSE)
     128    : fForceMode(kFALSE), fCamera(kTRUE), fForceTrigger(kFALSE),
     129    fOperationMode(kModeData)
    129130{
    130131    fName  = name  ? name  : "MJSimulation";
     
    140141    return kTRUE;
    141142}
    142 
    143 Bool_t MJSimulation::WriteResult(const MParList &plist)
     143/*
     144TString MJSimulation::GetOutFile(const MSequence &seq) const
     145{
     146    return seq.IsValid() ? Form("ceres%08d.root", seq.GetSequence()) : "ceres.root";
     147}
     148*/
     149
     150Bool_t MJSimulation::WriteResult(const MParList &plist, const MSequence &seq)
    144151{
    145152    if (fPathOut.IsNull())
     
    151158    TObjArray cont;
    152159    cont.Add(const_cast<TEnv*>(GetEnv()));
    153     //cont.Add(const_cast<MSequence*>(&fSequence));
     160    if (seq.IsValid())
     161        cont.Add(const_cast<MSequence*>(&seq));
    154162
    155163    cont.Add(plist.FindObject("PulseShape"));
     
    160168    if (fDisplay)
    161169    {
    162 //        TString title = "--  Reflector: ";
    163 //        title += fSequence.GetSequence();
    164 //        title += "  --";
    165 //        fDisplay->SetTitle(title, kFALSE);
     170        TString title = "--  Ceres";
     171        if (seq.IsValid())
     172        {
     173            title += ": ";
     174            title += seq.GetSequence();
     175        }
     176        title += "  --";
    166177        fDisplay->SetTitle("Ceres", kFALSE);
    167178
     
    169180    }
    170181
    171 //    const TString oname = Form("reflector%08d.root", fSequence.GetSequence());
    172     const TString oname = "ceres.root";
    173     return WriteContainer(cont, oname, "RECREATE");
     182    const TString name = seq.IsValid() ? Form("ceres%08d.root", seq.GetSequence()) : "ceres.root";
     183    return WriteContainer(cont, name, "RECREATE");
    174184}
    175185
     
    235245}
    236246
    237 Bool_t MJSimulation::Process(const MArgs &args)
     247Bool_t MJSimulation::Process(const MArgs &args, const MSequence &seq)
    238248{
    239249    /*
     
    245255    */
    246256
    247     //if (!HasWritePermission(GetPathOut()))
    248     //    return kFALSE;
     257//    if (!HasWritePermission(CombinePath(fPathOut, GetOutFile(seq))))
     258//        return kFALSE;
    249259
    250260    *fLog << inf;
     
    254264        return kFALSE;
    255265
    256     *fLog << warn << "FIXME: Monte Carlo simulation: Sequences not supported yet.";
    257     //*fLog << fSequence.GetFileName() << endl;
     266    if (seq.IsValid())
     267        *fLog << fSequence.GetFileName() << endl;
     268    else
     269        *fLog << args.GetNumArguments() << "-files" << endl;
    258270    *fLog << endl;
    259271
     272    MDirIter iter;
     273    if (seq.IsValid() && seq.GetRuns(iter, MSequence::kCorsika)<=0)
     274    {
     275        *fLog << err << "ERROR - Sequence valid but without files." << endl;
     276        return kFALSE;
     277    }
     278
    260279    // --------------------------------------------------------------------------------
    261 
    262     //MDirIter iter;
    263     //if (fSequence.GetRuns(iter, MSequence::kCalibrated)<=0)
    264     //    return kFALSE;
    265280
    266281    // Setup Parlist
     
    297312    //header.InitFadcType(3);
    298313
    299     header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData);
    300     if (args.GetNumArguments()==1)
    301     {
    302         if (!args.GetArgumentStr(0).CompareTo("pedestal", TString::kIgnoreCase))
    303         {
    304             header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal);
    305             header.SetSourceInfo("Pedestal");
    306         }
    307         if (!args.GetArgumentStr(0).CompareTo("calibration", TString::kIgnoreCase))
    308         {
    309             header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration);
    310             header.SetSourceInfo("Calibration");
    311         }
    312         if (!args.GetArgumentStr(0).CompareTo("pointrun", TString::kIgnoreCase))
    313             header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun);
     314    switch (fOperationMode)
     315    {
     316    case kModeData:
     317        header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData);
     318        break;
     319
     320    case kModePed:
     321        header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal);
     322        header.SetSourceInfo("Pedestal");
     323        break;
     324
     325    case kModeCal:
     326        header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration);
     327        header.SetSourceInfo("Calibration");
     328        break;
     329
     330    case kModePointRun:
     331        header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun);
     332        break;
    314333    }
    315334
     
    333352    read.SetForceMode(fForceMode);
    334353
    335     for (int i=0; i<args.GetNumArguments(); i++)
    336         read.AddFile(args.GetArgumentStr(i));
     354    if (!seq.IsValid())
     355    {
     356        for (int i=0; i<args.GetNumArguments(); i++)
     357            read.AddFile(args.GetArgumentStr(i));
     358    }
     359    else
     360        read.AddFiles(iter);
    337361
    338362    MSimMMCS simmmcs;
     
    366390    // -------------------------------------------------------------------
    367391
    368     MBinning binse( 100,     1,   100000, "BinningEnergy",    "log");
    369     MBinning binsth( 70,   0.9,   900000, "BinningThreshold", "log");
    370     MBinning binsee( 35,   0.9,   900000, "BinningEnergyEst", "log");
     392    MBinning binse( 120,     1,  1000000, "BinningEnergy",    "log");
     393    MBinning binsth( 60,   0.9,   900000, "BinningThreshold", "log");
     394    MBinning binsee( 36,   0.9,   900000, "BinningEnergyEst", "log");
    371395    MBinning binss( 100,     1, 10000000, "BinningSize",      "log");
    372396//    MBinning binsi( 100,  -500,      500, "BinningImpact");
    373     MBinning binsi(  55,     0,     1100, "BinningImpact");
     397    MBinning binsi(  32,     0,      800, "BinningImpact");
    374398    MBinning binsh( 150,     0,       50, "BinningHeight");
    375399    MBinning binsaz(720,  -360,      360, "BinningAz");
    376400    MBinning binszd( 70,     0,       70, "BinningZd");
    377     MBinning binsvc( 45,     0,        9, "BinningViewCone");
     401    MBinning binsvc( 35,     0,        7, "BinningViewCone");
    378402    MBinning binsel(150,     0,       50, "BinningTotLength");
    379403    MBinning binsew(150,     0,       15, "BinningMedLength");
     
    845869    //-------------------------------------------
    846870
    847     if (!WriteResult(plist))
     871    if (!WriteResult(plist, seq))
    848872        return kFALSE;
    849873
  • trunk/MagicSoft/Mars/mjobs/MJSimulation.h

    r9343 r9441  
    99class MArgs;
    1010class MParList;
     11class MSequence;
    1112class MWriteRootFile;
    1213
    1314class MJSimulation : public MJob
    1415{
     16public:
     17    enum Mode_t { kModeData, kModePed, kModeCal, kModePointRun };
     18
    1519private:
    1620    Bool_t fForceMode;      // Force execution even if RUNE-section was not foundm
     
    1923    Bool_t fForceTrigger;   // Force the use of the trigger "electronics"
    2024
    21     Bool_t WriteResult(const MParList &plist);
     25    Int_t fOperationMode;   // Operation mode (data, ped, cal, pointrun)
     26
     27    Bool_t WriteResult(const MParList &plist, const MSequence &seq);
    2228    Bool_t CheckEnvLocal();
    2329
     
    3036    void SetForceMode(Bool_t force=kTRUE) { fForceMode = force; }
    3137
     38    void SetMode(Int_t mode) { fOperationMode = mode; }
     39
    3240    // Process
    33     Bool_t Process(const MArgs &args);
     41    Bool_t Process(const MArgs &args, const MSequence &seq);
    3442
    3543    ClassDef(MJSimulation, 0) // Job to run the simulation (ceres)
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r9333 r9441  
    447447TString MSequence::InflateFileName(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type)
    448448{
     449    if (!night && type==kCorsika)
     450        return MString::Format("cer%06d", -run);
     451
    449452    const char *id="_";
    450453    switch ((RunType_t)(type&kRunType))
     
    711714    const TArrayI *r=0, *f=0;
    712715    GetArrays(r, f, type);
    713     return GetRuns(iter, *r, *f, type, path);
     716    return r==0 ? 0 : GetRuns(iter, *r, *f, type, path);
    714717}
    715718
     
    859862    const Bool_t rc = !fDataPath.IsNull() && gSystem->AccessPathName(fDataPath, kFileExists);
    860863    if (rc)
    861         gLog << err << "ERROR - Directory '" << path << "' doesn't exist." << endl;
     864        gLog << err << "ERROR - Directory '" << fDataPath << "' doesn't exist." << endl;
    862865
    863866    return !rc;
     
    942945//
    943946MSequence::MSequence(const char *fname, const char *path, UInt_t seq)
    944 {
     947   : fTelescope(1), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
     948     fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA),
     949     fMonteCarlo(kFALSE)
     950{
     951    fName  = "MSequence";
     952    fTitle = "Sequence file";
     953
     954    if (TString(fname).IsNull() && TString(path).IsNull() && seq==(UInt_t)-1)
     955        return;
     956
    945957    // regular expression to distinguish beween a mysql-path and
    946958    // a filename from where the sequence should be retrieved
     
    951963    const Bool_t rc1 = db.IsNull() ? ReadFile(fname, seq) : ReadDatabase(fname, seq);
    952964    const Bool_t rc2 = SetDataPath(path);
    953 
    954     fName  = "MSequence";
    955     fTitle = "Sequence file";
    956965
    957966    if (!rc1 || !rc2)
     
    13531362        out << pre << "Night:          " << fNight.GetStringFmt("%Y-%m-%d") << endl;
    13541363    out << endl;
    1355     out << pre << "LightCondition: ";
    1356     switch (fLightCondition)
    1357     {
    1358     case kNA:       out << "n/a" << endl;      break;
    1359     case kNoMoon:   out << "NoMoon" << endl;   break;
    1360     case kTwilight: out << "Twilight" << endl; break;
    1361     case kMoon:     out << "Moon" << endl;     break;
    1362     case kDay:      out << "Day" << endl;      break;
     1364    if (fLightCondition!=kNA)
     1365    {
     1366        out << pre << "LightCondition: ";
     1367        switch (fLightCondition)
     1368        {
     1369        case kNA:       out << "n/a" << endl;      break;
     1370        case kNoMoon:   out << "NoMoon" << endl;   break;
     1371        case kTwilight: out << "Twilight" << endl; break;
     1372        case kMoon:     out << "Moon" << endl;     break;
     1373        case kDay:      out << "Day" << endl;      break;
     1374        }
    13631375    }
    13641376
    13651377    if (fStart!=MTime())
    13661378        out << pre << "Start:          " << fStart.GetSqlDateTime() << endl;
    1367     if (fLastRun>=0)
     1379    if (fLastRun!=(UInt_t)-1)
    13681380        out << pre << "LastRun:        " << fLastRun << endl;
    1369     if (fNumEvents>=0)
     1381    if (fNumEvents!=(UInt_t)-1)
    13701382        out << pre << "NumEvents:      " << fNumEvents << endl;
    13711383    if (!fProject.IsNull())
  • trunk/MagicSoft/Mars/mjobs/MSequence.h

    r9039 r9441  
    2323        kRoot  =BIT(1),
    2424        kReport=BIT(2),
     25        kCer   =BIT(3),  // Corsika files
    2526    };
    2627    enum RunType_t {
    27         kPed   =BIT(3),
    28         kCal   =BIT(4),
    29         kDat   =BIT(5),
    30         kExcl  =BIT(6),
     28        kPed   =BIT(4),  // Don't use overlapping bits!
     29        kCal   =BIT(5),
     30        kDat   =BIT(6),
     31        kExcl  =BIT(7),
    3132        kAll   =kPed|kDat|kCal,
    32         kImage =BIT(7),
    33         kCalib =BIT(8)
     33        kImage =BIT(8),
     34        kCalib =BIT(9)
    3435    };
    3536
    3637    enum { kRunType   = kPed|kCal|kDat|kImage|kCalib };
    37     enum { kFileType  = kRaw|kRoot|kReport };
     38    enum { kFileType  = kRaw|kRoot|kReport|kCer };
    3839    enum { kFilePaths = kFileType|kImage|kCalib };
    3940
     
    5354        kCalibrated = kRoot  |kCalib,
    5455        kImages     = kRoot  |kImage,
     56        kCorsika    = kCer   |kDat,
    5557    };
    5658
     
    131133
    132134public:
     135/*
    133136    MSequence() : fTelescope(1), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
    134137        fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA), fMonteCarlo(kFALSE)
     
    137140        fTitle = "Sequence file";
    138141    }
    139     MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1);
     142    */
     143    MSequence(const char *fname=0, const char *path=0, UInt_t id=(UInt_t)-1);
    140144    MSequence(const char *fname, UInt_t seq, UShort_t tel=0);
    141145    MSequence(const MSequence &s) : MParContainer(s),
Note: See TracChangeset for help on using the changeset viewer.