Skip to content

Add EIC bunch structure for beam-related inputs - #106

Open
johnlajoie wants to merge 17 commits into
mainfrom
eic_bunch_pattern
Open

johnlajoie wants to merge 17 commits into
mainfrom
eic_bunch_pattern

Conversation

@johnlajoie

@johnlajoie johnlajoie commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Briefly, what does this PR introduce? Please link to any relevant presentations or discussions.

What is the urgency of this PR?

  • High (please describe reason below)
  • Medium
  • Low

What kind of change does this PR introduce?

Please check if any of the following apply

  • This PR introduces breaking changes. Please describe changes users need to make below.
  • This PR changes default behavior. Please describe changes below.
  • AI was used in preparing this PR. Please describe usage below.

This PR adds the EIC bunch structure, including the abort gap, to the output stream for beam-related streams that are merged into the timeframe. It is fully configurable, but in particular can handle both the low-energy electron fill pattern for 5-10 GeV (1160 bunches filled) as well as the 18 GeV electron pattern (290 bunches filled, one every four crossings).

These changes are particularly important, for example, for the 18 GeV configuration with every fourth bunch filled. Before the background and events were spread out over the timeframe, but with these modifications they are concentrated in filled beam crossings.

@johnlajoie
johnlajoie requested a review from simonge November 17, 2026 13:27
@johnlajoie

Copy link
Copy Markdown
Contributor Author

To do:

  • Double check the fill pattern from the simulation output.
  • Check with Andrii regarding the background rate calculations to ensure consistency
  • Update example configurations as part of this pull request.

@simonge simonge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this John, generally looks ok but I want to have a think about whether there is a neater/more generalizable way of achieving this.

Comment thread src/DataSource.cc Outdated
if (!config.already_merged) {

// Constrain to a valid bunch crossing
if(config.use_bunch_crossing || config.attach_to_beam){

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only need use_bunch_crossing here as attach_to_beam is only used to offset after use_bunch_crossing has been applied. Or that's the only way it makes sense but isn't currently the approach.

@johnlajoie johnlajoie Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have a misapprehension/interpretation here. From our email communication I interpreted use_bunch_crossing as being for collision sources, the timing of which needs to be handled carefully to avoid destroying the correlations in the event generator (via the abconv aftreburner). The attach_to_beam was for single beam sources of background, which don't have the same relationship within a beam crossing that collisions do. As I am thinking about it the two are mutually exclusive.

Comment thread src/DataHandler.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be scaled by the (populated-empty)/total bunch crossings in the timeframe.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so - not if the rates are calculated as I expect (integrated over the fill pattern). That's certainly true for collisions, but needs to be verified for the backgrounds.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe at the moment, filling a 2us timeframe where 1us of the frame is beam stop will just squash the expected events for 200 bunch crossings into the remaining 100, artificially doubling the backgrounds. I may have missed something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I see your point. I keep thinking about full timeframes that average over a large number of revolutions, but for what we do in simulations (which I call "tracking frames", is that a thing?) I agree that this would over-populate the filled crossings as it stands now.

Let me think about this more, you may be right about the correction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you're right.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this scaling factor needs to be in the mean of the initial sampled Poisson distribution rather than scaling afterwards. Here we will be rounding to integers twice so will end up under sampling backgrounds. The calculation of the livetime would probably have to come in somewhere here:

// Update number of events needed per source

live_fraction as size_t rather than float at the moment will also either be 0 or 1 rather than scaling.

There might need to be a bit more of a structural rethink to better allow more generalized time dependant sampling but probably worth bashing ahead with this for now

@johnlajoie

Copy link
Copy Markdown
Contributor Author

Thanks for this John, generally looks ok but I want to have a think about whether there is a neater/more generalizable way of achieving this.

Oh I'm sure there's a much neater way to do this than I did it. :-)

One nice thing would be to be able to access the global config like you do the source config, instead of passing long parameter lists around. But that should probably be a separate pull request.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

TimeframeBuilder reports for PR #106

Last updated 2026-11-18T06:36-05:00 c6211f4

This branch was successfully deployed

1 active (outdated) deployment
github-pages — 7919ac2a Deployed Nov 18, 2026 by johnlajoie via deploy-docs #191
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.

2 participants