source: trunk/source/track/src/G4ParticleChangeForGamma.cc @ 1331

Last change on this file since 1331 was 1058, checked in by garnier, 15 years ago

file release beta

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