Problem with 2D plot values

I do not get the same error. It seems your code has some invalid pointer:

Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
In file included from input_line_9:1:
/Users/couet/Downloads/calo.C:6886:14: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
                        p09sub = htemp9sub->GetFunction("gaus")->GetParameter(0);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hi @couet, I don’t know. I get the error just when I add

		TH1 *hh2 = henecdsubstringcutrelTHFsumdiff->DrawCopy("colz"); // creates all axes
			gPad->Modified();
			gPad->Update(); // make sure it's really (re)drawn
			TPaletteAxis * palette2 = (TPaletteAxis *) hh2->GetListOfFunctions()->FindObject("palette");
   			palette2->SetX1NDC(0.86);
   			palette2->SetX2NDC(0.90);
   			palette2->SetY1NDC(0.20);
   			palette2->SetY2NDC(0.80);
			c45->Modified();
			c45->Update();

otherwise, it works (but I can’t move the palette). Moreover, I would like to increase the marker size…so I wrote:

henecdsubstringcutrelTHFsumdiff->SetMarkerSize(20);

the marker size doesn’t increase.

The error I get is not due to the palette2 code. I commented it and I get the same error.

You are right…I commented it and I get error…but I downloaded again your file and I get error using it too o_O
When you uploaded it, it worked… I get the same error that in my printscreen…
line 3258 TH1 *hh = henecdsubstringcutrelTHF->DrawCopy("colz"); // creates all axes
I can’t understand what is happening…

Sometimes your histograms are empty and the fit does not produce any function. But you call GetParameter on this non existing function. This is why it crashes. I have put a few protections here and there to make your macro work. I would anyway recommend that you revisit it completely. It really looks very “draft” (no indentation, a lot of useless code, etc …).
calo.C (1.0 MB)

Hi @couet, thank you for your help.

  1. The macro currently works, but when I add
 TH1 *hh2 = henecdsubstringcutrelTHFsumdiff->DrawCopy("colz"); // creates all axes
         TPaletteAxis * palette2 = (TPaletteAxis *) hh2->GetListOfFunctions()->FindObject("palette");
         palette2->SetX2NDC(0.93);
         gPad->Modified();
         gPad->Update(); // make sure it's really (re)drawn
         c25->Modified();
         c25->Update();
         henecdsubstringcutrelTHFsumdiff->SetName(heneabname);
         gPad->Modified();
         gPad->Update(); // make sure it's really (re)drawn

to move also the second palette, it crashes again;
2. can you say me the useless code?
3. I would like to set the mark size. I wrote

henecdsubstringcutrelTHFsumdiff->SetMarkerSize(20);

but it doesn’t look to change…

  1. Please, can you check also this post please? Set energy 0 in a sum

Can you post the macro as you modified it ?

Hi @couet this is the macro. I just didn’t comment the second palette code.
calo.C (1.0 MB)

I ran you macro. I do not get any crash

Hi @couet, I don’t know the reason…
@bellenot do you think it could be releated to windows ROOT?

I can’t try, I don’t have the si-500636660.root file: Error in <TFile::TFile>: file C:/si-calo-sep18/si-500636660.root does not exist

@bellenot:
This macro and this file are the ones.

calo.C (1011.6 KB)

https://cernbox.cern.ch/index.php/s/GA61mMqpz06ih2O

OK, I can reproduce the problem on Windows

thank you @couet to share the root file

Ps. @bellenot Moreover, on Windows, I also can’t increase the marker size by using

henecdsubstringcutrelTHFsumdiff->SetMarkerSize(20);

OK, so you can’t create TH2F with 10000*10000 bins with 32 bit floating points on a 32 bit machine: 10000*10000*32 = 3.2GB! (max: 2GB)

Hi @bellenot , thank you. I rebinned it and it worked (It doesn’t crash and I can move the palette).
Currently I just can’t increase the marker size.

calo.C (1.0 MB)

Well, I’m not sure setting a marker size on a TH2F drawn with COLZ makes any sense. What you see is the bin size… Maybe @couet can comment on this one

You are right, it does not makes sense.

Thank you @bellenot and @couet . Then should I use other TH2F typology (not COLZ) to increase the marker size, or is there other way to increase them using the COLZ?

No, you don’t understand. What you see are not markers, they are bin contents. To see them bigger you have to zoom, or to decrease the bin numbers. Simply try with 50 bins in x and y, you’ll see what I mean…

1 Like