Changeset 18042 for trunk/Mars/mjoptim


Ignore:
Timestamp:
12/20/14 14:57:50 (10 years ago)
Author:
tbretz
Message:
Write a file containing the calculated disp and theta-square for plotting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mjoptim/MJOptimizeDisp.cc

    r18041 r18042  
    8383#include "MParameterCalc.h"
    8484#include "MFillH.h"
     85#include "MContinue.h"
     86#include "MWriteRootFile.h"
    8587
    8688// filters
     89#include "MFilterList.h"
    8790#include "MFDataMember.h"
    8891
     
    216219    //hist.GetAlphaFitter().Print("result");
    217220
     221    if (fNameOut.IsNull())
     222        return kTRUE;
     223
     224    fLog->Separator("Writing result");
     225
     226    MTaskList tlist;
     227    MParList plist;
     228    plist.AddToList(&tlist);
     229    plist.AddToList(&geom);
     230
     231    MReadTree read2("Events");
     232    read2.DisableAutoScheme();
     233    read2.AddFiles(read);
     234    tlist.AddToList(&read2);
     235
     236    MFilterList flist;
     237    flist.AddToList(fPreCuts);
     238    flist.SetName("PreCuts");
     239    flist.SetInverted(kTRUE);
     240
     241    MContinue cont(&flist);
     242    tlist.AddToList(&cont);
     243
     244    TString r(rule);
     245
     246    TIter Next(&fRules);
     247    TObject *o=0;
     248    Int_t num = 0;
     249    while ((o=Next()))
     250    {
     251        r.ReplaceAll(Form("M[%d]", num), Form("M%d.fVal", num));
     252
     253        MParameterCalc *c = new MParameterCalc(o->GetName(), Form("CalcM%d", num));
     254        c->SetNameParameter(Form("M%d", num++));
     255        c->SetBit(kCanDelete);
     256        tlist.AddToList(c);
     257    }
     258
     259    MParameterCalc calcr(r, "CalcDisp");
     260    calcr.SetVariables(GetParameters());
     261    calcr.SetNameParameter("Disp");
     262
     263    MParameterCalc calct("MHillasSrc.fDist^2*MGeomCam.fConvMm2Deg^2 + Disp.fVal^2 - 2*MHillasSrc.fDist*MGeomCam.fConvMm2Deg*Disp.fVal*cos(MHillasSrc.fAlpha*TMath::DegToRad())", "CalcTheta");
     264    calct.SetNameParameter("ThetaSquared");
     265
     266    tlist.AddToList(&calcr);
     267    tlist.AddToList(&calct);
     268
     269    tlist.AddToList(fTestTasks);
     270
     271    MWriteRootFile write(fNameOut);
     272    write.AddContainer("MHillas",      "Events");
     273    write.AddContainer("MHillasSrc",   "Events");
     274    write.AddContainer("MHillasExt",   "Events");
     275    write.AddContainer("MImagePar",    "Events");
     276    write.AddContainer("MNewImagePar", "Events");
     277    write.AddContainer("Disp",         "Events");
     278    write.AddContainer("ThetaSquared", "Events");
     279    write.AddContainer("MMcEvt",       "Events");
     280    write.AddContainer("DataType",     "Events");
     281    write.AddContainer("Weight",       "Events");
     282    write.AddContainer("FileId",       "Events");
     283    write.AddContainer("EvtNumber",    "Events");
     284    tlist.AddToList(&write);
     285
     286    MEvtLoop loop2;
     287    loop2.SetDisplay(fDisplay);
     288    loop2.SetParList(&plist);
     289    if (!oop2.Eventloop())
     290        return;
     291
    218292    // Store result if requested
    219     TObjArray cont;
     293    TObjArray arr;
    220294    if (fDisplay)
    221         cont.Add(fDisplay);
    222     cont.Add(&calc1);
    223     return WriteContainer(cont, fNameOut);
     295        arr.Add(fDisplay);
     296    arr.Add(&calc1);
     297    return WriteContainer(arr, fNameOut);
    224298}
Note: See TracChangeset for help on using the changeset viewer.