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 10.1.p3)


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