Show the slice of a TH2 following the mouse position.
{
TH2F *hpxpy =
new TH2F(
"hpxpy",
"py vs px",40,-4,4,40,-4,4);
for (
Int_t i = 0; i < 50000; i++) {
}
c1->AddExec(
"dynamic",
"DynamicExec()");
}
void DynamicExec()
{
if(!select) return;
int pyold =
gPad->GetUniqueID();
int px =
gPad->GetEventX();
int py =
gPad->GetEventY();
float uxmin =
gPad->GetUxmin();
float uxmax =
gPad->GetUxmax();
int pxmin =
gPad->XtoAbsPixel(uxmin);
int pxmax =
gPad->XtoAbsPixel(uxmax);
if(pyold)
gVirtualX->DrawLine(pxmin,pyold,pxmax,pyold);
if(
c2)
delete c2->GetPrimitive(
"Projection");
else c2 =
new TCanvas(
"c2",
"Projection Canvas",710,10,700,500);
TH1D *hp =
h->ProjectionX(
"",biny,biny);
char title[80];
sprintf(title,"Projection of biny=%d",biny);
}
- Author
- Rene Brun
Definition in file DynamicSlice.C.