00001
00002 Int_t i;
00003 Float_t ratio;
00004 TSlider *slider;
00005 TCanvas *c1;
00006
00007 void hsumTimer(Int_t nfill=100000)
00008 {
00009
00010
00011
00012
00013
00014
00015
00016 c1 = new TCanvas("c1","The HSUM example",200,10,600,400);
00017 c1->SetGrid();
00018
00019
00020
00021 total = new TH1F("total","This is the total distribution",100,-4,4);
00022 main = new TH1F("main","Main contributor",100,-4,4);
00023 s1 = new TH1F("s1","This is the first signal",100,-4,4);
00024 s2 = new TH1F("s2","This is the second signal",100,-4,4);
00025 total->Sumw2();
00026 total->SetMarkerStyle(21);
00027 total->SetMarkerSize(0.7);
00028 main->SetFillColor(16);
00029 s1->SetFillColor(42);
00030 s2->SetFillColor(46);
00031 total->SetMaximum(nfill/20.);
00032 total->Draw("e1p");
00033 main->Draw("same");
00034 s1->Draw("same");
00035 s2->Draw("same");
00036 c1->Update();slider = new TSlider("slider",
00037 "test",4.2,0,4.6,0.8*total->GetMaximum(),38);
00038 slider->SetFillColor(46);
00039
00040
00041 TTimer timer("hsumUpdate()",300);
00042 timer.TurnOn();
00043
00044
00045 Float_t xs1, xs2, xmain;
00046 gRandom->SetSeed();
00047 for (Int_t i=0; i<nfill; i++) {
00048 ratio = Float_t(i)/Float_t(nfill);
00049 if (gSystem->ProcessEvents()) break;
00050 xmain = gRandom->Gaus(-1,1.5);
00051 xs1 = gRandom->Gaus(-0.5,0.5);
00052 xs2 = gRandom->Landau(1,0.15);
00053 main->Fill(xmain);
00054 s1->Fill(xs1,0.3);
00055 s2->Fill(xs2,0.2);
00056 total->Fill(xmain);
00057 total->Fill(xs1,0.3);
00058 total->Fill(xs2,0.2);
00059 }
00060 timer.TurnOff();
00061 hsumUpdate();
00062 }
00063
00064 void hsumUpdate()
00065 {
00066
00067 if (slider) slider->SetRange(0,ratio);
00068 c1->Modified();
00069 c1->Update();
00070 }