/// Callback to construct processes (uses the G4 particle table) virtual void constructProcesses(G4VUserPhysicsList* physics_list) { this->Geant4PhysicsList::constructProcesses(physics_list); info("+++ Constructing optical_photon processes:"); info("+++ G4OpAbsorption G4OpRayleigh G4OpMieHG G4OpBoundaryProcess"); G4ParticleTable* table = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = table->FindParticle("opticalphoton"); if (0 == particle) { except("++ Cannot resolve 'opticalphoton' particle definition!"); } G4OpBoundaryProcess* fBoundaryProcess = new G4OpBoundaryProcess(); G4OpAbsorption* fAbsorptionProcess = new G4OpAbsorption(); G4OpRayleigh* fRayleighScatteringProcess = new G4OpRayleigh(); G4OpMieHG* fMieHGScatteringProcess = new G4OpMieHG(); fAbsorptionProcess->SetVerboseLevel(m_verbosity); fRayleighScatteringProcess->SetVerboseLevel(m_verbosity); fMieHGScatteringProcess->SetVerboseLevel(m_verbosity); fBoundaryProcess->SetVerboseLevel(m_verbosity); G4ProcessManager* pmanager = particle->GetProcessManager(); pmanager->AddDiscreteProcess(fAbsorptionProcess); pmanager->AddDiscreteProcess(fRayleighScatteringProcess); pmanager->AddDiscreteProcess(fMieHGScatteringProcess); pmanager->AddDiscreteProcess(fBoundaryProcess); }
void TestPhysicsList::ConstructProcess() { G4VUserPhysicsList::AddTransportation(); // process added for electrons only G4ParticleDefinition* particle = G4Electron::ElectronDefinition(); G4ProcessManager* process_manager = particle->GetProcessManager(); process_manager->AddDiscreteProcess(&m_process); }
void FastSimPhysics::ConstructProcess() { G4FastSimulationManagerProcess* fastSimProcess = new G4FastSimulationManagerProcess("G4FSMP"); aParticleIterator->reset(); // Fast simulation manager process is available for all the particles while( (*aParticleIterator)() ) { G4ParticleDefinition* particle = aParticleIterator->value(); G4ProcessManager* process_manager = particle->GetProcessManager(); process_manager->AddDiscreteProcess(fastSimProcess); } }
void CollimationEventAction::SetOutputParticle(double x, double px, double y, double py, double p) { OutputParticle->x = x; OutputParticle->xp = px; OutputParticle->y = y; OutputParticle->yp = py; G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particleTable->FindParticle("proton"); const G4double mp = particle->GetPDGMass(); double pp= sqrt(p*p + mp*mp); OutputParticle->p = pp; size_t oldprec = std::cout.precision(15); //std::cout << "OUT: " << x << "\t" << px << "\t" << y << "\t" << py << "\t" << pp << std::endl; std::cout.precision(oldprec); }
/// Callback to construct particle decays void Geant4PhysicsListActionSequence::constructDecays(G4VUserPhysicsList* physics_pointer) { G4ParticleTable* pt = G4ParticleTable::GetParticleTable(); G4ParticleTable::G4PTblDicIterator* iter = pt->GetIterator(); // Add Decay Process G4Decay* decay = new G4Decay(); info("ConstructDecays %p",physics_pointer); iter->reset(); while ((*iter)()) { G4ParticleDefinition* p = iter->value(); G4ProcessManager* mgr = p->GetProcessManager(); if (decay->IsApplicable(*p)) { mgr->AddProcess(decay); // set ordering for PostStepDoIt and AtRestDoIt mgr->SetProcessOrdering(decay, idxPostStep); mgr->SetProcessOrdering(decay, idxAtRest); } } }
void PhysicsList::AddDecay() { // Add Decay Process G4Decay* fDecayProcess = new G4Decay(); theParticleIterator->reset(); while( (*theParticleIterator)() ){ G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); if (fDecayProcess->IsApplicable(*particle) && !particle->IsShortLived()) { pmanager->AddProcess(fDecayProcess); // set ordering for PostStepDoIt and AtRestDoIt pmanager->SetProcessOrdering(fDecayProcess, idxPostStep); pmanager->SetProcessOrdering(fDecayProcess, idxAtRest); } } }
void Geant4ShowerGenerator:: generate_showers(unsigned num_events, calin::simulation::tracker::ParticleType type, double total_energy, const Eigen::Vector3d& x0, const Eigen::Vector3d& u0, double weight) { G4GeneralParticleSource* gps = new G4GeneralParticleSource(); // default particle kinematic G4ParticleTable* particle_table = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particle_table->FindParticle(particle_type_to_pdg_type(type)); if(total_energy * CLHEP::MeV < particle->GetPDGMass()) throw std::invalid_argument( "Total energy must be larger than particle rest mass (" + std::to_string(particle->GetPDGMass()/CLHEP::MeV) + " MeV)"); G4ThreeVector position; eigen_to_g4vec(position, x0, CLHEP::cm); G4ThreeVector momentum_direction; eigen_to_g4vec(momentum_direction, u0); G4SingleParticleSource* sps = gps->GetCurrentSource(); sps->SetParticleDefinition(particle); sps->GetPosDist()->SetPosDisType("Point"); sps->GetPosDist()->SetCentreCoords(position); sps->GetAngDist()->SetAngDistType("planar"); sps->GetAngDist()->SetParticleMomentumDirection(momentum_direction); sps->GetEneDist()->SetEnergyDisType("Mono"); sps->GetEneDist()->SetMonoEnergy(total_energy * CLHEP::MeV - particle->GetPDGMass()); gen_action_->setGPS(gps); // start a run run_manager_->BeamOn(num_events); }
/// Callback to construct processes (uses the G4 particle table) void Geant4PhysicsList::constructProcesses(G4VUserPhysicsList* physics_pointer) { debug("constructProcesses %p", physics_pointer); for (PhysicsProcesses::const_iterator i = m_discreteProcesses.begin(); i != m_discreteProcesses.end(); ++i) { const string& part_name = (*i).first; const ParticleProcesses& procs = (*i).second; vector<G4ParticleDefinition*> defs(Geant4ParticleHandle::g4DefinitionsRegEx(part_name)); if (defs.empty()) { except("Particle:%s Cannot find the corresponding entry in the particle table.", part_name.c_str()); } for (vector<G4ParticleDefinition*>::const_iterator id = defs.begin(); id != defs.end(); ++id) { G4ParticleDefinition* particle = *id; G4ProcessManager* mgr = particle->GetProcessManager(); for (ParticleProcesses::const_iterator ip = procs.begin(); ip != procs.end(); ++ip) { const Process& p = (*ip); G4VProcess* g4 = PluginService::Create<G4VProcess*>(p.name); if (!g4) { // Error no factory for this process except("Particle:%s -> [%s] Cannot create discrete physics process %s", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str()); } mgr->AddDiscreteProcess(g4); info("Particle:%s -> [%s] added discrete process %s", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str()); } } } for (PhysicsProcesses::const_iterator i = m_processes.begin(); i != m_processes.end(); ++i) { const string& part_name = (*i).first; const ParticleProcesses& procs = (*i).second; vector<G4ParticleDefinition*> defs(Geant4ParticleHandle::g4DefinitionsRegEx(part_name)); if (defs.empty()) { except("Particle:%s Cannot find the corresponding entry in the particle table.", part_name.c_str()); } for (vector<G4ParticleDefinition*>::const_iterator id = defs.begin(); id != defs.end(); ++id) { G4ParticleDefinition* particle = *id; G4ProcessManager* mgr = particle->GetProcessManager(); for (ParticleProcesses::const_iterator ip = procs.begin(); ip != procs.end(); ++ip) { const Process& p = (*ip); G4VProcess* g4 = PluginService::Create<G4VProcess*>(p.name); if (!g4) { // Error no factory for this process except("Particle:%s -> [%s] Cannot create physics process %s", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str()); } mgr->AddProcess(g4, p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); info("Particle:%s -> [%s] added process %s with flags (%d,%d,%d)", part_name.c_str(), particle->GetParticleName().c_str(), p.name.c_str(), p.ordAtRestDoIt, p.ordAlongSteptDoIt, p.ordPostStepDoIt); } } } }
void Geant4ExtraParticles::constructProcess(Constructor& ctor) { G4ParticleTable::G4PTblDicIterator* ParticleIterator = ctor.particleIterator(); #if G4VERSION_NUMBER < 940 if ( 0 == _scatter ) _scatter=new G4hMultipleScattering(); if ( 0 == _ionise ) _ionise=new G4hIonisation() if ( 0 == _decay ) _decay=new G4Decay() #endif while((*ParticleIterator)()) { G4ParticleDefinition* pdef = ParticleIterator->value(); G4ProcessManager* pmgr = pdef->GetProcessManager(); if (pdef->GetParticleType() == "extra") { if (pdef->GetPDGCharge() != 0) { #if G4VERSION_NUMBER < 940 pmgr->AddProcess(_scatter, -1, 1, 1); // multiple scattering pmgr->AddProcess(_ionise, -1, 2, 2); // ionisation pmgr->AddProcess(_decay, -1, -1, 2); // decay #else pmgr->AddProcess(new G4hMultipleScattering(), -1, 1, 1); //multiple scattering pmgr->AddProcess(new G4hIonisation(), -1, 2, 2); // ionisation pmgr->AddProcess(new G4Decay(), -1, -1, 2); // decay #endif } else { #if G4VERSION_NUMBER < 940 pmgr->AddProcess(_scatter=new G4hMultipleScattering(), -1, 1, 1); // multiple scattering pmgr->AddProcess(_decay=new G4Decay(), -1, -1, 2); // decay #else // pmgr->AddProcess(new G4hMultipleScattering(), -1, 1, 1); // multiple scattering pmgr->AddProcess(new G4Decay(), -1, -1, 2); // decay #endif } } } }
G4bool FastSimModelTracker::IsApplicable(const G4ParticleDefinition& aParticleType) { return aParticleType.GetPDGCharge() != 0; }
void PhysListEmStandardSS::ConstructProcess() { // Add standard EM Processes aParticleIterator->reset(); while( (*aParticleIterator)() ){ G4ParticleDefinition* particle = aParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == "gamma") { // gamma pmanager->AddDiscreteProcess(new G4PhotoElectricEffect); pmanager->AddDiscreteProcess(new G4ComptonScattering); pmanager->AddDiscreteProcess(new G4GammaConversion); } else if (particleName == "e-") { //electron pmanager->AddProcess(new G4eIonisation, -1, 1, 1); pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2); pmanager->AddDiscreteProcess(new G4CoulombScattering); } else if (particleName == "e+") { //positron pmanager->AddProcess(new G4eIonisation, -1, 1, 1); pmanager->AddProcess(new G4eBremsstrahlung, -1, 2, 2); pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 3); pmanager->AddDiscreteProcess(new G4CoulombScattering); } else if (particleName == "mu+" || particleName == "mu-" ) { //muon pmanager->AddProcess(new G4MuIonisation, -1, 1, 1); pmanager->AddProcess(new G4MuBremsstrahlung, -1, 2, 2); pmanager->AddProcess(new G4MuPairProduction, -1, 3, 3); pmanager->AddDiscreteProcess(new G4CoulombScattering); } else if (particleName == "alpha" || particleName == "He3") { pmanager->AddProcess(new G4ionIonisation, -1, 1, 1); G4CoulombScattering* cs = new G4CoulombScattering(); //cs->AddEmModel(0, new G4IonCoulombScatteringModel()); cs->SetBuildTableFlag(false); pmanager->AddDiscreteProcess(cs); } else if (particleName == "GenericIon" ) { pmanager->AddProcess(new G4ionIonisation, -1, 1, 1); G4CoulombScattering* cs = new G4CoulombScattering(); cs->AddEmModel(0, new G4IonCoulombScatteringModel()); cs->SetBuildTableFlag(false); pmanager->AddDiscreteProcess(cs); } else if ((!particle->IsShortLived()) && (particle->GetPDGCharge() != 0.0) && (particle->GetParticleName() != "chargedgeantino")) { //all others charged particles except geantino pmanager->AddDiscreteProcess(new G4CoulombScattering); pmanager->AddProcess(new G4hIonisation, -1, 1, 1); } } // Em options // // Main options and setting parameters are shown here. // Several of them have default values. // G4EmProcessOptions emOptions; //physics tables // emOptions.SetMinEnergy(100*eV); //default emOptions.SetMaxEnergy(100*TeV); //default emOptions.SetDEDXBinning(12*20); //default=12*7 emOptions.SetLambdaBinning(12*20); //default=12*7 emOptions.SetSplineFlag(true); //default //energy loss // emOptions.SetStepFunction(0.2, 100*um); //default=(0.2, 1*mm) emOptions.SetLinearLossLimit(1.e-2); //default //ionization // emOptions.SetSubCutoff(false); //default // scattering emOptions.SetPolarAngleLimit(0.0); }
void Physics::ConstructEM() { theParticleIterator->reset(); while( ( *theParticleIterator )() ) { G4ParticleDefinition * particle = theParticleIterator->value(); G4ProcessManager * pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == "gamma") { pmanager->AddDiscreteProcess(new G4PhotoElectricEffect); pmanager->AddDiscreteProcess(new G4ComptonScattering); pmanager->AddDiscreteProcess(new G4GammaConversion); pmanager->AddDiscreteProcess(new G4CoulombScattering); pmanager->AddDiscreteProcess(new G4RayleighScattering); } else if( particleName == "e-" ) { if( Run_Type == "Recon" ) { pmanager->AddProcess(new G4eIonisation, -1, 1, 1 ); } else { pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1 ); pmanager->AddProcess(new G4eIonisation, -1, 2, 2 ); if (fullBrem && supBrem) { std::cout<<"\n\nCANNOT USE FULL AND SUPPRESSED PHOTON BREMSSTRAHLUNG SIMULTANEOUSLY!\n\n"; std::cout<<"USING FULL BREMSSTRAHLUNG FOR ELECTRONS!\n\n"; supBrem = false; } else if (fullBrem) { pmanager->AddProcess(new G4eBremsstrahlung, -1, -1, 3 ); } else if (supBrem) { G4eBremsstrahlung * eBremP = new G4eBremsstrahlung; bremPhotonSuppression * bremSup = new bremPhotonSuppression; bremSup->RegisterProcess(eBremP); pmanager->AddProcess(bremSup, -1, -1, 3 ); } else { std::cout<<"\n\nNO ELECTRON BREMSSTRAHLUNG INCLUDED!\n\n"; } } } else if( particleName == "e+" ) { if( Run_Type == "Recon" ) { pmanager->AddProcess(new G4eIonisation, -1, 1, 1 ); } else { pmanager->AddProcess(new G4eMultipleScattering, -1, 1, 1 ); pmanager->AddProcess(new G4eIonisation, -1, 2, 2 ); if (fullBrem && supBrem) { std::cout<<"\n\nCANNOT USE FULL AND SUPPRESSED PHOTON BREMSSTRAHLUNG SIMULTANEOUSLY!\n\n"; std::cout<<"USING FULL BREMSSTRAHLUNG FOR POSITRONS!\n\n"; supBrem = false; } else if (fullBrem) { pmanager->AddProcess(new G4eBremsstrahlung, -1, -1, 3 ); } else if (supBrem) { G4eBremsstrahlung * eBremP = new G4eBremsstrahlung; bremPhotonSuppression * bremSup = new bremPhotonSuppression; bremSup->RegisterProcess(eBremP); pmanager->AddProcess(bremSup, -1, -1, 3 ); } else { std::cout<<"\n\nNO POSITRON BREMSSTRAHLUNG INCLUDED!\n\n"; } pmanager->AddProcess(new G4eplusAnnihilation, 0, -1, 4 ); } } else if( particleName == "mu+" || particleName == "mu-" ) { pmanager->AddProcess(new G4MuMultipleScattering, -1, 1, 1 ); pmanager->AddProcess(new G4MuIonisation, -1, 2, 2 ); if (fullBrem && supBrem) { std::cout<<"\n\nCANNOT USE FULL AND SUPPRESSED PHOTON BREMSSTRAHLUNG SIMULTANEOUSLY!\n\n"; std::cout<<"USING FULL BREMSSTRAHLUNG FOR MUONS!\n\n"; supBrem = false; } else if (fullBrem) { pmanager->AddProcess(new G4MuBremsstrahlung, -1, -1, 3 ); } else if (supBrem) { G4MuBremsstrahlung * eBremP = new G4MuBremsstrahlung; bremPhotonSuppression * bremSup = new bremPhotonSuppression; bremSup->RegisterProcess(eBremP); pmanager->AddProcess(bremSup, -1, -1, 3 ); } else { std::cout<<"\n\nNO MUON BREMSSTRAHLUNG INCLUDED!\n\n"; } pmanager->AddProcess(new G4MuPairProduction, -1, -1, 4 ); } // All others charged particles except chargedgeantino. else if( !( particle->IsShortLived() ) && particle->GetPDGCharge() != 0.0 && particle->GetParticleName() != "chargedgeantino" ) { if( Run_Type == "Recon" ) { pmanager->AddProcess(new G4hIonisation, -1, 1, 1 ); } else { pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1 ); pmanager->AddProcess(new G4hIonisation, -1, 2, 2 ); if (fullBrem && supBrem) { std::cout<<"\n\nCANNOT USE FULL AND SUPPRESSED PHOTON BREMSSTRAHLUNG SIMULTANEOUSLY!\n\n"; std::cout<<"USING FULL BREMSSTRAHLUNG FOR HADRONS!\n\n"; supBrem = false; } else if (fullBrem) { pmanager->AddProcess(new G4hBremsstrahlung, -1, -1, 3 ); } else if (supBrem) { G4hBremsstrahlung * eBremP = new G4hBremsstrahlung; bremPhotonSuppression * bremSup = new bremPhotonSuppression; bremSup->RegisterProcess(eBremP); pmanager->AddProcess(bremSup, -1, -1, 3 ); } else { std::cout<<"\n\nNO HADRON BREMSSTRAHLUNG INCLUDED!\n\n"; } pmanager->AddProcess(new G4hPairProduction, -1, -1, 4 ); } // Step limit. //pmanager->AddProcess(new G4StepLimiter, -1, -1, 3 ); //pmanager->AddProcess(new G4UserSpecialCuts, -1, -1, 4 ); } } }
void PhysListEmStandardGS::ConstructProcess() { // Add standard EM Processes // aParticleIterator->reset(); while( (*aParticleIterator)() ){ G4ParticleDefinition* particle = aParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == "gamma") { // gamma pmanager->AddDiscreteProcess(new G4PhotoElectricEffect); pmanager->AddDiscreteProcess(new G4ComptonScattering); pmanager->AddDiscreteProcess(new G4GammaConversion); } else if (particleName == "e-") { //electron G4eMultipleScattering* msc = new G4eMultipleScattering(); msc->AddEmModel(0, new G4GoudsmitSaundersonMscModel()); pmanager->AddProcess(msc, -1, 1, 1); pmanager->AddProcess(new G4eIonisation, -1, 2, 2); pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); } else if (particleName == "e+") { //positron G4eMultipleScattering* msc = new G4eMultipleScattering(); msc->AddEmModel(0, new G4GoudsmitSaundersonMscModel()); pmanager->AddProcess(msc, -1, 1, 1); pmanager->AddProcess(new G4eIonisation, -1, 2, 2); pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4); } else if (particleName == "mu+" || particleName == "mu-" ) { //muon pmanager->AddProcess(new G4MuMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3); pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4); } else if( particleName == "proton" || particleName == "pi-" || particleName == "pi+" ) { //proton pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4hIonisation, -1, 2, 2); pmanager->AddProcess(new G4hBremsstrahlung, -1, 3, 3); pmanager->AddProcess(new G4hPairProduction, -1, 4, 4); } else if( particleName == "alpha" || particleName == "He3" ) { //alpha pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4ionIonisation, -1, 2, 2); pmanager->AddProcess(new G4NuclearStopping, -1, 3,-1); } else if( particleName == "GenericIon" ) { //Ions pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); G4ionIonisation* ionIoni = new G4ionIonisation(); ionIoni->SetEmModel(new G4IonParametrisedLossModel()); pmanager->AddProcess(ionIoni, -1, 2, 2); pmanager->AddProcess(new G4NuclearStopping, -1, 3,-1); } else if ((!particle->IsShortLived()) && (particle->GetPDGCharge() != 0.0) && (particle->GetParticleName() != "chargedgeantino")) { //all others charged particles except geantino pmanager->AddProcess(new G4hMultipleScattering, -1, 1, 1); pmanager->AddProcess(new G4hIonisation, -1, 2, 2); } } // Em options // // Main options and setting parameters are shown here. // Several of them have default values. // G4EmProcessOptions emOptions; //physics tables // emOptions.SetMinEnergy(100*eV); //default emOptions.SetMaxEnergy(100*TeV); //default emOptions.SetDEDXBinning(12*20); //default=12*7 emOptions.SetLambdaBinning(12*20); //default=12*7 emOptions.SetSplineFlag(true); //default //multiple coulomb scattering // emOptions.SetMscStepLimitation(fUseDistanceToBoundary); //default=fUseSafety emOptions.SetMscRangeFactor(0.04); //default emOptions.SetMscGeomFactor (2.5); //default emOptions.SetSkin(3.); //default //energy loss // emOptions.SetStepFunction(0.2, 100*um); //default=(0.2, 1*mm) emOptions.SetLinearLossLimit(1.e-2); //default //ionization // emOptions.SetSubCutoff(false); //default }