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

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

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

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