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

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

update ti head

File size: 5.8 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.4 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//   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()
50 : G4VParticleChange(), currentTrack(0), proposedKinEnergy(0.)
51{
52  theSteppingControlFlag = NormalCondition;
53  debugFlag = false;
54#ifdef G4VERBOSE
55  if (verboseLevel>2) {
56    G4cout << "G4ParticleChangeForGamma::G4ParticleChangeForGamma() " << G4endl;
57  }
58#endif
59}
60
61G4ParticleChangeForGamma::~G4ParticleChangeForGamma()
62{
63#ifdef G4VERBOSE
64  if (verboseLevel>2) {
65    G4cout << "G4ParticleChangeForGamma::~G4ParticleChangeForGamma() " << G4endl;
66  }
67#endif
68}
69
70G4ParticleChangeForGamma::G4ParticleChangeForGamma(
71             const G4ParticleChangeForGamma &right): G4VParticleChange(right)
72{
73  if (verboseLevel>1) 
74    G4cout << "G4ParticleChangeForGamma::  copy constructor is called " << G4endl;
75 
76  currentTrack = right.currentTrack;
77  proposedKinEnergy = right.proposedKinEnergy;
78  proposedMomentumDirection = right.proposedMomentumDirection;
79  proposedPolarization = right.proposedPolarization;
80}
81
82// assignment operator
83G4ParticleChangeForGamma & G4ParticleChangeForGamma::operator=(
84                           const G4ParticleChangeForGamma &right)
85{
86  if (verboseLevel>1) 
87    G4cout << "G4ParticleChangeForGamma:: assignment operator is called " << G4endl;
88 
89  if (this != &right) {
90    theListOfSecondaries = right.theListOfSecondaries;
91    theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries;
92    theNumberOfSecondaries = right.theNumberOfSecondaries;
93    theStatusChange = right.theStatusChange;
94    theLocalEnergyDeposit = right.theLocalEnergyDeposit;
95    theSteppingControlFlag = right.theSteppingControlFlag;
96    theParentWeight = right.theParentWeight;
97
98    currentTrack = right.currentTrack;
99    proposedKinEnergy = right.proposedKinEnergy;
100    proposedMomentumDirection = right.proposedMomentumDirection;
101    proposedPolarization = right.proposedPolarization;
102  }
103  return *this;
104}
105
106//----------------------------------------------------------------
107// methods for printing messages
108//
109
110void G4ParticleChangeForGamma::DumpInfo() const
111{
112// use base-class DumpInfo
113  G4VParticleChange::DumpInfo();
114
115  G4int oldprc = G4cout.precision(3);
116  G4cout << "        Kinetic Energy (MeV): "
117       << std::setw(20) << proposedKinEnergy/MeV
118       << G4endl;
119  G4cout << "        Momentum Direction: "
120       << std::setw(20) << proposedMomentumDirection
121       << G4endl;
122  G4cout << "        Polarization: "
123       << std::setw(20) << proposedPolarization
124       << G4endl;
125  G4cout.precision(oldprc);
126}
127
128G4bool G4ParticleChangeForGamma::CheckIt(const G4Track& aTrack)
129{
130  G4bool    itsOK = true;
131  G4bool    exitWithError = false;
132
133  G4double  accuracy;
134
135  // Energy should not be lager than initial value
136  accuracy = ( proposedKinEnergy - aTrack.GetKineticEnergy())/MeV;
137  if (accuracy > accuracyForWarning) {
138#ifdef G4VERBOSE
139    G4cout << "G4ParticleChangeForGamma::CheckIt: ";
140    G4cout << "KinEnergy become larger than the initial value!" << G4endl;
141    G4cout << "  Difference:  " << accuracy  << "[MeV] " <<G4endl;
142#endif
143    itsOK = false;
144    if (accuracy > accuracyForException) exitWithError = true;
145  }
146
147  // dump out information of this particle change
148#ifdef G4VERBOSE
149  if (!itsOK) {
150    G4cout << "G4ParticleChangeForGamma::CheckIt " << G4endl;
151    DumpInfo();
152  }
153#endif
154
155  // Exit with error
156  if (exitWithError) {
157    G4Exception("G4ParticleChangeForGamma::CheckIt",
158                "400",
159                EventMustBeAborted,
160                "energy was  illegal");
161  }
162
163  //correction
164  if (!itsOK) {
165    proposedKinEnergy = aTrack.GetKineticEnergy();
166  }
167
168  itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
169  return itsOK;
170}
Note: See TracBrowser for help on using the repository browser.