source: trunk/source/processes/hadronic/models/qmd/src/G4QMDSystem.cc@ 900

Last change on this file since 900 was 819, checked in by garnier, 17 years ago

import all except CVS

File size: 3.4 KB
Line 
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#include "G4QMDSystem.hh"
27#include <iomanip>
28
29G4QMDSystem::G4QMDSystem()
30{
31 participants.clear();
32 numberOfCollision = 0;
33}
34
35
36
37G4QMDSystem::~G4QMDSystem()
38{
39 this->Clear();
40}
41
42
43// Insert nucleus to current system;
44void G4QMDSystem::SetSystem ( G4QMDSystem* nucleus , G4ThreeVector dp , G4ThreeVector dr )
45{
46 std::vector< G4QMDParticipant* >::iterator it;
47 for ( it = nucleus->participants.begin() ; it != nucleus->participants.end() ; it++ )
48 {
49 G4ThreeVector r = (*it)->GetPosition() + dr;
50 (*it)->SetPosition ( r );
51 G4ThreeVector p = (*it)->GetMomentum() + dp;
52 (*it)->SetMomentum ( p );
53 this->SetParticipant( *it );
54 }
55}
56
57void G4QMDSystem::SubtractSystem ( G4QMDSystem* nucleus )
58{
59
60 for ( G4int i = 0 ; i < nucleus->GetTotalNumberOfParticipant() ; i++ )
61 {
62 participants.erase ( std::find ( participants.begin() , participants.end() , nucleus->GetParticipant( i ) ) );
63 }
64}
65
66void G4QMDSystem::Clear ()
67{
68 for ( G4int i = 0 ; i < this->GetTotalNumberOfParticipant() ; i++ )
69 {
70 delete participants[i];
71 }
72 participants.clear();
73}
74
75
76
77void G4QMDSystem::ShowParticipants()
78{
79 G4ThreeVector p_sum( 0.0 );
80 std::vector< G4QMDParticipant* >::iterator it;
81 G4cout << "Momentum and Position of each participant " << G4endl;
82 G4int i = 0;
83 for ( it = participants.begin() ; it != participants.end() ; it++ )
84 {
85 G4cout << i
86 << " "
87 << (*it)->GetDefinition()->GetParticleName()
88 << " "
89 << std::setprecision( 8 )
90 << (*it)->GetMomentum()
91 << " "
92 << (*it)->GetPosition()
93 << G4endl;
94 p_sum += (*it)->GetMomentum();
95 i++;
96 }
97 G4cout << "Sum upped Momentum and mag " << p_sum << " " << p_sum.mag() << G4endl;
98}
Note: See TracBrowser for help on using the repository browser.