Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for TProfile and TProfile2D projectionX and projectionXY options in JSROOT #15851

Closed
will-cern opened this issue Jun 14, 2024 · 15 comments
Assignees

Comments

@will-cern
Copy link
Contributor

Feature description

The projection methods of profile plots (TProfile::ProjectionX and TProfile2D::ProjectionXY) have a bunch of useful options that allow us to visualize useful features like the RMS in each bin, or the sum of weights, or the number of entries in each bin.

I would like to propose that a new context submenu be added to JSROOT for profile plots, or at least a lot more options appear under the "proj" submenu for these plot types. All the different options from these two methods should be available (the options are the same between TProfile and TProfile2D). I actually dont know what the existing options under the "proj" submenu even do, to be honest?

Alternatives considered

No response

Additional context

No response

@linev linev self-assigned this Jun 14, 2024
@linev
Copy link
Member

linev commented Jun 14, 2024

Different kinds of projections are implemented for JSROOT. Like:

http://root.cern/js/latest/examples.htm#th2_projx1
http://root.cern/js/latest/examples.htm#th2_projy3
http://root.cern/js/latest/examples.htm#th2_projxy

It is functionality which is similar to TH2::SetShowProjectionX() / TH2::SetShowProjectionY() / TH2::SetShowProjectionXY().

In principle, it also works with TProfile2D.

That kind of functionality you are missing?

@will-cern
Copy link
Contributor Author

For example, we are missing the functionality that would show the following histogram:

profile2d->GetProjectionXY("_pxy",OPT)->Draw(DRAWOPT)

Where OPT and DRAWOPT are somehow to be determined. OPT can be one of:

""
"W"
"C=E"
"E"
"B"

@linev
Copy link
Member

linev commented Jun 14, 2024

Do I understand you correctly - you want to have new TProfile2D::ProjectionXY() method with different options which content will be in produced histogram? And also special implementation for TProfile2D::ProjectX() and TProfile2D::ProjectY()? And then display it with custom draw options?

Main question - do you want to have such projections only for visualization or it make sense implementing them in TProfile2D class of ROOT. If only visualization is interesting - one can provide pure JavaScript implementation.

If methods have to be implemented in C++ classes - probably this should be done first and then TWebCanvas/JSROOT can provide support of such methods.

@will-cern
Copy link
Contributor Author

The use case is that in ATLAS experiment we use JSROOT for display of detector monitoring plots, which include things like efficiency plots that exist as TProfile or TProfile2D. It would be nice to have a way in JSROOT to view the denominator distribution for such a plot, which is obtained from the ProjectionX or ProjectionXY method with the "B" option.

I think this is about visualization in JSROOT. If we had a C++ or python prompt we know what we need to do to view the projection. I just want to have a way to do that just with a JSROOT draw option

@linev
Copy link
Member

linev commented Jun 17, 2024

Now I found TProfile2D::ProjectionXY method. You want to have it implemented in JSROOT.

I need to think how graphically implement it.
Probably show projection on the left side from original histogram?

@will-cern
Copy link
Contributor Author

Since it's a 2d projection, I would have said you could either view it side-by-side with the original, or you could just this as a different draw option that's unique to tprofile2d. I was imagining the latter, where I see you have the "proj" submenu already, and I would have added options there for each of the options of "projectionxy". And similarly for TProfile::ProjectionX.

But then there is the question of how you would control the option that THAT histogram displays with. Here I can see the benefit of what you propose that it displays the "projection" side-by-side with the original plot. Then you can use the context menu of the projection to change the draw style of it.

@linev
Copy link
Member

linev commented Jun 19, 2024

I implement several new draw options for TProfile2D: projxyb, projxyc=e, projxyw

Example: https://jsroot.gsi.de/dev/examples.htm#tprofile2d_projxyb

I only skipped option 'e' while it makes no big sense - error just remain as is.

JSROOT does not modify histogram but just manipulates internally GetBinContent() method.
Therefore draw options can be switched any time to something else.

