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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/management/include/G4ParticleTable.hh (Version 11.3.0) and /particles/management/include/G4ParticleTable.hh (Version 1.0)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                                  7 //
 26 // G4ParticleTable                             <<   8 // $Id: G4ParticleTable.hh,v 1.12.2.1 1999/12/07 20:49:52 gunter Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-01-00 $
 27 //                                                 10 //
 28 // Class description:                          <<  11 // 
                                                   >>  12 // ------------------------------------------------------------
                                                   >>  13 //  GEANT 4 class header file 
 29 //                                                 14 //
 30 // G4ParticleTable is the table of pointers to <<  15 //  For information related to this code contact:
 31 // It is a "singleton" (only one static object <<  16 //  CERN, IT Division, ASD group
 32 // Each G4ParticleDefinition pointer is stored <<  17 //  History: first implementation, based on object model of
 33 // to itself. So, each G4ParticleDefinition ob <<  18 //  27 June 1996, H.Kurashige
 34 // name.                                       <<  19 // ------------------------------------------------------------
 35                                                <<  20 //      added fParticleMessenger         14 Nov., 97 H.Kurashige
 36 // Authors: G.Cosmo, 2 December 1995 - Design, <<  21 //      added Create/DeleteMessenger     06 Jul., 98 H.Kurashige
 37 //          H.Kurashige, 27 June 1996 - First  <<  22 //      modified FindIon                 02 Aug., 98 H.Kurashige
 38 // History:                                    <<  23 //      added dictionary for encoding    24 Sep., 98 H.Kurashige
 39 // - 14 Nov 1997, H.Kurashige - Added messenge <<  24 //      added RemoveAllParticles()        8 Nov., 98 H.Kurashige
 40 // - 24 Sep 1998, H.Kurashige - Added dictiona <<  25 //         --------------------------------
 41 // - 28 Oct 1999, H.Kurashige - Migration to S <<  26 //      fixed  some improper codings     08 Apr., 99 H.Kurashige
 42 // - 15 Sep 2017, K.L.Genser - Added support f <<  27 //      modified FindIon/GetIon methods  17 AUg., 99 H.Kurashige
 43 // ------------------------------------------- <<  28 //      implement new version for using STL map instaed of RW PtrHashedDictionary
 44 #ifndef G4ParticleTable_hh                     <<  29 //                                       28 ct., 99  H.Kurashige
 45 #define G4ParticleTable_hh 1                   <<  30 
                                                   >>  31 #ifndef G4ParticleTable_h
                                                   >>  32 #define G4ParticleTable_h 1
 46                                                    33 
 47 #include "G4ParticleDefinition.hh"             << 
 48 #include "G4ParticleTableIterator.hh"          << 
 49 #include "G4Threading.hh"                      << 
 50 #include "G4ios.hh"                                34 #include "G4ios.hh"
 51 #include "globals.hh"                              35 #include "globals.hh"
                                                   >>  36 #include "G4ParticleDefinition.hh"
 52                                                    37 
 53 #include <map>                                 <<  38 #ifdef G4USE_STL
                                                   >>  39 #include "g4std/map"
                                                   >>  40 #include "G4ParticleTableIterator.hh"
                                                   >>  41 #else
                                                   >>  42 #include "g4rw/tphdict.h"
                                                   >>  43 #endif 
 54                                                    44 
 55 class G4UImessenger;                               45 class G4UImessenger;
 56 class G4ParticleMessenger;                         46 class G4ParticleMessenger;
 57 class G4IonTable;                                  47 class G4IonTable;
                                                   >>  48 class G4ShortLivedTable;
 58                                                    49 
 59 class G4ParticleTable                              50 class G4ParticleTable
 60 {                                                  51 {
 61   public:                                      <<  52  // Class Description
 62     using G4PTblDictionary = G4ParticleTableIt <<  53  //   G4ParticleTable is the table of pointer to G4ParticleDefinition
 63     using G4PTblDicIterator = G4ParticleTableI <<  54  //   G4ParticleTable is a "singleton" (only one and staic object)
 64     using G4PTblEncodingDictionary = G4Particl <<  55  //   In G4ParticleTable, each G4ParticleDefinition pointer is stored
 65     using G4PTblEncodingDicIterator = G4Partic <<  56  //   with its name as a key to itself. So, each  G4ParticleDefinition 
 66                                                <<  57  //   object must have unique name for itself. 
 67     virtual ~G4ParticleTable();                <<  58  //   
 68                                                <<  59 
 69     // Copy constructor and assignment operato <<  60  public:
 70     G4ParticleTable(const G4ParticleTable&) =  <<  61 #ifdef G4USE_STL
 71     G4ParticleTable& operator=(const G4Particl <<  62    typedef G4ParticleTableIterator<G4String, G4ParticleDefinition*>::Map G4PTblDictionary;
 72                                                <<  63    typedef G4ParticleTableIterator<G4String, G4ParticleDefinition*> G4PTblDicIterator;
 73     // This method is similar to the construct <<  64    typedef G4ParticleTableIterator<G4int, G4ParticleDefinition*>::Map G4PTblEncodingDictionary;
 74     // thread to achieve the partial effect as <<  65    typedef G4ParticleTableIterator<G4int, G4ParticleDefinition*> G4PTblEncodingDicIterator;
 75     void WorkerG4ParticleTable();              <<  66 #else
 76                                                <<  67    typedef G4RWTPtrHashDictionary<G4String,G4ParticleDefinition> G4PTblDictionary;
 77     // This method is similar to the destructo <<  68    typedef G4RWTPtrHashDictionaryIterator<G4String,G4ParticleDefinition> G4PTblDicIterator;
 78     // thread to achieve the partial effect as <<  69    typedef G4RWTPtrHashDictionary<G4int,G4ParticleDefinition> G4PTblEncodingDictionary;
 79     void DestroyWorkerG4ParticleTable();       <<  70    typedef G4RWTPtrHashDictionaryIterator<G4int,G4ParticleDefinition> G4PTblEncodingDicIterator;
 80                                                << 
 81     // Return the pointer to the G4ParticleTab << 
 82     // G4ParticleTable is a "singleton" and ca << 
 83     // function. At the first time of calling  << 
 84     // G4ParticleTable object is instantiated  << 
 85     static G4ParticleTable* GetParticleTable() << 
 86                                                << 
 87     // Returns TRUE if the ParticleTable conta << 
 88     inline G4bool contains(const G4ParticleDef << 
 89     G4bool contains(const G4String& particle_n << 
 90                                                << 
 91     // Returns the number of particles in the  << 
 92     G4int entries() const;                     << 
 93     G4int size() const;                        << 
 94                                                << 
 95     // Returns a pointer to the i-th particle  << 
 96     // 0 <= index < entries()                  << 
 97     G4ParticleDefinition* GetParticle(G4int in << 
 98                                                << 
 99     // Returns the name of i-th particle in th << 
100     const G4String& GetParticleName(G4int inde << 
101                                                << 
102     // Returns a pointer to the particle (0 if << 
103     G4ParticleDefinition* FindParticle(G4int P << 
104     G4ParticleDefinition* FindParticle(const G << 
105     G4ParticleDefinition* FindParticle(const G << 
106                                                << 
107     // Returns a pointer to its anti-particle  << 
108     inline G4ParticleDefinition* FindAntiParti << 
109     inline G4ParticleDefinition* FindAntiParti << 
110     inline G4ParticleDefinition* FindAntiParti << 
111                                                << 
112     // Returns the pointer to the Iterator     << 
113     G4PTblDicIterator* GetIterator() const;    << 
114                                                << 
115     // Dumps information of particles specifie << 
116     void DumpTable(const G4String& particle_na << 
117                                                << 
118     // Returns the pointer to the G4IonTable o << 
119     G4IonTable* GetIonTable() const;           << 
120                                                << 
121     // Inserts the particle into ParticleTable << 
122     // Returned value is the same as particle  << 
123     //   or the pointer to another G4ParticleD << 
124     //      which has same particle name       << 
125     //   or nullptr if failing to insert by ot << 
126     G4ParticleDefinition* Insert(G4ParticleDef << 
127                                                << 
128     // Removes the particle from the table (no << 
129     G4ParticleDefinition* Remove(G4ParticleDef << 
130                                                << 
131     // Removes all particles from G4ParticleTa << 
132     void RemoveAllParticles();                 << 
133                                                << 
134     // Removes and deletes all particles from  << 
135     void DeleteAllParticles();                 << 
136                                                << 
137     // Creates messenger                       << 
138     G4UImessenger* CreateMessenger();          << 
139                                                << 
140     void SelectParticle(const G4String& name); << 
141                                                << 
142     inline const G4ParticleDefinition* GetSele << 
143                                                << 
144     inline void SetVerboseLevel(G4int value);  << 
145     inline G4int GetVerboseLevel() const;      << 
146                                                << 
147     inline void SetReadiness(G4bool val = true << 
148     inline G4bool GetReadiness() const;        << 
149                                                << 
150     inline G4ParticleDefinition* GetGenericIon << 
151     inline void SetGenericIon(G4ParticleDefini << 
152                                                << 
153     inline G4ParticleDefinition* GetGenericMuo << 
154     inline void SetGenericMuonicAtom(G4Particl << 
155                                                << 
156     // Public data --------------------------- << 
157                                                << 
158     // These fields should be thread local or  << 
159     // class, we can change any member field a << 
160     // because there is only one instance. The << 
161     // "G4ThreadLocal"                         << 
162     G4ParticleMessenger* fParticleMessenger =  << 
163     static G4ThreadLocal G4PTblDictionary* fDi << 
164     static G4ThreadLocal G4PTblDicIterator* fI << 
165     static G4ThreadLocal G4PTblEncodingDiction << 
166                                                << 
167     // Particle table is being shared          << 
168     static G4ParticleTable* fgParticleTable;   << 
169                                                << 
170     // This field should be thread private. Ho << 
171     // of the ion table pointer. So we change  << 
172     // G4IonTable to be thread local           << 
173     G4IonTable* fIonTable = nullptr;           << 
174                                                << 
175     // These shadow pointers are used by each  << 
176     // from the master thread                  << 
177     //                                         << 
178     static G4PTblDictionary* fDictionaryShadow << 
179     static G4PTblDicIterator* fIteratorShadow; << 
180     static G4PTblEncodingDictionary* fEncoding << 
181                                                << 
182 #ifdef G4MULTITHREADED                         << 
183     // Shared instance of a mutex              << 
184     static G4GLOB_DLL G4Mutex& particleTableMu << 
185     static G4GLOB_DLL G4int& lockCount();      << 
186 #endif                                             71 #endif
187                                                    72 
188   protected:                                   <<  73  protected:
189     const G4PTblDictionary* GetDictionary() co <<  74    G4ParticleTable();
                                                   >>  75    G4ParticleTable(const  G4ParticleTable &right);
                                                   >>  76 
                                                   >>  77  public:
                                                   >>  78    virtual ~G4ParticleTable();
                                                   >>  79   
                                                   >>  80  public: // With Description
                                                   >>  81    static G4ParticleTable* GetParticleTable();
                                                   >>  82    // return the pointer to G4ParticleTable object
                                                   >>  83    //   G4ParticleTable is a "singleton" and can get its pointer by this function
                                                   >>  84    //   At the first time of calling this function, the G4ParticleTable object
                                                   >>  85    //   is instantiated 
                                                   >>  86 
                                                   >>  87    G4bool   contains(const G4ParticleDefinition *particle);
                                                   >>  88    G4bool   contains(const G4String &particle_name);
                                                   >>  89    // returns TRUE if the ParticleTable contains 
                                                   >>  90 
                                                   >>  91    G4int    entries() const;
                                                   >>  92    G4int    size() const;
                                                   >>  93    // returns the number of Particles in the ParticleTable
                                                   >>  94    
                                                   >>  95    G4ParticleDefinition* GetParticle(G4int index);
                                                   >>  96    // returns a pointer to i-th particles in the ParticleTable
                                                   >>  97    //    0<= index < entries()
                                                   >>  98 
                                                   >>  99    const G4String& GetParticleName(G4int index);
                                                   >> 100    // returns name of i-th particles in the ParticleTable
                                                   >> 101 
                                                   >> 102    G4ParticleDefinition* FindParticle(G4int  PDGEncoding );
                                                   >> 103    G4ParticleDefinition* FindParticle(const G4String &particle_name);
                                                   >> 104    G4ParticleDefinition* FindParticle(const G4ParticleDefinition *particle);
                                                   >> 105    // returns a pointer to the particle (0 if not contained)
                                                   >> 106 
                                                   >> 107    G4ParticleDefinition* FindAntiParticle(G4int  PDGEncoding );
                                                   >> 108    G4ParticleDefinition* FindAntiParticle(const G4String &particle_name);
                                                   >> 109    G4ParticleDefinition* FindAntiParticle(const G4ParticleDefinition *particle);
                                                   >> 110    // returns a pointer to its anti-particle (0 if not contained)
                                                   >> 111 
                                                   >> 112    G4ParticleDefinition* FindIon( G4int    atomicNumber, 
                                                   >> 113           G4int    atomicMass, 
                                                   >> 114           G4double excitationEnergy );
                                                   >> 115    //  return the pointer to an ion  (returns 0 if the ion does not exist)
                                                   >> 116    //  the ion has excitation energy nearest to given excitationEnergy  (0: ground state)
                                                   >> 117 
                                                   >> 118    G4ParticleDefinition* GetIon(  G4int    atomicNumber, 
                                                   >> 119           G4int    atomicMass, 
                                                   >> 120           G4double   excitationEnergy);
                                                   >> 121    //  return the pointer to an ion ( create ion if the ion does not exist)
                                                   >> 122    //  It has excitation energy nearest to given excitationEnergy  (0: ground state)
                                                   >> 123   
                                                   >> 124    G4ParticleDefinition* FindIon( G4int atomicNumber, 
                                                   >> 125           G4int atomicMass, 
                                                   >> 126           G4int dummy1,
                                                   >> 127           G4int dummy2 );
                                                   >> 128    //  return the pointer to an ion
                                                   >> 129    //  !! This routine behaves same as GetIon( atomicNumber, atomicMass, 0) 
                                                   >> 130    //  !! The third and fourth arguments are meaningless
                                                   >> 131    //  !! This routine is provided for compatibility to old version
                                                   >> 132 
                                                   >> 133    G4PTblDicIterator* GetIterator();
                                                   >> 134    // return the pointer of Iterator (RW compatible)
                                                   >> 135    
                                                   >> 136    void DumpTable(const G4String &particle_name = "ALL");
                                                   >> 137    // dump information of particles specified by name 
                                                   >> 138 
                                                   >> 139  public: 
                                                   >> 140    G4ParticleDefinition* Insert(G4ParticleDefinition *particle);
                                                   >> 141    // insert the particle into ParticleTable 
                                                   >> 142    // return value is same as particle if successfully inserted
                                                   >> 143    //              or pointer to another G4ParticleDefinition object 
                                                   >> 144    //                   which has same name of particle
                                                   >> 145    //              or 0 if fail to insert by another reason
                                                   >> 146 
                                                   >> 147  protected:
                                                   >> 148    G4ParticleDefinition* Remove(G4ParticleDefinition *particle);
                                                   >> 149    // Remove Particle
                                                   >> 150 
                                                   >> 151    G4PTblDictionary* GetDictionary();
                                                   >> 152 
                                                   >> 153    const G4String& GetKey(const G4ParticleDefinition *particle) const;
                                                   >> 154    // return key value of the particle (i.e. particle name)
                                                   >> 155 
                                                   >> 156    const G4PTblEncodingDictionary* GetEncodingDictionary();
                                                   >> 157    // return the pointer to EncodingDictionary
                                                   >> 158 
                                                   >> 159  public: //With Description
                                                   >> 160 
                                                   >> 161    const G4IonTable* GetIonTable();
                                                   >> 162    // return the pointer to G4IonTable object
                                                   >> 163 
                                                   >> 164    const G4ShortLivedTable* GetShortLivedTable();
                                                   >> 165    // return the pointer to G4ShortLivedTable object
                                                   >> 166  
                                                   >> 167  public:
                                                   >> 168    G4UImessenger*       CreateMessenger();
                                                   >> 169    void                 DeleteMessenger();
                                                   >> 170   // create/delete messenger for the particle table 
                                                   >> 171  
                                                   >> 172  protected:  
                                                   >> 173    void RemoveAllParticles();
                                                   >> 174    // remove all particles from G4ParticleTable and 
                                                   >> 175    // delete them if they were created dynamically  (i.e. not static objects) 
                                                   >> 176 
                                                   >> 177 #ifndef G4USE_STL
                                                   >> 178  protected:
                                                   >> 179    static unsigned HashFun(const G4String& particle_name);
                                                   >> 180    static unsigned EncodingHashFun(const G4int& aEndcoding);
                                                   >> 181   // hash functions  
                                                   >> 182 #endif
190                                                   183 
191     // Returns key value of the particle (i.e. << 184  private:
192     inline const G4String& GetKey(const G4Part << 185    G4int verboseLevel;
                                                   >> 186    // controle flag for output message
                                                   >> 187    //  0: Silent
                                                   >> 188    //  1: Warning message
                                                   >> 189    //  2: More
                                                   >> 190 
                                                   >> 191  public:
                                                   >> 192    void  SetVerboseLevel(G4int value);
                                                   >> 193    G4int GetVerboseLevel() const;
                                                   >> 194 
                                                   >> 195  private:
                                                   >> 196    G4ParticleMessenger* fParticleMessenger;
                                                   >> 197    G4PTblDictionary*  fDictionary;
                                                   >> 198    G4PTblDicIterator* fIterator;
                                                   >> 199    G4PTblEncodingDictionary* fEncodingDictionary;
                                                   >> 200    G4int DictionaryBucketSize;
193                                                   201 
194     // Returns the pointer to EncodingDictiona << 202    static G4ParticleTable*  fgParticleTable;
195     const G4PTblEncodingDictionary* GetEncodin << 
196                                                   203 
197   private:                                     << 204    G4IonTable*            fIonTable;
198     // Provate default constructor             << 205    G4ShortLivedTable*     fShortLivedTable;
199     G4ParticleTable();                         << 
200                                                   206 
201     void CheckReadiness() const;               << 207    G4String               noName;
                                                   >> 208 };
                                                   >> 209 #include "G4ParticleTable.icc"
202                                                   210 
203     // Private data -------------------------- << 211 #endif
204                                                   212 
205     G4ParticleDefinition* genericIon = nullptr << 
206     G4ParticleDefinition* genericMuonicAtom =  << 
207     const G4ParticleDefinition* selectedPartic << 
208                                                   213 
209     const G4String noName = " ";               << 
210     G4String selectedName = "undefined";       << 
211                                                   214 
212     // Control flag for output message         << 
213     //  0: Silent                              << 
214     //  1: Warning message                     << 
215     //  2: More                                << 
216     G4int verboseLevel = 1;                    << 
217                                                   215 
218     G4bool readyToUse = false;                 << 
219 };                                             << 
220                                                   216 
221 #include "G4ParticleTable.icc"                 << 
222                                                   217 
223 #endif                                         << 
224                                                   218