00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 081120 Add InsertParticipant Method by T. Koi 00027 00028 #include "G4QMDSystem.hh" 00029 #include <iomanip> 00030 00031 G4QMDSystem::G4QMDSystem() 00032 { 00033 participants.clear(); 00034 numberOfCollision = 0; 00035 } 00036 00037 00038 00039 G4QMDSystem::~G4QMDSystem() 00040 { 00041 this->Clear(); 00042 } 00043 00044 00045 // Insert nucleus to current system; 00046 void G4QMDSystem::SetSystem ( G4QMDSystem* nucleus , G4ThreeVector dp , G4ThreeVector dr ) 00047 { 00048 std::vector< G4QMDParticipant* >::iterator it; 00049 for ( it = nucleus->participants.begin() ; it != nucleus->participants.end() ; it++ ) 00050 { 00051 G4ThreeVector r = (*it)->GetPosition() + dr; 00052 (*it)->SetPosition ( r ); 00053 G4ThreeVector p = (*it)->GetMomentum() + dp; 00054 (*it)->SetMomentum ( p ); 00055 this->SetParticipant( *it ); 00056 } 00057 } 00058 00059 void G4QMDSystem::SubtractSystem ( G4QMDSystem* nucleus ) 00060 { 00061 00062 for ( G4int i = 0 ; i < nucleus->GetTotalNumberOfParticipant() ; i++ ) 00063 { 00064 participants.erase ( std::find ( participants.begin() , participants.end() , nucleus->GetParticipant( i ) ) ); 00065 } 00066 } 00067 00068 void G4QMDSystem::Clear () 00069 { 00070 for ( G4int i = 0 ; i < this->GetTotalNumberOfParticipant() ; i++ ) 00071 { 00072 delete participants[i]; 00073 } 00074 participants.clear(); 00075 } 00076 00077 00078 00079 void G4QMDSystem::ShowParticipants() 00080 { 00081 G4ThreeVector p_sum( 0.0 ); 00082 std::vector< G4QMDParticipant* >::iterator it; 00083 G4cout << "Momentum and Position of each participant " << G4endl; 00084 G4int i = 0; 00085 for ( it = participants.begin() ; it != participants.end() ; it++ ) 00086 { 00087 G4cout << i 00088 << " " 00089 << (*it)->GetDefinition()->GetParticleName() 00090 << " " 00091 << std::setprecision( 8 ) 00092 << (*it)->GetMomentum() 00093 << " " 00094 << (*it)->GetPosition() 00095 << G4endl; 00096 p_sum += (*it)->GetMomentum(); 00097 i++; 00098 } 00099 G4cout << "Sum upped Momentum and mag " << p_sum << " " << p_sum.mag() << G4endl; 00100 } 00101 00102 00103 00104 void G4QMDSystem::InsertParticipant ( G4QMDParticipant* particle , G4int n ) 00105 { 00106 00107 if ( (size_t) n > participants.size()+1 ) 00108 G4cout << "G4QMDSystem::InsertParticipant size error" << G4endl; 00109 00110 std::vector< G4QMDParticipant* >::iterator it; 00111 it = participants.begin(); 00112 00113 for ( G4int i = 0; i < n ; i++ ) 00114 it++; 00115 00116 participants.insert( it, particle ); 00117 }