Geant4  10.01.p01
G4MoleculeGun.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 /*
27  * MoleculeGun.cc
28  *
29  * Created on: 29 janv. 2014
30  * Author: kara
31  */
32 
33 #include "G4MoleculeGun.hh"
34 #include "G4MoleculeTable.hh"
35 #include "G4Molecule.hh"
37 #include <cassert>
38 
40 {
41  // TODO Auto-generated constructor stub
42 
44 }
45 
47 {
48  // TODO Auto-generated destructor stub
49  if (fpMessenger) delete fpMessenger;
50 }
51 
53 {
55 
56  for (size_t i = 0; i < fTracks.size(); i++)
57  {
58  PushTrack(fTracks[i]);
59  }
60 
61  fTracks.clear();
62 }
63 
65  const G4ThreeVector& position,
66  double time)
67 {
68  G4Track* track = BuildTrack(name, position, time);
69  fTracks.push_back(track);
70 }
71 
73  const G4String& name,
74  const G4ThreeVector& position,
75  double time)
76 {
77  for (size_t i = 0; i < n; i++)
78  {
79  AddMolecule(name, position, time);
80  }
81 }
82 
84  const G4ThreeVector& position,
85  double time)
86 {
88  assert(model != 0);
89  G4Molecule* molecule = new G4Molecule(*model);
90 
91  return molecule->BuildTrack(time, position);
92 }
CLHEP::Hep3Vector G4ThreeVector
G4MoleculeGunMessenger * fpMessenger
virtual void DefineTracks()
G4String name
Definition: TRTMaterials.hh:40
void DefineTracks(G4MoleculeGun *)
#define position
Definition: xmlparse.cc:605
static G4MoleculeTable * Instance()
std::vector< G4Track * > fTracks
const G4int n
G4Track * BuildTrack(G4double globalTime, const G4ThreeVector &Position)
Definition: G4Molecule.cc:328
G4Track * BuildTrack(const G4String &name, const G4ThreeVector &position, double time=0)
G4Molecule * GetMoleculeModel(const G4String &, bool mustExist=true)
virtual ~G4MoleculeGun()
void AddNMolecules(size_t n, const G4String &name, const G4ThreeVector &position, double time=0)
Class Description The dynamic molecule holds all the data that change for a molecule It has a pointer...
Definition: G4Molecule.hh:93
void AddMolecule(const G4String &name, const G4ThreeVector &position, double time=0)
void PushTrack(G4Track *)
Definition: G4ITGun.cc:45