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

Histo EnergyMode assumes momentum amplitude spectrum in MeV #53

Open
AndrewEdmonds11 opened this issue Jan 8, 2015 · 1 comment
Open

Comments

@AndrewEdmonds11
Copy link

Hi Everyone.

I just want to highlight an important fact and a workaround I've done in case others need it.

The "histo" EnergyMode in g4sim assumes that you are passing a momentum amplitude spectrum in MeV. I was trying to use this to read in Nam's kinetic energy spectrum for protons but they obviously aren't compatible.

So I've written a script in commit 0be6cd4 that converts the histograms and saves the compatible one in the same ROOT file.

There is also a script in commit 919a313 that plots the initial kinetic energy spectrum from a MC run if you ever want to check that what you're putting in is what you're using.

@AndrewEdmonds11
Copy link
Author

After working with this a bit more - I'm not sure if this is good enough. I feel the bins may be a bit wide so I changed the code (not committed) to use Nam's histogram directly. Here's the diff:

--- a/src/PrimaryGeneratorAction.cc
+++ b/src/PrimaryGeneratorAction.cc
@@ -188,8 +188,8 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
        }

        if ( EnergyMode == "histo"){
-               G4double mom = EM_hist->GetRandom() * MeV;
-               G4double ekin = sqrt(mom*mom+mass*mass)-mass;
+               G4double ekin = EM_hist->GetRandom() * 1e3 * MeV;
+               //              G4double mom = sqrt(ekin*ekin + 2*ekin*mass);
                particleGun->SetParticleEnergy(ekin);
        }
        else if ( EnergyMode == "root" ){

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

No branches or pull requests

1 participant