33 const TString opt = args.size() > 2 ? args[2] :
"";
35 if (gPad ==
nullptr) {
36 Info(
"Cmd",
"warning: no pad");
40 TObject *hist_now = gPad->GetPrimitive(
"htemp");
42 hist_now = TCatHistManager::Instance()->GetCurrent();
43 if (!hist_now || !hist_now->InheritsFrom(
"TH1")) {
44 Info(
"Cmd",
"warning: no hist, please check using ls command");
49 if (!hist_now->InheritsFrom(TH2::Class())) {
50 Info(
"Cmd",
"warning: The current hist does not inherit from TH2 class");
54 Int_t nid = (gDirectory->GetList())->GetEntries();
55 Run((TH2 *)hist_now, opt);
56 Info(
"Run",
"id = %d hist is created", nid);
57 TCatHistManager::Instance()->DrawObject(nid,
"colz");
64 Double_t x1 = 0., y1 = 0., x2 = 0., y2 = 0.;
65 Info(
"Run",
"click on one corner: ");
66 TCatCmdXval::Instance()->Run(&x1, &y1);
67 Info(
"Run",
"X1: %g, Y1: %g", x1, y1);
69 Info(
"Run",
"click on the other corner: ");
70 TCatCmdXval::Instance()->Run(&x2, &y2);
71 Info(
"Run",
"X2: %g, Y2: %g", x2, y2);
85 Int_t x1bin, x2bin, y1bin, y2bin, nbinsx, nbinsy;
88 const TString namesuffix =
" blo", titlesuffix =
" blo";
90 x1bin = h2->GetXaxis()->FindBin(x1);
91 x2bin = h2->GetXaxis()->FindBin(x2);
92 y1bin = h2->GetYaxis()->FindBin(y1);
93 y2bin = h2->GetYaxis()->FindBin(y2);
95 nbinsx = (x2bin - x1bin) + 1;
96 nbinsy = (y2bin - y1bin) + 1;
98 TH2F *hnew =
new TH2F(
"name",
"title", nbinsx, x1, x2, nbinsy, y1, y2);
101 for (Int_t nx = x1bin; nx <= x2bin; nx++) {
102 for (Int_t ny = y1bin; ny <= y2bin; ny++) {
103 bc = h2->GetBinContent(nx, ny);
104 hnew->SetBinContent(nx - x1bin, ny - y1bin, bc);
109 hnew->SetName(TString(h2->GetName()) + namesuffix);
110 hnew->SetTitle(TString(h2->GetTitle()) + titlesuffix);
111 hnew->SetEntries(btotal);