Go to the documentation of this file.00001 #include "Riostream.h"
00002
00005
00006
00007
00009
00011
00012
00013
00014
00016 Bool_t profileX(const char* name1, Int_t firstybin, Int_t lastybin, Bool_t draw)
00017 {
00018 if(TGo4AbstractInterface::Instance()==0 || go4!=TGo4AbstractInterface::Instance()) {
00019 std::cout <<"FATAL: Go4 gui macro executed outside Go4 GUI!! returning." << std::endl;
00020 return kFALSE;
00021 }
00022 TString fullname1 = go4->FindItem(name1);
00023 TObject* ob1 = go4->GetObject(fullname1,1000);
00024 TH2 *his1(0);
00025 if(ob1 && ob1->InheritsFrom("TH2"))
00026 his1 = (TH2*) ob1;
00027 if(his1==0) {
00028 std::cout <<"profileX could not get 2d histogram "<<fullname1 << std::endl;
00029 return kFALSE;
00030 }
00031
00032 TString n1 = his1->GetName();
00033 TString t1 = his1->GetTitle();
00034 TString soper;
00035 soper.Form("(ylo=%d, yup=%d)",firstybin,lastybin);
00036 TString finalname = TString("X-Profile of ")+n1;
00037 TString finaltitle = TString("X-Prof.") + soper+" of "+t1;
00038 TH1* result = his1->ProfileX(finalname.Data(),firstybin,lastybin);
00039 result->SetTitle(finaltitle);
00040 result->SetDirectory(0);
00041 TString rname = go4->SaveToMemory("Profiles", result, kTRUE);
00042 std::cout<< "Saved result histogram to " << rname.Data() <<std::endl;
00043 if(draw) {
00044 ViewPanelHandle panel1 = go4->StartViewPanel();
00045 go4->DivideViewPanel(panel1, 1, 2);
00046 go4->SelectPad(panel1, 1);
00047 go4->DrawItem(fullname1, panel1,"COLZ");
00048 go4->SelectPad(panel1, 2);
00049 go4->DrawItem(rname, panel1);
00050 }
00051 return kTRUE;
00052 }