Dear Geant4 Users,
I want to define a source array, which has different intensity of these source. The source class is G4GeneralParticleSource. And the source is Co-60. I find I can’t set source in the constructed function. The source should be set in GeneratePrimaries(G4Event*) function.
Here is the source I defined. It seems the distribution of source will be run when the particle is generated. The number of the source is several hundred. How can I define the source effectively?
By the way, when I run, the terminal print “Error: Volume Shape does not exist”, which seems agrees with the shape and distribution of source.
How can I deal with this problem?
Thanks a lot.
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* evt)
{
std::map<G4int, G4double>::iterator itSD;
for(itSD=sourceActivity.begin(); itSD!=sourceActivity.end(); itSD++)
{
G4int sourceID = itSD->first;
G4double acitivity = itSD->second;
G4ThreeVector pos = sourceID_Pos[sourceID];
fgps->AddaSource(acitivity);
fgps->SetParticleDefinition(G4IonTable::GetIonTable()->GetIon(27, 60, 0));
fgps->GetCurrentSource()->GetPosDist()->SetCentreCoords(pos);
fgps->GetCurrentSource()->GetPosDist()->SetPosDisType("Volume");
fgps->GetCurrentSource()->GetPosDist()->SetPosDisShape("Cylinder");
fgps->GetCurrentSource()->GetPosDist()->SetRadius(fDetector->GetSourceRadius());
fgps->GetCurrentSource()->GetPosDist()->SetHalfZ(fDetector->GetSourceHalfZ());
fgps->GetCurrentSource()->GetEneDist()->SetMonoEnergy(0.*MeV);
}
fgps->GeneratePrimaryVertex(evt);
}