Geant4-11
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//
27// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
28//
29// History:
30// -----------
31// 10 Oct 2011 M.Karamitros created
32//
33// -------------------------------------------------------------------
34
35#include "G4ITReactionChange.hh"
36
38 fSecondaries(0),
39 fNumberOfSecondaries(0),
40 fKillParents(false),
41 fParticleChangeIsSet(false)
42{
43 //ctor
44}
45
47{
48 //dtor
49 delete fSecondaries;
50 fSecondaries = 0;
51}
52
53// Should not be used
55 fSecondaries(0),
56 fNumberOfSecondaries(0),
57 fKillParents(false),
58 fParticleChangeIsSet(false)
59{
60 //copy ctor
61}
62
63// should not be used
65{
66 if (this == &rhs) return *this; // handle self assignment
67 //assignment operator
68 return *this;
69}
70
72 const G4Track& trackB,
73 G4VParticleChange* particleChangeA,
74 G4VParticleChange* particleChangeB)
75{
76 fParticleChange.clear();
77 fParticleChange[&trackA] = particleChangeA;
78 fParticleChange[&trackB] = particleChangeB;
79
80 if (particleChangeA || particleChangeB)
81 {
82 G4bool test = particleChangeA && particleChangeB;
83
84 if (test == false)
85 {
86 G4ExceptionDescription exceptionDescription;
87 exceptionDescription << "If you give for one track a particleChange, ";
88 exceptionDescription
89 << "G4ITReactionChange is expecting that you give for both ";
90 exceptionDescription << "reacting tracks a particleChange.";
91 G4Exception("G4ITReactionChange::Initialize", "ITReactionChange001",
92 FatalErrorInArgument, exceptionDescription);
93 }
94
96
97 fParticleChange[&trackA]->Initialize(trackA);
98 fParticleChange[&trackB]->Initialize(trackB);
99 ;
100
101 }
102
103 fSecondaries = 0;
105 fKillParents = false;
106}
107
109{
110 if (fSecondaries == 0) fSecondaries = new std::vector<G4Track*>();
111 fSecondaries->push_back(aTrack);
113}
114
116{
117 fParticleChange[stepA->GetTrack()]->UpdateStepForPostStep(stepA);
118 fParticleChange[stepB->GetTrack()]->UpdateStepForPostStep(stepB);
119}
120
122{
123 std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange
124 .find(track);
125
126 if (it == fParticleChange.end()) return 0;
127 else return it->second;
128}
129
131{
132 auto it = fParticleChange.begin();
133 if (it != fParticleChange.end())
134 {
135 return it->first;
136 }
137
138 G4ExceptionDescription exceptionDescription;
139 exceptionDescription
140 << "No track A found ! Have you initialized the ReactionChange ?";
141 G4Exception("G4ITReactionChange::GetTrackA", "ITReactionChange001",
142 FatalErrorInArgument, exceptionDescription);
143 return 0;
144}
145
147{
148 auto it = fParticleChange.begin();
149 auto next = it++;
150 if (next == fParticleChange.end())
151 {
152 G4ExceptionDescription exceptionDescription;
153 exceptionDescription
154 << "No track B found ! Have you initialized the ReactionChange ?";
155 G4Exception("G4ITReactionChange::GetTrackB", "ITReactionChange002",
156 FatalErrorInArgument, exceptionDescription);
157 }
158
159 return it->first;
160}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
bool G4bool
Definition: G4Types.hh:86
const G4Track * GetTrackB()
std::map< const G4Track *, G4VParticleChange * > fParticleChange
G4VParticleChange * GetParticleChange(const G4Track *)
void AddSecondary(G4Track *aSecondary)
G4ITReactionChange & operator=(const G4ITReactionChange &other)
void Initialize(const G4Track &, const G4Track &, G4VParticleChange *particleChangeA=0, G4VParticleChange *particleChangeB=0)
const G4Track * GetTrackA()
void UpdateStepInfo(G4Step *, G4Step *)
std::vector< G4Track * > * fSecondaries
Definition: G4Step.hh:62
G4Track * GetTrack() const
Definition: test.py:1