Skip to content

Correct implementation for the multiple t-slopes feature in gen_amp_v2 - #429

Open
iljatt wants to merge 10 commits into
masterfrom
temporary_fix_gen_amp_V2
Open

iljatt wants to merge 10 commits into
masterfrom
temporary_fix_gen_amp_V2

Conversation

@iljatt

@iljatt iljatt commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

This modification resets the t-slope sampling in the right position in the code. This will enable control over the generation of -t distribution with the multiple "-t slope weight" input settings.

@gluex

gluex commented Nov 17, 2026

Copy link
Copy Markdown

Test status for this pull request: SUCCESS

Summary: summary.txt
Logs: results/log

Build log: make_temporary_fix_gen_amp_V2.log
Build report: report_temporary_fix_gen_amp_V2.txt

@iljatt

iljatt commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Ilia_comments.pdf
I leave here some slides with argumentation and example of this modification.

@mashephe

Copy link
Copy Markdown
Contributor

I think this modification looks good -- can you please verify that two samples produce the same mass distributions:

  1. a sample with a sum of t distributions that you specify - plot the UV mass and weight by the provided weight
  2. a sample with no t slope specified - plot the UV mass

This would verify that the reweighted distribution recovers phase space. I'm pretty sure this is correct since the choice of t slope should factorize from the problem. It is just like you've turned the generator into a sum of generators that each individually generate with a fixed t slope based on the old algorithm, right?

@iljatt

iljatt commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello, Matt

It is just like you've turned the generator into a sum of generators that each individually generate with a fixed t slope based on the old algorithm, right?

I would say even simpler: the algorithm remains unchanged, the modification is only resetting -t to a value of given probability: now it is reset one time per every kin = ftGen.generate() call.

I will make the checks tomorrow.

Can you say,

a sample with no t slope specified - plot the UV mass
a sample with a sum of t distributions that you specify - plot the UV mass and weight by the provided weight

should I weight my UV mass spectrum with the mask weight or with some other weight for this check ?

@mashephe

Copy link
Copy Markdown
Contributor

Can you say,

a sample with no t slope specified - plot the UV mass
a sample with a sum of t distributions that you specify - plot the UV mass and weight by the provided weight

should I weight my UV mass spectrum with the mask weight or with some other weight for this check ?

Yes, you use the weight provided by the generator. It is the weight data member in the Kinematics class. In both cases you should not specify any Breit Wigners, etc. This is just a test to verify that the reweighted UV mass (and also t-slope if you want) matches that of true phase space. This is important for physics reasons.

As I noted, I'm pretty sure this will check out OK, but it is a good final check on the implementation. I like this change that you have made -- it will make it easier for people to get the t slope they desire.

@iljatt

iljatt commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

These are the comparisons with 1M generated events for both the single-slope generation and the multiple-slope generation. I didn't specify any BWs for the LV and UV at the generation.
Ilia_checks.pdf

@mashephe

Copy link
Copy Markdown
Contributor

(It would probably be most helpful to scale the plots to a common integral and plot the blue shaded histogram with Sumw2 turned on. I think the wild variations there are just what is going on at the edges of phase space.)

The top page looks fine -- good.

I'm a bit concernend about the deviation from phase space in the lower left of the 2nd page. I'm surprised by this a bit... I'm curious if it goes away when you revert to the old algorithm.

In words, it seems the problem is that your modification has lost the relative normalization of the samples with different t slopes needed to recover phase space. This was preserved in the old algorithm because t was always drawn from the same distribution no mater what. The new algorithm pics a t slope and then keeps drawing t from that specific slope until the kinematic boundary conditions are met. The probability of meeting the boundary conditions varies with choice of t slope (this is the particular inefficiency you were trying to remove).

You may have to investigate modifing your algorithm to renormalize the weight based on the particular t-slope that is drawn before you call genCosThetaCM. Maybe it is sufficient to modify the weight returned by 1 / P_t_i, where P is the user-configured probability for a particular t slope. In that case it is really like running multiple instances of the single-slope case and adding them together with appropriate weights.

You have:

tSlope = m_tSlopeVec[m_tSlopeChannel()];

You can do:

int tIdx = m_tSlopeChannel();
double tSlope = m_tSlopeVec[tIdx];
double tProb = m_tSlopeChannel.getProb( tIdx );

Then take the returned weight from genCosThetaCM and divide it by tProb.

Matt

@iljatt

iljatt commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Hello, Matt,

I have added comparison with the current version of gen_amp_V2 for the case of three slopes.
The deviation shows up as well.
Ilia_checks2.pdf

I am working on adjusting the weight by the input probabilities. I will produce more tests, I think we will learn something.

Best,
Ilia

@mashephe

Copy link
Copy Markdown
Contributor

It is interesting that the current version with multiple slopes shows a similar issue. This is not the intent and I think you might have uncovered a bug in the current implementation. (This is independent of the solution to the problem you are trying to solve.) I think the problem is that line 389 of the original implementation of FixedTargetGenerator.cc misses the factor that is the probability of drawing a particular t slope. It is this line:

cosThetaWeight.second = 1 /
( 2 * pcm( m_W, m_beam.M(), m_target.M() ) * puvCM * exp( *t * tSlope ) );

This needs a extra factor that is the factor tProb in the code snippet above. In the original code, could you modify line 376 to use something like this:

int tIdx = m_tSlopeChannel();
double tSlope = m_tSlopeVec[tIdx];
double tProb = m_tSlopeChannel.getProb( tIdx );

And then modify 389 so it is:

cosThetaWeight.second = 1 /
( 2 * pcm( m_W, m_beam.M(), m_target.M() ) * puvCM * exp( *t * tSlope ) ) * tProb;

Could you then see if multiple t slopes recovers phase space? That at least would give us a firm understanding of the starting point.

As I was mentioning in the call this morning, I think the place to control t consistent with design practices is to do so in the AT config file. Then you can use t arguments to gen_amp_v2 as "hints" to improve accept/reject efficiency for that AT-specified t distribution.

@iljatt

iljatt commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Matt,

Can you say, should I divide by tProb, or multiply ? Initially, you suggested dividing, but then you wrote multiplying in the last snippet. I will do this check on the original gen_amp.

@mashephe

mashephe commented Nov 19, 2026 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants