JeffersonLab / halld_sim

Simulation for the GlueX Experiment in Hall D
6 stars 10 forks source link

Amplitude for MC generation using a histogram in a ROOT file #169

Closed niwgit closed 1 year ago

niwgit commented 3 years ago

Would it be possible to read a histogram in a ROOT file and use the shape of the histogram as an amplitude to generate MC using gen_amp or other generator?

Thanks. Nilanga

aaust commented 3 years ago

Yes, it is possible in gen_amp. Please have a look at this amplitude for example: https://github.com/JeffersonLab/halld_sim/blob/master/src/libraries/AMPTOOLS_AMPS/Pi0SAID.cc

jrstevenjlab commented 3 years ago

Right, the question that came up during the discussion this afternoon was if a more general amplitude would be useful to read a generic histogram of Mass vs E_gamma, for example, and generate events based on that. Then the user could provide their own histogram as input and not need to write a new amplitude each time.

It sounded like this might be desirable, so I volunteered to give it a try for Nilanga's test case, thus the new feature request issue.

jrstevenjlab commented 3 years ago

I created a branch https://github.com/JeffersonLab/halld_sim/tree/hist_amplitude with a new amplitude libraries/AMPTOOLS_AMPS/Hist2D

It reads in a 2D histogram (of Mass vs Beam energy) from an input ROOT file and generates events according to the intensity distribution provided by that histogram. This could be extended to other 2D intensity distributions if it's found to be useful, with flags to switch between different options.

An example config file for gen_amp is located at /work/halld2/home/jrsteven/forHist2D/ and can be run with the gen_amp command line

gen_amp -c gen_hist2D.cfg -o output.root -hd output.hddm -a 8.0 -b 11.6

Inside the config file you can specify the name of the ROOT file, histogram name and list of particle indices to sum when computing the invariant mass (in this case 23=Sigma0 Pi0)

reaction KSigmaPi0 Beam K+ Sigma0 Pi0 amplitude KSigmaPi0::total::hist2D Hist2D input.root MassVsEgamma 23

The zeroth order test shows it can reproduce the mass distribution of an input histogram

image

@niwgit or @markdalton, please give it a try and let me know if this is what you intended or if other features are needed.

niwgit commented 3 years ago

Thanks Justin for the new branch.

I used a 2D histogram of M_{Sigma0 pi0} vs beam energy from data (shown below) and ran gen_amp. For minimum beam energies 3.0 and 3.1 GeV it crashed with the following error. ConfigFileParser ERROR: Minimum photon energy not high enough to create resonance!

MassVsEgamma

But for minimum beam energy 3.2 GeV it worked fine. The screen output can be found in: /w/halld-scifs17exp/halld2/home/nwickjlb/analysis/Lambda_1520_2017_data/Sigma_pi0/Amplitude/output.txt

I looked at the gen_amp_diagnostic.root file and the resonance mass histogram looks great! Here's a zoomed in version of the histogram. The weighted resonance mass looks quite different in the higher mass range. Can someone comment on what "weighted resonance mass" histogram is? I'm new to gen_amp.

Thanks. Nilanga

M M_W

s6pepaul commented 3 years ago

The error message that you see is possibly related to what I mentioned here: https://github.com/JeffersonLab/halld_sim/commit/96c7428f0505fa8278010faf1ab0ed67cccb3cb7#commitcomment-41813378

The way the CM energy is calculated is wrong, I think.

markdalton commented 3 years ago

Thanks @jrstevenjlab for the code, thanks @niwgit for testing. @s6pepaul why don't you fix the bug and submit a pull request? @niwgit remember that you need to acceptance correct and back out the beam flux before using this method. I think you can afford much larger bins in energy, put the final histogram through a smoothing routine like TH2::Smooth() and make sure that there are no bins with negative content.

aaust commented 1 year ago

172 fixed the bug, #197 added the amplitude to the master