Skip to content

Commit

Permalink
Merge pull request #531 from wdconinc/bugfix-beam-target-as-object-in…
Browse files Browse the repository at this point in the history
…-primary-generator

Bugfix: beam target as object in primary generator
  • Loading branch information
wdconinc authored Oct 15, 2021
2 parents b106bae + 7d30cb5 commit ec94615
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 3 additions & 2 deletions include/remollPrimaryGeneratorAction.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef remollPrimaryGeneratorAction_h
#define remollPrimaryGeneratorAction_h 1

#include "remollBeamTarget.hh"

#include "G4VUserPrimaryGeneratorAction.hh"
#include "G4VPrimaryGenerator.hh"
#include "G4GenericMessenger.hh"
Expand All @@ -11,7 +13,6 @@

class G4ParticleGun;
class G4Event;
class remollBeamTarget;
class remollVEventGen;
class remollEvent;

Expand Down Expand Up @@ -39,7 +40,7 @@ class remollPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction

G4ParticleGun* fParticleGun;

remollBeamTarget *fBeamTarg;
remollBeamTarget fBeamTarg;


remollEvent *fEvent;
Expand Down
12 changes: 4 additions & 8 deletions src/remollPrimaryGeneratorAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <memory>

remollPrimaryGeneratorAction::remollPrimaryGeneratorAction()
: fEventGen(0),fPriGen(0),fParticleGun(0),fBeamTarg(0),fEvent(0),fEffCrossSection(0)
: fEventGen(0),fPriGen(0),fParticleGun(0),fEvent(0),fEffCrossSection(0)
{
static bool has_been_warned = false;
if (! has_been_warned) {
Expand Down Expand Up @@ -73,9 +73,6 @@ remollPrimaryGeneratorAction::remollPrimaryGeneratorAction()
#endif
#endif

// Create beam target
fBeamTarg = new remollBeamTarget();

// Default generator
G4String default_generator = "moller";
SetGenerator(default_generator);
Expand All @@ -87,7 +84,6 @@ remollPrimaryGeneratorAction::remollPrimaryGeneratorAction()

remollPrimaryGeneratorAction::~remollPrimaryGeneratorAction()
{
if (fBeamTarg) delete fBeamTarg;
}

void remollPrimaryGeneratorAction::SetGenerator(G4String& genname)
Expand Down Expand Up @@ -126,7 +122,7 @@ void remollPrimaryGeneratorAction::SetGenerator(G4String& genname)

// Set the beam target
if (fEventGen) {
fEventGen->SetBeamTarget(fBeamTarg);
fEventGen->SetBeamTarget(&fBeamTarg);
}
}

Expand Down Expand Up @@ -201,10 +197,10 @@ void remollPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// Calculate rate
SamplingType_t sampling_type = fEventGen->GetSamplingType();
if (fEvent->fRate == 0) { // If the rate is set to 0 then calculate it using the cross section
fEvent->fRate = fEvent->fEffXs * fBeamTarg->GetEffLumin(sampling_type) / nthrown;
fEvent->fRate = fEvent->fEffXs * fBeamTarg.GetEffLumin(sampling_type) / nthrown;

} else { // For LUND - calculate rate and cross section
fEvent->fEffXs = fEvent->fRate * nthrown / fBeamTarg->GetEffLumin(sampling_type);
fEvent->fEffXs = fEvent->fRate * nthrown / fBeamTarg.GetEffLumin(sampling_type);
fEvent->fRate = fEvent->fRate / nthrown;
}

Expand Down

0 comments on commit ec94615

Please sign in to comment.