Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 85244 2014-10-27 08:24:13Z 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  fParticleChange.clear();
78  fParticleChange[&trackA] = particleChangeA;
79  fParticleChange[&trackB] = particleChangeB;
80 
81  if (particleChangeA || particleChangeB)
82  {
83  G4bool test = particleChangeA && particleChangeB;
84 
85  if (test == false)
86  {
87  G4ExceptionDescription exceptionDescription;
88  exceptionDescription << "If you give for one track a particleChange, ";
89  exceptionDescription
90  << "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 
104  fSecondaries = 0;
106  fKillParents = false;
107 }
108 
110 {
111  if (fSecondaries == 0) fSecondaries = new std::vector<G4Track*>();
112  fSecondaries->push_back(aTrack);
114 }
115 
117 {
118  fParticleChange[stepA->GetTrack()]->UpdateStepForPostStep(stepA);
119  fParticleChange[stepB->GetTrack()]->UpdateStepForPostStep(stepB);
120 }
121 
123 {
124  std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange
125  .find(track);
126 
127  if (it == fParticleChange.end()) return 0;
128  else return it->second;
129 }
130 
132 {
133  std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange
134  .begin();
135  if (it != fParticleChange.end())
136  {
137  return it->first;
138  }
139 
140  G4ExceptionDescription exceptionDescription;
141  exceptionDescription
142  << "No track A found ! Have you initialized the ReactionChange ?";
143  G4Exception("G4ITReactionChange::GetTrackA", "ITReactionChange001",
144  FatalErrorInArgument, exceptionDescription);
145  return 0;
146 }
147 
149 {
150  std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange
151  .begin();
152  std::map<const G4Track*, G4VParticleChange*>::iterator next = it++;
153  if (next == fParticleChange.end())
154  {
155  G4ExceptionDescription exceptionDescription;
156  exceptionDescription
157  << "No track B found ! Have you initialized the ReactionChange ?";
158  G4Exception("G4ITReactionChange::GetTrackB", "ITReactionChange002",
159  FatalErrorInArgument, exceptionDescription);
160  }
161 
162  return it->first;
163 }
const G4Track * GetTrackA()
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
std::vector< G4Track * > * fSecondaries
G4VParticleChange * GetParticleChange(const G4Track *)
G4ITReactionChange & operator=(const G4ITReactionChange &other)
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
G4Track * GetTrack() const
program test
Definition: Main_HIJING.f:1
void AddSecondary(G4Track *aSecondary)