28 Error(
"exec2",
"gPad is null, you are not supposed to run this macro");
33 TObject *select = gPad->GetSelected();
35 if (!select->InheritsFrom(TH2::Class())) {gPad->SetUniqueID(0);
return;}
36 gPad->GetCanvas()->FeedbackMode(kTRUE);
39 int pyold = gPad->GetUniqueID();
40 int px = gPad->GetEventX();
41 int py = gPad->GetEventY();
42 float uxmin = gPad->GetUxmin();
43 float uxmax = gPad->GetUxmax();
44 int pxmin = gPad->XtoAbsPixel(uxmin);
45 int pxmax = gPad->XtoAbsPixel(uxmax);
46 if(pyold) gVirtualX->DrawLine(pxmin,pyold,pxmax,pyold);
47 gVirtualX->DrawLine(pxmin,py,pxmax,py);
48 gPad->SetUniqueID(py);
49 Float_t upy = gPad->AbsPixeltoY(py);
50 Float_t y = gPad->PadtoY(upy);
53 TVirtualPad *padsav = gPad;
54 TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(
"c2");
55 if(c2)
delete c2->GetPrimitive(
"Projection");
56 else c2 =
new TCanvas(
"c2");
60 TH2 *h = (TH2*)select;
61 Int_t biny = h->GetYaxis()->FindBin(y);
62 TH1D *hp = h->ProjectionX(
"",biny,biny);
64 sprintf(title,
"Projection of biny=%d",biny);
65 hp->SetName(
"Projection");