00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "G4EmMultiModel.hh"
00049 #include "Randomize.hh"
00050
00051
00052
00053 G4EmMultiModel::G4EmMultiModel(const G4String& nam)
00054 : G4VEmModel(nam), nModels(0)
00055 {
00056 model.clear();
00057 cross_section.clear();
00058 }
00059
00060
00061
00062 G4EmMultiModel::~G4EmMultiModel()
00063 {}
00064
00065
00066
00067 void G4EmMultiModel::AddModel(G4VEmModel* p)
00068 {
00069 cross_section.push_back(0.0);
00070 model.push_back(p);
00071 ++nModels;
00072 }
00073
00074
00075
00076 void G4EmMultiModel::Initialise(const G4ParticleDefinition* p,
00077 const G4DataVector& cuts)
00078 {
00079 if(nModels > 0) {
00080 G4cout << "### Initialisation of EM MultiModel " << GetName()
00081 << " including following list of models:" << G4endl;
00082 for(G4int i=0; i<nModels; ++i) {
00083 G4cout << " " << (model[i])->GetName();
00084 (model[i])->SetParticleChange(pParticleChange, GetModelOfFluctuations());
00085 (model[i])->Initialise(p, cuts);
00086 }
00087 G4cout << G4endl;
00088 }
00089 }
00090
00091
00092
00093 G4double G4EmMultiModel::ComputeDEDX(const G4MaterialCutsCouple* couple,
00094 const G4ParticleDefinition* p,
00095 G4double kineticEnergy,
00096 G4double cutEnergy)
00097 {
00098 SetCurrentCouple(couple);
00099 G4double dedx = 0.0;
00100
00101 if(nModels > 0) {
00102 for(G4int i=0; i<nModels; i++) {
00103 dedx += (model[i])->ComputeDEDX(couple, p, cutEnergy, kineticEnergy);
00104 }
00105 }
00106
00107 return dedx;
00108 }
00109
00110
00111
00112 G4double G4EmMultiModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition* p,
00113 G4double kinEnergy,
00114 G4double Z,
00115 G4double A,
00116 G4double cutEnergy,
00117 G4double maxEnergy)
00118 {
00119 G4double cross = 0.0;
00120 if(nModels>0) {
00121 for(G4int i=0; i<nModels; ++i) {
00122 (model[i])->SetCurrentCouple(CurrentCouple());
00123 cross += (model[i])->ComputeCrossSectionPerAtom(p, kinEnergy, Z, A,
00124 cutEnergy, maxEnergy);
00125 }
00126 }
00127 return cross;
00128 }
00129
00130
00131
00132 void G4EmMultiModel::SampleSecondaries(std::vector<G4DynamicParticle*>* vdp,
00133 const G4MaterialCutsCouple* couple,
00134 const G4DynamicParticle* dp,
00135 G4double minEnergy,
00136 G4double maxEnergy)
00137 {
00138 SetCurrentCouple(couple);
00139 if(nModels > 0) {
00140 G4int i;
00141 G4double cross = 0.0;
00142 for(i=0; i<nModels; ++i) {
00143 cross += (model[i])->CrossSection(couple, dp->GetParticleDefinition(),
00144 dp->GetKineticEnergy(), minEnergy, maxEnergy);
00145 cross_section[i] = cross;
00146 }
00147
00148 cross *= G4UniformRand();
00149
00150 for(i=0; i<nModels; ++i) {
00151 if(cross <= cross_section[i]) {
00152 (model[i])->SampleSecondaries(vdp, couple, dp, minEnergy, maxEnergy);
00153 return;
00154 }
00155 }
00156 }
00157 }
00158
00159
00160