How Can I Implement ROOT Multivariate Reweighting in a Program?

  • Thread starter Thread starter ChrisVer
  • Start date Start date
  • Tags Tags
    Multivariate Root
Click For Summary

Discussion Overview

The discussion revolves around the implementation of multivariate reweighting using ROOT in a programming context, specifically focusing on the challenges of managing histogram data for signal and background events. Participants explore how to effectively store and retrieve weight histograms for later use in calculations involving other variables.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes a program that generates histograms for signal and background events and expresses difficulty in accessing weight histograms after their creation.
  • Another participant suggests that the program should be run in two stages: first to generate the weight histograms and then to use those weights to fill other histograms.
  • A participant questions the programming language being used, implying that array allocation might simplify the process.
  • There is a suggestion to create a smaller TTree with only the necessary variables if processing time is a concern.
  • One participant acknowledges the complexity of the program, noting that the signal and background data come from different regions, complicating the implementation of the suggested solutions.

Areas of Agreement / Disagreement

Participants generally agree on the need to separate the weight generation and histogram filling processes, but there is disagreement on the feasibility of implementing the suggested solutions given the complexity of the participant's program.

Contextual Notes

Participants express concerns about the limitations of their current programming approach, particularly regarding the management of data across different stages of execution and the implications of processing time.

ChrisVer
Science Advisor
Messages
3,372
Reaction score
465
Suppose I have a programme. In there I have the creation of histograms:

signal:
histo_s_Pt
histo_s_v1
histo_s_v2
background:
histo_b_Pt,
histo_b_v1
histo_b_v2

iteration to fill signal/bckg from events j.

So at this point I'm having the 6 above histograms filled. Now if I wanted to compare the variables v1,v2 between signal/background with the reweight of the momenta Pt s or b, I have to make a new histogram that will contain the weights :

histo_weight = Divide( signal Pt , background Pt).

My problem is that this can happen only at the end of the program, and then I cannot call these weights back in order to reweight the histos of variables v1, v2 .

I was told I can save the histo_weight in some root file and then recall it. However I am not sure that this can work.
Suppose I save it in a TFile weight.root
How can I open the weight.root in the first place? since it again is saved in the end.

Any ideas?
 
Technology news on Phys.org
What language are you working in that you can't just allocate an array?
 
Dr. Courtney said:
What language are you working in that you can't just allocate an array?

C++ I guess... what do you mean by that?
 
You don't have the weights at the time you fill the histograms, obviously. Run your program to get the weights, store them, then run it again to fill the other histograms using the stored file. Or combine both in a single program with two loops, the first for the weights the second for the other histograms. There is no way to avoid that.

If running over the dataset takes too much time, you can make a smaller TTree only with those three variables.

@Dr. Courtney: He is running over some dataset, generating both pT, v1 and v2. To properly fill the v1 and v2 histograms, he needs the full information of pT, which is not available at that time.
 
  • Like
Likes   Reactions: ChrisVer
So you suggest:
1. Run it once without using the weights, just to generate the weight histograms.
2. Save those histograms in a root file (let's call it "weight.root").
3. Go back into the program and open and recall the histogram from weight.root and use its info
4. Rerun the program
?

your second solution might be easy in a simple program, but mine is not that simple. The signal and background are taken from two totally different regions in the main body (here I simplified the problem), and it's almost impossible to make that. It would be easier if they were in the same region since yes, I could work the Pt's first individually and use them in a second iteration.
 
ChrisVer said:
So you suggest:
1. Run it once without using the weights, just to generate the weight histograms.
2. Save those histograms in a root file (let's call it "weight.root").
3. Go back into the program and open and recall the histogram from weight.root and use its info
4. Rerun the program
Sure.
 
  • Like
Likes   Reactions: ChrisVer

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
11K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 10 ·
Replies
10
Views
4K