Changeset 7151


Ignore:
Timestamp:
06/13/05 10:20:58 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MLog.cc

    r7001 r7151  
    259259void MLog::Underline()
    260260{
     261    if (fIsNull)
     262        return;
     263
    261264    SetBit(kIsUnderlined);
    262265
  • trunk/MagicSoft/Mars/mhbase/MBinning.cc

    r7142 r7151  
    428428    const Double_t cud = ud<0 ? cos(ud)-1 : 1-cos(ud);
    429429
    430     SetEdgesASin(nbins, ld, ud);
    431     /*
    432     const Double_t binsize = (cld-cud)/nbins;
    433     fEdges.Set(nbins+1);
    434     for (int i=0; i<=nbins; i++)
    435     {
    436         const Double_t a = cld-binsize*i;
    437         fEdges[i] = a<0 ? -acos(1+a)*kRad2Deg : acos(1-a)*kRad2Deg;
    438         cout << a << " " << fEdges[i] << endl;
    439     }
    440 
    441     fType = kIsCosinic;*/
     430    SetEdgesASin(nbins, cld, cud);
    442431}
    443432
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc

    r7142 r7151  
    135135
    136136    for (int i=5; i<fFunc->GetNpar(); i++)
    137         fFunc->ReleaseParameter(i);
     137        if (fFitBackground)
     138            fFunc->ReleaseParameter(i);
     139        else
     140            fFunc->SetParameter(i, 0);
    138141
    139142    // options : N  do not store the function, do not draw
     
    142145    //           Q  quiet mode
    143146    //           E  Perform better Errors estimation using Minos technique
    144     h.Fit(fFunc, "NQI", "", bgmin, bgmax);
    145 
    146     fChiSqBg = fFunc->GetChisquare()/fFunc->GetNDF();
     147    if (fFitBackground)
     148    {
     149        h.Fit(fFunc, "NQI", "", bgmin, bgmax);
     150        fChiSqBg = fFunc->GetChisquare()/fFunc->GetNDF();
     151    }
     152
    147153
    148154    // ------------------------------------
    149     if (paint)
     155    if (paint && fFitBackground)
    150156    {
    151157        fFunc->SetRange(0, 90);
     
    209215    fSignificance     = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground);
    210216
     217    if (TMath::IsNaN(fSignificance))
     218        fSignificance=0;
     219
    211220    if (fEventsExcess<0)
    212221        fEventsExcess=0;
     
    240249    fSignificance     = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground/alpha, alpha);
    241250
     251    if (TMath::IsNaN(fSignificance))
     252        fSignificance=0;
    242253    if (fEventsExcess<0)
    243254        fEventsExcess=0;
    244 /*
    245     TF1 func("", "gaus(0)+pol0(3)", 0., 90.);
    246 
    247     const Double_t A  = fEventsSignal/bin;
    248     const Double_t dA = TMath::Abs(A);
    249     func.SetParLimits(0, -dA*4, dA*4);
    250     func.SetParLimits(2, 0, 90);
    251     func.SetParLimits(3, -dA, dA);
    252 
    253     func.SetParameter(0, A);
    254     func.FixParameter(1, 0);
    255     func.SetParameter(2, fSigMax*0.75);
    256     func.SetParameter(3, 0);
    257 
    258     // options : N  do not store the function, do not draw
    259     //           I  use integral of function in bin rather than value at bin center
    260     //           R  use the range specified in the function range
    261     //           Q  quiet mode
    262     //           E  Perform better Errors estimation using Minos technique
    263     TH1D h(hon);
    264     h.Add(&hof, -1);
    265     h.Fit(&func, "NQI", "", 0, 90);
    266 
    267     fChiSqSignal = func.GetChisquare()/func.GetNDF();
    268 
    269     const Int_t bin1 = h.GetXaxis()->FindFixBin(func.GetParameter(2)*2);
    270 
    271     fChiSqBg = 0;
    272     for (int i=bin1; i<=h.GetNbinsX(); i++)
    273     {
    274         const Float_t val = h.GetBinContent(i);
    275         fChiSqBg = val*val;
    276     }
    277     if (fChiSqBg>0)
    278         fChiSqBg /= h.GetNbinsX()+1-bin1;
    279 
    280     fCoefficients.Set(func.GetNpar(), func.GetParameters());
    281 
    282     // ------------------------------------
    283     if (paint)
    284     {
    285         func.SetLineColor(kBlue);
    286         func.SetLineWidth(2);
    287         func.Paint("same");
    288     }
    289     // ------------------------------------
    290   */
     255
    291256    return kTRUE;
    292257}
     
    323288    f.fScaleMax     = fScaleMax;
    324289    f.fPolynomOrder = fPolynomOrder;
     290    f.fFitBackground= fFitBackground;
     291    f.fSignalFunc   = fSignalFunc;
    325292    f.fScaleMode    = fScaleMode;
    326293    f.fScaleUser    = fScaleUser;
     
    350317{
    351318    *fLog << GetDescriptor() << ": Fitting..." << endl;
    352     *fLog << " ...background from " << fBgMin << " to " << fBgMax << endl;
    353319    *fLog << " ...signal to " << fSigMax << " (integrate into bin at " << fSigInt << ")" << endl;
    354     *fLog << " ...polynom order " << fPolynomOrder << endl;
    355     *fLog << " ...scale mode: ";
    356     switch (fScaleMode)
    357     {
    358     case kNone:        *fLog << "none.";         break;
    359     case kEntries:     *fLog << "entries.";      break;
    360     case kIntegral:    *fLog << "integral.";     break;
    361     case kOffRegion:   *fLog << "off region (integral between " << fScaleMin << " and " << fScaleMax << ")"; break;
    362     case kBackground:  *fLog << "background (integral between " << fBgMin    << " and " << fBgMax    << ")"; break;
    363     case kLeastSquare: *fLog << "least square (N/A)"; break;
    364     case kUserScale:   *fLog << "user def (" << fScaleUser << ")"; break;
     320    *fLog << " ...signal function: ";
     321    switch (fSignalFunc)
     322    {
     323    case kGauss:       *fLog << "gauss(x)";        break;
     324    case kThetaSq:     *fLog << "gauss(sqrt(x))";  break;
    365325    }
    366326    *fLog << endl;
     327    if (!fFitBackground)
     328        *fLog << " ...no background." << endl;
     329    else
     330    {
     331        *fLog << " ...background from " << fBgMin << " to " << fBgMax << endl;
     332        *fLog << " ...polynom order " << fPolynomOrder << endl;
     333        *fLog << " ...scale mode: ";
     334        switch (fScaleMode)
     335        {
     336        case kNone:        *fLog << "none.";         break;
     337        case kEntries:     *fLog << "entries.";      break;
     338        case kIntegral:    *fLog << "integral.";     break;
     339        case kOffRegion:   *fLog << "off region (integral between " << fScaleMin << " and " << fScaleMax << ")"; break;
     340        case kBackground:  *fLog << "background (integral between " << fBgMin    << " and " << fBgMax    << ")"; break;
     341        case kLeastSquare: *fLog << "least square (N/A)"; break;
     342        case kUserScale:   *fLog << "user def (" << fScaleUser << ")"; break;
     343        }
     344        *fLog << endl;
     345    }
    367346
    368347    if (TString(o).Contains("result"))
     
    402381}
    403382
     383Bool_t MAlphaFitter::FitTime(const TH3D &hon, UInt_t bin, Bool_t paint)
     384{
     385    const TString name(Form("TempAlphaTime%06d", gRandom->Integer(1000000)));
     386
     387    hon.GetZaxis()->SetRange(bin,bin);
     388    TH1D *h = (TH1D*)hon.Project3D("ye");
     389    hon.GetZaxis()->SetRange(-1,9999);
     390
     391    h->SetDirectory(0);
     392
     393    const Bool_t rc = Fit(*h, paint);
     394    delete h;
     395    return rc;
     396}
     397
    404398Bool_t MAlphaFitter::FitAlpha(const TH3D &hon, Bool_t paint)
    405399{
     
    448442    return rc;
    449443}
    450 
     444/*
     445Bool_t MAlphaFitter::FitTime(const TH3D &hon, const TH3D &hof, UInt_t bin, Bool_t paint)
     446{
     447    const TString name1(Form("TempAlphaTime%06d_on",  gRandom->Integer(1000000)));
     448    const TString name0(Form("TempAlphaTime%06d_off", gRandom->Integer(1000000)));
     449
     450    hon.GetZaxis()->SetRange(bin,bin);
     451    TH1D *h1 = (TH1D*)hon.Project3D("ye");
     452    hon.GetZaxis()->SetRange(-1,9999);
     453    h1->SetDirectory(0);
     454
     455    hof.GetZaxis()->SetRange(bin,bin);
     456    TH1D *h0 = (TH1D*)hof.Project3D("ye");
     457    hof.GetZaxis()->SetRange(-1,9999);
     458    h0->SetDirectory(0);
     459
     460    const Bool_t rc = ScaleAndFit(*h1, h0, paint);
     461
     462    delete h0;
     463    delete h1;
     464
     465    return rc;
     466}
     467*/
    451468Bool_t MAlphaFitter::FitAlpha(const TH3D &hon, const TH3D &hof, Bool_t paint)
    452469{
     
    541558    case kExcess:
    542559        return -GetEventsExcess();
     560    case kGaussSigma:
     561        return GetGausSigma();
    543562    }
    544563    return 0;
     
    601620        if (txt==(TString)"excess")
    602621            fStrategy = kExcess;
     622        if (txt==(TString)"gausssigma" || txt==(TString)"gaussigma")
     623            fStrategy = kGaussSigma;
    603624        rc = kTRUE;
    604625    }
     
    625646        rc = kTRUE;
    626647    }
     648    if (IsEnvDefined(env, prefix, "Signalfunction", print))
     649    {
     650        TString txt = GetEnvValue(env, prefix, "SignalFunction", "");
     651        txt = txt.Strip(TString::kBoth);
     652        txt.ToLower();
     653        if (txt==(TString)"gauss" || txt==(TString)"gaus")
     654            SetSignalFunction(kGauss);
     655        if (txt==(TString)"thetasq")
     656            SetSignalFunction(kThetaSq);
     657        rc = kTRUE;
     658    }
    627659    if (IsEnvDefined(env, prefix, "Scale", print))
    628660    {
  • trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h

    r7066 r7151  
    3434        kSignificanceLogExcess,
    3535        kSignificanceExcess,
    36         kExcess
     36        kExcess,
     37        kGaussSigma
    3738    };
     39    enum SignalFunc_t {
     40        kGauss, kThetaSq
     41    };
     42
    3843private:
    39     Float_t fSigInt;
    40     Float_t fSigMax;
    41     Float_t fBgMin;
    42     Float_t fBgMax;
    43     Float_t fScaleMin;
    44     Float_t fScaleMax;
    45     Int_t   fPolynomOrder;
    46 
    47     Double_t fSignificance;
    48     Double_t fEventsExcess;
    49     Double_t fEventsSignal;
    50     Double_t fEventsBackground; // fScaleFactor already applied
    51 
    52     Double_t fChiSqSignal;
    53     Double_t fChiSqBg;
    54     Double_t fIntegralMax;
    55     Double_t fScaleFactor;  // Scale factor for off-data
    56 
    57     TArrayD fCoefficients;
    58 
    59     TF1 *fFunc;
    60 
    61     ScaleMode_t fScaleMode;
    62     Double_t fScaleUser;
    63 
    64     Strategy_t fStrategy;
     44    // Fitting Setup
     45    Float_t fSigInt;            // minimum of range to fit the signal
     46    Float_t fSigMax;            // maximum of range to fit the signal
     47    Float_t fBgMin;             // minimum of range to fit the background
     48    Float_t fBgMax;             // minimum of range to fit the background
     49    Float_t fScaleMin;          // minimum of range to determin the scale factor of the background
     50    Float_t fScaleMax;          // maximum of range to determin the scale factor of the background
     51    Int_t   fPolynomOrder;      // order of polyom to be fitted to the background
     52    Bool_t  fFitBackground;     // Backround fit: yes/no
     53    SignalFunc_t fSignalFunc;  // Type of signal function
     54    // Result
     55    Double_t fSignificance;     // significance of signal
     56    Double_t fEventsExcess;     // calculated number of excess events (signal-bg)
     57    Double_t fEventsSignal;     // calculated number of signal events
     58    Double_t fEventsBackground; // calculated number of bg events (fScaleFactor already applied)
     59
     60    Double_t fChiSqSignal;      // Reduced (chi^2/NDF) chisq of signal fit
     61    Double_t fChiSqBg;          // Reduced (chi^2/NDF) chisq of bg fit
     62    Double_t fIntegralMax;      // Calculated bin border to which it was integrated
     63    Double_t fScaleFactor;      // Scale factor for off-data
     64
     65    TArrayD fCoefficients;      // Fit result
     66
     67    // Function
     68    TF1 *fFunc;                 // fit function (gauss + polynom)
     69
     70    // Scaling setup
     71    ScaleMode_t fScaleMode;     // scaling mode
     72    Double_t    fScaleUser;     // user scale factor
     73
     74    // Minimization strategy
     75    Strategy_t fStrategy;       // How to calc minimization value
    6576
    6677public:
    6778    // Implementing the function yourself is only about 5% faster
    68     MAlphaFitter(const char *name=0, const char *title=0) : fSigInt(15), fSigMax(75), fBgMin(45), fBgMax(85), fScaleMin(40), fScaleMax(80), fPolynomOrder(2), fCoefficients(3+fPolynomOrder+1), fFunc(new TF1("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90)), fScaleMode(kOffRegion), fScaleUser(1), fStrategy(kSignificance)
     79    MAlphaFitter(const char *name=0, const char *title=0) : fSigInt(15),
     80        fSigMax(75), fBgMin(45), fBgMax(85), fScaleMin(40), fScaleMax(80),
     81        fPolynomOrder(2), fFitBackground(kTRUE), fSignalFunc(kGauss),
     82        fCoefficients(3+fPolynomOrder+1),
     83        fFunc(new TF1("", Form("gaus(0) + pol%d(3)", fPolynomOrder), 0, 90)),
     84        fScaleMode(kOffRegion), fScaleUser(1), fStrategy(kSignificance)
    6985    {
    7086        fName  = name  ? name  : "MAlphaFitter";
     
    86102    }
    87103
     104    // TObject
    88105    void Clear(Option_t *o="");
    89106    void Print(Option_t *o="") const; //*MENU*
    90107    void Copy(TObject &o) const;
    91     /*
    92     TObject *Clone(const char *name) const
    93     {
    94         return new MAlphaFitter(*this);
    95     }
    96     */
    97 
     108
     109    // Setter
    98110    void SetScaleUser(Float_t scale)       { fScaleUser = scale; fScaleMode=kUserScale; }
    99111    void SetScaleMode(ScaleMode_t mode)    { fScaleMode    = mode; }
     
    105117    void SetScaleMin(Float_t s)            { fScaleMin     = s; }
    106118    void SetScaleMax(Float_t s)            { fScaleMax     = s; }
    107     void SetPolynomOrder(Int_t s)          { if (s==fPolynomOrder) return; fPolynomOrder = s; delete fFunc; fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", s));
     119    void SetPolynomOrder(Int_t s)
     120    {
     121        if (s==fPolynomOrder)
     122            return;
     123
     124        fPolynomOrder = s;
     125
     126        SetSignalFunction(fSignalFunc);
     127    }
     128    void SetSignalFunction(SignalFunc_t func)
     129    {
     130        delete fFunc;
     131        switch (func)
     132        {
     133        case kGauss:
     134            fFunc=new TF1 ("", Form("gaus(0) + pol%d(3)", fPolynomOrder));
     135            break;
     136        case kThetaSq:
     137            fFunc=new TF1 ("", Form("[0]*exp(-((sqrt(x)-[1])/[2])^2) + pol%d(3)", fPolynomOrder));
     138            break;
     139        }
     140        fSignalFunc=func;
    108141        gROOT->GetListOfFunctions()->Remove(fFunc);
    109142        fFunc->SetName("Dummy");
    110         fCoefficients.Set(3+s+1); fCoefficients.Reset(); }
    111 
     143        fCoefficients.Set(3+fPolynomOrder+1);
     144        fCoefficients.Reset();
     145    }
     146    void EnableBackgroundFit(Bool_t b=kTRUE) { fFitBackground=b; }
     147
     148    // Getter
    112149    Double_t GetSignalIntegralMax() const  { return fSigInt; }
    113150
     
    127164    Double_t GetCoefficient(Int_t i) const { return fCoefficients[i]; }
    128165    const TArrayD &GetCoefficients() const { return fCoefficients; }
    129 
    130     void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035) const;
    131 
     166    Double_t Eval(Double_t d) const { return fFunc ? fFunc->Eval(d) : 0; }
     167
     168    // Interface to fit
    132169    Bool_t Fit(TH1D &h, Bool_t paint=kFALSE);
    133170    Bool_t Fit(const TH1D &on, const TH1D &off, Double_t alpha, Bool_t paint=kFALSE);
     
    149186    Bool_t FitEnergy(const TH3D &h, UInt_t bin, Bool_t paint=kFALSE);
    150187    Bool_t FitTheta(const TH3D &h,  UInt_t bin, Bool_t paint=kFALSE);
     188    //Bool_t FitTime(const TH3D &h,  UInt_t bin, Bool_t paint=kFALSE);
    151189
    152190    Bool_t FitAlpha(const TH3D &on, const TH3D &off, Bool_t paint=kFALSE);
    153191    Bool_t FitEnergy(const TH3D &on, const TH3D &off, UInt_t bin, Bool_t paint=kFALSE);
    154192    Bool_t FitTheta(const TH3D &on, const TH3D &off, UInt_t bin, Bool_t paint=kFALSE);
     193    //Bool_t FitTime(const TH3D &on, const TH3D &off, UInt_t bin, Bool_t paint=kFALSE);
    155194
    156195    Bool_t FitAlpha(const TH3D &on, const TH3D *off, Bool_t paint=kFALSE)
     
    165204    {
    166205        return off ? FitTheta(on, *off, bin, paint) : FitTheta(on, bin, paint);
    167     }
     206    }/*
     207    Bool_t FitTime(const TH3D &on, const TH3D *off, UInt_t bin, Bool_t paint=kFALSE)
     208    {
     209        return off ? FitTime(on, *off, bin, paint) : FitTime(on, bin, paint);
     210    }*/
    168211
    169212    Double_t Scale(TH1D &off, const TH1D &on) const;
    170213
     214    // Interface to result
     215    void PaintResult(Float_t x=0.04, Float_t y=0.94, Float_t size=0.035) const;
     216
     217    // MTask
    171218    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    172219
  • trunk/MagicSoft/Mars/mhflux/MHAlpha.cc

    r7142 r7151  
    292292    if (!fResult)
    293293        return kFALSE;
     294    fSigma = (MParameterD*)const_cast<MParList*>(pl)->FindCreateObj("MParameterD", "GaussSigma");
     295    if (!fSigma)
     296        return kFALSE;
    294297
    295298    //fExcess = (MParameterD*)const_cast<MParList*>(pl)->FindCreateObj("MParameterD", "MExcess");
     
    469472            size = fHillas->GetSize();
    470473        energy = fEnergy   ? fEnergy->GetVal() : (fHillas?fHillas->GetSize():1000);
    471         theta  = fPointPos ? fPointPos->GetZd()   : 0;
    472     }
    473 
    474     //if (size>0)
    475     //    alpha /= (2.4 + 1.13*(log10((energy-14)/0.37)-5)*(log10((energy-14)/0.37)-5))/15;
     474        theta  = fPointPos ? fPointPos->GetZd() : 0;
     475    }
    476476
    477477    // enhance histogram if necessary
     
    480480    // Fill histograms
    481481    fHist.Fill(theta, energy, TMath::Abs(alpha), w);
    482 
    483     // Check cuts
    484     /*
    485     if ( (fEnergyMin>=0 && energy<fEnergyMin) ||
    486          (fEnergyMax>=0 && energy>fEnergyMax) ||
    487          (fSizeMin>=0   && size  <fSizeMin)   ||
    488          (fSizeMax>=0   && size  >fSizeMin) )
    489          return kTRUE;
    490          */
    491482
    492483    if (!fSkipHistTime)
     
    851842
    852843    fResult->SetVal(fFit.GetMinimizationValue());
     844    fSigma->SetVal(fFit.GetGausSigma());
    853845
    854846    if (!fSkipHistEnergy)
  • trunk/MagicSoft/Mars/mhflux/MHAlpha.h

    r7122 r7151  
    4444
    4545    MParameterD   *fResult;     //!
     46    MParameterD   *fSigma;      //!
    4647    MParameterD   *fEnergy;     //!
    4748    MHillas       *fHillas;     //!
  • trunk/MagicSoft/Mars/mhflux/MHThetaSq.h

    r7147 r7151  
    2424
    2525    Bool_t SetupFill(const MParList *pl);
    26     void InitMapping(MHMatrix *mat, Int_t type=0);
    2726
    2827    // MParContainer
     
    3130public:
    3231    MHThetaSq(const char *name=NULL, const char *title=NULL);
     32
     33    void InitMapping(MHMatrix *mat, Int_t type=0);
    3334
    3435    void SetNumBinsSignal(UInt_t n) { fNumBinsSignal=TMath::Max(n, 1U); }
  • trunk/MagicSoft/Mars/mjobs/JobsLinkDef.h

    r7121 r7151  
    1919#pragma link C++ class MJSpectrum+;
    2020
    21 #pragma link C++ class MJOptimize+;
    22 #pragma link C++ class MJOptimizeCuts+;
    23 #pragma link C++ class MJOptimizeEnergy+;
    24 
    2521#endif
  • trunk/MagicSoft/Mars/mjobs/MJOptimize.cc

    r7121 r7151  
    158158    MParList *plist = fEvtLoop->GetParList();
    159159
    160     MParameterD   *eval = (MParameterD*)plist->FindObject("MinimizationValue", "MParameterD");
     160    MParameterD   *eval = (MParameterD*)plist->FindObject(fNameMinimizationValue, "MParameterD");
    161161    MParContainer *pars = (MParContainer*)plist->FindObject("MParameters", "MParContainer");
    162162
     
    172172        *fLog << endl;
    173173    }
    174  
     174
    175175    pars->SetVariables(par);
    176176    eval->SetVal(0);
     
    225225}
    226226
    227 MJOptimize::MJOptimize() : fDebug(-1), fNumEvents(0), fType(kSimplex), fNumMaxCalls(0), fTolerance(0), fTestTrain(0)
     227MJOptimize::MJOptimize() : fDebug(-1), fNumEvents(0), fType(kSimplex), fNumMaxCalls(0), fTolerance(0), fTestTrain(0), fNameMinimizationValue("MinimizationValue")
    228228{
    229229    fRules.SetOwner();
     
    648648{
    649649    // Checks to make sure, that fcn doesn't crash
    650     if (!parlist.FindCreateObj("MParameterD", "MinimizationValue"))
     650    if (!parlist.FindCreateObj("MParameterD", fNameMinimizationValue))
    651651        return kFALSE;
    652652
  • trunk/MagicSoft/Mars/mjobs/MJOptimize.h

    r7142 r7151  
    7373    Float_t fTolerance;
    7474    Int_t   fTestTrain;
     75    TString fNameMinimizationValue;
    7576
    7677    Bool_t Optimize(MEvtLoop &evtloop);
     
    112113    void SetTolerance(Float_t tol=0)  { fTolerance=tol; }
    113114    void EnableTestTrain(Int_t b=1)   { fTestTrain=b; } // Use 1 and -1
     115    void SetNameMinimizationValue(const char *name="MinimizationValue") { fNameMinimizationValue = name; }
    114116
    115117    // Parameter access
  • trunk/MagicSoft/Mars/mjobs/MJOptimizeEnergy.cc

    r7121 r7151  
    2727// MJOptimize
    2828//
    29 // Class for otimizing the parameters of the supercuts
     29// Class for otimizing a rule to estimate the energy. For more details see
     30// MJOptimize.
    3031//
    31 // Minimization Control
    32 // ====================
     32// Example:
     33// --------
    3334//
    34 //   To choose the minimization algorithm use:
    35 //         void SetOptimizer(Optimizer_t o);
    36 //
    37 //   Allowed options are:
    38 //        enum Optimizer_t
    39 //        {
    40 //            kMigrad,      // Minimize by the method of Migrad
    41 //            kSimplex,     // Minimize by the method of Simplex
    42 //            kMinimize,    // Migrad + Simplex (if Migrad fails)
    43 //            kMinos,       // Minos error determination
    44 //            kImprove,     // Local minimum search
    45 //            kSeek,        // Minimize by the method of Monte Carlo
    46 //            kNone         // Skip optimization
    47 //        };
    48 //
    49 //   For more details on the methods see TMinuit.
    50 //
    51 //
    52 //   You can change the behaviour of the minimization using
    53 //
    54 //        void SetNumMaxCalls(UInt_t num=0);
    55 //        void SetTolerance(Float_t tol=0);
    56 //
    57 //   While NumMaxCalls is the first, Tolerance the second arguement.
    58 //   For more details start root and type
    59 //
    60 //        gMinuit->mnhelp("command")
    61 //
    62 //   while command can be
    63 //        * MIGRAD
    64 //        * SIMPLEX
    65 //        * MINIMIZE
    66 //        * MINOS
    67 //        * IMPROVE
    68 //        * SEEK
    69 //
    70 //   The default (num==0 and tol==0) should always give you the
    71 //   corresponding defaults used in Minuit.
    72 //
    73 //
    74 // FIXME: Implement changing cut in hadronness...
    75 // FIXME: Show MHSignificance on MStatusDisplay during filling...
    76 // FIXME: Choose step-size percentage as static data membewr
    77 // FIXME: Choose minimization method
     35//    MJOptimizeEnergy opt;
     36//    opt.SetDebug(2);
     37//    opt.SetOptimizer(MJOptimize::kMigrad);
     38//    opt.SetNumEvents(20000);
     39//    opt.EnableTestTrain();
     40//    opt.AddParameter("MHillas.fSize");
     41//    opt.SetParameter(0, 1, 0, 2);
     42//    char *r = "[0]*M[0]"; //Rule to calculate estimated energy
     43//    MStatusDisplay *d = new MStatusDisplay;
     44//    opt.SetDisplay(d);
     45//    opt.RunDisp("ganymed-summary.root", r);
    7846//
    7947/////////////////////////////////////////////////////////////////////////////
     
    11684// energy estimator.
    11785//
    118 Bool_t MJOptimizeEnergy::RunEnergy(const char *fname, const char *rule)
     86Bool_t MJOptimizeEnergy::RunEnergy(const char *fname, const char *rule, MTask *weights)
    11987{
    12088    fLog->Separator("Preparing Energy optimization");
     
    139107    hist.InitMapping(&m);
    140108
    141     MEnergyEstimate est("MParameters");
    142     est.SetRule(rule);
     109    MParameterCalc est(rule, "MParameters");
     110    est.SetNameParameter("MEnergyEst");
    143111    parlist.AddToList(&est);
    144112
     
    159127
    160128    MFillH fill(&hist);
     129    if (weights)
     130        fill.SetWeight();
    161131
    162132    MMatrixLoop loop(&m);
     
    164134    tasklist.AddToList(&loop);
    165135    tasklist.AddToList(&est);
     136    if (weights)
     137        tasklist.AddToList(weights);
    166138    tasklist.AddToList(&fill);
    167139
  • trunk/MagicSoft/Mars/mjobs/MJOptimizeEnergy.h

    r7121 r7151  
    66#endif
    77
     8class MTask;
     9
    810class MJOptimizeEnergy : public MJOptimize
    911{
    1012public:
     13    MJOptimizeEnergy() : MJOptimize() { }
     14
    1115    // Special optimizing routines
    12     Bool_t RunEnergy(const char *fname, const char *rule);
    13     Bool_t RunEnergy(const char *rule)
     16    Bool_t RunEnergy(const char *fname, const char *rule, MTask *weights=0);
     17    Bool_t RunEnergy(const char *rule, MTask *weights=0)
    1418    {
    15         return RunEnergy(0, rule);
     19        return RunEnergy(0, rule, weights);
    1620    }
    1721
Note: See TracChangeset for help on using the changeset viewer.