Changeset 7409 for trunk/MagicSoft/Mars/mhflux
- Timestamp:
- 11/18/05 17:15:30 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhflux/MHEnergyEst.cc
r7388 r7409 35 35 #include "MHEnergyEst.h" 36 36 37 #include <TF1.h> 37 38 #include <TLine.h> 38 39 #include <TCanvas.h> … … 79 80 fHResolution.SetDirectory(NULL); 80 81 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}"); 82 83 fHResolution.SetXTitle("E_{est} [GeV]"); 83 84 fHResolution.SetYTitle("E_{mc} [GeV]"); 84 fHResolution.SetZTitle(" lg(E_{est}) - lg(E_{mc})");85 fHResolution.SetZTitle("E_{est}/E_{mc}-1"); 85 86 86 87 fHImpact.SetDirectory(NULL); 87 88 fHImpact.SetName("Impact"); 88 fHImpact.SetTitle("\\Delta lg(E)vs Impact parameter");89 fHImpact.SetTitle("\\Delta E/E vs Impact parameter"); 89 90 fHImpact.SetXTitle("Impact parameter [m]"); 90 fHImpact.SetYTitle(" lg(E_{est}) - lg(E_{mc})");91 fHImpact.SetYTitle("E_{est}/E_{mc}-1"); 91 92 92 93 fHEnergy.Sumw2(); … … 95 96 96 97 MBinning binsi, binse, binst, binsr; 97 binse.SetEdgesLog( 15, 10, 1000000);98 binse.SetEdgesLog(25, 10, 1000000); 98 99 binst.SetEdgesASin(51, -0.005, 0.505); 99 100 binsi.SetEdges(10, 0, 400); 100 binsr.SetEdges( 50, -1.3, 1.3);101 binsr.SetEdges(75, -1.75, 1.75); 101 102 102 103 SetBinning(&fHEnergy, &binse, &binse, &binst); … … 149 150 fChisq = 0; 150 151 fBias = 0; 152 151 153 fHEnergy.Reset(); 152 154 fHImpact.Reset(); … … 155 157 return kTRUE; 156 158 } 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 164 160 // -------------------------------------------------------------------------- 165 161 // … … 172 168 const Double_t imp = fMatrix ? GetVal(1) : fMcEvt->GetImpact()/100; 173 169 const Double_t theta = fMatrix ? GetVal(2) : fMcEvt->GetTelescopeTheta()*TMath::RadToDeg(); 174 const Double_t res = log10(eest)-log10(etru);///log10(etru);175 170 const Double_t resE = (eest-etru)/etru; 176 171 … … 179 174 fHImpact.Fill(imp, resE, w); 180 175 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; 193 182 194 183 return kTRUE; 195 184 } 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 228 186 Bool_t MHEnergyEst::Finalize() 229 187 { 230 //Double_t chisq, prob;231 //CalcChisq(chisq, prob);232 233 188 fChisq /= GetNumExecutions(); 234 189 fBias /= GetNumExecutions(); 235 190 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 242 193 Print(); 243 194 … … 247 198 void MHEnergyEst::Print(Option_t *o) const 248 199 { 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); 253 204 if (TMath::IsNaN(res)) 254 205 { … … 257 208 } 258 209 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; 263 225 } 264 226 … … 411 373 h1->SetBit(kCanDelete); 412 374 h1->SetLineWidth(2); 413 h1->SetLineColor(k Red);375 h1->SetLineColor(kBlue); 414 376 h1->SetFillStyle(4000); 415 377 h1->SetStats(kFALSE); 416 378 417 379 h2->Draw(""); 418 h1->Draw("E 3hist C same");380 h1->Draw("E0 hist C same"); 419 381 // h1->Draw("Chistsame"); 420 382 … … 509 471 //h->SetXTitle("\\frac{lg(E_{est}) - lg(E_{mc})}{lg(E_{mc})}"); 510 472 h->SetYTitle("Counts"); 511 h->SetTitle("Distribution of \\Delta lg(E)");473 h->SetTitle("Distribution of \\Delta E/E"); 512 474 h->SetDirectory(NULL); 513 475 h->SetBit(kCanDelete); … … 535 497 h = MakePlot(fHResolution, "zy"); 536 498 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}"); 539 501 h->SetMinimum(-1.3); 540 502 h->SetMaximum(1.3); … … 543 505 h = MakePlot(fHResolution, "zx"); 544 506 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}"); 547 509 h->SetMinimum(-1.3); 548 510 h->SetMaximum(1.3);
Note:
See TracChangeset
for help on using the changeset viewer.