#include <G4AdjointPrimaryGeneratorAction.hh>
Inheritance diagram for G4AdjointPrimaryGeneratorAction:
Public Member Functions | |
G4AdjointPrimaryGeneratorAction () | |
~G4AdjointPrimaryGeneratorAction () | |
void | GeneratePrimaries (G4Event *) |
void | SetRndmFlag (const G4String &val) |
void | SetEmin (G4double val) |
void | SetEmax (G4double val) |
void | SetEminIon (G4double val) |
void | SetEmaxIon (G4double val) |
void | SetSphericalAdjointPrimarySource (G4double radius, G4ThreeVector pos) |
void | SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume (const G4String &volume_name) |
void | ConsiderParticleAsPrimary (const G4String &particle_name) |
void | NeglectParticleAsPrimary (const G4String &particle_name) |
void | SetPrimaryIon (G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon) |
void | UpdateListOfPrimaryParticles () |
size_t | GetNbOfAdjointPrimaryTypes () |
std::vector< G4ParticleDefinition * > | GetListOfPrimaryFwdParticles () |
const G4String & | GetPrimaryIonName () |
Definition at line 78 of file G4AdjointPrimaryGeneratorAction.hh.
G4AdjointPrimaryGeneratorAction::G4AdjointPrimaryGeneratorAction | ( | ) |
Definition at line 47 of file G4AdjointPrimaryGeneratorAction.cc.
00048 : Emin(0.), Emax(0.), EminIon(0.), EmaxIon(0.), NbOfAdjointPrimaryTypes(0), 00049 index_particle(100000), last_generated_part_was_adjoint(false), 00050 radius_spherical_source(0.), fwd_ion(0), adj_ion(0), 00051 ion_name("not_defined") 00052 { 00053 theAdjointPrimaryGenerator= new G4AdjointPrimaryGenerator(); 00054 00055 PrimariesConsideredInAdjointSim[G4String("e-")]=false; 00056 PrimariesConsideredInAdjointSim[G4String("gamma")]=false; 00057 PrimariesConsideredInAdjointSim[G4String("proton")]=false; 00058 PrimariesConsideredInAdjointSim[G4String("ion")]=false; 00059 00060 ListOfPrimaryFwdParticles.clear(); 00061 ListOfPrimaryAdjParticles.clear(); 00062 }
G4AdjointPrimaryGeneratorAction::~G4AdjointPrimaryGeneratorAction | ( | ) |
void G4AdjointPrimaryGeneratorAction::ConsiderParticleAsPrimary | ( | const G4String & | particle_name | ) |
Definition at line 194 of file G4AdjointPrimaryGeneratorAction.cc.
References UpdateListOfPrimaryParticles().
Referenced by G4AdjointSimManager::ConsiderParticleAsPrimary().
00195 { 00196 if (PrimariesConsideredInAdjointSim.find(particle_name) != PrimariesConsideredInAdjointSim.end()){ 00197 PrimariesConsideredInAdjointSim[particle_name]=true; 00198 } 00199 UpdateListOfPrimaryParticles(); 00200 }
void G4AdjointPrimaryGeneratorAction::GeneratePrimaries | ( | G4Event * | ) | [virtual] |
Implements G4VUserPrimaryGeneratorAction.
Definition at line 71 of file G4AdjointPrimaryGeneratorAction.cc.
References G4Event::AddPrimaryVertex(), G4AdjointPrimaryGenerator::GenerateAdjointPrimaryVertex(), G4AdjointSimManager::GetAdjointSourceArea(), G4AdjointSimManager::GetInstance(), G4PrimaryParticle::GetMomentum(), G4PrimaryVertex::GetPosition(), G4PrimaryVertex::GetPrimary(), G4Event::GetPrimaryVertex(), G4INCL::Math::pi, G4AdjointSimManager::RegisterAdjointPrimaryWeight(), G4AdjointSimManager::SetAdjointTrackingMode(), G4PrimaryVertex::SetPosition(), G4PrimaryVertex::SetPrimary(), G4PrimaryVertex::SetT0(), G4PrimaryVertex::SetWeight(), and UpdateListOfPrimaryParticles().
00072 { 00073 if ( !last_generated_part_was_adjoint ) { 00074 00075 index_particle++; 00076 if (index_particle >= ListOfPrimaryAdjParticles.size()) index_particle =0; 00077 00078 00079 G4double E1=Emin; 00080 G4double E2=Emax; 00081 if (!ListOfPrimaryAdjParticles[index_particle]) UpdateListOfPrimaryParticles();//ion has not been created yet 00082 00083 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_proton") { 00084 E1=EminIon; 00085 E2=EmaxIon; 00086 } 00087 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() == "adjoint_nucleus") { 00088 G4int A= ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass(); 00089 E1=EminIon*A; 00090 E2=EmaxIon*A; 00091 } 00092 theAdjointPrimaryGenerator->GenerateAdjointPrimaryVertex(anEvent, 00093 ListOfPrimaryAdjParticles[index_particle], 00094 E1,E2); 00095 G4PrimaryVertex* aPrimVertex = anEvent->GetPrimaryVertex(); 00096 00097 00098 p=aPrimVertex->GetPrimary()->GetMomentum(); 00099 pos=aPrimVertex->GetPosition(); 00100 G4double pmag=p.mag(); 00101 00102 G4double m0=ListOfPrimaryAdjParticles[index_particle]->GetPDGMass(); 00103 G4double ekin=std::sqrt( m0*m0 + pmag*pmag) -m0; 00104 00105 00106 //The factor pi is to normalise the weight to the directional flux 00107 G4double adjoint_source_area = G4AdjointSimManager::GetInstance()->GetAdjointSourceArea(); 00108 G4double adjoint_weight = ComputeEnergyDistWeight(ekin,E1,E2)*adjoint_source_area*pi; 00109 00110 aPrimVertex->SetWeight(adjoint_weight); 00111 00112 last_generated_part_was_adjoint =true; 00113 G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(true); 00114 G4AdjointSimManager::GetInstance()->RegisterAdjointPrimaryWeight(adjoint_weight); 00115 } 00116 else { 00117 //fwd particle equivalent to the last generated adjoint particle ios generated 00118 G4PrimaryVertex* aPrimVertex = new G4PrimaryVertex(); 00119 aPrimVertex->SetPosition(pos.x(),pos.y(),pos.z()); 00120 aPrimVertex->SetT0(0.); 00121 G4PrimaryParticle* aPrimParticle = new G4PrimaryParticle(ListOfPrimaryFwdParticles[index_particle], 00122 -p.x(),-p.y(),-p.z()); 00123 00124 aPrimVertex->SetPrimary(aPrimParticle); 00125 anEvent->AddPrimaryVertex(aPrimVertex); 00126 last_generated_part_was_adjoint =false; 00127 G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(false); 00128 } 00129 }
std::vector<G4ParticleDefinition*> G4AdjointPrimaryGeneratorAction::GetListOfPrimaryFwdParticles | ( | ) | [inline] |
Definition at line 100 of file G4AdjointPrimaryGeneratorAction.hh.
Referenced by G4AdjointSimManager::GetListOfPrimaryFwdParticles(), and G4AdjointSimManager::RegisterAtEndOfAdjointTrack().
size_t G4AdjointPrimaryGeneratorAction::GetNbOfAdjointPrimaryTypes | ( | ) | [inline] |
Definition at line 99 of file G4AdjointPrimaryGeneratorAction.hh.
Referenced by G4AdjointSimManager::RunAdjointSimulation().
const G4String& G4AdjointPrimaryGeneratorAction::GetPrimaryIonName | ( | ) | [inline] |
Definition at line 101 of file G4AdjointPrimaryGeneratorAction.hh.
Referenced by G4AdjointSimManager::GetPrimaryIonName().
void G4AdjointPrimaryGeneratorAction::NeglectParticleAsPrimary | ( | const G4String & | particle_name | ) |
Definition at line 203 of file G4AdjointPrimaryGeneratorAction.cc.
References UpdateListOfPrimaryParticles().
Referenced by G4AdjointSimManager::NeglectParticleAsPrimary().
00204 { 00205 if (PrimariesConsideredInAdjointSim.find(particle_name) != PrimariesConsideredInAdjointSim.end()){ 00206 PrimariesConsideredInAdjointSim[particle_name]= false; 00207 } 00208 UpdateListOfPrimaryParticles(); 00209 }
void G4AdjointPrimaryGeneratorAction::SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume | ( | const G4String & | volume_name | ) |
Definition at line 187 of file G4AdjointPrimaryGeneratorAction.cc.
References G4AdjointPrimaryGenerator::SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume().
Referenced by G4AdjointSimManager::DefineAdjointSourceOnTheExtSurfaceOfAVolume().
00188 { 00189 type_of_adjoint_source ="ExternalSurfaceOfAVolume"; 00190 theAdjointPrimaryGenerator->SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(volume_name); 00191 }
void G4AdjointPrimaryGeneratorAction::SetEmax | ( | G4double | val | ) |
Definition at line 139 of file G4AdjointPrimaryGeneratorAction.cc.
Referenced by G4AdjointSimManager::SetAdjointSourceEmax().
void G4AdjointPrimaryGeneratorAction::SetEmaxIon | ( | G4double | val | ) |
void G4AdjointPrimaryGeneratorAction::SetEmin | ( | G4double | val | ) |
Definition at line 132 of file G4AdjointPrimaryGeneratorAction.cc.
Referenced by G4AdjointSimManager::SetAdjointSourceEmin().
void G4AdjointPrimaryGeneratorAction::SetEminIon | ( | G4double | val | ) |
void G4AdjointPrimaryGeneratorAction::SetPrimaryIon | ( | G4ParticleDefinition * | adjointIon, | |
G4ParticleDefinition * | fwdIon | |||
) |
Definition at line 244 of file G4AdjointPrimaryGeneratorAction.cc.
References UpdateListOfPrimaryParticles().
Referenced by G4AdjointSimManager::SetPrimaryIon().
00245 { 00246 fwd_ion = fwdIon; 00247 adj_ion = adjointIon; 00248 UpdateListOfPrimaryParticles(); 00249 }
void G4AdjointPrimaryGeneratorAction::SetRndmFlag | ( | const G4String & | val | ) | [inline] |
void G4AdjointPrimaryGeneratorAction::SetSphericalAdjointPrimarySource | ( | G4double | radius, | |
G4ThreeVector | pos | |||
) |
Definition at line 178 of file G4AdjointPrimaryGeneratorAction.cc.
References G4AdjointPrimaryGenerator::SetSphericalAdjointPrimarySource().
Referenced by G4AdjointSimManager::DefineSphericalAdjointSource(), and G4AdjointSimManager::DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume().
00179 { 00180 radius_spherical_source = radius; 00181 center_spherical_source = center_pos; 00182 type_of_adjoint_source ="Spherical"; 00183 theAdjointPrimaryGenerator->SetSphericalAdjointPrimarySource(radius,center_pos); 00184 }
void G4AdjointPrimaryGeneratorAction::UpdateListOfPrimaryParticles | ( | ) |
Definition at line 212 of file G4AdjointPrimaryGeneratorAction.cc.
References G4ParticleTable::FindParticle(), and G4ParticleTable::GetParticleTable().
Referenced by ConsiderParticleAsPrimary(), GeneratePrimaries(), NeglectParticleAsPrimary(), G4AdjointSimManager::RunAdjointSimulation(), and SetPrimaryIon().
00213 { 00214 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable(); 00215 ListOfPrimaryFwdParticles.clear(); 00216 ListOfPrimaryAdjParticles.clear(); 00217 std::map<G4String, G4bool>::iterator iter; 00218 for( iter = PrimariesConsideredInAdjointSim.begin(); iter != PrimariesConsideredInAdjointSim.end(); ++iter ) { 00219 if(iter->second) { 00220 G4String fwd_particle_name = iter->first; 00221 if ( fwd_particle_name != "ion") { 00222 G4String adj_particle_name = G4String("adj_") + fwd_particle_name; 00223 ListOfPrimaryFwdParticles.push_back(theParticleTable->FindParticle(fwd_particle_name)); 00224 ListOfPrimaryAdjParticles.push_back(theParticleTable->FindParticle(adj_particle_name)); 00225 } 00226 else { 00227 if (fwd_ion ){ 00228 ion_name=fwd_ion->GetParticleName(); 00229 G4String adj_ion_name=G4String("adj_") +ion_name; 00230 ListOfPrimaryFwdParticles.push_back(fwd_ion); 00231 ListOfPrimaryAdjParticles.push_back(adj_ion); 00232 } 00233 else { 00234 ListOfPrimaryFwdParticles.push_back(0); 00235 ListOfPrimaryAdjParticles.push_back(0); 00236 00237 } 00238 } 00239 } 00240 } 00241 }