Not getting colored 2d plots

Hello,

To plot the colored 2d plot I am using option “colz” even though I am not getting the colored plots.

   tmpTree->Draw(TString(bnames[i])+">>H_"+TString(fnames[i]),"trackx@.GetEntries()==1 && tracky@.GetEntries()==1 && trackx.q>0 && tra    cky.q>0","colz");

Plot is attached. What should I change in it so that it becomes colored.

Thanks in advance for suggestation.

Ram


Well, somehow I cannot believe that the command you show produces the plot you show.
What are “bnames[i]” and “fnames[i]” for this plot supposed to be?
And what is your ROOT version?

Dear coyote,

The bnames and fnames are defined as:

char *bnames[nbranch]={ “g1xcl.geoposX:g1xcl.geoposX”, “g1xcl.geoposX:g2xcl.geoposX”};

char *fnames[nbranch] = {“g1x_geoposX_vs_g1x_geoposX”, “g1x_geoposX_vs_g2x_geoposX”};

The root version is 5.34.00.

But, when I use
tmpTree->Draw(“g1xcl.geoposX:g2xcl.geoposX>>correlationg1xg2x”,“g3ycl@.GetEntries()==1 && g3xcl@.GetEntries()==1 && trackx.q>0 && t racky.q>0”,“colz”);

I mean instead of taking name of branches and histogram form array (using fnames and bnames) when I put them directly it works.

Can you try to ouptut:

TString(bnames[i])+">>H_"+TString(fnames[i])

May be try to put that in a temporary TSTring tmp and draw tmp.Data()

From your first post then, I can see that it tries to fill two histograms:
H_g1x_geoposX_vs_g1x_geoposX
H_g1x_geoposX_vs_g2x_geoposX

Do these two histograms exist prior to the “Draw” call or does the “Draw” call create them?

P.S. Well, 5.34/00 is quite old, it’s 5.34/23 now.

BTW. What Olivier suggests to try could be something like this: TString tmpString = TString(bnames[i]) + ">>H_" + TString(fnames[i]); std::cout << "tmpString ===" << tmpString << "===" << std::endl; // "debug" printout tmpTree->Draw(tmpString.Data(), "trackx@.GetEntries()==1 && tracky@.GetEntries()==1 && trackx.q>0 && tra cky.q>0", "colz");

Hi Coyote,

Thanks for your reply.

[quote=“Wile E. Coyote”]From your first post then, I can see that it tries to fill two histograms:
H_g1x_geoposX_vs_g1x_geoposX
H_g1x_geoposX_vs_g2x_geoposX

Do these two histograms exist prior to the “Draw” call or does the “Draw” call create them?[/code][/quote]

Yes, The histogram exists because I defined it just before the draw like

hist[i] = new TH2F(“H_”+TString(fnames[i]),TString(bnames[i]),100,range[k],range[k+1],100,range[k+2],range[k+3]);

[quote=“Wile E. Coyote”]
P.S. Well, 5.34/00 is quite old, it’s 5.34/23 now.[/code][/quote]

I am working with 5.34/00 because with the latest release my software (which is for the CMS-GEM test beam data analysis) is not working.

[quote=“Wile E. Coyote”]
BTW. What Olivier suggests to try could be something like this: TString tmpString = TString(bnames[i]) + ">>H_" + TString(fnames[i]); std::cout << "tmpString = " << tmpString << std::endl; // "debug" printout tmpTree->Draw(tmpString.Data(), "trackx@.GetEntries()==1 && tracky@.GetEntries()==1 && trackx.q>0 && tra cky.q>0", "colz");[/quote]

I tried it. The output of tmpString is fine. Even though it is not working.

I am also attaching my code, you can have a look at it.
BeamProfile.C (6.71 KB)

Two bug fixes (the first string in a sum must be a TString) …
hist[i] = new TH2F(TString(“H_”)+fnames[i], …
hprofile[i] = new TProfile(TString(“P_”)+fnames[i], …

And another one … change … hist[i]->Draw(); … into … hist[i]->Draw(“colz”);

Thank you very much Coyote.

After using hist[i]->Draw(“colz”); it worked.