Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing Correction for MuonDIS generation #510

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

anupama-reghunath
Copy link
Contributor

@anupama-reghunath anupama-reghunath commented Sep 12, 2024

Attached are the SBT response plots produced for the previous MuonDIS(involving backwards travelling muons), and with the suggested corrections with the new MuonDIS. SBThits are color coded wrt to the time of DIS. New method preserves the incoming muon's time as well as its veto response, and ensures that the event is temporally consistent.

Before:
SBT_event_oldmuDIS
After:
SBT_event_newmuDIS

Copy link
Contributor

@olantwin olantwin left a comment

Choose a reason for hiding this comment

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

Very nice improvements. Generally looking good, but some nitpicks.

Once all other issues are resolved, it would be good to run clang-format and ruff over the touched code.

I would suggest fixing issues with --fixup commits, and then at the end we can do a rebase and automatically squash the fixes.
You might want to check out git-absorb to make that process a bit simpler.

macro/run_simScript.py Outdated Show resolved Hide resolved
macro/run_simScript.py Outdated Show resolved Hide resolved
macro/run_simScript.py Outdated Show resolved Hide resolved
macro/run_simScript.py Outdated Show resolved Hide resolved
muonDIS/add_muonresponse.py Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.cxx Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.cxx Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.cxx Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.cxx Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.h Outdated Show resolved Hide resolved
@olantwin
Copy link
Contributor

olantwin commented Oct 3, 2024

_ No description provided. _

Could you add some explanation to your first post, maybe with the before/after plots you sent me?

@olantwin
Copy link
Contributor

olantwin commented Oct 3, 2024

This change would also benefit from a description in the CHANGELOG (probably an entire paragraph!)

@olantwin
Copy link
Contributor

@maksymovchynnikov Could you please have a look and ideally test these changes? It would be good to merge these ASAP.

@olantwin olantwin added this to the later milestone Oct 30, 2024
@olantwin
Copy link
Contributor

@maksymovchynnikov Your monthly reminder that your feedback would be very welcome on this pull request.

muonDIS/make_nTuple_Tr.py Outdated Show resolved Hide resolved
@olantwin
Copy link
Contributor

@anupama-reghunath I also noticed that there are still a lot of open comments.

@olantwin olantwin linked an issue Nov 12, 2024 that may be closed by this pull request
@olantwin olantwin removed the request for review from maksymovchynnikov November 13, 2024 14:43
macro/run_simScript.py Outdated Show resolved Hide resolved
@anupama-reghunath anupama-reghunath marked this pull request as ready for review November 20, 2024 17:06
@anupama-reghunath
Copy link
Contributor Author

@olantwin I have addressed the open comments. Can you please let me know if anything else is needed?

Copy link
Contributor

@olantwin olantwin left a comment

Choose a reason for hiding this comment

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

First part of comments, hopefully I get around to review the rest soon.

muonDIS/add_muonresponse.py Outdated Show resolved Hide resolved
muonDIS/add_muonresponse.py Outdated Show resolved Hide resolved
muonDIS/add_muonresponse.py Outdated Show resolved Hide resolved
muonDIS/add_muonresponse.py Outdated Show resolved Hide resolved
muonDIS/add_muonresponse.py Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.cxx Outdated Show resolved Hide resolved
shipgen/MuDISGenerator.cxx Outdated Show resolved Hide resolved
Comment on lines +44 to +48
if args.path:
path = args.path
else:
path = "/eos/experiment/ship/simulation/bkg/MuonBack_2024helium/sc_v6_10_spills"

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not handle this by giving --path a default value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how this improves readability, and like this the default value is not visible in the --help output

muonDIS/make_nTuple_SBT.py Outdated Show resolved Hide resolved
muonDIS/make_nTuple_SBT.py Outdated Show resolved Hide resolved
@olantwin
Copy link
Contributor

olantwin commented Dec 3, 2024

For any new code, we should not use TVectorD anymore, I'll make an exception for this PR, as the muon DIS was already using it.

We should consider refactoring to use STL containers.

# dPartDIS.ConstructedAt(nPart).Use(part) #to be adapted later
dPartDIS[nPart] = part
if itrk == 1:
with open(f"sigmadata_{args.nJob}.txt", "a") as fcross:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reasoning for having an external textfile to save the DIS cross section from Pythia6:

  1. As is, the DIS cross section otherwise is not saved anywhere
  2. Consider generating N >>1 DIS events for the single muon. Since Pythia generates the cross-section value events-by-event, it converges from some meaningless value for the 1st event to the proper value for the Nth event. In the proper implementation, all the events must share the same correct cross-section. As a temporary fix,we achieve this by reading the Nth DIS cross section entry for a given muon to calculate the weight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My plan of action to avoid this external file is:

1.Directly write the cross section to the muonDis file ( which is passed as the input for muonDIS production)
2. Set weight of the scattered muon to the cross section in the simulation (atm both the incoming and scattered have the same weight from the spill).

Perhaps also set a minimum value for the number of DIS per muon to allow for convergence?

Please let me know what you think! @olantwin

Copy link
Contributor Author

@anupama-reghunath anupama-reghunath Dec 6, 2024

Choose a reason for hiding this comment

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

Heres a sample from 200 DIS events per muon from a test sample. There is a reset at the halfpoint mark when the fixed target changes from proton to neutron.
Cross_sections

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, this is now much clearer, thanks!

I agree, that this information should be directly in the sample. Is there a weight field in the event header? Otherwise, using the weight of the scattered muon seems like an OK workaround (maybe we can preserve the weight of the incoming muon from the target sim).

We do not use the cross section anywhere else, right?

Could you prepare that plot also relative to the final cross section? That allow us to estimate a good default number of events to generate.

Copy link
Contributor Author

@anupama-reghunath anupama-reghunath Dec 11, 2024

Choose a reason for hiding this comment

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

I agree, that this information should be directly in the sample. Is there a weight field in the event header?

I couldnt find one in ShipEventHeader.

Otherwise, using the weight of the scattered muon seems like an OK workaround (maybe we can preserve the weight of the incoming muon from the target sim).

At the moment I save the cross section onto the scattered muon and also refactor the incoming muon's weight to include the DIS multiplicity such that we maintain the event weight's normalisation to a spill. Previously this refactoring was explicitly done in the analysis, but the meta data (nDIS per muon) needed to be explicitly plugged in to calculate weight for any sim file.

We do not use the cross section anywhere else, right?

Only when calculating the weight of the event. ( Done during analysis)

Could you prepare that plot also relative to the final cross section? That allow us to estimate a good default number of events to generate.

For 2000 DIS events, the convergence seems to be inversely correlated with the energy of the muon.
image

Removed Condor Process variable in makeMuonDIS.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

muon DIS and inactivateMuonProcesses
2 participants