source: trunk/source/track/src/G4ParticleChangeForLoss.cc @ 1358

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

update ti head

File size: 6.3 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: G4ParticleChangeForLoss.cc,v 1.18 2010/07/21 09:30:15 gcosmo Exp $
28// GEANT4 tag $Name: track-V09-03-09 $
29//
30//
31// --------------------------------------------------------------
32//      GEANT 4 class implementation file
33//
34// ------------------------------------------------------------
35//   Implemented for the new scheme                 23 Mar. 1998  H.Kurahige
36// --------------------------------------------------------------
37//
38//   Modified:
39//   16.01.04 V.Ivanchenko update for model variant of energy loss
40//   15.04.05 V.Ivanchenko inline update methods
41//   28.08.06 V.Ivanchenko Add access to current track and polarizaion
42//
43// ------------------------------------------------------------
44//
45#include "G4ParticleChangeForLoss.hh"
46#include "G4Track.hh"
47#include "G4Step.hh"
48#include "G4DynamicParticle.hh"
49#include "G4ExceptionSeverity.hh"
50
51G4ParticleChangeForLoss::G4ParticleChangeForLoss()
52  : G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.),
53    lowEnergyLimit(1.0*eV), currentCharge(0.)
54{
55  theSteppingControlFlag = NormalCondition;
56  debugFlag = false;
57#ifdef G4VERBOSE
58  if (verboseLevel>2) {
59    G4cout << "G4ParticleChangeForLoss::G4ParticleChangeForLoss() " << G4endl;
60  }
61#endif
62}
63
64G4ParticleChangeForLoss::~G4ParticleChangeForLoss()
65{
66#ifdef G4VERBOSE
67  if (verboseLevel>2) {
68    G4cout << "G4ParticleChangeForLoss::~G4ParticleChangeForLoss() " << G4endl;
69  }
70#endif
71}
72
73G4ParticleChangeForLoss::
74G4ParticleChangeForLoss(const G4ParticleChangeForLoss &right)
75  : G4VParticleChange(right)
76{
77  if (verboseLevel>1) {
78    G4cout << "G4ParticleChangeForLoss::  copy constructor is called " << G4endl;
79  }
80  currentTrack = right.currentTrack;
81  proposedKinEnergy = right.proposedKinEnergy;
82  lowEnergyLimit = right.lowEnergyLimit;
83  currentCharge = right.currentCharge;
84  proposedMomentumDirection = right.proposedMomentumDirection;
85}
86
87// assignment operator
88G4ParticleChangeForLoss & G4ParticleChangeForLoss::operator=(
89                                   const G4ParticleChangeForLoss &right)
90{
91  if (verboseLevel>1) {
92    G4cout << "G4ParticleChangeForLoss:: assignment operator is called " << G4endl;
93  }
94  if (this != &right) {
95    theListOfSecondaries = right.theListOfSecondaries;
96    theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
97    theNumberOfSecondaries = right.theNumberOfSecondaries;
98    theStatusChange = right.theStatusChange;
99    theLocalEnergyDeposit = right.theLocalEnergyDeposit;
100    theSteppingControlFlag = right.theSteppingControlFlag;
101    theParentWeight = right.theParentWeight;
102
103    currentTrack = right.currentTrack;
104    proposedKinEnergy = right.proposedKinEnergy;
105    currentCharge = right.currentCharge;
106    proposedMomentumDirection = right.proposedMomentumDirection;
107  }
108  return *this;
109}
110
111//----------------------------------------------------------------
112// methods for printing messages
113//
114
115void G4ParticleChangeForLoss::DumpInfo() const
116{
117// use base-class DumpInfo
118  G4VParticleChange::DumpInfo();
119
120  G4int oldprc = G4cout.precision(3);
121  G4cout << "        Charge (eplus)   : "
122       << std::setw(20) << currentCharge/eplus
123       << G4endl;
124  G4cout << "        Kinetic Energy (MeV): "
125       << std::setw(20) << proposedKinEnergy/MeV
126       << G4endl;
127  G4cout << "        Momentum Direct - x : "
128       << std::setw(20) << proposedMomentumDirection.x()
129       << G4endl;
130  G4cout << "        Momentum Direct - y : "
131       << std::setw(20) << proposedMomentumDirection.y()
132       << G4endl;
133  G4cout << "        Momentum Direct - z : "
134       << std::setw(20) << proposedMomentumDirection.z()
135       << G4endl;
136  G4cout.precision(oldprc);
137}
138
139G4bool G4ParticleChangeForLoss::CheckIt(const G4Track& aTrack)
140{
141  G4bool    itsOK = true;
142  G4bool    exitWithError = false;
143
144  G4double  accuracy;
145
146  // Energy should not be lager than initial value
147  accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
148  if (accuracy > accuracyForWarning) {
149#ifdef G4VERBOSE
150    G4cout << "G4ParticleChangeForLoss::CheckIt: ";
151    G4cout << "KinEnergy become larger than the initial value!" << G4endl;
152    G4cout << "  Difference:  " << accuracy  << "[MeV] " <<G4endl;
153#endif
154    itsOK = false;
155    if (accuracy > accuracyForException) exitWithError = true;
156  }
157
158  // dump out information of this particle change
159#ifdef G4VERBOSE
160  if (!itsOK) {
161    G4cout << "G4ParticleChangeForLoss::CheckIt " << G4endl;
162    DumpInfo();
163  }
164#endif
165
166  // Exit with error
167  if (exitWithError) {
168    G4Exception("G4ParticleChangeForLoss::CheckIt",
169                "400",
170                EventMustBeAborted,
171                "energy was  illegal");
172  }
173
174  //correction
175  if (!itsOK) {
176    proposedKinEnergy = aTrack.GetKineticEnergy();
177  }
178
179  itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
180  return itsOK;
181}
Note: See TracBrowser for help on using the repository browser.