//void PaintArea (TH1 *h, Int_t binl, Int_t binh, Int_t color) { gROOT->Reset(); TCanvas * c1 = new TCanvas("c1", "c1", 600, 100, 600, 400); TFile f("hsimple.root"); Float_t from = 0; Float_t to = 50; TFile f1("hnew.root", "RECREATE"); TH1F * h = new TH1F("threeg", "Three gaussians", 200, from, to); TF1 * fg3 = new TF1("fg3", "gaus(0) + gaus(3) + gaus(6)", from, to); fg3->SetParName(0, "gc_1"); fg3->SetParName(1, "gm_1"); fg3->SetParName(2, "gs_1"); fg3->SetParName(3, "gc_2"); fg3->SetParName(4, "gm_2"); fg3->SetParName(5, "gs_2"); fg3->SetParName(6, "gc_3"); fg3->SetParName(7, "gm_3"); fg3->SetParName(8, "gs_3"); fg3->SetParameter(0, 5); fg3->SetParameter(1, 10); fg3->SetParameter(2, 4); fg3->SetParameter(3, 3); fg3->SetParameter(4, 20); fg3->SetParameter(5, 2); fg3->SetParameter(6, 1); fg3->SetParameter(7, 30); fg3->SetParameter(8, 7); for (Int_t i=0; i < 1000; i++) { h->FillRandom("fg3"); } h->Draw(); h->SetFillStyle(1001); h->SetFillColor(94); Int_t binl = 65; Int_t binh = 100; Int_t color = 4; Int_t colora = 7; h->Draw(); // printf("%d %d %d\n", bin, color, h->GetBinContent(bin)); Int_t nbins = binh - binl + 1; TGraph * pl = new TGraph(2 * nbins + 3); Int_t ip = 0; Axis_t ymin = h->GetYaxis()->GetXmin(); for (Int_t bin = binl; bin <= binh; bin++) { pl->SetPoint(ip, h->GetBinLowEdge(bin), h->GetBinContent(bin)); pl->SetPoint(ip + 1 , h->GetBinLowEdge(bin) + h->GetBinWidth(bin), h->GetBinContent(bin)); ip += 2; } pl->SetPoint(ip, (pl->GetX())[ip-1], ymin); pl->SetPoint(ip+1, (pl->GetX())[0], ymin ); pl->SetPoint(ip+2, (pl->GetX())[0], (pl->GetY())[1]); pl->SetFillColor(color); pl->Draw("LF"); c1->Modified(); c1->Update(); // c1->Print("cblue.gif"); // pl->SetFillColor(colora); // c1->Modified(); // c1->Update(); // c1->Print("ccyan.gif"); h->GetListOfFunctions()->Add(pl, "LF"); h->Write(); // let it blink in 0.3 sec for (Int_t i = 0; i < 100; i++) { if (gSystem->ProcessEvents()) break; gSystem->Sleep(200); pl->SetFillColor(colora); c1->Modified(); c1->Update(); if (gSystem->ProcessEvents()) break; gSystem->Sleep(200); pl->SetFillColor(color); c1->Modified(); c1->Update(); if (gSystem->ProcessEvents()) break; } }