21 TH1F *hpx, *total, *hmain, *s1, *s2;
22 TThread *thread1, *thread2, *threadj;
31 hpx =
new TH1F(
"hpx",
"This is the px distribution", 100, -4, 4);
32 hpx->SetFillColor(48);
36 for (Int_t i = 0; i < nfills; i++) {
37 gRandom->Rannor(px, py);
40 if (i && (i%upd) == 0) {
48 TMethodCall c(c1->IsA(),
"Print",
"");
52 arr[3] = (
void*)
"\"hpxanim.gif+50\"";
53 (*gThreadXAR)(
"METH", 4, arr, NULL);
58 TMethodCall c(c1->IsA(),
"Print",
"");
62 arr[3] = (
void*)
"\"hpxanim.gif++\"";
63 (*gThreadXAR)(
"METH", 4, arr, NULL);
73 total =
new TH1F(
"total",
"This is the total distribution",100,-4,4);
74 hmain =
new TH1F(
"hmain",
"Main contributor",100,-4,4);
75 s1 =
new TH1F(
"s1",
"This is the first signal",100,-4,4);
76 s2 =
new TH1F(
"s2",
"This is the second signal",100,-4,4);
78 total->SetMarkerStyle(21);
79 total->SetMarkerSize(0.7);
80 hmain->SetFillColor(16);
84 Float_t xs1, xs2, xmain;
86 for (Int_t i = 0; i < nfills; i++) {
87 xmain = gRandom->Gaus(-1,1.5);
88 xs1 = gRandom->Gaus(-0.5,0.5);
89 xs2 = gRandom->Landau(1,0.15);
96 if (i && (i%upd) == 0) {
107 TMethodCall c(c2->IsA(),
"Print",
"");
111 arr[3] = (
void*)
"\"hsumanim.gif+50\"";
112 (*gThreadXAR)(
"METH", 4, arr, NULL);
115 total->Draw(
"sameaxis");
119 TMethodCall c(c2->IsA(),
"Print",
"");
123 arr[3] = (
void*)
"\"hsumanim.gif++\"";
124 (*gThreadXAR)(
"METH", 4, arr, NULL);
138 void tryclosing(Int_t
id)
141 if (!finished)
return;
142 if (
id == 1) ((TRootCanvas *)c1->GetCanvasImp())->CloseWindow();
143 else if (
id == 2) ((TRootCanvas *)c2->GetCanvasImp())->CloseWindow();
150 if (gROOT->IsBatch()) {
153 c1 =
new TCanvas(
"c1",
"Dynamic Filling Example", 100, 30, 400, 300);
154 c1->SetFillColor(42);
155 c1->GetFrame()->SetFillColor(21);
156 c1->GetFrame()->SetBorderSize(6);
157 c1->GetFrame()->SetBorderMode(-1);
160 TRootCanvas *rc =
dynamic_cast<TRootCanvas*
>(c1->GetCanvasImp());
163 rc->Connect(
"CloseWindow()", 0, 0,
164 "tryclosing(Int_t=1)");
167 c2 =
new TCanvas(
"c2",
"Dynamic Filling Example", 515, 30, 400, 300);
171 rc =
dynamic_cast<TRootCanvas*
>(c2->GetCanvasImp());
173 rc->Connect(
"CloseWindow()", 0, 0,
174 "tryclosing(Int_t=2)");
179 gSystem->Unlink(
"hpxanim.gif");
180 gSystem->Unlink(
"hsumanim.gif");
182 printf(
"Starting Thread 0\n");
183 thread1 =
new TThread(
"t0", handle1, (
void*) 0);
185 printf(
"Starting Thread 1\n");
186 thread2 =
new TThread(
"t1", handle2, (
void*) 1);
188 printf(
"Starting Joiner Thread \n");
189 threadj =
new TThread(
"t4", joiner, (
void*) 3);
196 gSystem->ProcessEvents();