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