Signalize points out of scale

Hi everyone! I want to do something in my analysis but i don’t really know how to do it. What i want to do is the same done in the pull plot bellow

There is some points there are out of scale, and the image signalizes them with those triangles. I want to do it too in one of my recent works, but as i said i have no idea how to. So i would appreciate any helps, tips or references on the topic. I am using PyROOT but any tips in c++ would work out fine for me too.

ROOT Version: Latest
Platform: Ubuntu
Compiler: Not Provided


Maybe @couet has an idea how to achieve this. He will probably take a look next week

1 Like

You can check each point on that graph to see whether it’s higher/lower than the max/min y, and create a TMarker for each of those points (e.g. with an array of TMarkers) with the corresponding x coordinate and an appropriate y (e.g. 1.25 or 0.8 in your example plot), then you just draw those markers on the same pad; you can search the Forum for more examples, but here’s one:
https://root.cern/root/roottalk/roottalk04/1207.html

2 Likes

I am trying to do what you proposed, but i having some difficulties. what i am plotting in the pull plot is a ratio between two histograms. So what i thinked was to loop through the histogram entries and check if each one of they was lower or higher then ymax/min. So i tried the following code to loop through the histogram data.

nEntries= ratio.GetEntries()
print(nEntries)

nEntries = int(nEntries)

for i in range(nEntries):
	ratio.GetEntry(i)	

But the problems are the following: the number nEntries is a float for some reason, so i turned it by force into a integer, but when i try to obtain the entries of the histogram i get the following error:

ratio.GetEntry(i)
AttributeError: ‘TH1F’ object has no attribute ‘GetEntry’

I think this maybe be some Newbie error, but i cound´t solve it.

There is no GetEntry for histograms (only for TTrees). You need to loop over the bins and use GetBinContent; note that bin numbers start from 1 (check at the top of that TH1 documentation page).

1 Like

It worked, thanks so much for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.