00001
00002 void exec2()
00003 {
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 TObject *select = gPad->GetSelected();
00019 if(!select) return;
00020 if (!select->InheritsFrom(TH2::Class())) {gPad->SetUniqueID(0); return;}
00021 gPad->GetCanvas()->FeedbackMode(kTRUE);
00022
00023
00024 int pyold = gPad->GetUniqueID();
00025 int px = gPad->GetEventX();
00026 int py = gPad->GetEventY();
00027 float uxmin = gPad->GetUxmin();
00028 float uxmax = gPad->GetUxmax();
00029 int pxmin = gPad->XtoAbsPixel(uxmin);
00030 int pxmax = gPad->XtoAbsPixel(uxmax);
00031 if(pyold) gVirtualX->DrawLine(pxmin,pyold,pxmax,pyold);
00032 gVirtualX->DrawLine(pxmin,py,pxmax,py);
00033 gPad->SetUniqueID(py);
00034 Float_t upy = gPad->AbsPixeltoY(py);
00035 Float_t y = gPad->PadtoY(upy);
00036
00037
00038 TVirtualPad *padsav = gPad;
00039 TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2");
00040 if(c2) delete c2->GetPrimitive("Projection");
00041 else c2 = new TCanvas("c2");
00042 c2->cd();
00043
00044
00045 TH2 *h = (TH2*)select;
00046 Int_t biny = h->GetYaxis()->FindBin(y);
00047 TH1D *hp = h->ProjectionX("",biny,biny);
00048 char title[80];
00049 sprintf(title,"Projection of biny=%d",biny);
00050 hp->SetName("Projection");
00051 hp->SetTitle(title);
00052 hp->Fit("gaus","ql");
00053 c2->Update();
00054 padsav->cd();
00055 }