BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPhysicsCherenkov.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSDebug.hh"
19#include "BDSException.hh"
20#include "BDSPhysicsCherenkov.hh"
21
22#include "G4AutoDelete.hh"
23#include "G4Cerenkov.hh"
24#include "G4Gamma.hh"
25#include "G4LeptonConstructor.hh"
26#include "G4OpticalPhoton.hh"
27#include "G4ParticleDefinition.hh"
28#include "G4PhysicsListHelper.hh"
29#include "G4Version.hh"
30
31
32BDSPhysicsCherenkov::BDSPhysicsCherenkov(G4int maxPhotonsPerStepIn,
33 G4double maxBetaChangePerStepIn):
34 G4VPhysicsConstructor("BDSPhysicsCherenkov"),
35 maxPhotonsPerStep(maxPhotonsPerStepIn),
36 maxBetaChangePerStep(maxBetaChangePerStepIn)
37{
38 if (maxBetaChangePerStep > 100.0)
39 {throw BDSException(__METHOD_NAME__, "the option 'maxBetaChangePerStep' must be less than 100 %");}
40 if (maxBetaChangePerStep < 0)
41 {throw BDSException(__METHOD_NAME__, "the option 'maxBetaChangePerStep' must be >= 0 %");}
42}
43
44BDSPhysicsCherenkov::~BDSPhysicsCherenkov()
45{;}
46
47void BDSPhysicsCherenkov::ConstructParticle()
48{
49 G4LeptonConstructor::ConstructParticle();
50 G4Gamma::Gamma();
51 G4OpticalPhoton::OpticalPhotonDefinition();
52}
53
54void BDSPhysicsCherenkov::ConstructProcess()
55{
56 if (Activated())
57 {return;}
58
59 G4Cerenkov* cherenkov = new G4Cerenkov();
60 G4AutoDelete::Register(cherenkov);
61
62 // reduce memory profile
63 cherenkov->SetTrackSecondariesFirst(true);
64
65 // common settings (similar to optical physics) - 0 allowed
66 if (maxPhotonsPerStep > -1)
67 {cherenkov->SetMaxNumPhotonsPerStep(maxPhotonsPerStep);}
68 cherenkov->SetMaxBetaChangePerStep(maxBetaChangePerStep);
69
70 G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
71
72#if G4VERSION_NUMBER > 1029
73 auto aParticleIterator = GetParticleIterator();
74#endif
75 aParticleIterator->reset();
76 while( (*aParticleIterator)() )
77 {
78 G4ParticleDefinition* particle = aParticleIterator->value();
79
80 if (cherenkov->IsApplicable(*particle))
81 {ph->RegisterProcess(cherenkov, particle);}
82 }
83
85}
General exception with possible name of object and message.
G4bool Activated() const
Get whether this instance has been activated.
void SetActivated()
Flag this instance as activated for later querying.