Changeset 6949 for trunk/MagicSoft


Ignore:
Timestamp:
04/18/05 10:35:54 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r6948 r6949  
    5454     - fixed a typo in output
    5555     - allow to exchange Test-/Train-Sample
     56
     57   * ganymed.cc:
     58     - implemented "-mc" option to allow cutting MC samples
     59
     60   * showlog.cc:
     61     - implemented real treatment of debug-levels
     62     - return 1 instead of 0 in cae of normal finish
     63
     64   * manalysis/MEnergyEstimate.h, mbase/MContinue.h,
     65     mhflux/MAlphaFitter.h:
     66     - added Print() to context //*MENU*
     67
     68   * manalysis/MMatrixLoop.cc:
     69     - fixed returning of number of entries if using split mode
     70
     71   * mbase/MContinue.cc:
     72     - implemented Print() function
     73
     74   * mbase/MParContainer.[h,cc]:
     75     - in Read set name of object to argument name if argument!=NULL
     76     - reordered some checks for Method calls
     77
     78   * mdata/MDataFormula.cc:
     79     - fixed a problem with the replacement if using [?] for
     80       fits
     81
     82   * mfbase/MFEventSelector2.cc:
     83     - replaced some +=1 and -=1 by ++ and --
     84
     85   * mfileio/MReadMarsFile.cc:
     86     - fixed a bug which caused Preprocess to crahs if instatiated
     87       with default constructor
     88
     89   * mhbase/MH.cc, mhflux/MHEffectiveOnTime.cc:
     90     - use dynamic_cast if getting "stats"
     91
     92   * mhflux/MAlphaFitter.cc:
     93     - small updates to output
     94
     95   * mhflux/MHEnergyEst.cc:
     96     - fixed all axis lables
     97     - implemented fit of resolution
     98     - initialize fBias=0 in SetupFill
     99     - enhances Print() output
     100
     101   * mjobs/MJCalibrateSignal.cc:
     102     - added all tasks for interleaved calibration events to
     103       a third tasklist. Skip all following tasks for these events
     104
     105   * mjobs/MJCut.[h,cc]:
     106     - implemented correct treatment of MC files
     107     - write resulting events to result file if no filename set
     108     - moved energy estimator behind cuts
     109
     110   * mjobs/MJOptimize.cc:
     111     - changed RunEnergy such, that it can correctly treat
     112       MC files written by ganymed using wobble-mode
    56113
    57114
  • trunk/MagicSoft/Mars/NEWS

    r6948 r6949  
    11                                                               -*-*- END -*-*-
    22 *** Version <cvs>
     3
     4   - Do NOT further process interleaved calibration events in
     5     MJCalibrateSignal - exspecially do not write them to output!
    36
    47
  • trunk/MagicSoft/Mars/ganymed.cc

    r6932 r6949  
    4949    gLog << "   -b                        Batch mode (no graphical output to screen)" << endl<<endl;
    5050    gLog << " Operation Mode:" << endl;
     51    gLog << "   -mc                       Monte Carlo dataset (no times)" << endl;
    5152    gLog << "   --wobble                  Force wobble mode (overwrites dataset)" << endl;
    5253    gLog << "   --no-wobble               Force normal mode (overwrites dataset)" << endl << endl;
     
    120121    //const Bool_t  kForceExec   = arg.HasOnlyAndRemove("-ff");
    121122
     123    const Bool_t  kIsMc          = arg.HasOnlyAndRemove("-mc");
    122124    const Bool_t  kWobbleModeOn  = arg.HasOnlyAndRemove("--wobble");
    123125    const Bool_t  kWobbleModeOff = arg.HasOnlyAndRemove("--no-wobble");
     
    239241    job.EnableWobbleMode(iswobble);
    240242    job.EnableFullDisplay(kFullDisplay);
     243    job.EnableMonteCarloMode(kIsMc);
    241244    if (kWriteSummary) // Don't change flag set in SetNameSummaryFile
    242245        job.EnableStorageOfSummary();
  • trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h

    r6932 r6949  
    2828    void SetVariables(const TArrayD &);
    2929
    30     void Print(Option_t *o="") const;
     30    void Print(Option_t *o="") const; //*MENU*
    3131
    3232    ClassDef(MEnergyEstimate, 1) // Task to estimate the energy by a rule
  • trunk/MagicSoft/Mars/manalysis/MMatrixLoop.cc

    r6924 r6949  
    5858UInt_t MMatrixLoop::GetEntries()
    5959{
    60     return fMatrix ? fMatrix->GetNumRows() : 0;
     60    if (!fMatrix)
     61        return 0;
     62
     63    return fOperationMode==kDefault ? fMatrix->GetNumRows() : (fMatrix->GetNumRows()+1)/2;
    6164}
    6265
  • trunk/MagicSoft/Mars/mbase/MContinue.cc

    r5994 r6949  
    227227}
    228228
     229void MContinue::Print(Option_t *o) const
     230{
     231    *fLog << all << GetDescriptor() << ":";
     232    if (GetFilter())
     233        *fLog << " <" << GetFilter()->GetDescriptor() << ">";
     234    *fLog << endl;
     235    if (GetFilter())
     236        Getfilter()->Print();
     237}
     238
    229239// --------------------------------------------------------------------------
    230240//
  • trunk/MagicSoft/Mars/mbase/MContinue.h

    r5994 r6949  
    4242    Bool_t IsAllowEmpty() const { return TestBit(kAllowEmpty); }
    4343
    44 
    4544    void SetInverted(Bool_t i=kTRUE);
    4645    Bool_t IsInverted() const;
     
    5150    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    5251
     52    // TObject
     53    void Print(Option_t *o="") const; //*MENU*
     54
    5355    ClassDef(MContinue, 1) //Task returning kCONTINUE
    5456};
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r6500 r6949  
    321321}
    322322
     323Int_t MParContainer::Read(const char *name)
     324{
     325    const Int_t rc = TObject::Read(name?name:(const char*)fName);
     326    if (name)
     327        SetName(name);
     328    return rc;
     329}
     330
    323331// --------------------------------------------------------------------------
    324332//
     
    640648
    641649    *fLog << "Trying to find MethodCall '" << ClassName();
    642     *fLog << "::Get" << part1 << "' instead..." << flush;
    643     call = new TMethodCall(IsA(), (TString)"Get"+part1, "");
     650    *fLog << "::" << part1 << "' instead..." << flush;
     651    call = new TMethodCall(IsA(), part1, "");
    644652    if (call->GetMethod())
    645653    {
     
    653661
    654662    *fLog << "Trying to find MethodCall '" << ClassName();
    655     *fLog << "::" << part1 << "' instead..." << flush;
    656     call = new TMethodCall(IsA(), part1, "");
     663    *fLog << "::Get" << part1 << "' instead..." << flush;
     664    call = new TMethodCall(IsA(), (TString)"Get"+part1, "");
    657665    if (call->GetMethod())
    658666    {
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r6500 r6949  
    122122    virtual Bool_t AsciiWrite(ostream &out) const;
    123123
    124     Int_t Read(const char *name=NULL) { return TObject::Read(name?name:(const char*)fName); }
     124    Int_t Read(const char *name=NULL);
    125125
    126126    virtual void GetNames(TObjArray &arr) const;
  • trunk/MagicSoft/Mars/mdata/MDataFormula.cc

    r6894 r6949  
    108108        fMembers.AddLast(chain);
    109109
    110         txt.ReplaceAll(arg, Form("[%d]", num++));
     110        args.Remove(0, len+1);
    111111        pos1 += len;
    112112
    113         args.Remove(0, len+1);
     113        txt.Replace(txt.Index(arg), len, Form("[%d]", num++));
    114114    }
    115115
  • trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc

    r6916 r6949  
    481481    {
    482482        // how many events do we still want to read in this bin
    483         fNom[bin] -= 1;
     483        fNom[bin]--;
    484484        rc = kTRUE;
    485485
     
    491491
    492492    // how many events are still pending to be read
    493     fIs[bin] -= 1;
     493    fIs[bin]--;
    494494
    495495    return rc;
     
    530530      {
    531531        fResult = kFALSE;
    532         fCounter[1] += 1;
     532        fCounter[1]++;
    533533        return kTRUE;
    534534      }
     
    539539    if (!fResult)
    540540    {
    541       fCounter[2] += 1;
     541      fCounter[2]++;
    542542      return kTRUE;
    543543    }
    544544
    545     fCounter[0] += 1;
     545    fCounter[0]++;
    546546
    547547    return kTRUE;
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc

    r6513 r6949  
    142142    // returns the number of file which were added
    143143    //
     144    if (!fRun)
     145        return -1;
     146
    144147    Int_t n1 = fRun->AddFile(fname);
    145148    Int_t n2 = MReadTree::AddFile(fname, entries);
     
    231234Int_t MReadMarsFile::PreProcess(MParList *pList)
    232235{
     236    if (!fRun)
     237    {
     238        *fLog << err << "Error - Cannot use MReadMarsFile instantiated with default constructor... aborting." << endl;
     239        return kFALSE;
     240    }
     241
    233242    fParList = pList;
    234243
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r6948 r6949  
    771771    // Rename first statistics box
    772772    //
    773     TPaveStats *s1 = (TPaveStats*)gPad->FindObject("stats");
     773    TPaveStats *s1 = dynamic_cast<TPaveStats*>(gPad->FindObject("stats"));
    774774    if (!s1)
    775         s1 = (TPaveStats*)hist1.GetListOfFunctions()->FindObject("stats");
     775        s1 = dynamic_cast<TPaveStats*>(hist1.GetListOfFunctions()->FindObject("stats"));
    776776    else
    777777        s1->SetName((TString)"Stat"+hist1.GetTitle());
     
    793793    // Draw Legend
    794794    //
    795     TPaveStats *s2 = (TPaveStats*)gPad->FindObject("stats");
     795    TPaveStats *s2 = dynamic_cast<TPaveStats*>(gPad->FindObject("stats"));
    796796    if (!s2)
    797         s2 = (TPaveStats*)hist2.GetListOfFunctions()->FindObject("stats");
     797        s2 = dynamic_cast<TPaveStats*>(hist2.GetListOfFunctions()->FindObject("stats"));
    798798
    799799    if (s2)
     
    866866    //
    867867    // Where to get the TPaveStats depends on the root version
    868     TPaveStats *s1 = (TPaveStats*)gPad->FindObject("stats");
     868    TPaveStats *s1 = dynamic_cast<TPaveStats*>(gPad->FindObject("stats"));
    869869    if (!s1)
    870         s1 = (TPaveStats*)hist1.GetListOfFunctions()->FindObject("stats");
     870        s1 = dynamic_cast<TPaveStats*>(hist1.GetListOfFunctions()->FindObject("stats"));
    871871    else
    872872        s1->SetName((TString)"Stat"+hist1.GetTitle());
     
    889889    //
    890890    // Where to get the TPaveStats depends on the root version
    891     TPaveStats *s2 = (TPaveStats*)gPad->FindObject("stats");
     891    TPaveStats *s2 = dynamic_cast<TPaveStats*>(gPad->FindObject("stats"));
    892892    if (!s2)
    893         s2 = (TPaveStats*)hist2.GetListOfFunctions()->FindObject("stats");
     893        s2 = dynamic_cast<TPaveStats*>(hist2.GetListOfFunctions()->FindObject("stats"));
    894894
    895895    if (s2)
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc

    r6926 r6949  
    347347    {
    348348        *fLog << "Result:" << endl;
    349         *fLog << " - Significance           " << fSignificance << endl;
    350         *fLog << " - Excess Events          " << fEventsExcess << endl;
    351         *fLog << " - Signal Events          " << fEventsSignal << endl;
    352         *fLog << " - Background Events      " << fEventsBackground << endl;
    353         *fLog << " - Chi^2/ndf (Signal)     " << fChiSqSignal << endl;
    354         *fLog << " - Chi^2/ndf (Background) " << fChiSqBg << endl;
    355         *fLog << " - Signal integrated     " << fIntegralMax << "°" << endl;
    356         *fLog << " - Scale Factor (Off)     " << fScaleFactor << endl;
     349        *fLog << " - Significance (Li/Ma)    " << fSignificance << endl;
     350        *fLog << " - Excess Events           " << fEventsExcess << endl;
     351        *fLog << " - Signal Events           " << fEventsSignal << endl;
     352        *fLog << " - Background Events       " << fEventsBackground << endl;
     353        *fLog << " - Chi^2/ndf (Signal)      " << fChiSqSignal << endl;
     354        *fLog << " - Chi^2/ndf (Background)  " << fChiSqBg << endl;
     355        *fLog << " - Signal integrated up to " << fIntegralMax << "°" << endl;
     356        *fLog << " - Scale Factor (Off)      " << fScaleFactor << endl;
    357357    }
    358358}
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h

    r6892 r6949  
    8686
    8787    void Clear(Option_t *o="");
    88     void Print(Option_t *o="") const;
     88    void Print(Option_t *o="") const; //*MENU*
    8989    void Copy(TObject &o) const;
    9090    /*
  • trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc

    r6283 r6949  
    660660            {
    661661                TVirtualPad *p=gPad->GetPad(x+1)->GetPad(y+1);
    662                 if (!(st = (TPaveStats*)p->GetPrimitive("stats")))
     662                if (!(st = dynamic_cast<TPaveStats*>(p->GetPrimitive("stats"))))
    663663                    continue;
    664664
  • trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc

    r6932 r6949  
    3636
    3737#include <TLine.h>
    38 #include <TCanvas.h>
     38#include <TCanvas.h>
     39#include <TStyle.h>
    3940#include <TProfile.h>
     41#include <TPaveStats.h>
    4042
    4143#include "MString.h"
     
    7880    fHResolution.SetDirectory(NULL);
    7981    fHResolution.SetName("EnergyRes");
    80     fHResolution.SetTitle("Histogram in \\frac{\\Delta lg(E)}{lg(E_{mc})} vs E_{est} and E_{mc}");
     82    fHResolution.SetTitle("Histogram in \\Delta lg(E) vs E_{est} and E_{mc}");
    8183    fHResolution.SetXTitle("E_{est} [GeV]");
    8284    fHResolution.SetYTitle("E_{mc} [GeV]");
    83     fHResolution.SetZTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}");
     85    fHResolution.SetZTitle("lg(E_{est}) - lg(E_{mc})");
    8486
    8587    fHImpact.SetDirectory(NULL);
    8688    fHImpact.SetName("Impact");
    87     fHImpact.SetTitle("\\frac{\\Delta lg(E)}{lg(E)} vs Impact parameter");
     89    fHImpact.SetTitle("\\Delta lg(E) vs Impact parameter");
    8890    fHImpact.SetXTitle("Impact parameter [m]");
    89     fHImpact.SetYTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}");
     91    fHImpact.SetYTitle("lg(E_{est}) - lg(E_{mc})");
    9092
    9193    fHEnergy.Sumw2();
     
    147149
    148150    fChisq = 0;
     151    fBias  = 0;
    149152    fHEnergy.Reset();
    150153    fHImpact.Reset();
     
    164167    const Double_t imp   = fMatrix ? GetVal(1) : fMcEvt->GetImpact()/100;
    165168    const Double_t theta = fMatrix ? GetVal(2) : fMcEvt->GetTelescopeTheta()*TMath::RadToDeg();
    166     const Double_t res   = (log10(eest)-log10(etru));///log10(etru);
    167     const Double_t resE   = (eest-etru)/etru;
     169    const Double_t res   = log10(eest)-log10(etru);///log10(etru);
     170    const Double_t resE  = (eest-etru)/etru;
    168171
    169172    fHEnergy.Fill(eest, etru, theta, w);
     
    171174    fHImpact.Fill(imp, resE, w);
    172175
    173     fChisq += res*res;
    174     fBias  += res;
     176    //if (etru>125 && etru<750)
     177    //    return kCONTINUE;
     178
     179    // lg(N)  = 4.3*lg(E)-6
     180    // lg(N0) = 4.3*2.2-6
     181
     182    const Double_t n  = 2; //pow(10, -4.3*(log10(etru)-2.2));
     183
     184    fChisq += log10(etru)<2.2? res*res*n/2:res*res;
     185    fBias  += log10(etru)<2.2? res*sqrt(n/2):res;
    175186
    176187    return kTRUE;
     
    192203void MHEnergyEst::Print(Option_t *o) const
    193204{
     205    const Double_t res  =   TMath::Sqrt(fChisq-fBias*fBias);
     206    const Double_t resp =   TMath::Power(10,  res)-1;
     207    const Double_t resm = 1-TMath::Power(10, -res);
     208
     209    if (TMath::IsNaN(res))
     210    {
     211        *fLog << all << "MHEnergyEst::Print: ERROR - Resolution is NaN (not a number)." << endl;
     212        return;
     213    }
     214
    194215    *fLog << all;
    195     *fLog << "Mean log10(Energy) Resoltion: " << Form("%5.2f%%", TMath::Sqrt(fChisq-fBias*fBias)) << endl;
    196     *fLog << "Mean log10(Energy) Bias:      " << Form("%5.2f%%", fBias) << endl;
     216    *fLog << "Mean log10(Energy) Resoltion: +/- " << Form("%4.2f", res) << endl;
     217    *fLog << "Mean log10(Energy) Bias:         "  << Form("%+4.2f", fBias) << endl;
     218    *fLog << "Asymmetric Energy  Resoltion:   +"  << Form("%4.1f%%", resp*100) << " -" << Form("%4.1f%%", resm*100) << endl;
    197219}
    198220
     
    246268
    247269            pad->GetPad(1)->GetPad(2)->cd(2);
    248             /*=*/fHResolution.ProjectionZ("Resolution");
    249             ///*h =*/ fHImpact.ProjectionX("Impact", -1, 9999, "e");
     270            hx = (TH1D*)fHResolution.ProjectionZ("Resolution");
     271            TPaveStats *stats = dynamic_cast<TPaveStats*>(hx->FindObject("stats"));
     272            if (stats)
     273            {
     274                stats->SetBit(BIT(17)); // TStyle.cxx: kTakeStyle=BIT(17)
     275                stats->SetX1NDC(0.63);
     276                stats->SetY1NDC(0.68);
     277            }
     278
     279            hx->Fit("gaus", "Q");
     280            gPad=NULL;
     281            gStyle->SetOptFit(101);
    250282        }
    251283    }
     
    325357//    h1->Draw("Chistsame");
    326358
    327     return h1;
     359    return h2;
    328360}
    329361
     
    415447    //h->SetXTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}");
    416448    h->SetYTitle("Counts");
    417     h->SetTitle("Distribution of \\Delta lg(E) / lg(E_{mc})");
     449    h->SetTitle("Distribution of \\Delta lg(E)");
    418450    h->SetDirectory(NULL);
    419451    h->SetBit(kCanDelete);
    420452    h->GetXaxis()->SetRangeUser(-1.3, 1.3);
    421453    h->Draw("");
     454    //h->Fit("gaus");
    422455    // ----------------------------------------
    423456
     
    440473    h = MakePlot(fHResolution, "zy");
    441474    h->SetXTitle("E_{mc} [GeV]");
    442     h->SetYTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}");
    443     h->SetTitle("Energy resolution \\Delta lg(E) / lg(E) vs Monte Carlo energy E_{mc}");
     475    h->SetYTitle("lg(E_{est}) - lg(E_{mc})");
     476    h->SetTitle("Energy resolution \\Delta lg(E) vs Monte Carlo energy E_{mc}");
    444477    h->SetMinimum(-1.3);
    445478    h->SetMaximum(1.3);
     
    448481    h = MakePlot(fHResolution, "zx");
    449482    h->SetXTitle("E_{est} [GeV]");
    450     h->SetYTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}");
    451     h->SetTitle("Energy Resolution \\Delta lg(E) / lg(E) vs estimated Energy E_{est}");
     483    h->SetYTitle("lg(E_{est}) - lg(E_{mc})");
     484    h->SetTitle("Energy Resolution \\Delta lg(E) vs estimated Energy E_{est}");
    452485    h->SetMinimum(-1.3);
    453486    h->SetMaximum(1.3);
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc

    r6919 r6949  
    726726    tlist2.AddToList(&pedlo3);
    727727    //-----------------------------------------------------------
     728
     729    MTaskList tlist3;
     730    tlist3.SetFilter(&fcalib);
     731
     732    MContinue contcal;
    728733    if (fIsInterlaced)
    729734    {
    730         pinext.SetFilter(&fcalib);
    731         bldext.SetFilter(&fcalib);
    732         taskenv3.SetFilter(&fcalib);
    733         pacalc.SetFilter(&fcalib);
    734         filcam.SetFilter(&fcalib);
    735         filtme.SetFilter(&fcalib);
    736         filbnd.SetFilter(&fcalib);
    737         filpin.SetFilter(&fcalib);
    738         chcalc.SetFilter(&fcalib);
    739         recalc.SetFilter(&fcalib);
    740 
    741735        tlist2.AddToList(&fcalib);
    742         tlist2.AddToList(&pinext);
    743         tlist2.AddToList(&bldext);
    744         tlist2.AddToList(&taskenv3);
    745         tlist2.AddToList(&pacalc);
    746         tlist2.AddToList(&filcam);
     736        tlist2.AddToList(&tlist3);
     737
     738        tlist3.AddToList(&pinext);
     739        tlist3.AddToList(&bldext);
     740        tlist3.AddToList(&taskenv3);
     741        tlist3.AddToList(&pacalc);
     742        tlist3.AddToList(&filcam);
    747743        if (fIsRelTimesUpdate)
    748           tlist2.AddToList(&filtme);
     744          tlist3.AddToList(&filtme);
    749745        if (IsUseBlindPixel())
    750             tlist2.AddToList(&filbnd);
     746            tlist3.AddToList(&filbnd);
    751747        if (IsUsePINDiode())
    752             tlist2.AddToList(&filpin);
    753         tlist2.AddToList(&chcalc);
     748            tlist3.AddToList(&filpin);
     749        tlist3.AddToList(&chcalc);
    754750        if (fIsRelTimesUpdate)
    755           tlist2.AddToList(&recalc);
    756     }
     751            tlist3.AddToList(&recalc);
     752        tlist3.AddToList(&fill8);
     753        tlist3.AddToList(&contcal);
     754    } 
    757755
    758756    tlist2.AddToList(&conttp);
     
    772770    if (extractor2 || extractor1->InheritsFrom("MExtractTimeAndCharge"))
    773771        tlist2.AddToList(&caltm);
    774     if (fIsInterlaced)
    775       tlist2.AddToList(&fill8);
    776772    tlist2.AddToList(&bpcal);
    777773    tlist2.AddToList(&treat);
  • 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
  • trunk/MagicSoft/Mars/mjobs/MJCut.h

    r6948 r6949  
    1818    Bool_t  fWriteOnly;
    1919    Bool_t  fIsWobble;
     20    Bool_t  fIsMonteCarlo;
    2021    Bool_t  fFullDisplay;
    2122    //Bool_t  fSubstraction;
     
    4849    void EnableWriteOnly(Bool_t b=kTRUE)         { fWriteOnly    = b; }
    4950    void EnableWobbleMode(Bool_t b=kTRUE)        { fIsWobble     = b; }
     51    void EnableMonteCarloMode(Bool_t b=kTRUE)    { fIsMonteCarlo = b; }
    5052    void EnableFullDisplay(Bool_t b=kTRUE)       { fFullDisplay  = b; }
    5153    //void EnableSubstraction(Bool_t b=kTRUE)      { fSubstraction = b; }
  • trunk/MagicSoft/Mars/mjobs/MJOptimize.cc

    r6948 r6949  
    9494#include "MGeomCamCT1.h"
    9595#include "MFEventSelector.h"
     96#include "MFDataMember.h"
    9697#include "MReadTree.h"
    9798#include "MHMatrix.h"
     
    111112#include "MContinue.h"
    112113#include "MGeomCamMagic.h"
    113 #include "../mimage/MHillasSrcCalc.h"
     114#include "MHillasSrcCalc.h"
    114115#include "MHMatrix.h"
    115116#include "MMatrixLoop.h"
     
    118119#include "../mhflux/MHEnergyEst.h"
    119120#include "MDirIter.h"
    120 #include "../mjobs/MSequence.h"
     121#include "MSequence.h"
    121122
    122123using namespace std;
     
    9991000    MParList parlist;
    10001001
     1002    MParameterI par("DataType");
     1003    par.SetVal(1);
     1004    parlist.AddToList(&par);
     1005
     1006    MFDataMember filter("DataType.fVal", '>', 0.5);
     1007    fPreCuts.Add(&filter);
     1008
    10011009    MGeomCamMagic geom; // For GetConvMm2Deg
    10021010    parlist.AddToList(&geom);
     
    10231031        return kFALSE;
    10241032
     1033    fPreCuts.Remove(&filter);
     1034
    10251035    MTaskList tasklist;
    10261036    parlist.Replace(&tasklist);
  • trunk/MagicSoft/Mars/showlog.cc

    r6888 r6949  
    9999        else
    100100            s.ReplaceAll("", "\033");
    101         gLog << s << endl;
     101
     102        // Check whether it is an empty line
     103        if (s=="\033[0m")
     104        {
     105            gLog << endl;
     106            continue;
     107        }
     108
     109        while (!s.IsNull())
     110        {
     111            Ssiz_t pos = s.First("\033[");
     112            if (pos<0)
     113            {
     114                gLog << s;
     115                break;
     116            }
     117
     118            gLog << s(0, pos);
     119            s.Remove(0, pos+1);
     120            if (s.BeginsWith("0m") && s.Length()>3)
     121            {
     122                gLog << all;
     123                s.Remove(0, 2);
     124                continue;
     125            }
     126            if (s.BeginsWith("31m"))
     127            {
     128                gLog << err;
     129                s.Remove(0, 3);
     130                continue;
     131            }
     132            if (s.BeginsWith("32m"))
     133            {
     134                gLog << inf;
     135                s.Remove(0, 3);
     136                continue;
     137            }
     138            if (s.BeginsWith("33m"))
     139            {
     140                gLog << warn;
     141                s.Remove(0, 3);
     142                continue;
     143            }
     144            if (s.BeginsWith("34m"))
     145            {
     146                gLog << dbg;
     147                s.Remove(0, 3);
     148                continue;
     149            }
     150            gLog << "\033[";
     151        }
     152        gLog << endl;
    102153    }
    103154
     
    105156        delete in;
    106157
    107     return 0;
     158    return 1;
    108159}
Note: See TracChangeset for help on using the changeset viewer.