Go to the documentation of this file.00001 #include "Riostream.h"
00002
00005
00006
00007
00009
00011
00012
00014 Bool_t divhistos(const char* name1, const char* name2, Bool_t draw)
00015 {
00016 if(TGo4AbstractInterface::Instance()==0 || go4!=TGo4AbstractInterface::Instance()) {
00017 std::cout <<"FATAL: Go4 gui macro executed outside Go4 GUI!! returning." << std::endl;
00018 return kFALSE;
00019 }
00020 TString fullname1 = go4->FindItem(name1);
00021 TObject* ob1 = go4->GetObject(fullname1,1000);
00022 TH1 *his1(0), *his2(0);
00023 if(ob1 && ob1->InheritsFrom("TH1"))
00024 his1 = (TH1*)ob1;
00025 if(his1==0) {
00026 std::cout <<"divhistos could not get histogram "<<fullname1 << std::endl;
00027 return kFALSE;
00028 }
00029 TString fullname2 = go4->FindItem(name2);
00030 TObject* ob2 = go4->GetObject(fullname2,1000);
00031 if(ob2 && ob2->InheritsFrom("TH1"))
00032 his2 = (TH1*)ob2;
00033 if(his2==0) {
00034 std::cout <<"divhistos could not get histogram "<<fullname2 << std::endl;
00035 return kFALSE;
00036 }
00037 TH1* result= (TH1*) his1->Clone();
00038
00039 TString n1 = his1->GetName();
00040 TString n2 = his2->GetName();
00041 TString t1 = his1->GetTitle();
00042 TString t2 = his2->GetTitle();
00043 TString soper;
00044 soper.Form(") : (");
00045 TString finalname = TString("(")+n1+soper+n2+")";
00046 TString finaltitle = TString("(")+t1+soper+t2+")";
00047 result->SetName(finalname);
00048 result->SetTitle(finalname);
00049 result->Sumw2();
00050 result->Divide(his2);
00051 result->SetDirectory(0);
00052 TString rname = go4->SaveToMemory("Divs", result, kTRUE);
00053 std::cout<< "Saved result histogram to " << rname.Data() <<std::endl;
00054 if(draw) go4->DrawItem(rname);
00055 return kTRUE;
00056 }