00001 void hsumanim() {
00002
00003
00004
00005
00006
00007 c1 = new TCanvas("c1","The HSUM example",200,10,600,400);
00008 c1->SetGrid();
00009
00010 gBenchmark->Start("hsum");
00011
00012
00013 total = new TH1F("total","This is the total distribution",100,-4,4);
00014 main = new TH1F("main","Main contributor",100,-4,4);
00015 s1 = new TH1F("s1","This is the first signal",100,-4,4);
00016 s2 = new TH1F("s2","This is the second signal",100,-4,4);
00017 total->Sumw2();
00018 total->SetMarkerStyle(21);
00019 total->SetMarkerSize(0.7);
00020 main->SetFillColor(16);
00021 s1->SetFillColor(42);
00022 s2->SetFillColor(46);
00023 TSlider *slider = 0;
00024 gSystem->Unlink("hsumanim.gif");
00025
00026
00027 gRandom->SetSeed();
00028 const Int_t kUPDATE = 500;
00029 Float_t xs1, xs2, xmain;
00030 Int_t gifcnt = 0;
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","test",4.2,0,4.6,total->GetMaximum(),38);
00049 slider->SetFillColor(46);
00050 }
00051 if (slider) slider->SetRange(0,Float_t(i)/10000.);
00052 c1->Modified();
00053 c1->Update();
00054 if (gROOT->IsBatch()) {
00055 c1->Print("hsumanim.gif+");
00056 printf("i = %d\n", i);
00057 }
00058 }
00059 }
00060 slider->SetRange(0,1);
00061 total->Draw("sameaxis");
00062 c1->Modified();
00063
00064 if (gROOT->IsBatch()) c1->Print("hsumanim.gif++");
00065
00066
00067
00068 gBenchmark->Show("hsum");
00069 }