Geant4  10.00.p01
G4ITReactionChange.cc
Go to the documentation of this file.
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: G4ITReactionChange.cc 64057 2012-10-30 15:04:49Z gcosmo $
27 //
28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29 //
30 // History:
31 // -----------
32 // 10 Oct 2011 M.Karamitros created
33 //
34 // -------------------------------------------------------------------
35 
36 #include "G4ITReactionChange.hh"
37 
39  fSecondaries(0),
40  fNumberOfSecondaries(0),
41  fKillParents(false),
42  fParticleChangeIsSet(false)
43 {
44  //ctor
45 }
46 
48 {
49  //dtor
50  delete fSecondaries;
51  fSecondaries = 0 ;
52 }
53 
54 // Should not be used
56  fSecondaries(0),
57  fNumberOfSecondaries(0),
58  fKillParents(false),
59  fParticleChangeIsSet(false)
60 {
61  //copy ctor
62 }
63 
64 // should not be used
66 {
67  if (this == &rhs) return *this; // handle self assignment
68  //assignment operator
69  return *this;
70 }
71 
73  const G4Track& trackB,
74  G4VParticleChange* particleChangeA,
75  G4VParticleChange* particleChangeB
76  )
77 {
78  fParticleChange.clear();
79  fParticleChange[&trackA] = particleChangeA;
80  fParticleChange[&trackB] = particleChangeB;
81 
82  if(particleChangeA || particleChangeB)
83  {
84  G4bool test = particleChangeA && particleChangeB ;
85 
86  if(test == false)
87  {
88  G4ExceptionDescription exceptionDescription ;
89  exceptionDescription << "If you give for one track a particleChange, ";
90  exceptionDescription << "G4ITReactionChange is expecting that you give for both ";
91  exceptionDescription << "reacting tracks a particleChange.";
92  G4Exception("G4ITReactionChange::Initialize","ITReactionChange001",
93  FatalErrorInArgument,exceptionDescription);
94  }
95 
96  fParticleChangeIsSet = true;
97 
98  fParticleChange[&trackA]->Initialize(trackA);
99  fParticleChange[&trackB]->Initialize(trackB);;
100 
101  }
102 
103  fSecondaries = 0;
105  fKillParents = false;
106 }
107 
109 {
111 
112  // add a secondary after size check
114  {
117  }
118  else
119  {
120  G4cerr << "G4ITReactionChange::AddSecondary() Warning ";
121  G4cerr << "fSecondaries is full !! " << G4endl;
122  G4cerr << " The object will not be added in fSecondaries" << G4endl;
123  }
124 }
125 
127 {
128  fParticleChange[stepA->GetTrack()]->UpdateStepForPostStep(stepA);
129  fParticleChange[stepB->GetTrack()]->UpdateStepForPostStep(stepB);
130 }
131 
133 {
134  std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange.find(track);
135 
136  if(it == fParticleChange.end()) return 0;
137  else return it ->second;
138 }
139 
141 {
142  std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange.begin();
143  if(it != fParticleChange.end())
144  {
145  return it->first;
146  }
147 
148  G4ExceptionDescription exceptionDescription ;
149  exceptionDescription << "No track A found ! Have you initialized the ReactionChange ?";
150  G4Exception("G4ITReactionChange::GetTrackA","ITReactionChange001",
151  FatalErrorInArgument,exceptionDescription);
152  return 0;
153 }
154 
156 {
157  std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange.begin();
158  std::map<const G4Track*, G4VParticleChange*>::iterator next = it++;
159  if(next == fParticleChange.end())
160  {
161  G4ExceptionDescription exceptionDescription ;
162  exceptionDescription << "No track B found ! Have you initialized the ReactionChange ?";
163  G4Exception("G4ITReactionChange::GetTrackB","ITReactionChange002",
164  FatalErrorInArgument,exceptionDescription);
165  }
166 
167  return it->first;
168 }
void SetElement(G4int anIndex, Type *anElement)
Definition: G4FastVector.hh:76
Similar to G4ParticleChange, but deal with two tracks rather than one.
const G4Track * GetTrackA()
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4ITReactionChange()
Default constructor.
G4VParticleChange * GetParticleChange(const G4Track *)
G4ITReactionChange & operator=(const G4ITReactionChange &other)
Assignment operator.
void UpdateStepInfo(G4Step *, G4Step *)
void Initialize(const G4Track &, const G4Track &, G4VParticleChange *particleChangeA=0, G4VParticleChange *particleChangeB=0)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
const G4Track * GetTrackB()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::map< const G4Track *, G4VParticleChange * > fParticleChange
G4FastVector< G4Track, G4TrackFastVectorSize > G4TrackFastVector
virtual ~G4ITReactionChange()
Default destructor.
#define G4endl
Definition: G4ios.hh:61
const G4int G4TrackFastVectorSize
G4TrackFastVector * fSecondaries
G4Track * GetTrack() const
void AddSecondary(G4Track *aSecondary)
G4GLOB_DLL std::ostream G4cerr