Changeset 1968
- Timestamp:
- 04/21/03 14:25:52 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHHadronness.cc
r1952 r1968 92 92 fGraph->SetTitle("Acceptance Gammas vs. Hadrons"); 93 93 fGraph->SetMaximum(1); 94 95 fGhness = new TH1D("Ghness", "Hadronness", nbins, 0, 1); 96 fPhness = new TH1D("Phness", "Hadronness", nbins, 0, 1); 94 fGraph->SetMarkerStyle(kFullDotSmall); 95 96 fGhness = new TH1D("Ghness", "H. Gammas", nbins, 0, 1); 97 fPhness = new TH1D("Phness", "H. Hadrons", nbins, 0, 1); 97 98 fGhness->SetXTitle("Hadronness"); 98 99 fPhness->SetXTitle("Hadronness"); 99 100 fGhness->SetYTitle("Counts"); 100 101 fPhness->SetYTitle("Counts"); 102 fPhness->SetLineColor(kRed); 103 fGhness->SetDirectory(NULL); 104 fPhness->SetDirectory(NULL); 101 105 102 106 fIntGhness = new TH1D("AccGammas", "Acceptance", nbins, 0, 1); … … 108 112 fIntGhness->SetMaximum(1.1); 109 113 fIntPhness->SetMaximum(1.1); 114 fIntGhness->SetDirectory(NULL); 115 fIntPhness->SetDirectory(NULL); 116 fIntPhness->SetLineColor(kRed); 117 fIntGhness->SetBit(TH1::kNoStats); 118 fIntPhness->SetBit(TH1::kNoStats); 110 119 111 120 fQfac = new TGraph; 112 121 fQfac->SetTitle(" Naive Quality factor "); 113 114 fGhness->SetDirectory(NULL); 115 fPhness->SetDirectory(NULL); 116 fIntGhness->SetDirectory(NULL); 117 fIntPhness->SetDirectory(NULL); 122 fQfac->SetMarkerStyle(kFullDotSmall); 118 123 } 119 124 … … 241 246 // - fill the Quality histogram (formular see class description) 242 247 // 243 Bool_t MHHadronness::Finalize()248 void MHHadronness::CalcGraph(Double_t sumg, Double_t sump) 244 249 { 245 250 Int_t n = fGhness->GetNbinsX(); … … 248 253 fQfac->Set(n); 249 254 255 // Calculate acceptances 256 Float_t max=0; 257 258 for (Int_t i=1; i<=n; i++) 259 { 260 const Stat_t ip = fPhness->Integral(1, i)/sump; 261 const Stat_t ig = fGhness->Integral(1, i)/sumg; 262 263 fIntPhness->SetBinContent(i, ip); 264 fIntGhness->SetBinContent(i, ig); 265 266 fGraph->SetPoint(i, ip, ig); 267 268 if (ip<=0) 269 continue; 270 271 const Double_t val = ig/sqrt(ip); 272 fQfac->SetPoint(i, ig, val); 273 274 if (val>max) 275 max = val; 276 } 277 278 fQfac->SetMaximum(max*1.05); 279 } 280 281 Bool_t MHHadronness::Finalize() 282 { 250 283 const Stat_t sumg = fGhness->Integral(); 251 284 const Stat_t sump = fPhness->Integral(); 252 285 253 286 *fLog << inf << "Sum Hadronness: gammas=" << sumg << " hadrons=" << sump << endl; 254 255 if (sumg==0 )256 *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl;257 if (sump==0)258 *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl;259 287 260 288 // Normalize photon distribution 261 289 if (sumg>0) 262 290 fGhness->Scale(1./sumg); 291 else 292 *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl; 263 293 264 294 // Normalize hadron distribution 265 295 if (sump>0) 266 296 fPhness->Scale(1./sump); 267 268 // Calculate acceptances 269 Float_t max=0; 270 271 for (Int_t i=1; i<=n; i++) 272 { 273 const Stat_t ip = fPhness->Integral(1, i); 274 const Stat_t ig = fGhness->Integral(1, i); 275 276 fIntPhness->SetBinContent(i, ip); 277 fIntGhness->SetBinContent(i, ig); 278 279 fGraph->SetPoint(i, ip, ig); 280 281 if (ip<=0) 282 continue; 283 284 const Double_t val = ig/sqrt(ip); 285 fQfac->SetPoint(i, ig, val); 286 287 if (val>max) 288 max = val; 289 } 290 291 fQfac->SetMaximum(max*1.05); 297 else 298 *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl; 299 300 CalcGraph(1, 1); 292 301 293 302 return kTRUE; 303 } 304 305 void MHHadronness::Paint(Option_t *opt="") 306 { 307 Stat_t sumg = fGhness->Integral(); 308 Stat_t sump = fPhness->Integral(); 309 310 // Normalize photon distribution 311 if (sumg<=0) 312 sumg=1; 313 314 // Normalize hadron distribution 315 if (sump<=0) 316 sump=1; 317 318 CalcGraph(sumg, sump); 294 319 } 295 320 … … 399 424 // -------------------------------------------------------------------------- 400 425 // 401 // Draw clone of all histograms. (For the Meaning see class description) 402 // 403 TObject *MHHadronness::DrawClone(Option_t *opt) const 404 { 405 if (fGraph->GetN()==0) 406 return NULL; 407 408 TCanvas &c = *MakeDefCanvas("Hadronness", fTitle); 409 c.Divide(2, 2); 410 411 gROOT->SetSelectedPad(NULL); 412 413 c.cd(1); 426 // Draw all histograms. (For the Meaning see class description) 427 // 428 void MHHadronness::Draw(Option_t *) 429 { 430 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas("Hadronness", fTitle); 431 pad->SetBorderMode(0); 432 433 AppendPad(""); 434 435 pad->Divide(2, 2); 436 437 TH1 *h; 438 439 pad->cd(1); 440 gPad->SetBorderMode(0); 414 441 //gStyle->SetOptStat(10); 415 Getghness()->DrawCopy(); 416 Getphness()->SetLineColor(kRed); 417 Getphness()->DrawCopy("same"); 418 419 c.cd(2); 420 //gStyle->SetOptStat(0); 421 Getighness()->DrawCopy(); 422 Getiphness()->SetLineColor(kRed); 423 Getiphness()->DrawCopy("same"); 424 425 c.cd(3); 426 TGraph &g2 = (TGraph&)*fQfac->DrawClone("A*"); 427 g2.SetBit(kCanDelete); 428 gPad->Modified(); 429 gPad->Update(); 430 if (g2.GetHistogram()) 431 { 432 g2.GetXaxis()->SetRangeUser(0, 1); 433 g2.GetXaxis()->SetTitle("Acceptance Gammas"); 434 g2.GetYaxis()->SetTitle("Quality"); 435 g2.SetMarkerStyle(kFullDotSmall); 436 g2.Draw("P"); 437 438 gPad->Modified(); 439 gPad->Update(); 440 } 441 442 c.cd(4); 443 gPad->Modified(); 444 gPad->Update(); 445 TGraph &g = (TGraph&)*fGraph->DrawClone("AC"); 446 g.SetBit(kCanDelete); 447 gPad->Modified(); 448 gPad->Update(); 449 if (g.GetHistogram()) 450 { 451 g.GetXaxis()->SetRangeUser(0, 1); 452 g.GetXaxis()->SetTitle("Acceptance Hadrons"); 453 g.GetYaxis()->SetTitle("Acceptance Gammas"); 454 g.SetMarkerStyle(kFullDotSmall); 455 g.Draw("P"); 456 457 gPad->Modified(); 458 gPad->Update(); 459 } 460 /* 461 const Int_t h = fMinDist->GetMaximumBin(); 462 TMarker *m = new TMarker(fIntPhness->GetBinContent(h), 463 fIntGhness->GetBinContent(h), kStar); 464 m->SetMarkerColor(kBlue); 465 m->SetBit(kCanDelete); 466 m->Draw(); 467 */ 468 469 gStyle->SetOptStat(1111); 470 471 return &c; 472 } 473 474 // -------------------------------------------------------------------------- 475 // 476 // Draw all histograms. (For the Meaning see class description) 477 // 478 void MHHadronness::Draw(Option_t *) 479 { 480 if (fGraph->GetN()==0) 481 return; 482 483 if (!gPad) 484 MakeDefCanvas("Hadronness", fTitle); 485 486 gPad->Divide(2, 2); 487 488 gPad->cd(1); 489 //gStyle->SetOptStat(10); 490 Getghness()->Draw(); 491 Getphness()->SetLineColor(kRed); 492 Getphness()->Draw("same"); 493 494 gPad->cd(2); 495 //gStyle->SetOptStat(0); 496 Getighness()->Draw(); 497 Getiphness()->SetLineColor(kRed); 498 Getiphness()->Draw("same"); 499 500 gPad->cd(3); 442 MH::Draw(*fGhness, *fPhness, "Hadronness"); // Displ both stat boxes 443 444 pad->cd(2); 445 gPad->SetBorderMode(0); 446 fIntGhness->Draw(); 447 fIntPhness->Draw("same"); 448 449 pad->cd(3); 450 gPad->SetBorderMode(0); 501 451 fQfac->Draw("A*"); 502 452 gPad->Modified(); 503 453 gPad->Update(); 504 if (fQfac->GetHistogram()) 505 { 506 fQfac->GetXaxis()->SetRangeUser(0, 1); 507 fQfac->GetXaxis()->SetTitle("Acceptance Gammas"); 508 fQfac->GetYaxis()->SetTitle("Quality"); 509 fQfac->SetMarkerStyle(kFullDotSmall); 454 if ((h=fQfac->GetHistogram())) 455 { 456 h->GetXaxis()->SetRangeUser(0, 1); 457 h->SetXTitle("Acceptance Gammas"); 458 h->SetYTitle("Quality"); 510 459 fQfac->Draw("P"); 511 512 460 gPad->Modified(); 513 461 gPad->Update(); 514 462 } 515 gPad->cd(4); 516 gPad->Modified();517 gPad-> Update();463 464 pad->cd(4); 465 gPad->SetBorderMode(0); 518 466 fGraph->Draw("AC"); 519 467 gPad->Modified(); 520 468 gPad->Update(); 521 if (fGraph->GetHistogram()) 522 { 523 fGraph->GetXaxis()->SetRangeUser(0, 1); 524 fGraph->GetXaxis()->SetTitle("Acceptance Hadrons"); 525 fGraph->GetYaxis()->SetTitle("Acceptance Gammas"); 526 fGraph->SetMarkerStyle(kFullDotSmall); 469 if ((h=fGraph->GetHistogram())) 470 { 471 h->GetXaxis()->SetRangeUser(0, 1); 472 h->SetXTitle("Acceptance Hadrons"); 473 h->SetYTitle("Acceptance Gammas"); 527 474 fGraph->Draw("P"); 528 475 gPad->Modified(); -
trunk/MagicSoft/Mars/mhist/MHHadronness.h
r1910 r1968 26 26 TGraph *fGraph; //-> gamma acceptance vs. hadron acceptance 27 27 28 void Paint(Option_t *opt=""); 29 void CalcGraph(Double_t sumg, Double_t sump); 30 28 31 public: 29 32 MHHadronness(Int_t nbins=100, const char *name=NULL, const char *title=NULL); … … 48 51 49 52 void Draw(Option_t *opt=""); 50 TObject *DrawClone(Option_t *opt="") const;51 53 52 54 ClassDef(MHHadronness, 1) // Gamma/Hadron Separation Quality Histograms
Note:
See TracChangeset
for help on using the changeset viewer.