00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4ITReactionChange.hh"
00037
00038 G4ITReactionChange::G4ITReactionChange():
00039 fSecondaries(0),
00040 fNumberOfSecondaries(0),
00041 fKillParents(false),
00042 fParticleChangeIsSet(false)
00043 {
00044
00045 }
00046
00047 G4ITReactionChange::~G4ITReactionChange()
00048 {
00049
00050 delete fSecondaries;
00051 fSecondaries = 0 ;
00052 }
00053
00054
00055 G4ITReactionChange::G4ITReactionChange(const G4ITReactionChange& ) :
00056 fSecondaries(0),
00057 fNumberOfSecondaries(0),
00058 fKillParents(false),
00059 fParticleChangeIsSet(false)
00060 {
00061
00062 }
00063
00064
00065 G4ITReactionChange& G4ITReactionChange::operator=(const G4ITReactionChange& rhs)
00066 {
00067 if (this == &rhs) return *this;
00068
00069 return *this;
00070 }
00071
00072 void G4ITReactionChange::Initialize(const G4Track& trackA,
00073 const G4Track& trackB,
00074 G4VParticleChange* particleChangeA,
00075 G4VParticleChange* particleChangeB
00076 )
00077 {
00078 fParticleChange.clear();
00079 fParticleChange[&trackA] = particleChangeA;
00080 fParticleChange[&trackB] = particleChangeB;
00081
00082 if(particleChangeA || particleChangeB)
00083 {
00084 G4bool test = particleChangeA && particleChangeB ;
00085
00086 if(test == false)
00087 {
00088 G4ExceptionDescription exceptionDescription ;
00089 exceptionDescription << "If you give for one track a particleChange, ";
00090 exceptionDescription << "G4ITReactionChange is expecting that you give for both ";
00091 exceptionDescription << "reacting tracks a particleChange.";
00092 G4Exception("G4ITReactionChange::Initialize","ITReactionChange001",
00093 FatalErrorInArgument,exceptionDescription);
00094 }
00095
00096 fParticleChangeIsSet = true;
00097
00098 fParticleChange[&trackA]->Initialize(trackA);
00099 fParticleChange[&trackB]->Initialize(trackB);;
00100
00101 }
00102
00103 fSecondaries = 0;
00104 fNumberOfSecondaries = 0;
00105 fKillParents = false;
00106 }
00107
00108 void G4ITReactionChange::AddSecondary(G4Track* aTrack)
00109 {
00110 if(fSecondaries==0) fSecondaries = new G4TrackFastVector();
00111
00112
00113 if (G4TrackFastVectorSize > fNumberOfSecondaries)
00114 {
00115 fSecondaries->SetElement(fNumberOfSecondaries, aTrack);
00116 fNumberOfSecondaries++;
00117 }
00118 else
00119 {
00120 G4cerr << "G4ITReactionChange::AddSecondary() Warning ";
00121 G4cerr << "fSecondaries is full !! " << G4endl;
00122 G4cerr << " The object will not be added in fSecondaries" << G4endl;
00123 }
00124 }
00125
00126 void G4ITReactionChange::UpdateStepInfo(G4Step* stepA, G4Step* stepB)
00127 {
00128 fParticleChange[stepA->GetTrack()]->UpdateStepForPostStep(stepA);
00129 fParticleChange[stepB->GetTrack()]->UpdateStepForPostStep(stepB);
00130 }
00131
00132 G4VParticleChange* G4ITReactionChange::GetParticleChange(const G4Track* track)
00133 {
00134 std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange.find(track);
00135
00136 if(it == fParticleChange.end()) return 0;
00137 else return it ->second;
00138 }
00139
00140 const G4Track* G4ITReactionChange::GetTrackA()
00141 {
00142 std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange.begin();
00143 if(it != fParticleChange.end())
00144 {
00145 return it->first;
00146 }
00147
00148 G4ExceptionDescription exceptionDescription ;
00149 exceptionDescription << "No track A found ! Have you initialized the ReactionChange ?";
00150 G4Exception("G4ITReactionChange::GetTrackA","ITReactionChange001",
00151 FatalErrorInArgument,exceptionDescription);
00152 return 0;
00153 }
00154
00155 const G4Track* G4ITReactionChange::GetTrackB()
00156 {
00157 std::map<const G4Track*, G4VParticleChange*>::iterator it = fParticleChange.begin();
00158 std::map<const G4Track*, G4VParticleChange*>::iterator next = it++;
00159 if(next == fParticleChange.end())
00160 {
00161 G4ExceptionDescription exceptionDescription ;
00162 exceptionDescription << "No track B found ! Have you initialized the ReactionChange ?";
00163 G4Exception("G4ITReactionChange::GetTrackB","ITReactionChange002",
00164 FatalErrorInArgument,exceptionDescription);
00165 }
00166
00167 return it->first;
00168 }