How Can I Implement ROOT Multivariate Reweighting in a Program?

  • Thread starter Thread starter ChrisVer
  • Start date Start date
  • Tags Tags
    Multivariate Root
AI Thread Summary
The discussion revolves around the challenge of comparing variables v1 and v2 between signal and background histograms while incorporating weights derived from the momenta Pt. The user has created six histograms for signal and background but faces difficulty in applying the weights to the v1 and v2 histograms since the weights can only be calculated at the end of the program. Suggestions include saving the weight histogram in a ROOT file and then recalling it in a subsequent run of the program. However, the user expresses concern about the complexity of their program, which involves different regions for signal and background, making it difficult to implement a straightforward two-loop solution. The conversation emphasizes the need for a method to efficiently manage and utilize the weights without compromising the program's structure.
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 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 ChrisVer
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top