diboye
July 3, 2017, 11:10am
1
Dear All,
I would like to plot a 2D histo using colz option (let’s say the background) and on top of it I plot the signal using box option. It works pretty well but if I set z axis in logscale by doing for instance this:
c1->SetLogz();
the signal disappears. Can someone tell me please how to resolve it?
Thanks in adavance.
Cheers
Warnings concerning a “logarithmic palette” (maybe it’s just TGraph2D specific) … I think this problem has not been fixed: Number of divisions on palette
couet
July 3, 2017, 11:40am
3
I will look at it. thanks
diboye
July 3, 2017, 11:48am
4
Hi,
Thanks for replying, hope there will be a solution .
Cheers
Diallo
couet
July 3, 2017, 12:37pm
5
I tried the following and it seems ok:
void colcontsame() {
TH2F *h1 = new TH2F("h1","h1",100,-10,10,100,-10,10);
TH2F *h2 = new TH2F("h2","h2",40,-3,3,40,-3,3);
for (Int_t i=0;i<1000;i++) {
double x,y;
gRandom->Rannor(x,y);
h1->Fill(5*x,5*y,4);
if(x<0 && y<0) h2->Fill(x,y,3);
}
h1->SetFillColor(1);
h2->SetLineColor(kRed);
h2->SetContour(5);
h1->Draw("col");
h2->Draw("cont3 same");
gPad->SetLogz();
}
replacing cont3
by box
seems fine too.
diboye
July 3, 2017, 12:45pm
6
Hi,
Thanks so much it works with cont 3 option
Cheers
Diallo
couet
July 3, 2017, 12:46pm
7
As I said box option is fine too in that case.
diboye
July 3, 2017, 12:50pm
8
HI,
If I put box instead of cont3 the bar will appear with logScal but the signal is not plotted.
Cheers
Diallo
couet
July 3, 2017, 12:53pm
9
Ok … to help further I would need a example.
With my macro both box and cont3 are fine.
diboye
July 3, 2017, 1:06pm
10
Ok here is the code for instance:
TFile* f2 = new TFile("/afs/cern.ch/user/d/diboye/diboye_work/ZdZdTruthArea/run/Plots/Mzd50GeV_Gamma4MeV_KinVar_ACC.root");
TFile* f8 = new TFile("/afs/cern.ch/user/d/diboye/diboye_work/ZdZdRecoArea/run/Diamoond_Square_Circle_Bkg/bkg_ggFH_KinVar_ACC.root");
TH2D * Hist_M12vsM34_ACC = (TH2D*)f2->Get("myHist_M12vsM34_all");
Double_t scale48 = 1/Hist_M12vsM34_ACC->Integral();
Hist_M12vsM34_ACC->Scale(scale48);
Hist_M12vsM34_ACC->SetFillColor(1);
Hist_M12vsM34_ACC->SetMarkerColor(1);
TH2D * Hist_M12vsM34_ACC_bkg_ggFH = (TH2D*)f8->Get("myHist_M12vsM34_all");
Double_t scale54 = 1/Hist_M12vsM34_ACC_bkg_ggFH->Integral();
Hist_M12vsM34_ACC_bkg_ggFH->Scale(scale54);
Hist_M12vsM34_ACC_bkg_ggFH->SetFillColor(4);
gStyle->SetPalette(55);
Hist_M12vsM34_ACC_bkg_ggFH->GetXaxis()->SetTitle("M_{34}[GeV]");
Hist_M12vsM34_ACC_bkg_ggFH->GetYaxis()->SetTitle("M_{12}[GeV]");
Hist_M12vsM34_ACC->SetContour(5);
Hist_M12vsM34_ACC->SetLineColor(1);
Hist_M12vsM34_ACC_bkg_ggFH->Draw("colz");
Hist_M12vsM34_ACC->Draw("box same");
c1->SetLogz();
bkg_ggFH_KinVar_ACC.root (15.0 KB)
Mzd50GeV_Gamma4MeV_KinVar_ACC.root (117.4 KB)
I uploaded a part of my macro which is supposed to do the job with the files.
Cheers
Diallo
couet
July 3, 2017, 1:19pm
11
I do not know why but:
{
TFile* f2 = new TFile("Mzd50GeV_Gamma4MeV_KinVar_ACC.root");
TH2D * Hist_M12vsM34_ACC = (TH2D*)f2->Get("myHist_M12vsM34_all");
Double_t scale48 = 1/Hist_M12vsM34_ACC->Integral();
Hist_M12vsM34_ACC->Scale(scale48); // if you comment this line then the box option works with logz
Hist_M12vsM34_ACC->Draw("box ");
c1->SetLogz();
}
diboye
July 3, 2017, 1:34pm
12
Hi,
You are right, it’s a bit strange but it works like that, the same also for “scat” option.
Cheers
Diallo
couet
July 3, 2017, 2:05pm
13
I am investigating why it does not show in case of box
couet
July 4, 2017, 1:21pm
15
This problem now fixed in the ROOT master.
diboye
July 4, 2017, 1:44pm
16
Hi
Thanks very much, really appreciate
diboye
July 4, 2017, 1:51pm
17
By the way did you try with the code I sent you? didn’t manage yet to use box option with the line uncomment
couet
July 4, 2017, 1:54pm
18
That was the bug I fixed in the master …
1 Like
system
Closed
July 18, 2017, 1:54pm
19
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.