Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 081120 Add InsertParticipant Method by T. K << 27 << 28 #include "G4QMDSystem.hh" 26 #include "G4QMDSystem.hh" 29 #include <iomanip> 27 #include <iomanip> 30 28 31 G4QMDSystem::G4QMDSystem() 29 G4QMDSystem::G4QMDSystem() 32 { 30 { 33 participants.clear(); 31 participants.clear(); 34 numberOfCollision = 0; 32 numberOfCollision = 0; 35 } 33 } 36 34 37 35 38 36 39 G4QMDSystem::~G4QMDSystem() 37 G4QMDSystem::~G4QMDSystem() 40 { 38 { 41 this->Clear(); 39 this->Clear(); 42 } 40 } 43 41 44 42 45 // Insert nucleus to current system; 43 // Insert nucleus to current system; 46 void G4QMDSystem::SetSystem ( G4QMDSystem* nuc 44 void G4QMDSystem::SetSystem ( G4QMDSystem* nucleus , G4ThreeVector dp , G4ThreeVector dr ) 47 { 45 { 48 std::vector< G4QMDParticipant* >::iterator 46 std::vector< G4QMDParticipant* >::iterator it; 49 for ( it = nucleus->participants.begin() ; 47 for ( it = nucleus->participants.begin() ; it != nucleus->participants.end() ; it++ ) 50 { 48 { 51 G4ThreeVector r = (*it)->GetPosition() + 49 G4ThreeVector r = (*it)->GetPosition() + dr; 52 (*it)->SetPosition ( r ); 50 (*it)->SetPosition ( r ); 53 G4ThreeVector p = (*it)->GetMomentum() + 51 G4ThreeVector p = (*it)->GetMomentum() + dp; 54 (*it)->SetMomentum ( p ); 52 (*it)->SetMomentum ( p ); 55 this->SetParticipant( *it ); 53 this->SetParticipant( *it ); 56 } 54 } 57 } 55 } 58 56 59 void G4QMDSystem::SubtractSystem ( G4QMDSystem 57 void G4QMDSystem::SubtractSystem ( G4QMDSystem* nucleus ) 60 { 58 { 61 59 62 for ( G4int i = 0 ; i < nucleus->GetTotalNu 60 for ( G4int i = 0 ; i < nucleus->GetTotalNumberOfParticipant() ; i++ ) 63 { 61 { 64 participants.erase ( std::find ( partici 62 participants.erase ( std::find ( participants.begin() , participants.end() , nucleus->GetParticipant( i ) ) ); 65 } 63 } 66 } 64 } 67 65 68 void G4QMDSystem::Clear () 66 void G4QMDSystem::Clear () 69 { 67 { 70 for ( G4int i = 0 ; i < this->GetTotalNumbe 68 for ( G4int i = 0 ; i < this->GetTotalNumberOfParticipant() ; i++ ) 71 { 69 { 72 delete participants[i]; 70 delete participants[i]; 73 } 71 } 74 participants.clear(); 72 participants.clear(); 75 } 73 } 76 74 77 75 78 76 79 void G4QMDSystem::ShowParticipants() 77 void G4QMDSystem::ShowParticipants() 80 { 78 { 81 //store orginal precision << 82 std::ios::fmtflags oldform = G4cout.flags() << 83 << 84 G4ThreeVector p_sum( 0.0 ); 79 G4ThreeVector p_sum( 0.0 ); 85 std::vector< G4QMDParticipant* >::iterator 80 std::vector< G4QMDParticipant* >::iterator it; 86 G4cout << "Momentum and Position of each pa 81 G4cout << "Momentum and Position of each participant " << G4endl; 87 G4int i = 0; 82 G4int i = 0; 88 for ( it = participants.begin() ; it != par 83 for ( it = participants.begin() ; it != participants.end() ; it++ ) 89 { 84 { 90 G4cout << i 85 G4cout << i 91 << " " 86 << " " 92 << (*it)->GetDefinition()->GetPar 87 << (*it)->GetDefinition()->GetParticleName() 93 << " " 88 << " " 94 << std::setprecision( 8 ) 89 << std::setprecision( 8 ) 95 << (*it)->GetMomentum() 90 << (*it)->GetMomentum() 96 << " " 91 << " " 97 << (*it)->GetPosition() 92 << (*it)->GetPosition() 98 << G4endl; 93 << G4endl; 99 p_sum += (*it)->GetMomentum(); 94 p_sum += (*it)->GetMomentum(); 100 i++; 95 i++; 101 } 96 } 102 G4cout << "Sum upped Momentum and its mag " << 97 G4cout << "Sum upped Momentum and mag " << p_sum << " " << p_sum.mag() << G4endl; 103 << 104 //restore orginal precision << 105 G4cout.flags( oldform ); << 106 } << 107 << 108 << 109 << 110 void G4QMDSystem::InsertParticipant ( G4QMDPar << 111 { << 112 << 113 if ( (size_t) n > participants.size()+1 ) << 114 G4cout << "G4QMDSystem::InsertParticipan << 115 << 116 std::vector< G4QMDParticipant* >::iterator << 117 it = participants.begin(); << 118 << 119 for ( G4int i = 0; i < n ; i++ ) << 120 it++; << 121 << 122 participants.insert( it, particle ); << 123 } 98 } 124 99