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 1.0)


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