LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
pyG4ParticleList.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 // pyG4ParticleList.cc
28 //
29 // 2005 Q
30 // ====================================================================
31 #include <boost/python.hpp>
32 #include "G4ParticleTable.hh"
33 
34 using namespace boost::python;
35 
36 // ====================================================================
37 // internal class
38 // ====================================================================
39 
41 public:
42  typedef std::vector<G4ParticleDefinition*> ParticleList;
44 
45  static ParticleList particleTableCache;
46 
47  p_iterator p_begin() {
48  G4ParticleTable* particleTable= G4ParticleTable::GetParticleTable();
49  if(particleTableCache.size() != particleTable-> size() ) {
50  particleTableCache.clear();
51  G4ParticleTable::G4PTblDicIterator*
52  theParticleIterator= particleTable-> GetIterator();
53  theParticleIterator-> reset();
54  while( (*theParticleIterator)() ){
55  G4ParticleDefinition* particle= theParticleIterator-> value();
56  particleTableCache.push_back(particle);
57  }
58  }
59  return particleTableCache.begin();
60  }
61 
62  p_iterator p_end() {
63  G4ParticleTable* particleTable= G4ParticleTable::GetParticleTable();
64  if(particleTableCache.size() != particleTable-> size() ) {
65  particleTableCache.clear();
66  G4ParticleTable::G4PTblDicIterator*
67  theParticleIterator= particleTable-> GetIterator();
68  theParticleIterator-> reset();
69  while( (*theParticleIterator)() ){
70  G4ParticleDefinition* particle= theParticleIterator-> value();
71  particleTableCache.push_back(particle);
72  }
73  }
74  return particleTableCache.end();
75  }
76 };
77 
79 
80 
81 // ====================================================================
82 // module definition
83 // ====================================================================
85 {
86  class_<PyG4ParticleList>("PyG4ParticleList", "particle list")
88  .add_property("particles", range(&PyG4ParticleList::p_begin,
90  ;
91 }
92 
intermediate_table::iterator iterator
std::vector< G4ParticleDefinition * > ParticleList
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
p_iterator p_end()
static ParticleList particleTableCache
ParticleList::iterator p_iterator
p_iterator p_begin()
double value
Definition: spectrum.C:18
void export_PyG4ParticleList()