Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/particles/management/src/G4VDecayChannel.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/management/src/G4VDecayChannel.cc (Version 11.3.0) and /particles/management/src/G4VDecayChannel.cc (Version 9.5.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4VDecayChannel                             << 
 27 //                                                 26 //
 28 // Author: H.Kurashige, 27 July 1996           <<  27 // $Id: G4VDecayChannel.cc,v 1.21 2010-12-22 07:07:59 kurasige Exp $
 29 // ------------------------------------------- <<  28 // GEANT4 tag $Name: not supported by cvs2svn $
 30                                                <<  29 //
 31 #include "G4VDecayChannel.hh"                  <<  30 // 
                                                   >>  31 // ------------------------------------------------------------
                                                   >>  32 //      GEANT 4 class header file
                                                   >>  33 //
                                                   >>  34 //      History: first implementation, based on object model of
                                                   >>  35 //      27 July 1996 H.Kurashige
                                                   >>  36 //      30 May 1997  H.Kurashige
                                                   >>  37 //      23 Mar. 2000 H.Weber      : add GetAngularMomentum
                                                   >>  38 // ------------------------------------------------------------
 32                                                    39 
 33 #include "G4AutoLock.hh"                       << 
 34 #include "G4DecayProducts.hh"                  << 
 35 #include "G4DecayTable.hh"                     << 
 36 #include "G4ParticleDefinition.hh"                 40 #include "G4ParticleDefinition.hh"
 37 #include "G4ParticleTable.hh"                      41 #include "G4ParticleTable.hh"
 38 #include "G4SystemOfUnits.hh"                  <<  42 #include "G4DecayTable.hh"
 39 #include "Randomize.hh"                        <<  43 #include "G4DecayProducts.hh"
                                                   >>  44 #include "G4VDecayChannel.hh"
 40                                                    45 
 41 const G4String G4VDecayChannel::noName = " ";      46 const G4String G4VDecayChannel::noName = " ";
 42                                                    47 
 43 G4VDecayChannel::G4VDecayChannel()                 48 G4VDecayChannel::G4VDecayChannel()
                                                   >>  49   :kinematics_name(""),
                                                   >>  50    rbranch(0.0),
                                                   >>  51    numberOfDaughters(0),
                                                   >>  52    parent_name(0), daughters_name(0),
                                                   >>  53    particletable(0),
                                                   >>  54    parent(0), daughters(0),
                                                   >>  55    parent_mass(0.0), daughters_mass(0),
                                                   >>  56    verboseLevel(1)    
 44 {                                                  57 {
 45   // set pointer to G4ParticleTable (static an     58   // set pointer to G4ParticleTable (static and singleton object)
 46   particletable = G4ParticleTable::GetParticle     59   particletable = G4ParticleTable::GetParticleTable();
 47 }                                                  60 }
 48                                                    61 
 49 G4VDecayChannel::G4VDecayChannel(const G4Strin <<  62 
 50   : kinematics_name(aName), verboseLevel(verbo <<  63 G4VDecayChannel::G4VDecayChannel(const G4String &aName, G4int Verbose)
                                                   >>  64   :kinematics_name(aName),
                                                   >>  65    rbranch(0.0),
                                                   >>  66    numberOfDaughters(0),
                                                   >>  67    parent_name(0), daughters_name(0),
                                                   >>  68    particletable(0),
                                                   >>  69    parent(0), daughters(0),
                                                   >>  70    parent_mass(0.0), daughters_mass(0),
                                                   >>  71    verboseLevel(Verbose)    
 51 {                                                  72 {
 52   // set pointer to G4ParticleTable (static an     73   // set pointer to G4ParticleTable (static and singleton object)
 53   particletable = G4ParticleTable::GetParticle     74   particletable = G4ParticleTable::GetParticleTable();
 54 }                                                  75 }
 55                                                    76 
 56 G4VDecayChannel::G4VDecayChannel(const G4Strin <<  77 G4VDecayChannel::G4VDecayChannel(const G4String  &aName, 
 57                                  G4double theB <<  78              const G4String& theParentName,
 58                                  const G4Strin <<  79              G4double        theBR,
 59                                  const G4Strin <<  80              G4int           theNumberOfDaughters,
 60                                  const G4Strin <<  81              const G4String& theDaughterName1,
 61   : kinematics_name(aName), rbranch(theBR), nu <<  82              const G4String& theDaughterName2,
                                                   >>  83              const G4String& theDaughterName3,
                                                   >>  84              const G4String& theDaughterName4 )
                                                   >>  85                :kinematics_name(aName),
                                                   >>  86     rbranch(theBR),
                                                   >>  87     numberOfDaughters(theNumberOfDaughters),
                                                   >>  88     parent_name(0), daughters_name(0),
                                                   >>  89     particletable(0),
                                                   >>  90     parent(0), daughters(0),
                                                   >>  91     parent_mass(0.0), daughters_mass(0),
                                                   >>  92     verboseLevel(1)   
 62 {                                                  93 {
 63   // set pointer to G4ParticleTable (static an     94   // set pointer to G4ParticleTable (static and singleton object)
 64   particletable = G4ParticleTable::GetParticle     95   particletable = G4ParticleTable::GetParticleTable();
 65                                                    96 
 66   // parent name                                   97   // parent name
 67   parent_name = new G4String(theParentName);       98   parent_name = new G4String(theParentName);
 68                                                    99 
 69   // cleate array                                 100   // cleate array
 70   daughters_name = new G4String*[numberOfDaugh    101   daughters_name = new G4String*[numberOfDaughters];
 71   for (G4int index = 0; index < numberOfDaught << 102   for (G4int index=0;index<numberOfDaughters;index++) daughters_name[index]=0;
 72     daughters_name[index] = nullptr;           << 
 73   }                                            << 
 74                                                   103 
 75   // daughters' name                              104   // daughters' name
 76   if (numberOfDaughters > 0) daughters_name[0] << 105   if (numberOfDaughters>0) daughters_name[0] = new G4String(theDaughterName1);
 77   if (numberOfDaughters > 1) daughters_name[1] << 106   if (numberOfDaughters>1) daughters_name[1] = new G4String(theDaughterName2);
 78   if (numberOfDaughters > 2) daughters_name[2] << 107   if (numberOfDaughters>2) daughters_name[2] = new G4String(theDaughterName3);
 79   if (numberOfDaughters > 3) daughters_name[3] << 108   if (numberOfDaughters>3) daughters_name[3] = new G4String(theDaughterName4);
 80   if (numberOfDaughters > 4) daughters_name[4] << 
 81                                                << 
 82   if (rbranch < 0.)                            << 
 83     rbranch = 0.0;                             << 
 84   else if (rbranch > 1.0)                      << 
 85     rbranch = 1.0;                             << 
 86 }                                                 109 }
 87                                                   110 
 88 G4VDecayChannel::G4VDecayChannel(const G4VDeca << 111 
                                                   >> 112 
                                                   >> 113 G4VDecayChannel::G4VDecayChannel(const G4VDecayChannel &right)
 89 {                                                 114 {
 90   kinematics_name = right.kinematics_name;        115   kinematics_name = right.kinematics_name;
 91   verboseLevel = right.verboseLevel;              116   verboseLevel = right.verboseLevel;
 92   rbranch = right.rbranch;                        117   rbranch = right.rbranch;
 93   rangeMass = right.rangeMass;                 << 
 94                                                   118 
 95   // copy parent name                             119   // copy parent name
 96   parent_name = new G4String(*right.parent_nam    120   parent_name = new G4String(*right.parent_name);
                                                   >> 121   parent = 0;
                                                   >> 122   parent_mass = 0.0; 
 97                                                   123 
 98   // create array                              << 124   //create array
 99   numberOfDaughters = right.numberOfDaughters;    125   numberOfDaughters = right.numberOfDaughters;
100                                                   126 
101   daughters_name = nullptr;                    << 127   daughters_name =0;
102   if (numberOfDaughters > 0) {                 << 128   if ( numberOfDaughters >0 ) {
103     daughters_name = new G4String*[numberOfDau    129     daughters_name = new G4String*[numberOfDaughters];
104     // copy daughters name                     << 130     //copy daughters name
105     for (G4int index = 0; index < numberOfDaug << 131     for (G4int index=0; index < numberOfDaughters; index++)
106       daughters_name[index] = new G4String(*ri << 132       {
107     }                                          << 133   daughters_name[index] = new G4String(*right.daughters_name[index]);
                                                   >> 134       }
108   }                                               135   }
109                                                   136 
                                                   >> 137   //
                                                   >> 138   daughters_mass = 0;
                                                   >> 139   daughters = 0;
                                                   >> 140 
110   // particle table                               141   // particle table
111   particletable = G4ParticleTable::GetParticle    142   particletable = G4ParticleTable::GetParticleTable();
112                                                << 
113   parent_polarization = right.parent_polarizat << 
114                                                << 
115   G4MUTEXINIT(daughtersMutex);                 << 
116   G4MUTEXINIT(parentMutex);                    << 
117 }                                                 143 }
118                                                   144 
119 G4VDecayChannel& G4VDecayChannel::operator=(co << 145 G4VDecayChannel & G4VDecayChannel::operator=(const G4VDecayChannel &right)
120 {                                                 146 {
121   if (this != &right) {                        << 147   if (this != &right) { 
122     kinematics_name = right.kinematics_name;      148     kinematics_name = right.kinematics_name;
123     verboseLevel = right.verboseLevel;            149     verboseLevel = right.verboseLevel;
124     rbranch = right.rbranch;                      150     rbranch = right.rbranch;
125     rangeMass = right.rangeMass;               << 151 
126     parent_polarization = right.parent_polariz << 
127     // copy parent name                           152     // copy parent name
128     delete parent_name;                        << 
129     parent_name = new G4String(*right.parent_n    153     parent_name = new G4String(*right.parent_name);
130                                                   154 
131     // clear daughters_name array                 155     // clear daughters_name array
132     ClearDaughtersName();                         156     ClearDaughtersName();
133                                                   157 
134     // recreate array                             158     // recreate array
135     numberOfDaughters = right.numberOfDaughter    159     numberOfDaughters = right.numberOfDaughters;
136     if (numberOfDaughters > 0) {               << 160     if ( numberOfDaughters >0 ) {
                                                   >> 161       if (daughters_name !=0) ClearDaughtersName();
137       daughters_name = new G4String*[numberOfD    162       daughters_name = new G4String*[numberOfDaughters];
138       // copy daughters name                   << 163       //copy daughters name
139       for (G4int index = 0; index < numberOfDa << 164       for (G4int index=0; index < numberOfDaughters; index++) {
140         daughters_name[index] = new G4String(* << 165     daughters_name[index] = new G4String(*right.daughters_name[index]);
141       }                                           166       }
142     }                                             167     }
143   }                                               168   }
144                                                   169 
                                                   >> 170   //
                                                   >> 171   parent = 0;
                                                   >> 172   daughters = 0;
                                                   >> 173   parent_mass = 0.0;
                                                   >> 174   daughters_mass = 0;
                                                   >> 175 
145   // particle table                               176   // particle table
146   particletable = G4ParticleTable::GetParticle    177   particletable = G4ParticleTable::GetParticleTable();
147                                                   178 
148   G4MUTEXINIT(daughtersMutex);                 << 
149   G4MUTEXINIT(parentMutex);                    << 
150                                                << 
151   return *this;                                   179   return *this;
152 }                                                 180 }
153                                                   181 
                                                   >> 182 
154 G4VDecayChannel::~G4VDecayChannel()               183 G4VDecayChannel::~G4VDecayChannel()
155 {                                                 184 {
156   ClearDaughtersName();                           185   ClearDaughtersName();
157   delete parent_name;                          << 186   if (parent_name != 0) delete parent_name;
158   parent_name = nullptr;                       << 187   parent_name = 0;
159   delete[] G4MT_daughters_mass;                << 188   if (daughters_mass != 0) delete [] daughters_mass;
160   G4MT_daughters_mass = nullptr;               << 189   daughters_mass =0;
161   delete[] G4MT_daughters_width;               << 190 } 
162   G4MT_daughters_width = nullptr;              << 
163   G4MUTEXDESTROY(daughtersMutex);              << 
164   G4MUTEXDESTROY(parentMutex);                 << 
165 }                                              << 
166                                                   191 
167 void G4VDecayChannel::ClearDaughtersName()        192 void G4VDecayChannel::ClearDaughtersName()
168 {                                                 193 {
169   G4AutoLock l(&daughtersMutex);               << 194   if ( daughters_name != 0) {
170   if (daughters_name != nullptr) {             << 195     if (numberOfDaughters>0) {
171     if (numberOfDaughters > 0) {               << 196 #ifdef G4VERBOSE
172 #ifdef G4VERBOSE                               << 197       if (verboseLevel>1) {
173       if (verboseLevel > 1) {                  << 198   G4cerr << "G4VDecayChannel::ClearDaughtersName "
174         G4cout << "G4VDecayChannel::ClearDaugh << 199          << " for " << *parent_name << G4endl;
175                << " for " << *parent_name << G << 
176       }                                           200       }
177 #endif                                            201 #endif
178       for (G4int index = 0; index < numberOfDa << 202       for (G4int index=0; index < numberOfDaughters; index++) { 
179         delete daughters_name[index];          << 203   if (daughters_name[index] != 0) delete daughters_name[index];
180       }                                           204       }
181     }                                             205     }
182     delete[] daughters_name;                   << 206     delete [] daughters_name;
183     daughters_name = nullptr;                  << 207     daughters_name = 0;
184   }                                               208   }
185                                                << 209   // 
186   delete[] G4MT_daughters;                     << 210   if (daughters != 0) delete [] daughters;
187   delete[] G4MT_daughters_mass;                << 211   if (daughters_mass != 0) delete [] daughters_mass;
188   delete[] G4MT_daughters_width;               << 212   daughters = 0;
189   G4MT_daughters_width = nullptr;              << 213   daughters_mass = 0;
190   G4MT_daughters = nullptr;                    << 
191   G4MT_daughters_mass = nullptr;               << 
192                                                   214 
193   numberOfDaughters = 0;                          215   numberOfDaughters = 0;
194 }                                                 216 }
195                                                   217 
196 void G4VDecayChannel::SetNumberOfDaughters(G4i    218 void G4VDecayChannel::SetNumberOfDaughters(G4int size)
197 {                                                 219 {
198   if (size > 0) {                              << 220   if (size >0) {
199     // remove old contents                        221     // remove old contents
200     ClearDaughtersName();                         222     ClearDaughtersName();
201     // cleate array                               223     // cleate array
202     daughters_name = new G4String*[size];         224     daughters_name = new G4String*[size];
203     for (G4int index = 0; index < size; ++inde << 225     for (G4int index=0;index<size;index++) daughters_name[index]=0;
204       daughters_name[index] = nullptr;         << 
205     }                                          << 
206     numberOfDaughters = size;                     226     numberOfDaughters = size;
207   }                                               227   }
208 }                                                 228 }
209                                                   229 
210 void G4VDecayChannel::SetDaughter(G4int anInde << 230 void G4VDecayChannel::SetDaughter(G4int anIndex, 
                                                   >> 231          const G4String &particle_name)
211 {                                                 232 {
212   // check numberOfDaughters is positive          233   // check numberOfDaughters is positive
213   if (numberOfDaughters <= 0) {                << 234   if (numberOfDaughters<=0) {
214 #ifdef G4VERBOSE                                  235 #ifdef G4VERBOSE
215     if (verboseLevel > 0) {                    << 236     if (verboseLevel>0) {
216       G4cout << "G4VDecayChannel::SetDaughter( << 237       G4cerr << "G4VDecayChannel::SetDaughter: "
217              << "Number of daughters is not de    238              << "Number of daughters is not defined" << G4endl;
218     }                                             239     }
219 #endif                                            240 #endif
220     return;                                       241     return;
221   }                                               242   }
222                                                   243 
223   // An analysis of this code, shows that this << 244   // check existence of daughters_name array
224   // only in the constructor of derived classe << 245   if (daughters_name == 0) {
225   // The general idea of this method is probab << 246     // cleate array
226   // the possibility to re-define daughters on << 247     daughters_name = new G4String*[numberOfDaughters];
227   // this design is extremely problematic for  << 248     for (G4int index=0;index<numberOfDaughters;index++) {
228   // require (as practically happens) that the << 249       daughters_name[index]=0;
229   // at construction, i.e. when G4MT_daughters << 250     }
230   // moreover this method can be called only a << 
231   // has been called (see previous if), in suc << 
232   //                                           << 
233   if (daughters_name == nullptr) {             << 
234     G4Exception("G4VDecayChannel::SetDaughter( << 
235                 "Trying to add a daughter with << 
236     return;                                    << 
237   }                                            << 
238   if (G4MT_daughters != nullptr) {             << 
239     G4Exception("G4VDecayChannel::SetDaughter( << 
240                 "Trying to modify a daughter o << 
241                  but decay channel already has << 
242     return;                                    << 
243   }                                               251   }
244                                                   252 
245   // check an index                            << 253   // check an index    
246   if ((anIndex < 0) || (anIndex >= numberOfDau << 254   if ( (anIndex<0) || (anIndex>=numberOfDaughters) ) {
247 #ifdef G4VERBOSE                                  255 #ifdef G4VERBOSE
248     if (verboseLevel > 0) {                    << 256     if (verboseLevel>0) {
249       G4cout << "G4VDecayChannel::SetDaughter( << 257       G4cerr << "G4VDecayChannel::SetDaughter"
250              << "index out of range " << anInd    258              << "index out of range " << anIndex << G4endl;
251     }                                             259     }
252 #endif                                            260 #endif
253   }                                            << 261   } else {
254   else {                                       << 262     // delete the old name if it exists
                                                   >> 263     if (daughters_name[anIndex]!=0) delete daughters_name[anIndex];
255     // fill the name                              264     // fill the name
256     daughters_name[anIndex] = new G4String(par    265     daughters_name[anIndex] = new G4String(particle_name);
                                                   >> 266     // refill the array of daughters[] if it exists
                                                   >> 267     if (daughters != 0) FillDaughters();
257 #ifdef G4VERBOSE                                  268 #ifdef G4VERBOSE
258     if (verboseLevel > 1) {                    << 269     if (verboseLevel>1) {
259       G4cout << "G4VDecayChannel::SetDaughter[ << 270       G4cout << "G4VDecayChannel::SetDaughter[" << anIndex <<"] :";
260       G4cout << daughters_name[anIndex] << ":" << 271       G4cout << daughters_name[anIndex] << ":" << *daughters_name[anIndex]<<G4endl;
261     }                                             272     }
262 #endif                                            273 #endif
263   }                                               274   }
264 }                                                 275 }
265                                                   276 
266 void G4VDecayChannel::SetDaughter(G4int anInde << 277 void G4VDecayChannel::SetDaughter(G4int anIndex, const G4ParticleDefinition * parent_type)
267 {                                                 278 {
268   if (parent_type != nullptr) SetDaughter(anIn << 279   if (parent_type != 0) SetDaughter(anIndex, parent_type->GetParticleName());
269 }                                                 280 }
270                                                   281 
271 void G4VDecayChannel::FillDaughters()             282 void G4VDecayChannel::FillDaughters()
272 {                                                 283 {
273   G4AutoLock lock(&daughtersMutex);            << 
274                                                << 
275   // Double check, check again if another thre << 
276   // case do not need to do anything           << 
277   if (G4MT_daughters != nullptr) return;       << 
278                                                << 
279   G4int index;                                    284   G4int index;
280                                                << 285   
281 #ifdef G4VERBOSE                                  286 #ifdef G4VERBOSE
282   if (verboseLevel > 1) G4cout << "G4VDecayCha << 287   if (verboseLevel>1) G4cout << "G4VDecayChannel::FillDaughters()" <<G4endl;
283 #endif                                            288 #endif
284   if (G4MT_daughters != nullptr) {             << 289   if (daughters != 0) {
285     delete[] G4MT_daughters;                   << 290     delete [] daughters;
286     G4MT_daughters = nullptr;                  << 291     daughters = 0;
287   }                                               292   }
288                                                   293 
289   // parent mass                                  294   // parent mass
290   CheckAndFillParent();                        << 295   if (parent == 0) FillParent();  
291   G4double parentmass = G4MT_parent->GetPDGMas << 296   G4double parentmass = parent->GetPDGMass();
292                                                   297 
293   //                                              298   //
294   G4double sumofdaughtermass = 0.0;               299   G4double sumofdaughtermass = 0.0;
295   G4double sumofdaughterwidthsq = 0.0;         << 300   if ((numberOfDaughters <=0) || (daughters_name == 0) ){
296                                                << 
297   if ((numberOfDaughters <= 0) || (daughters_n << 
298 #ifdef G4VERBOSE                                  301 #ifdef G4VERBOSE
299     if (verboseLevel > 0) {                    << 302     if (verboseLevel>0) {
300       G4cout << "G4VDecayChannel::FillDaughter << 303       G4cerr << "G4VDecayChannel::FillDaughters   "
301              << "[ " << G4MT_parent->GetPartic << 304              << "[ " << parent->GetParticleName() << " ]"
302              << "numberOfDaughters is not defi    305              << "numberOfDaughters is not defined yet";
303     }                                             306     }
304 #endif                                            307 #endif
305     G4MT_daughters = nullptr;                  << 308     daughters = 0;
306     G4Exception("G4VDecayChannel::FillDaughter << 309     G4Exception("G4VDecayChannel::FillDaughters",
307                 "Cannot fill daughters: number << 310     "PART011", FatalException,
308   }                                            << 311     "Can not fill daughters: numberOfDaughters is not defined yet");    
309                                                << 312   } 
310   // create and set the array of pointers to d << 313 
311   G4MT_daughters = new G4ParticleDefinition*[n << 314   //create and set the array of pointers to daughter particles
312   delete[] G4MT_daughters_mass;                << 315   daughters = new G4ParticleDefinition*[numberOfDaughters];
313   delete[] G4MT_daughters_width;               << 316   if (daughters_mass != 0) delete [] daughters_mass;
314   G4MT_daughters_mass = new G4double[numberOfD << 317   daughters_mass = new G4double[numberOfDaughters];
315   G4MT_daughters_width = new G4double[numberOf << 
316   // loop over all daughters                      318   // loop over all daughters
317   for (index = 0; index < numberOfDaughters; + << 319   for (index=0; index < numberOfDaughters;  index++) { 
318     if (daughters_name[index] == nullptr) {    << 320     if (daughters_name[index] == 0) {
319       // daughter name is not defined             321       // daughter name is not defined
320 #ifdef G4VERBOSE                                  322 #ifdef G4VERBOSE
321       if (verboseLevel > 0) {                  << 323       if (verboseLevel>0) {
322         G4cout << "G4VDecayChannel::FillDaught << 324   G4cerr << "G4VDecayChannel::FillDaughters  "
323                << "[ " << G4MT_parent->GetPart << 325          << "[ " << parent->GetParticleName() << " ]"
324                << "-th daughter is not defined << 326          << index << "-th daughter is not defined yet" << G4endl;
325       }                                           327       }
326 #endif                                            328 #endif
327       G4MT_daughters[index] = nullptr;         << 329       daughters[index] = 0;
328       G4Exception("G4VDecayChannel::FillDaught << 330       G4Exception("G4VDecayChannel::FillDaughters",
329                   "Cannot fill daughters: name << 331       "PART011", FatalException,
330     }                                          << 332       "Can not fill daughters: name of a daughter is not defined yet");    
331     // search daughter particles in the partic << 333     } 
332     G4MT_daughters[index] = particletable->Fin << 334     //search daughter particles in the particle table 
333     if (G4MT_daughters[index] == nullptr) {    << 335     daughters[index] = particletable->FindParticle(*daughters_name[index]);
334       // cannot find the daughter particle     << 336     if (daughters[index] == 0) {
335 #ifdef G4VERBOSE                               << 337       // can not find the daughter particle
336       if (verboseLevel > 0) {                  << 338 #ifdef G4VERBOSE
337         G4cout << "G4VDecayChannel::FillDaught << 339       if (verboseLevel>0) {
338                << "[ " << G4MT_parent->GetPart << 340   G4cerr << "G4VDecayChannel::FillDaughters  "
339                << *daughters_name[index] << "  << 341           << "[ " << parent->GetParticleName() << " ]"
340         G4cout << " The BR of this decay mode  << 342                << index << ":" << *daughters_name[index]
                                                   >> 343          << " is not defined !!" << G4endl;
                                                   >> 344         G4cerr << " The BR of this decay mode is set to zero " << G4endl;
341       }                                           345       }
342 #endif                                            346 #endif
343       SetBR(0.0);                                 347       SetBR(0.0);
344       return;                                     348       return;
345     }                                             349     }
346 #ifdef G4VERBOSE                                  350 #ifdef G4VERBOSE
347     if (verboseLevel > 1) {                    << 351     if (verboseLevel>1) {
348       G4cout << index << ":" << *daughters_nam    352       G4cout << index << ":" << *daughters_name[index];
349       G4cout << ":" << G4MT_daughters[index] < << 353       G4cout << ":" << daughters[index] << G4endl;
350     }                                             354     }
351 #endif                                            355 #endif
352     G4MT_daughters_mass[index] = G4MT_daughter << 356     daughters_mass[index] = daughters[index]->GetPDGMass();
353     G4double d_width = G4MT_daughters[index]-> << 357     sumofdaughtermass += daughters[index]->GetPDGMass();
354     G4MT_daughters_width[index] = d_width;     << 
355     sumofdaughtermass += G4MT_daughters[index] << 
356     sumofdaughterwidthsq += d_width * d_width; << 
357   }  // end loop over all daughters               358   }  // end loop over all daughters
358                                                   359 
359   // check sum of daghter mass                    360   // check sum of daghter mass
360   G4double widthMass =                         << 361   G4double widthMass = parent->GetPDGWidth();
361     std::sqrt(G4MT_parent->GetPDGWidth() * G4M << 362   if ( (parent->GetParticleType() != "nucleus") &&
362   if ((G4MT_parent->GetParticleType() != "nucl << 363        (sumofdaughtermass > parentmass + 5*widthMass) ){
363       && (sumofdaughtermass > parentmass + ran << 364    // !!! illegal mass  !!!
364   {                                            << 365 #ifdef G4VERBOSE
365     // !!! illegal mass  !!!                   << 366    if (GetVerboseLevel()>0) {
366 #ifdef G4VERBOSE                               << 367      G4cerr << "G4VDecayChannel::FillDaughters "
367     if (GetVerboseLevel() > 0) {               << 368             << "[ " << parent->GetParticleName() << " ]"
368       G4cout << "G4VDecayChannel::FillDaughter << 369             << "    Energy/Momentum conserevation breaks " <<G4endl;
369              << "[ " << G4MT_parent->GetPartic << 370      if (GetVerboseLevel()>1) {
370              << "    Energy/Momentum consereva << 371        G4cerr << "    parent:" << *parent_name
371       if (GetVerboseLevel() > 1) {             << 372               << " mass:" << parentmass/GeV << "[GeV/c/c]" <<G4endl;
372         G4cout << "    parent:" << *parent_nam << 373        for (index=0; index < numberOfDaughters; index++){
373                << G4endl;                      << 374    G4cerr << "     daughter " << index << ":" << *daughters_name[index]
374         for (index = 0; index < numberOfDaught << 375           << " mass:" << daughters[index]->GetPDGMass()/GeV
375           G4cout << "     daughter " << index  << 376             << "[GeV/c/c]" <<G4endl;
376                  << " mass:" << G4MT_daughters << 377        }
377         }                                      << 378      }
378       }                                        << 379    }
379     }                                          << 
380 #endif                                            380 #endif
381   }                                            << 381  }
382 }                                                 382 }
383                                                   383 
                                                   >> 384 
384 void G4VDecayChannel::FillParent()                385 void G4VDecayChannel::FillParent()
385 {                                                 386 {
386   G4AutoLock lock(&parentMutex);               << 387   if (parent_name == 0) {
387                                                << 
388   // Double check, check again if another thre << 
389   // case do not need to do anything           << 
390   if (G4MT_parent != nullptr) return;          << 
391                                                << 
392   if (parent_name == nullptr) {                << 
393     // parent name is not defined                 388     // parent name is not defined
394 #ifdef G4VERBOSE                                  389 #ifdef G4VERBOSE
395     if (verboseLevel > 0) {                    << 390     if (verboseLevel>0) {
396       G4cout << "G4VDecayChannel::FillParent() << 391       G4cerr << "G4VDecayChannel::FillParent   "
397              << "parent name is not defined !! << 392              << ": parent name is not defined !!" << G4endl;
398     }                                             393     }
399 #endif                                            394 #endif
400     G4MT_parent = nullptr;                     << 395     parent = 0;
401     G4Exception("G4VDecayChannel::FillParent() << 396     G4Exception("G4VDecayChannel::FillParent()",
402                 "Cannot fill parent: parent na << 397     "PART012", FatalException,
403     return;                                    << 398     "Can not fill parent: parent name is not defined yet");    
404   }                                               399   }
405                                                << 
406   // search parent particle in the particle ta    400   // search parent particle in the particle table
407   G4MT_parent = particletable->FindParticle(*p << 401   parent = particletable->FindParticle(*parent_name);
408   if (G4MT_parent == nullptr) {                << 402   if (parent == 0) {
409     // parent particle does not exist             403     // parent particle does not exist
410 #ifdef G4VERBOSE                                  404 #ifdef G4VERBOSE
411     if (verboseLevel > 0) {                    << 405     if (verboseLevel>0) {
412       G4cout << "G4VDecayChannel::FillParent() << 406       G4cerr << "G4VDecayChannel::FillParent   "
413              << G4endl;                        << 407              << *parent_name << " does not exist !!" << G4endl;
414     }                                             408     }
415 #endif                                            409 #endif
416     G4Exception("G4VDecayChannel::FillParent() << 410     G4Exception("G4VDecayChannel::FillParent()",
417                 "Cannot fill parent: parent do << 411     "PART012", FatalException,
418     return;                                    << 412     "Can not fill parent: parent does not exist");    
419   }                                               413   }
420   G4MT_parent_mass = G4MT_parent->GetPDGMass() << 414   parent_mass = parent->GetPDGMass();
421 }                                                 415 }
422                                                   416 
423 void G4VDecayChannel::SetParent(const G4Partic << 417 void G4VDecayChannel::SetParent(const G4ParticleDefinition * parent_type)
424 {                                                 418 {
425   if (parent_type != nullptr) SetParent(parent << 419   if (parent_type != 0) SetParent(parent_type->GetParticleName());
426 }                                                 420 }
427                                                   421 
428 G4int G4VDecayChannel::GetAngularMomentum()       422 G4int G4VDecayChannel::GetAngularMomentum()
429 {                                                 423 {
430   // determine angular momentum                   424   // determine angular momentum
431                                                   425 
432   // fill pointers to daughter particles if no << 426   // fill pointers to daughter particles if not yet set  
433   CheckAndFillDaughters();                     << 427   if (daughters == 0) FillDaughters();
434                                                   428 
435   const G4int PiSpin = G4MT_parent->GetPDGiSpi << 429   const G4int PiSpin = parent->GetPDGiSpin();
436   const G4int PParity = G4MT_parent->GetPDGiPa << 430   const G4int PParity = parent->GetPDGiParity();
437   if (2 == numberOfDaughters)  // up to now we << 431   if (2==numberOfDaughters) {     // up to now we can only handle two particle decays
438   {                                            << 432     const G4int D1iSpin  = daughters[0]->GetPDGiSpin();
439     const G4int D1iSpin = G4MT_daughters[0]->G << 433     const G4int D1Parity = daughters[0]->GetPDGiParity();
440     const G4int D1Parity = G4MT_daughters[0]-> << 434     const G4int D2iSpin  = daughters[1]->GetPDGiSpin();
441     const G4int D2iSpin = G4MT_daughters[1]->G << 435     const G4int D2Parity = daughters[1]->GetPDGiParity();
442     const G4int D2Parity = G4MT_daughters[1]-> << 436     const G4int MiniSpin = std::abs (D1iSpin - D2iSpin);
443     const G4int MiniSpin = std::abs(D1iSpin -  << 
444     const G4int MaxiSpin = D1iSpin + D2iSpin;     437     const G4int MaxiSpin = D1iSpin + D2iSpin;
445     const G4int lMax = (PiSpin + D1iSpin + D2i << 438     const G4int lMax = (PiSpin+D1iSpin+D2iSpin)/2; // l is allways int
446     G4int lMin;                                   439     G4int lMin;
447 #ifdef G4VERBOSE                                  440 #ifdef G4VERBOSE
448     if (verboseLevel > 1) {                    << 441     if (verboseLevel>1) {
449       G4cout << "iSpin: " << PiSpin << " -> "     442       G4cout << "iSpin: " << PiSpin << " -> " << D1iSpin << " + " << D2iSpin << G4endl;
450       G4cout << "2*jmin, 2*jmax, lmax " << Min    443       G4cout << "2*jmin, 2*jmax, lmax " << MiniSpin << " " << MaxiSpin << " " << lMax << G4endl;
451     }                                             444     }
452 #endif                                            445 #endif
453     for (G4int j = MiniSpin; j <= MaxiSpin; j  << 446     for (G4int j=MiniSpin; j<=MaxiSpin; j+=2){    // loop over all possible spin couplings
454     {  // spin couplings                       << 447       lMin = std::abs(PiSpin-j)/2;
455       lMin = std::abs(PiSpin - j) / 2;         << 448 #ifdef G4VERBOSE 
456 #ifdef G4VERBOSE                               << 449       if (verboseLevel>1)
457       if (verboseLevel > 1) G4cout << "-> chec << 450   G4cout << "-> checking 2*j=" << j << G4endl;
458 #endif                                         << 451 #endif
459       for (G4int l = lMin; l <= lMax; ++l) {   << 452       for (G4int l=lMin; l<=lMax; l++) {
460 #ifdef G4VERBOSE                               << 453 #ifdef G4VERBOSE
461         if (verboseLevel > 1) G4cout << " chec << 454   if (verboseLevel>1)
462 #endif                                         << 455     G4cout << " checking l=" << l << G4endl;
463         if (l % 2 == 0) {                      << 456 #endif
464           if (PParity == D1Parity * D2Parity)  << 457         if (l%2==0) {
465             return l;                          << 458     if (PParity == D1Parity*D2Parity) {    // check parity for this l
466         }                                      << 459       return l;
467         else {                                 << 460           } 
468           if (PParity == -1 * D1Parity * D2Par << 461   } else {
                                                   >> 462     if (PParity == -1*D1Parity*D2Parity) {    // check parity for this l
469             return l;                             463             return l;
                                                   >> 464           }
470         }                                         465         }
471       }                                           466       }
472     }                                             467     }
473   }                                            << 468   } else {
474   else {                                       << 469     G4Exception("G4VDecayChannel::GetAngularMomentum",
475     G4Exception("G4VDecayChannel::GetAngularMo << 470     "PART111", JustWarning,
476                 "Sorry, can't handle 3 particl << 471     "Sorry, can't handle 3 particle decays (up to now)");
477     return 0;                                     472     return 0;
478   }                                               473   }
479   G4Exception("G4VDecayChannel::GetAngularMome << 474   G4Exception ("G4VDecayChannel::GetAngularMomentum",
480               "Can't find angular momentum for << 475     "PART111", JustWarning,
                                                   >> 476     "Can't find angular momentum for this decay");
481   return 0;                                       477   return 0;
482 }                                                 478 }
483                                                   479 
484 void G4VDecayChannel::DumpInfo()                  480 void G4VDecayChannel::DumpInfo()
485 {                                                 481 {
486   G4cout << " BR:  " << rbranch << "  [" << ki    482   G4cout << " BR:  " << rbranch << "  [" << kinematics_name << "]";
487   G4cout << "   :  ";                          << 483   G4cout << "   :  " ;
488   for (G4int index = 0; index < numberOfDaught << 484   for (G4int index=0; index < numberOfDaughters; index++)
489     if (daughters_name[index] != nullptr) {    << 485   {
                                                   >> 486     if(daughters_name[index] != 0) {
490       G4cout << " " << *(daughters_name[index]    487       G4cout << " " << *(daughters_name[index]);
491     }                                          << 488     } else {
492     else {                                     << 
493       G4cout << " not defined ";                  489       G4cout << " not defined ";
494     }                                             490     }
495   }                                               491   }
496   G4cout << G4endl;                               492   G4cout << G4endl;
497 }                                                 493 }
498                                                   494 
499 const G4String& G4VDecayChannel::GetNoName() c    495 const G4String& G4VDecayChannel::GetNoName() const
500 {                                                 496 {
501   return noName;                                  497   return noName;
502 }                                              << 
503                                                << 
504 G4double G4VDecayChannel::DynamicalMass(G4doub << 
505 {                                              << 
506   if (width <= 0.0) return massPDG;            << 
507   if (maxDev > rangeMass) maxDev = rangeMass;  << 
508   if (maxDev <= -1. * rangeMass) return massPD << 
509                                                << 
510   G4double x = G4UniformRand() * (maxDev + ran << 
511   G4double y = G4UniformRand();                << 
512   const std::size_t MAX_LOOP = 10000;          << 
513   for (std::size_t loop_counter = 0; loop_coun << 
514     if (y * (width * width * x * x + massPDG * << 
515         <= massPDG * massPDG * width * width)  << 
516       break;                                   << 
517     x = G4UniformRand() * (maxDev + rangeMass) << 
518     y = G4UniformRand();                       << 
519   }                                            << 
520   G4double mass = massPDG + x * width;         << 
521   return mass;                                 << 
522 }                                              << 
523                                                << 
524 G4bool G4VDecayChannel::IsOKWithParentMass(G4d << 
525 {                                              << 
526   G4double sumOfDaughterMassMin = 0.0;         << 
527   CheckAndFillParent();                        << 
528   CheckAndFillDaughters();                     << 
529   // skip one body decay                       << 
530   if (numberOfDaughters == 1) return true;     << 
531                                                << 
532   for (G4int index = 0; index < numberOfDaught << 
533     sumOfDaughterMassMin += G4MT_daughters_mas << 
534   }                                            << 
535   return (parentMass >= sumOfDaughterMassMin); << 
536 }                                              << 
537                                                << 
538 void G4VDecayChannel::SetBR(G4double value)    << 
539 {                                              << 
540   rbranch = value;                             << 
541   if (rbranch < 0.)                            << 
542     rbranch = 0.0;                             << 
543   else if (rbranch > 1.0)                      << 
544     rbranch = 1.0;                             << 
545 }                                                 498 }
546                                                   499