Ignore:
Timestamp:
11/18/05 17:15:30 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc

    r7388 r7409  
    3535#include "MHEnergyEst.h"
    3636
     37#include <TF1.h>
    3738#include <TLine.h>
    3839#include <TCanvas.h>
     
    7980    fHResolution.SetDirectory(NULL);
    8081    fHResolution.SetName("EnergyRes");
    81     fHResolution.SetTitle("Histogram in \\Delta lg(E) vs E_{est} and E_{mc}");
     82    fHResolution.SetTitle("Histogram in \\Delta E/E vs E_{est} and E_{mc}");
    8283    fHResolution.SetXTitle("E_{est} [GeV]");
    8384    fHResolution.SetYTitle("E_{mc} [GeV]");
    84     fHResolution.SetZTitle("lg(E_{est}) - lg(E_{mc})");
     85    fHResolution.SetZTitle("E_{est}/E_{mc}-1");
    8586
    8687    fHImpact.SetDirectory(NULL);
    8788    fHImpact.SetName("Impact");
    88     fHImpact.SetTitle("\\Delta lg(E) vs Impact parameter");
     89    fHImpact.SetTitle("\\Delta E/E vs Impact parameter");
    8990    fHImpact.SetXTitle("Impact parameter [m]");
    90     fHImpact.SetYTitle("lg(E_{est}) - lg(E_{mc})");
     91    fHImpact.SetYTitle("E_{est}/E_{mc}-1");
    9192
    9293    fHEnergy.Sumw2();
     
    9596
    9697    MBinning binsi, binse, binst, binsr;
    97     binse.SetEdgesLog(15, 10, 1000000);
     98    binse.SetEdgesLog(25, 10, 1000000);
    9899    binst.SetEdgesASin(51, -0.005, 0.505);
    99100    binsi.SetEdges(10, 0, 400);
    100     binsr.SetEdges(50, -1.3, 1.3);
     101    binsr.SetEdges(75, -1.75, 1.75);
    101102
    102103    SetBinning(&fHEnergy,     &binse, &binse, &binst);
     
    149150    fChisq = 0;
    150151    fBias  = 0;
     152
    151153    fHEnergy.Reset();
    152154    fHImpact.Reset();
     
    155157    return kTRUE;
    156158}
    157 /*
    158 #include <TSpline.h>
    159 Double_t x[] = {33, 75, 153, 343, 745, 1617, 3509, 7175};
    160 Double_t y[] = {2,  24, 302, 333, 132,   53,   11,    1};
    161 Int_t n = 8;
    162 TSpline3 spline("", x, y, n);
    163 */
     159
    164160// --------------------------------------------------------------------------
    165161//
     
    172168    const Double_t imp   = fMatrix ? GetVal(1) : fMcEvt->GetImpact()/100;
    173169    const Double_t theta = fMatrix ? GetVal(2) : fMcEvt->GetTelescopeTheta()*TMath::RadToDeg();
    174     const Double_t res   = log10(eest)-log10(etru);///log10(etru);
    175170    const Double_t resE  = (eest-etru)/etru;
    176171
     
    179174    fHImpact.Fill(imp, resE, w);
    180175
    181     //if (etru>125 && etru<750)
    182     //    return kCONTINUE;
    183 
    184     // lg(N)  = 4.3*lg(E)-6
    185     // lg(N0) = 4.3*2.2-6
    186 
    187     const Double_t n  = 2.;///spline.Eval(etru); //pow(10, -4.3*(log10(etru)-2.2));
    188     if (n<=0)
    189         return kCONTINUE;
    190 
    191     fChisq += log10(etru)>0 ? res*res*n/2   : res*res;
    192     fBias  += log10(etru)>0 ? res*sqrt(n/2) : res;
     176    // For the fit we use a different quantity
     177    //const Double_t res = TMath::Log10(eest/etru);
     178    const Double_t res = eest-etru;
     179
     180    fChisq += res*res;
     181    fBias  += res;
    193182
    194183    return kTRUE;
    195184}
    196 /*
    197 void MHEnergyEst::CalcChisq(Double_t &chisq, Double_t &prob) const
    198 {
    199     TH1D *h1 = (TH1D*)fHEnergy.Project3D("dum2_ex");
    200     TH1D *h2 = (TH1D*)fHEnergy.Project3D("dum2_ey");
    201 
    202     Int_t df = 0;
    203     chisq    = 0;
    204     prob     = 0;
    205 
    206     for (Int_t i=1; i<=h1->GetNbinsX(); i++)
    207     {
    208         if (h1->GetBinContent(i)>0 && h2->GetBinContent(i)>0)
    209         {
    210             const Double_t bin1 = log10(h1->GetBinContent(i));
    211             const Double_t bin2 = log10(h2->GetBinContent(i));
    212 
    213             const Double_t temp = bin1-bin2;
    214 
    215             chisq += temp*temp/(bin1+bin2);
    216             df ++;
    217         }
    218     }
    219  
    220     prob = TMath::Prob(0.5*chisq, Int_t(0.5*df));
    221 
    222     chisq /= df;
    223  
    224     delete h1;
    225     delete h2;
    226 }
    227 */
     185
    228186Bool_t MHEnergyEst::Finalize()
    229187{
    230     //Double_t chisq, prob;
    231     //CalcChisq(chisq, prob);
    232  
    233188    fChisq /= GetNumExecutions();
    234189    fBias  /= GetNumExecutions();
    235190
    236     fResult->SetVal(TMath::Sqrt(fChisq));
    237 
    238 /*
    239     Double_t sigma = TMath::Sqrt(fChisq);//+TMath::Abs(fBias);
    240     fResult->SetVal(sigma);
    241 */
     191    fResult->SetVal(fChisq);
     192
    242193    Print();
    243194
     
    247198void MHEnergyEst::Print(Option_t *o) const
    248199{
    249     const Double_t res  =   TMath::Sqrt(fChisq-fBias*fBias);
    250     const Double_t resp =   TMath::Power(10,  res)-1;
    251     const Double_t resm = 1-TMath::Power(10, -res);
    252 
     200    //    const Double_t resp =   TMath::Power(10,  res)-1;
     201    //    const Double_t resm = 1-TMath::Power(10, -res);
     202
     203    const Double_t res = TMath::Sqrt(fChisq-fBias*fBias);
    253204    if (TMath::IsNaN(res))
    254205    {
     
    257208    }
    258209
    259     *fLog << all;
    260     *fLog << "Mean log10(Energy) Resoltion: +/- " << Form("%4.2f", res) << endl;
    261     *fLog << "Mean log10(Energy) Bias:         "  << Form("%+4.2f", fBias) << endl;
    262     *fLog << "Asymmetric Energy  Resoltion:   +"  << Form("%4.1f%%", resp*100) << " -" << Form("%4.1f%%", resm*100) << endl;
     210    TH1D *h = (TH1D*)fHResolution.ProjectionZ("Resolution");
     211    h->Fit("gaus", "Q0");
     212
     213    TF1 *f = h->GetFunction("gaus");
     214
     215    *fLog << all << "F=" << fChisq << endl;
     216    *fLog << "Results from Histogram:" << endl;
     217    *fLog << " Mean  of Delta E/E: " << Form("%+4.2f%%", 100*h->GetMean()) << endl;
     218    *fLog << " RMS   of Delta E/E: " << Form("%4.2f%%",  100*h->GetRMS()) << endl;
     219    *fLog << "Results from Histogram-Fit:" << endl;
     220    *fLog << " Bias  of Delta E/E: " << Form("%+4.2f%%", 100*f->GetParameter(1)) << endl;
     221    *fLog << " Sigma of Delta E/E: " << Form("%4.2f%%",  100*f->GetParameter(2)) << endl;
     222    *fLog << " Res   of Delta E/E: " << Form("%4.2f%%",  100*TMath::Hypot(f->GetParameter(1), f->GetParameter(2))) << endl;
     223
     224    delete h;
    263225}
    264226
     
    411373    h1->SetBit(kCanDelete);
    412374    h1->SetLineWidth(2);
    413     h1->SetLineColor(kRed);
     375    h1->SetLineColor(kBlue);
    414376    h1->SetFillStyle(4000);
    415377    h1->SetStats(kFALSE);
    416378
    417379    h2->Draw("");
    418     h1->Draw("E3 hist C same");
     380    h1->Draw("E0 hist C same");
    419381//    h1->Draw("Chistsame");
    420382
     
    509471    //h->SetXTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}");
    510472    h->SetYTitle("Counts");
    511     h->SetTitle("Distribution of \\Delta lg(E)");
     473    h->SetTitle("Distribution of \\Delta E/E");
    512474    h->SetDirectory(NULL);
    513475    h->SetBit(kCanDelete);
     
    535497    h = MakePlot(fHResolution, "zy");
    536498    h->SetXTitle("E_{mc} [GeV]");
    537     h->SetYTitle("lg(E_{est}) - lg(E_{mc})");
    538     h->SetTitle("Energy resolution \\Delta lg(E) vs Monte Carlo energy E_{mc}");
     499    h->SetYTitle("(E_{est}/E_{mc}-1");
     500    h->SetTitle("Energy resolution \\Delta E/E vs Monte Carlo Energy E_{mc}");
    539501    h->SetMinimum(-1.3);
    540502    h->SetMaximum(1.3);
     
    543505    h = MakePlot(fHResolution, "zx");
    544506    h->SetXTitle("E_{est} [GeV]");
    545     h->SetYTitle("lg(E_{est}) - lg(E_{mc})");
    546     h->SetTitle("Energy Resolution \\Delta lg(E) vs estimated Energy E_{est}");
     507    h->SetYTitle("(E_{est}/E_{mc}-1");
     508    h->SetTitle("Energy resolution \\Delta E/E vs estimated Energy E_{est}");
    547509    h->SetMinimum(-1.3);
    548510    h->SetMaximum(1.3);
Note: See TracChangeset for help on using the changeset viewer.