How Can I Implement ROOT Multivariate Reweighting in a Program?

  • Thread starter Thread starter ChrisVer
  • Start date Start date
  • Tags Tags
    Multivariate Root
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 2K views
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?
 
Physics news on Phys.org
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