source: trunk/source/processes/decay/src/G4UnknownDecay.cc @ 846

Last change on this file since 846 was 819, checked in by garnier, 16 years ago

import all except CVS

File size: 6.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4UnknownDecay.cc,v 1.5 2007/10/06 07:01:09 kurasige Exp $
28// GEANT4 tag $Name: geant4-09-01-patch-02 $
29//
30//
31// --------------------------------------------------------------
32//      GEANT 4 class implementation file
33//
34// ------------------------------------------------------------
35//
36
37#include "G4UnknownDecay.hh"
38#include "G4DynamicParticle.hh"
39#include "G4DecayProducts.hh"
40#include "G4PhysicsLogVector.hh"
41#include "G4ParticleChangeForDecay.hh"
42
43// constructor
44G4UnknownDecay::G4UnknownDecay(const G4String& processName)
45                               :G4VDiscreteProcess(processName, fDecay),
46                                verboseLevel(1),
47                                HighestValue(20.0)
48{
49#ifdef G4VERBOSE
50  if (GetVerboseLevel()>1) {
51    G4cout << "G4UnknownDecay  constructor " << "  Name:" << processName << G4endl;
52  }
53#endif
54  pParticleChange = &fParticleChangeForDecay;
55}
56
57G4UnknownDecay::~G4UnknownDecay()
58{
59}
60
61G4bool G4UnknownDecay::IsApplicable(const G4ParticleDefinition& aParticleType)
62{
63  if(aParticleType.GetParticleName()=="unknown") return true;
64  return false;
65}
66
67G4double G4UnknownDecay::GetMeanFreePath(const G4Track& /*aTrack*/,G4double, G4ForceCondition*)
68{
69   return  DBL_MIN;
70}
71
72void G4UnknownDecay::BuildPhysicsTable(const G4ParticleDefinition&)
73{
74  return;
75}
76
77G4VParticleChange* G4UnknownDecay::DecayIt(const G4Track& aTrack, const G4Step& )
78{
79  // The DecayIt() method returns by pointer a particle-change object.
80  // Units are expressed in GEANT4 internal units.
81
82  //   Initialize ParticleChange
83  //     all members of G4VParticleChange are set to equal to
84  //     corresponding member in G4Track
85  fParticleChangeForDecay.Initialize(aTrack);
86
87  // get particle
88  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
89
90  //check if thePreAssignedDecayProducts exists
91  const G4DecayProducts* o_products = (aParticle->GetPreAssignedDecayProducts());
92  G4bool isPreAssigned = (o_products != 0);   
93  G4DecayProducts* products = 0;
94
95  if (!isPreAssigned ){
96    fParticleChangeForDecay.SetNumberOfSecondaries(0);
97    // Kill the parent particle
98    fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
99    fParticleChangeForDecay.ProposeLocalEnergyDeposit(0.0); 
100   
101    ClearNumberOfInteractionLengthLeft();
102    return &fParticleChangeForDecay ;
103  }
104
105  // copy decay products
106  products = new G4DecayProducts(*o_products); 
107 
108  // get parent particle information ...................................
109  G4double   ParentEnergy  = aParticle->GetTotalEnergy();
110  G4double   ParentMass    = aParticle->GetMass();
111  if (ParentEnergy < ParentMass) {
112    ParentEnergy = ParentMass;
113#ifdef G4VERBOSE
114    if (GetVerboseLevel()>1) {
115      G4cout << "G4UnknownDecay::DoIt  : Total Energy is less than its mass" << G4endl;
116      G4cout << " Particle: " << aParticle->GetDefinition()->GetParticleName();
117      G4cout << " Energy:"    << ParentEnergy/MeV << "[MeV]";
118      G4cout << " Mass:"    << ParentMass/MeV << "[MeV]";
119      G4cout << G4endl;
120    }
121#endif
122  }
123  G4ThreeVector ParentDirection(aParticle->GetMomentumDirection());
124
125  G4double energyDeposit = 0.0;
126  G4double finalGlobalTime = aTrack.GetGlobalTime();
127  //boost all decay products to laboratory frame
128  //if the particle has traveled
129  if(aParticle->GetPreAssignedDecayProperTime()>0.) {
130    products->Boost( ParentEnergy, ParentDirection);
131  }
132
133  //add products in fParticleChangeForDecay
134  G4int numberOfSecondaries = products->entries();
135  fParticleChangeForDecay.SetNumberOfSecondaries(numberOfSecondaries);
136#ifdef G4VERBOSE
137  if (GetVerboseLevel()>1) {
138    G4cout << "G4UnknownDecay::DoIt  : Decay vertex :";
139    G4cout << " Time: " << finalGlobalTime/ns << "[ns]";
140    G4cout << " X:" << (aTrack.GetPosition()).x() /cm << "[cm]";
141    G4cout << " Y:" << (aTrack.GetPosition()).y() /cm << "[cm]";
142    G4cout << " Z:" << (aTrack.GetPosition()).z() /cm << "[cm]";
143    G4cout << G4endl;
144    G4cout << "G4UnknownDecay::DoIt  : decay products in Lab. Frame" << G4endl;
145    products->DumpInfo();
146  }
147#endif
148  G4int index;
149  G4ThreeVector currentPosition;
150  const G4TouchableHandle thand = aTrack.GetTouchableHandle();
151  for (index=0; index < numberOfSecondaries; index++)
152  {
153     // get current position of the track
154     currentPosition = aTrack.GetPosition();
155     // create a new track object
156     G4Track* secondary = new G4Track( products->PopProducts(),
157                                      finalGlobalTime ,
158                                      currentPosition );
159     // switch on good for tracking flag
160     secondary->SetGoodForTrackingFlag();
161     secondary->SetTouchableHandle(thand);
162     // add the secondary track in the List
163     fParticleChangeForDecay.AddSecondary(secondary);
164  }
165  delete products;
166
167  // Kill the parent particle
168  fParticleChangeForDecay.ProposeTrackStatus( fStopAndKill ) ;
169  fParticleChangeForDecay.ProposeLocalEnergyDeposit(energyDeposit); 
170  fParticleChangeForDecay.ProposeGlobalTime( finalGlobalTime );
171  // reset NumberOfInteractionLengthLeft
172  ClearNumberOfInteractionLengthLeft();
173
174  return &fParticleChangeForDecay ;
175} 
176
177
178
179
180
181
Note: See TracBrowser for help on using the repository browser.