Back to home page

EIC code displayed by LXR

 
 

    


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

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 file
0030 //
0031 // Description: Data structure for cross sections per materials
0032 //
0033 // Author:      V.Ivanchenko 31.05.2018
0034 //
0035 // Modifications:
0036 //
0037 //----------------------------------------------------------------------------
0038 //
0039 
0040 #ifndef HadronXSDataTable_h
0041 #define HadronXSDataTable_h 1
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 #include "globals.hh"
0046 #include "G4Element.hh"
0047 #include "G4ElementVector.hh"
0048 #include "G4PhysicsVector.hh"
0049 #include "Randomize.hh"
0050 #include <vector>
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 class G4Material;
0055 class G4DynamicParticle;
0056 class G4CrossSectionDataStore;
0057 
0058 class G4HadElementSelector 
0059 {
0060 public:
0061 
0062   G4HadElementSelector(G4DynamicParticle*, G4CrossSectionDataStore*, 
0063                const G4Material*, G4int bins, 
0064                G4double emin, G4double emax, G4bool spline);
0065 
0066   ~G4HadElementSelector();
0067 
0068   void Dump();
0069 
0070   inline const G4Element* SelectRandomAtom(G4double e) const
0071   {
0072     const G4Element* element = (*theElementVector)[nElmMinusOne];
0073     if (nElmMinusOne > 0) {
0074       G4double x = G4UniformRand();
0075       for(G4int i=0; i<nElmMinusOne; ++i) {
0076     if (x <= xSections[i]->Value(e)) {
0077       element = (*theElementVector)[i];
0078       break;
0079     }
0080       }
0081     }
0082     return element;
0083   }
0084 
0085 private:
0086 
0087   G4HadElementSelector(G4HadElementSelector &) = delete;
0088   G4HadElementSelector& operator=(const G4HadElementSelector &right) = delete;
0089 
0090   G4int nElmMinusOne;
0091   const G4ElementVector* theElementVector;
0092   std::vector<G4PhysicsVector*> xSections;
0093 };
0094 
0095 class G4HadronXSDataTable
0096 {
0097 
0098 public:
0099 
0100   explicit G4HadronXSDataTable();
0101 
0102   ~G4HadronXSDataTable();
0103 
0104   void Initialise(G4DynamicParticle*, G4CrossSectionDataStore*, 
0105           G4int bins, G4double emin, G4double emax, 
0106           G4bool spline);
0107 
0108   inline const G4PhysicsVector* HasData(size_t idx) const
0109   {
0110     return xsData[idx];
0111   };
0112 
0113   inline G4double GetCrossSection(G4double e, size_t idx) const
0114   {
0115     return xsData[idx]->Value(e);
0116   };
0117 
0118   inline const G4Element* SelectRandomAtom(G4double e, size_t idx) const
0119   {
0120     return elmSelectors[idx]->SelectRandomAtom(e);
0121   };
0122 
0123   void Dump();
0124 
0125 private:
0126 
0127   // Assignment operator and copy constructor
0128   G4HadronXSDataTable & operator=
0129     (const G4HadronXSDataTable &right) = delete;
0130   G4HadronXSDataTable(const G4HadronXSDataTable&) = delete;
0131   
0132   std::vector<G4PhysicsVector*> xsData;
0133   std::vector<G4HadElementSelector*> elmSelectors;
0134 
0135   size_t nMaterials;
0136 };
0137 
0138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0139 
0140 #endif
0141