source: trunk/source/processes/hadronic/models/cascade/cascade/src/G4CascadParticle.cc @ 1340

Last change on this file since 1340 was 1340, checked in by garnier, 14 years ago

update ti head

File size: 4.0 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// $Id: G4CascadParticle.cc,v 1.18 2010/10/20 14:34:26 mkelsey Exp $
27// Geant4 tag: $Name: hadr-casc-V09-03-85 $
28//
29// 20100112  M. Kelsey -- Remove G4CascadeMomentum, use G4LorentzVector directly
30// 20100114  M. Kelsey -- Replace vector<G4Double> position with G4ThreeVector
31// 20101012  M. Kelsey -- Check for negative d2 in getPathToTheNextZone()
32
33#include "G4CascadParticle.hh"
34#include "G4ios.hh"
35#include <cmath>
36
37G4CascadParticle::G4CascadParticle()
38  : verboseLevel(0), current_zone(-1), current_path(-1.), movingIn(false),
39    reflectionCounter(0), reflected(false), generation(-1) {
40  if (verboseLevel > 3) {
41    G4cout << " >>> G4CascadParticle::G4CascadParticle" << G4endl;
42  }
43}
44
45G4double G4CascadParticle::getPathToTheNextZone(G4double rz_in, 
46                                                G4double rz_out) {
47  if (verboseLevel > 3) {
48    G4cout << " >>> G4CascadParticle::getPathToTheNextZone rz_in " << rz_in
49           << " rz_out " << rz_out << G4endl;
50  }
51
52  const G4LorentzVector& mom = getMomentum();
53
54  G4double path = -1.0;
55  G4double rp = mom.vect().dot(position);
56  G4double rr = position.mag2();
57  G4double pp = mom.vect().mag2();
58
59  G4double ra = rr - rp * rp / pp;
60  pp = std::sqrt(pp);
61  G4double ds;
62  G4double d2;
63
64  if (verboseLevel > 3) {
65    G4cout << " current_zone " << current_zone << " rr " << rr
66           << " rp " << rp << " pp " << pp << " ra " << ra << G4endl;
67  }
68
69  if (current_zone == 0 || rp > 0.0) {
70    d2 = rz_out * rz_out - ra;
71    if (d2 > 0.0) {
72      ds = 1.0;
73      movingIn = false;
74    } else {
75      d2 = rz_in * rz_in - ra;
76      ds = -1.0;
77      movingIn = true;
78    }
79  } else { 
80    d2 = rz_in * rz_in - ra;
81    if (d2 > 0.0) {
82      ds = -1.0;
83      movingIn = true;
84    } else {
85      d2 = rz_out * rz_out - ra;
86      ds = 1.0;
87      movingIn = false;
88    }
89  }
90
91  if (verboseLevel > 3) G4cout << " ds " << ds << " d2 " << d2 << G4endl;
92
93  path = ds * std::sqrt(d2) - rp / pp;
94
95  return path;   
96}
97
98void G4CascadParticle::propagateAlongThePath(G4double path) {
99  if (verboseLevel > 3) {
100    G4cout << " >>> G4CascadParticle::propagateAlongThePath" << G4endl;
101  }
102
103  position += getMomentum().vect().unit()*path;
104}
105
106void G4CascadParticle::print() const {
107  theParticle.printParticle();
108  G4cout << " zone " << current_zone << " current_path " << current_path
109         << " reflectionCounter " << reflectionCounter << G4endl
110         << " x " << position.x() << " y " << position.y()
111         << " z " << position.z() << G4endl;
112}
113
Note: See TracBrowser for help on using the repository browser.