Back to home page

EIC code displayed by LXR

 
 

    


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

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 #ifndef G4_CASCADE_FUNCTIONS_ICC
0027 #define G4_CASCADE_FUNCTIONS_ICC
0028 //
0029 // 20100512  M. Kelsey -- Pass std::vector<> buffer as argument to
0030 //      getOutgoingPartTypes().
0031 // 20100803  M. Kelsey -- Add printing function for debugging
0032 // 20100804  M. Kelsey -- Pretty up printing function
0033 // 20110725  M. Kelsey -- Use ctor to register table in lookup factory
0034 // 20110728  M. Kelsey -- Fix Coverity #22955, recursive #include; fix
0035 //      Coverity #20228, test (mult>maxMult), set to max if over
0036 // 20110916  M. Kelsey -- Drop self-registration due to platform inconsistencies
0037 //      Drop "inline" keyword on complex functions
0038 // 20110923  M. Kelsey -- Add optional ostream& argument to printTable(),
0039 //      pass through to SAMP and DATA
0040 
0041 #include "G4CascadeChannelTables.hh"
0042 #include "globals.hh"
0043 
0044 
0045 // Constructor registers table in lookup
0046 
0047 template <class DATA, class SAMP>
0048 G4CascadeFunctions<DATA,SAMP>::G4CascadeFunctions() : SAMP() {}
0049 
0050 
0051 // Compare summed partial cross section with total cross section
0052 // Truncate multiplicity at maximum if summed < total
0053 
0054 template <class DATA, class SAMP>
0055 G4int G4CascadeFunctions<DATA,SAMP>::getMultiplicity(G4double ke) const {
0056   // Use pointer comparison to see whether tot is just a ref to sum)
0057   if (&DATA::data.sum != &DATA::data.tot) {
0058     G4double summed = this->findCrossSection(ke, DATA::data.sum); 
0059     G4double total  = this->findCrossSection(ke, DATA::data.tot);
0060     if (G4UniformRand() > summed/total) return DATA::data.maxMultiplicity();
0061   }
0062 
0063   return this->findMultiplicity(ke, DATA::data.multiplicities);
0064 }
0065 
0066 
0067 // Generate list of final state particles
0068 
0069 template <class DATA, class SAMP>
0070 void G4CascadeFunctions<DATA,SAMP>::
0071 getOutgoingParticleTypes(std::vector<G4int>& kinds, 
0072              G4int mult, G4double ke) const {
0073   const G4int maxMult = DATA::data.maxMultiplicity();
0074 
0075   if (mult > maxMult) {
0076     G4cerr << " Illegal multiplicity " << mult << " > " << maxMult << G4endl;
0077     mult = maxMult;
0078   }
0079 
0080   kinds.clear();
0081   kinds.reserve(mult);
0082 
0083   G4int channel = this->findFinalStateIndex(mult, ke, DATA::data.index,
0084                             DATA::data.crossSections);
0085 #ifdef G4CASCADE_DEBUG_SAMPLER
0086   G4cout << " getOutgoingParticleTypes: mult=" << mult << " KE=" << ke
0087      << ": channel=" << channel << G4endl;
0088 #endif
0089 
0090   // Identify final-state array to be copied
0091   const G4int* chan = 0;
0092   if (mult == 2) chan = DATA::data.x2bfs[channel];
0093   if (mult == 3) chan = DATA::data.x3bfs[channel];
0094   if (mult == 4) chan = DATA::data.x4bfs[channel];
0095   if (mult == 5) chan = DATA::data.x5bfs[channel];
0096   if (mult == 6) chan = DATA::data.x6bfs[channel];
0097   if (mult == 7) chan = DATA::data.x7bfs[channel];
0098   if (mult == 8) chan = DATA::data.x8bfs[channel];
0099   if (mult == 9) chan = DATA::data.x9bfs[channel];
0100 
0101   if (!chan) {
0102     G4cerr << " getOutgoingParticleTypes: invalid multiplicity " << mult
0103        << G4endl;
0104     return;
0105   }
0106 
0107   kinds.insert(kinds.begin(), chan, chan+mult); // Transfer data into vector
0108   return;
0109 }
0110 
0111 
0112 // Dump lookup tables, including interpolation bins, to log file
0113 
0114 template <class DATA, class SAMP>
0115 void G4CascadeFunctions<DATA,SAMP>::printTable(std::ostream& os) const {
0116   os << " ---------- " << DATA::data.name << " ----------" << G4endl;
0117   SAMP::print(os);
0118   DATA::data.print(os);
0119   os << " ------------------------------" << G4endl;
0120 }
0121 
0122 #endif  /* G4_CASCADE_FUNCTIONS_ICC */