G4EmMultiModel.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00028 // -------------------------------------------------------------------
00029 //
00030 // GEANT4 Class file
00031 //
00032 //
00033 // File name:   G4EmMultiModel
00034 //
00035 // Author:        Vladimir Ivanchenko
00036 // 
00037 // Creation date: 03.05.2004
00038 //
00039 // Modifications: 
00040 // 15-04-05 optimize internal interface (V.Ivanchenko)
00041 // 04-07-10 updated interfaces according to g4 9.4 (V.Ivanchenko)
00042 //
00043 
00044 
00045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00047 
00048 #include "G4EmMultiModel.hh"
00049 #include "Randomize.hh"
00050 
00051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00052 
00053 G4EmMultiModel::G4EmMultiModel(const G4String& nam)
00054   : G4VEmModel(nam), nModels(0)
00055 {
00056   model.clear();
00057   cross_section.clear();
00058 }
00059 
00060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00061 
00062 G4EmMultiModel::~G4EmMultiModel()
00063 {}
00064 
00065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00160 

Generated on Mon May 27 17:48:09 2013 for Geant4 by  doxygen 1.4.7