ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4StatMFMicroManager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4StatMFMicroManager.cc
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 //
27 //
28 // Hadronic Process: Nuclear De-excitations
29 // by V. Lara
30 
31 #include "G4StatMFMicroManager.hh"
32 #include "G4HadronicException.hh"
33 
34 // Copy constructor
36 {
37  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMicroManager::copy_constructor meant to not be accessable");
38 }
39 
40 // Operators
41 
44 {
45  throw G4HadronicException(__FILE__, __LINE__, "G4StatMFMicroManager::operator= meant to not be accessable");
46  return *this;
47 }
48 
49 
51 {
52  return false;
53 }
54 
55 
57 {
58  return true;
59 }
60 
61 // constructor
63  G4int multiplicity,
64  G4double FreeIntE, G4double SCompNuc) :
65  _Normalization(0.0)
66 {
67  // Perform class initialization
68  Initialize(theFragment,multiplicity,FreeIntE,SCompNuc);
69 }
70 
71 // destructor
73 {
74  if (!_Partition.empty())
75  {
76  std::for_each(_Partition.begin(),_Partition.end(),
77  DeleteFragment());
78  }
79 }
80 
81 void G4StatMFMicroManager::Initialize(const G4Fragment & theFragment, G4int im,
82  G4double FreeIntE, G4double SCompNuc)
83 {
84  G4int i;
85 
86  G4double U = theFragment.GetExcitationEnergy();
87 
88  G4int A = theFragment.GetA_asInt();
89  G4int Z = theFragment.GetZ_asInt();
90 
91  // Statistical weights
92  _WW = 0.0;
93 
94  // Mean breakup multiplicity
95  _MeanMultiplicity = 0.0;
96 
97  // Mean channel temperature
98  _MeanTemperature = 0.0;
99 
100  // Mean channel entropy
101  _MeanEntropy = 0.0;
102 
103  // Keep fragment atomic numbers
104  // G4int * FragmentAtomicNumbers = new G4int(static_cast<G4int>(A+0.5));
105  // G4int * FragmentAtomicNumbers = new G4int(m);
106  G4int FragmentAtomicNumbers[4];
107 
108  // We distribute A nucleons between m fragments mantaining the order
109  // FragmentAtomicNumbers[m-1]>FragmentAtomicNumbers[m-2]>...>FragmentAtomicNumbers[0]
110  // Our initial distribution is
111  // FragmentAtomicNumbers[m-1]=A, FragmentAtomicNumbers[m-2]=0, ..., FragmentAtomicNumbers[0]=0
112  FragmentAtomicNumbers[im-1] = A;
113  for (i = 0; i < (im - 1); i++) FragmentAtomicNumbers[i] = 0;
114 
115  // We try to distribute A nucleons in partitions of m fragments
116  // MakePartition return true if it is possible
117  // and false if it is not
118 
119  // Loop checking, 05-Aug-2015, Vladimir Ivanchenko
120  while (MakePartition(im,FragmentAtomicNumbers)) {
121  // Allowed partitions are stored and its probability calculated
122 
123  G4StatMFMicroPartition * aPartition = new G4StatMFMicroPartition(A,Z);
124  G4double PartitionProbability = 0.0;
125 
126  for (i = im-1; i >= 0; i--) aPartition->SetPartitionFragment(FragmentAtomicNumbers[i]);
127  PartitionProbability = aPartition->CalcPartitionProbability(U,FreeIntE,SCompNuc);
128  _Partition.push_back(aPartition);
129 
130  _WW += PartitionProbability;
131  _MeanMultiplicity += im*PartitionProbability;
132  _MeanTemperature += aPartition->GetTemperature() * PartitionProbability;
133  if (PartitionProbability > 0.0)
134  _MeanEntropy += PartitionProbability * aPartition->GetEntropy();
135  }
136 }
137 
139 // Distributes A nucleons between k fragments
140 // mantaining the order ANumbers[k-1] > ANumbers[k-2] > ... > ANumbers[0]
141 // If it is possible returns true. In other case returns false
142 {
143  G4int l = 1;
144  // Loop checking, 05-Aug-2015, Vladimir Ivanchenko
145  while (l < k) {
146  G4int tmp = ANumbers[l-1] + ANumbers[k-1];
147  ANumbers[l-1] += 1;
148  ANumbers[k-1] -= 1;
149  if (ANumbers[l-1] > ANumbers[l] || ANumbers[k-2] > ANumbers[k-1]) {
150  ANumbers[l-1] = 1;
151  ANumbers[k-1] = tmp - 1;
152  l++;
153  } else return true;
154  }
155  return false;
156 }
157 
159 {
160  _Normalization = Norm;
161  _WW /= Norm;
162  _MeanMultiplicity /= Norm;
163  _MeanTemperature /= Norm;
164  _MeanEntropy /= Norm;
165 
166  return;
167 }
168 
171 {
172  G4double RandNumber = _Normalization * _WW * G4UniformRand();
173  G4double AccumWeight = 0.0;
174 
175  for (std::vector<G4StatMFMicroPartition*>::iterator i = _Partition.begin();
176  i != _Partition.end(); ++i)
177  {
178  AccumWeight += (*i)->GetProbability();
179  if (RandNumber < AccumWeight)
180  return (*i)->ChooseZ(A0,Z0,MeanT);
181  }
182 
183  throw G4HadronicException(__FILE__, __LINE__,
184  "G4StatMFMicroCanonical::ChooseChannel: Couldn't find a channel.");
185  return 0;
186 }