Ignore:
Timestamp:
04/18/05 10:35:54 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r6948 r6949  
    4545
    4646#include "MReadReports.h"
     47#include "MReadMarsFile.h"
    4748#include "MPrint.h"
    4849#include "MContinue.h"
     
    7475MJCut::MJCut(const char *name, const char *title)
    7576    : fStoreSummary(kFALSE), fStoreResult(kFALSE), fWriteOnly(kFALSE),
    76     fIsWobble(kFALSE), fFullDisplay(kFALSE), /*fSubstraction(kFALSE),*/
     77    fIsWobble(kFALSE), fIsMonteCarlo(kFALSE),  fFullDisplay(kFALSE), /*fSubstraction(kFALSE),*/
    7778    fEstimateEnergy(0), fCalcHadronness(0)
    7879{
     
    181182        return kFALSE;
    182183    }
    183     env1 = o ? (MTask*)o->Clone() : NULL;
     184    env1 = o ? (MTask*)o->Clone() : FNULL;
    184185
    185186    o = file.Get("CalcHadronness");
     
    212213    *fLog << inf << "Writing to file: " << oname << endl;
    213214
    214     TFile file(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCut", 9);
    215     if (!file.IsOpen())
     215    TFile *file = 0;
     216    if (fNameResult.IsNull())
     217    {
     218        file = (TFile*)gROOT->GetListOfFiles()->FindObject(oname);
     219        if (file)
     220            file->cd();
     221    }
     222    else
     223        file = TFile::Open(oname, fOverwrite?"RECREATE":"NEW", "File created by MJCut", 9);
     224
     225    if (!file)
    216226    {
    217227        *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl;
     
    219229    }
    220230
    221     return WriteContainer(cont);
     231    const Bool_t rc = WriteContainer(cont);
     232
     233    if (!fNameResult.IsNull())
     234        delete file;
     235
     236    return rc;
    222237}
    223238
     
    260275    EnableStorageOfResult(GetEnv("ResultFile", fStoreResult));
    261276    EnableWobbleMode(GetEnv("WobbleMode", fIsWobble));
     277    EnableMonteCarloMode(GetEnv("MonteCarlo", fIsMonteCarlo));
    262278    EnableFullDisplay(GetEnv("FullDisplay", fFullDisplay));
    263279    //EnableSubstraction(GetEnv("HistogramSubstraction", fSubstraction));
     
    292308    write->AddContainer("MHadronness",    "Events", kFALSE);
    293309    write->AddContainer("MEnergyEst",     "Events", kFALSE);
     310    write->AddContainer("MMcEvt",         "Events", kFALSE);
    294311    write->AddContainer("DataType",       "Events");
    295312
     
    398415
    399416    // ------------- Loop Off Data --------------------
    400     MReadReports readoff;
    401     readoff.AddTree("Events", "MTime.", kTRUE);
    402     readoff.AddTree("Drive");
    403     readoff.AddTree("EffectiveOnTime");
     417    MReadReports readoffdata;
     418    readoffdata.AddTree("Events", "MTime.", kTRUE);
     419    readoffdata.AddTree("Drive");
     420    readoffdata.AddTree("EffectiveOnTime");
     421
     422    MReadMarsFile readoffmc("Events");
     423    readoffmc.DisableAutoScheme();
     424
     425    MRead &readoff = fIsMonteCarlo ? (MRead&)readoffmc : (MRead&)readoffdata;
    404426    if (fIsWobble)
    405427        set.AddFilesOn(readoff);
     
    411433    TString fname1(path);
    412434    fname0 += fNameSummary.IsNull() ?  (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary;
    413     fname1 += fNameResult.IsNull()  ?  (TString) Form("ganymed%08d-result.root",  set.GetNumAnalysis()) : fNameResult;
     435    fname1 += fNameResult.IsNull()  ?  (TString) Form("ganymed%08d.root",         set.GetNumAnalysis()) : fNameResult;
    414436
    415437    MWriteRootFile *write0 = CanStoreSummary() ? new MWriteRootFile(fPathOut.IsNull()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW") : 0;
     
    443465
    444466    MPrint print2("MEffectiveOnTime");
     467    print2.EnableSkip();
    445468
    446469    // How to get source position from off- and on-data?
     
    460483    if (fIsWobble)
    461484        tlist2.AddToList(&hcalc2);
    462     tlist2.AddToList(&taskenv1);
    463485    tlist2.AddToList(&taskenv2);
    464486    tlist2.AddToList(&cont0);
     
    468490        tlist2.AddToList(&fill1a);
    469491    tlist2.AddToList(&cont1);
     492    tlist2.AddToList(&taskenv1);
    470493    if (!fWriteOnly && !fIsWobble)
    471494        tlist2.AddToList(&ffs);
     
    503526        return kFALSE;
    504527
     528    TObjArray cont;
     529    cont.Add(&fit);
     530    cont.Add(&cont0);
     531    cont.Add(&cont1);
     532    cont.Add(&cont2);
     533    cont.Add(&cont3);
     534    if (taskenv1.GetTask())
     535        cont.Add(taskenv1.GetTask());
     536    if (taskenv2.GetTask())
     537        cont.Add(taskenv2.GetTask());
     538
     539    if (!WriteTasks(set.GetNumAnalysis(), cont))
     540        return kFALSE;
     541
    505542    if (set.HasOffSequences() || fIsWobble)
    506543    {
     
    524561
    525562    // ------------- Loop On Data --------------------
    526     MReadReports readon;
    527     readon.AddTree("Events", "MTime.", kTRUE);
    528     readon.AddTree("Drive");
    529     readon.AddTree("EffectiveOnTime");
     563    MReadReports readondata;
     564    readondata.AddTree("Events", "MTime.", kTRUE);
     565    readondata.AddTree("Drive");
     566    readondata.AddTree("EffectiveOnTime");
     567
     568    MReadMarsFile readonmc("Events");
     569    readonmc.DisableAutoScheme();
     570
     571    MRead &readon = fIsMonteCarlo ? (MRead&)readonmc : (MRead&)readondata;
    530572    set.AddFilesOn(readon);
    531573
     
    614656            tlist2.Replace(&ffs2);
    615657
    616         tlist.AddToList(&fillvs, "EffectiveOnTime");
     658        if (!fIsMonteCarlo)
     659            tlist.AddToList(&fillvs, "EffectiveOnTime");
    617660    }
    618661
    619662    par.SetVal(1);
    620 
    621     TObjArray cont;
    622     cont.Add(&cont0);
    623     cont.Add(&cont1);
    624     cont.Add(&cont2);
    625     cont.Add(&cont3);
    626     if (taskenv1.GetTask())
    627         cont.Add(taskenv1.GetTask());
    628     if (taskenv2.GetTask())
    629         cont.Add(taskenv2.GetTask());
    630 
    631     if (!WriteTasks(set.GetNumAnalysis(), cont))
    632         return kFALSE;
    633663
    634664    // Execute first analysis
Note: See TracChangeset for help on using the changeset viewer.