source: trunk/source/processes/hadronic/models/pre_equilibrium/exciton_model/src/G4PreCompoundFragmentVector.cc @ 1228

Last change on this file since 1228 was 1228, checked in by garnier, 14 years ago

update geant4.9.3 tag

File size: 4.3 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// $Id: G4PreCompoundFragmentVector.cc,v 1.11 2009/02/10 16:01:37 vnivanch Exp $
27// GEANT4 tag $Name: geant4-09-03 $
28//
29// Hadronic Process: Nuclear Preequilibrium
30// by V. Lara
31
32#include "G4PreCompoundFragmentVector.hh"
33#include "G4HadronicException.hh"
34
35const G4PreCompoundFragmentVector & 
36G4PreCompoundFragmentVector::
37operator=(const G4PreCompoundFragmentVector &)
38{
39    throw G4HadronicException(__FILE__, __LINE__, "G4PreCompoundFragmentVector::operator= meant to not be accessable");
40    return *this;
41}
42
43
44G4bool G4PreCompoundFragmentVector::
45operator==(const G4PreCompoundFragmentVector &) const
46{
47    return false;
48}
49
50G4bool G4PreCompoundFragmentVector::
51operator!=(const G4PreCompoundFragmentVector &) const
52{
53    return true;
54}
55
56
57
58G4double G4PreCompoundFragmentVector::
59CalculateProbabilities(const G4Fragment & aFragment)
60{
61  TotalEmissionProbability = 0.0;
62  pcfvector::iterator aChannel; 
63  for (aChannel=theChannels->begin(); aChannel != theChannels->end(); 
64       aChannel++) 
65    {
66      // Calculate emission probailities
67      // Compute total (integrated over kinetic energy) emission
68      // probability of a fragment and
69      // Summing channel emission probabilities
70      TotalEmissionProbability += (*aChannel)->CalcEmissionProbability(aFragment);
71    }
72  return TotalEmissionProbability;
73}
74
75
76G4VPreCompoundFragment * G4PreCompoundFragmentVector::
77ChooseFragment(void)
78{
79  const G4int NumOfFrags = theChannels->size();
80  std::vector<G4double> running;
81  running.reserve(NumOfFrags);
82 
83  pcfvector::iterator i;
84  G4double accumulation = 0.0;
85  for (i = theChannels->begin(); i != theChannels->end(); ++i) {
86    accumulation += (*i)->GetEmissionProbability();
87
88    running.push_back(accumulation);
89  }
90       
91  // Choose an emission channel
92  G4double aChannel = G4UniformRand()*TotalEmissionProbability;
93  G4int ChosenChannel = -1;
94  std::vector<G4double>::iterator ich;
95  for (ich = running.begin(); ich != running.end(); ++ich) 
96    {
97      if (aChannel <= *ich) 
98        {
99#ifdef G4NO_ISO_VECDIST
100          std::vector<G4double>::difference_type n = 0;
101          std::distance(running.begin(),ich,n);
102          ChosenChannel = n;
103#else
104          ChosenChannel = std::distance(running.begin(),ich);
105#endif
106          break;
107        }
108    }
109  running.clear();
110  if (ChosenChannel < 0) 
111    {
112      G4cerr
113        << "G4PreCompoundFragmentVector::ChooseFragment: I can't determine a channel\n"
114        << "Probabilities: ";
115      for (i = theChannels->begin(); i != theChannels->end(); ++i) 
116        {
117          G4cout << (*i)->GetEmissionProbability() << "  ";
118        }
119      G4cout << '\n';
120      return 0;
121    }
122  else
123    {
124      for (i = theChannels->begin(); i != theChannels->end(); ++i) 
125        {
126          (*i)->IncrementStage();
127        }
128    }
129
130  return theChannels->operator[](ChosenChannel);
131}
Note: See TracBrowser for help on using the repository browser.