Same kind of projection I will provide for TProfile class later.

@will-cern
Copy link
Contributor Author

Many thanks, this looks super helpful for us because it will save us having to save the bin entries as a separate histogram for our monitoring framework (which displays monitoring plots with JSROOT).
When you add the feature for TProfile, it would be good if at the same time you could do something similar for TEfficiency, to allow display of the "Total histogram" (equivalent to a projection with option "B" in a TProfile that has been used for efficiency), since some of our plots are TEfficiency rather than TProfile.

@linev
Copy link
Member

linev commented Jun 21, 2024

@will-cern
Copy link
Contributor Author

Thank you! For the TEfficiency, is it possible to add that draw option to the context menu of the TEfficiency? I note at the moment there is in fact no context menu for TEfficiency (if I select it from the list of drawn primitives, no menu is displayed). Adding a way to switch between the different draw options of TEfficiency through such a context menu is what we ultimately would prefer. Is that possible to do?
Thanks!

@linev
Copy link
Member

linev commented Jun 21, 2024

TEfficiency itself is not drawn - but derived objects like graph or histogram.
Only in the hierarchy browser on left side efficiency can be seen as is.
I will add 'b' as list of supported options, but filling of context menu can be tricky.

@linev
Copy link
Member

linev commented Jun 25, 2024

I made first prototype of redrawing TEfficiency, THStack, TMultiGraph objects with different draw options.

https://jsroot.gsi.de/dev/examples.htm#tefficiency_docu1

You can access TEfficiency context menu either via derived objects TGraphAssymErrors or via ? pad button which allows to access context menu of any drawn objects.

linev added a commit to linev/root that referenced this issue Jun 25, 2024
1. TProfile and TProfile2D projections root-project#15851
2. Draw total histogram from TEfficiency when draw option starts with 'b'
3. Let redraw TEfficiency, THStack and TMultiGraph with different draw options via hist context menu
4. Support 'pads' draw options for TMultiGraph, support context menu for it
5. Internals - do not select pad (aka gPad) for objects drawing, always use assigned pad painter
6. Fix - properly save zoomed ranges in drawingJSON()
7. Fix - properly redraw TMultuGraph
linev added a commit that referenced this issue Jun 26, 2024
1. TProfile and TProfile2D projections #15851
2. Draw total histogram from TEfficiency when draw option starts with 'b'
3. Let redraw TEfficiency, THStack and TMultiGraph with different draw options via hist context menu
4. Support 'pads' draw options for TMultiGraph, support context menu for it
5. Internals - do not select pad (aka gPad) for objects drawing, always use assigned pad painter
6. Fix - properly save zoomed ranges in drawingJSON()
7. Fix - properly redraw TMultuGraph
@linev
Copy link
Member

linev commented Jun 26, 2024

Now functionality in JSROOT and ROOT master

@linev linev closed this as completed Jun 26, 2024
@will-cern
Copy link
Contributor Author

I made first prototype of redrawing TEfficiency, THStack, TMultiGraph objects with different draw options.

https://jsroot.gsi.de/dev/examples.htm#tefficiency_docu1

You can access TEfficiency context menu either via derived objects TGraphAssymErrors or via ? pad button which allows to access context menu of any drawn objects.

This works really nicely! Thanks for adding all this functionality, I'm looking forward to rolling it out to our monitoring framework

Copy link

Hi @linev,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely,
🤖

silverweed pushed a commit to silverweed/root that referenced this issue Aug 19, 2024
1. TProfile and TProfile2D projections root-project#15851
2. Draw total histogram from TEfficiency when draw option starts with 'b'
3. Let redraw TEfficiency, THStack and TMultiGraph with different draw options via hist context menu
4. Support 'pads' draw options for TMultiGraph, support context menu for it
5. Internals - do not select pad (aka gPad) for objects drawing, always use assigned pad painter
6. Fix - properly save zoomed ranges in drawingJSON()
7. Fix - properly redraw TMultuGraph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Issues
Development

No branches or pull requests

2 participants