Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:12

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // -------------------------------------------------------------------
0028 //
0029 // GEANT4 Class header file
0030 //
0031 //
0032 // File name:     G4EmElementSelector
0033 //
0034 // Author:        Vladimir Ivanchenko
0035 //
0036 // Creation date: 29.05.2008
0037 //
0038 // Modifications:
0039 //
0040 //
0041 // Class Description:
0042 //
0043 // Generic helper class for the random selection of an element
0044 
0045 // -------------------------------------------------------------------
0046 //
0047 
0048 #ifndef G4EmElementSelector_h
0049 #define G4EmElementSelector_h 1
0050 
0051 #include "globals.hh"
0052 #include "G4ParticleDefinition.hh"
0053 #include "G4Material.hh"
0054 #include "G4Element.hh"
0055 #include "G4ElementVector.hh"
0056 #include "G4PhysicsLogVector.hh"
0057 #include "Randomize.hh"
0058 #include <vector>
0059 
0060 class G4VEmModel;
0061 
0062 class G4EmElementSelector
0063 {
0064 
0065 public:
0066 
0067   G4EmElementSelector(G4VEmModel*, const G4Material*, G4int bins, 
0068                       G4double emin, G4double emax, 
0069                       G4bool spline = true);
0070 
0071   ~G4EmElementSelector();
0072 
0073   void Initialise(const G4ParticleDefinition*, G4double cut = 0.0);
0074 
0075   void Dump(const G4ParticleDefinition* p = nullptr);
0076 
0077   const G4Element* SelectRandomAtom(const G4double kineticEnergy,
0078                                     const G4double logEKin) const;
0079 
0080   inline const G4Element* SelectRandomAtom(G4double kineticEnergy) const;
0081 
0082   inline const G4Material* GetMaterial() const;
0083 
0084   //  hide assignment operator
0085   G4EmElementSelector & operator=(const  G4EmElementSelector &right) = delete;
0086   G4EmElementSelector(const  G4EmElementSelector&) = delete;
0087 
0088 private:
0089 
0090   G4VEmModel*       model;
0091   const G4Material* material;
0092   const G4ElementVector* theElementVector;
0093 
0094   G4int    nElmMinusOne;
0095   G4int    nbins;
0096 
0097   G4double cutEnergy;
0098   G4double lowEnergy;
0099   G4double highEnergy;
0100 
0101   std::vector<G4PhysicsLogVector*> xSections;
0102   
0103 };
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0107 
0108 inline const G4Element* G4EmElementSelector::SelectRandomAtom(G4double e) const
0109 {
0110   const G4Element* element = (*theElementVector)[nElmMinusOne];
0111   if (nElmMinusOne > 0) {
0112     G4double x = G4UniformRand();
0113     size_t idx(0);
0114     for(G4int i=0; i<nElmMinusOne; ++i) {
0115       if (x <= (xSections[i])->Value(e, idx)) {
0116         element = (*theElementVector)[i];
0117         break;
0118       }
0119     }
0120   }
0121   return element;
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0125 
0126 inline const G4Material* G4EmElementSelector::GetMaterial() const
0127 {
0128   return material;
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0132 
0133 #endif
0134