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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 10.7.p3)


  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 // G4ParticleTable                                 26 // G4ParticleTable
 27 //                                                 27 //
 28 // Class description:                              28 // Class description:
 29 //                                                 29 //
 30 // G4ParticleTable is the table of pointers to     30 // G4ParticleTable is the table of pointers to G4ParticleDefinition.
 31 // It is a "singleton" (only one static object     31 // It is a "singleton" (only one static object).
 32 // Each G4ParticleDefinition pointer is stored     32 // Each G4ParticleDefinition pointer is stored with its name as a key
 33 // to itself. So, each G4ParticleDefinition ob     33 // to itself. So, each G4ParticleDefinition object must have unique
 34 // name.                                       <<  34 // name. 
 35                                                    35 
 36 // Authors: G.Cosmo, 2 December 1995 - Design,     36 // Authors: G.Cosmo, 2 December 1995 - Design, based on object model
 37 //          H.Kurashige, 27 June 1996 - First      37 //          H.Kurashige, 27 June 1996 - First implementation
 38 // History:                                        38 // History:
 39 // - 14 Nov 1997, H.Kurashige - Added messenge     39 // - 14 Nov 1997, H.Kurashige - Added messenger
 40 // - 24 Sep 1998, H.Kurashige - Added dictiona     40 // - 24 Sep 1998, H.Kurashige - Added dictionary for encoding
 41 // - 28 Oct 1999, H.Kurashige - Migration to S     41 // - 28 Oct 1999, H.Kurashige - Migration to STL maps
 42 // - 15 Sep 2017, K.L.Genser - Added support f     42 // - 15 Sep 2017, K.L.Genser - Added support for MuonicAtom
 43 // -------------------------------------------     43 // --------------------------------------------------------------------
 44 #ifndef G4ParticleTable_hh                         44 #ifndef G4ParticleTable_hh
 45 #define G4ParticleTable_hh 1                       45 #define G4ParticleTable_hh 1
 46                                                    46 
 47 #include "G4ParticleDefinition.hh"             <<  47 #include <map>
 48 #include "G4ParticleTableIterator.hh"          <<  48 
 49 #include "G4Threading.hh"                      << 
 50 #include "G4ios.hh"                                49 #include "G4ios.hh"
 51 #include "globals.hh"                              50 #include "globals.hh"
 52                                                <<  51 #include "G4Threading.hh"
 53 #include <map>                                 <<  52 #include "G4ParticleDefinition.hh"
                                                   >>  53 #include "G4ParticleTableIterator.hh"
 54                                                    54 
 55 class G4UImessenger;                               55 class G4UImessenger;
 56 class G4ParticleMessenger;                         56 class G4ParticleMessenger;
 57 class G4IonTable;                                  57 class G4IonTable;
 58                                                    58 
 59 class G4ParticleTable                              59 class G4ParticleTable
 60 {                                                  60 {
 61   public:                                          61   public:
 62     using G4PTblDictionary = G4ParticleTableIt << 
 63     using G4PTblDicIterator = G4ParticleTableI << 
 64     using G4PTblEncodingDictionary = G4Particl << 
 65     using G4PTblEncodingDicIterator = G4Partic << 
 66                                                    62 
 67     virtual ~G4ParticleTable();                <<  63     using G4PTblDictionary =
                                                   >>  64             G4ParticleTableIterator<G4String, G4ParticleDefinition*>::Map;
                                                   >>  65     using G4PTblDicIterator =
                                                   >>  66             G4ParticleTableIterator<G4String, G4ParticleDefinition*>;
                                                   >>  67     using G4PTblEncodingDictionary =
                                                   >>  68             G4ParticleTableIterator<G4int, G4ParticleDefinition*>::Map;
                                                   >>  69     using G4PTblEncodingDicIterator =
                                                   >>  70             G4ParticleTableIterator<G4int, G4ParticleDefinition*>;
 68                                                    71 
 69     // Copy constructor and assignment operato << 
 70     G4ParticleTable(const G4ParticleTable&) =      72     G4ParticleTable(const G4ParticleTable&) = delete;
 71     G4ParticleTable& operator=(const G4Particl     73     G4ParticleTable& operator=(const G4ParticleTable&) = delete;
                                                   >>  74       // Copy constructor and assignment operator not allowed
 72                                                    75 
 73     // This method is similar to the construct << 
 74     // thread to achieve the partial effect as << 
 75     void WorkerG4ParticleTable();                  76     void WorkerG4ParticleTable();
                                                   >>  77       // This method is similar to the constructor. It is used by each worker
                                                   >>  78       // thread to achieve the partial effect as that of the master thread
 76                                                    79 
 77     // This method is similar to the destructo <<  80     virtual ~G4ParticleTable();
 78     // thread to achieve the partial effect as << 
 79     void DestroyWorkerG4ParticleTable();           81     void DestroyWorkerG4ParticleTable();
 80                                                <<  82       // This method is similar to the destructor. It is used by each worker
 81     // Return the pointer to the G4ParticleTab <<  83       // thread to achieve the partial effect as that of the master thread
 82     // G4ParticleTable is a "singleton" and ca <<  84   
 83     // function. At the first time of calling  << 
 84     // G4ParticleTable object is instantiated  << 
 85     static G4ParticleTable* GetParticleTable()     85     static G4ParticleTable* GetParticleTable();
                                                   >>  86       // Return the pointer to the G4ParticleTable object
                                                   >>  87       // G4ParticleTable is a "singleton" and can get its pointer by this
                                                   >>  88       // function. At the first time of calling this function, the
                                                   >>  89       // G4ParticleTable object is instantiated 
 86                                                    90 
 87     // Returns TRUE if the ParticleTable conta << 
 88     inline G4bool contains(const G4ParticleDef     91     inline G4bool contains(const G4ParticleDefinition* particle) const;
 89     G4bool contains(const G4String& particle_n     92     G4bool contains(const G4String& particle_name) const;
                                                   >>  93       // Returns TRUE if the ParticleTable contains the particle's pointer
 90                                                    94 
 91     // Returns the number of particles in the  << 
 92     G4int entries() const;                         95     G4int entries() const;
 93     G4int size() const;                            96     G4int size() const;
 94                                                <<  97       // Returns the number of particles in the ParticleTable
 95     // Returns a pointer to the i-th particle  <<  98    
 96     // 0 <= index < entries()                  << 
 97     G4ParticleDefinition* GetParticle(G4int in     99     G4ParticleDefinition* GetParticle(G4int index) const;
                                                   >> 100       // Returns a pointer to the i-th particle in the ParticleTable
                                                   >> 101       // 0 <= index < entries()
 98                                                   102 
 99     // Returns the name of i-th particle in th << 
100     const G4String& GetParticleName(G4int inde    103     const G4String& GetParticleName(G4int index) const;
                                                   >> 104       // Returns the name of i-th particle in the ParticleTable
101                                                   105 
102     // Returns a pointer to the particle (0 if << 106     G4ParticleDefinition* FindParticle(G4int PDGEncoding );
103     G4ParticleDefinition* FindParticle(G4int P << 
104     G4ParticleDefinition* FindParticle(const G    107     G4ParticleDefinition* FindParticle(const G4String& particle_name);
105     G4ParticleDefinition* FindParticle(const G    108     G4ParticleDefinition* FindParticle(const G4ParticleDefinition* particle);
                                                   >> 109       // Returns a pointer to the particle (0 if not contained)
106                                                   110 
107     // Returns a pointer to its anti-particle  << 111     inline G4ParticleDefinition* FindAntiParticle(G4int PDGEncoding );
108     inline G4ParticleDefinition* FindAntiParti << 
109     inline G4ParticleDefinition* FindAntiParti    112     inline G4ParticleDefinition* FindAntiParticle(const G4String& p_name);
110     inline G4ParticleDefinition* FindAntiParti    113     inline G4ParticleDefinition* FindAntiParticle(const G4ParticleDefinition* p);
                                                   >> 114       // Returns a pointer to its anti-particle (0 if not contained)
111                                                   115 
112     // Returns the pointer to the Iterator     << 
113     G4PTblDicIterator* GetIterator() const;       116     G4PTblDicIterator* GetIterator() const;
114                                                << 117       // Returns the pointer to the Iterator
115     // Dumps information of particles specifie << 118    
116     void DumpTable(const G4String& particle_na    119     void DumpTable(const G4String& particle_name = "ALL");
                                                   >> 120       // Dumps information of particles specified by name 
                                                   >> 121  
                                                   >> 122     G4IonTable* GetIonTable() const; 
                                                   >> 123       // Returns the pointer to the G4IonTable object
117                                                   124 
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    125     G4ParticleDefinition* Insert(G4ParticleDefinition* particle);
                                                   >> 126       // Inserts the particle into ParticleTable.
                                                   >> 127       // Returned value is the same as particle if successfully inserted
                                                   >> 128       //   or the pointer to another G4ParticleDefinition object 
                                                   >> 129       //      which has same particle name
                                                   >> 130       //   or nullptr if failing to insert by other reason
127                                                   131 
128     // Removes the particle from the table (no << 
129     G4ParticleDefinition* Remove(G4ParticleDef    132     G4ParticleDefinition* Remove(G4ParticleDefinition* particle);
                                                   >> 133       // Removes the particle from the table (not delete)
130                                                   134 
131     // Removes all particles from G4ParticleTa << 
132     void RemoveAllParticles();                    135     void RemoveAllParticles();
                                                   >> 136       // Removes all particles from G4ParticleTable 
133                                                   137 
134     // Removes and deletes all particles from  << 
135     void DeleteAllParticles();                    138     void DeleteAllParticles();
                                                   >> 139       // Removes and deletes all particles from G4ParticleTable  
136                                                   140 
137     // Creates messenger                       << 
138     G4UImessenger* CreateMessenger();             141     G4UImessenger* CreateMessenger();
                                                   >> 142       // Creates messenger
139                                                   143 
140     void SelectParticle(const G4String& name);    144     void SelectParticle(const G4String& name);
141                                                   145 
142     inline const G4ParticleDefinition* GetSele    146     inline const G4ParticleDefinition* GetSelectedParticle() const;
143                                                   147 
144     inline void SetVerboseLevel(G4int value);  << 148     inline void  SetVerboseLevel(G4int value);
145     inline G4int GetVerboseLevel() const;         149     inline G4int GetVerboseLevel() const;
146                                                   150 
147     inline void SetReadiness(G4bool val = true    151     inline void SetReadiness(G4bool val = true);
148     inline G4bool GetReadiness() const;           152     inline G4bool GetReadiness() const;
149                                                   153 
150     inline G4ParticleDefinition* GetGenericIon    154     inline G4ParticleDefinition* GetGenericIon() const;
151     inline void SetGenericIon(G4ParticleDefini    155     inline void SetGenericIon(G4ParticleDefinition*);
152                                                   156 
153     inline G4ParticleDefinition* GetGenericMuo    157     inline G4ParticleDefinition* GetGenericMuonicAtom() const;
154     inline void SetGenericMuonicAtom(G4Particl    158     inline void SetGenericMuonicAtom(G4ParticleDefinition*);
155                                                   159 
156     // Public data ---------------------------    160     // Public data ----------------------------------------------------
157                                                   161 
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 =     162     G4ParticleMessenger* fParticleMessenger = nullptr;
163     static G4ThreadLocal G4PTblDictionary* fDi << 163     static G4ThreadLocal G4PTblDictionary*  fDictionary;
164     static G4ThreadLocal G4PTblDicIterator* fI    164     static G4ThreadLocal G4PTblDicIterator* fIterator;
165     static G4ThreadLocal G4PTblEncodingDiction    165     static G4ThreadLocal G4PTblEncodingDictionary* fEncodingDictionary;
166                                                << 166       // These fields should be thread local or thread private. For a singleton
167     // Particle table is being shared          << 167       // class, we can change any member field as static without any problem
                                                   >> 168       // because there is only one instance. Then we are allowed to add 
                                                   >> 169       // "G4ThreadLocal"
                                                   >> 170  
168     static G4ParticleTable* fgParticleTable;      171     static G4ParticleTable* fgParticleTable;
                                                   >> 172       // Particle table is being shared
169                                                   173 
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     G4IonTable* fIonTable = nullptr;
                                                   >> 175       // This field should be thread private. However, we have to keep one copy
                                                   >> 176       // of the ion table pointer. So we change all important fields of
                                                   >> 177       // G4IonTable to be thread local
174                                                   178 
175     // These shadow pointers are used by each     179     // These shadow pointers are used by each worker thread to copy the content
176     // from the master thread                     180     // from the master thread
177     //                                            181     //
178     static G4PTblDictionary* fDictionaryShadow    182     static G4PTblDictionary* fDictionaryShadow;
179     static G4PTblDicIterator* fIteratorShadow;    183     static G4PTblDicIterator* fIteratorShadow;
180     static G4PTblEncodingDictionary* fEncoding    184     static G4PTblEncodingDictionary* fEncodingDictionaryShadow;
181                                                   185 
182 #ifdef G4MULTITHREADED                            186 #ifdef G4MULTITHREADED
183     // Shared instance of a mutex                 187     // Shared instance of a mutex
184     static G4GLOB_DLL G4Mutex& particleTableMu    188     static G4GLOB_DLL G4Mutex& particleTableMutex();
185     static G4GLOB_DLL G4int& lockCount();         189     static G4GLOB_DLL G4int& lockCount();
186 #endif                                            190 #endif
187                                                   191 
188   protected:                                      192   protected:
                                                   >> 193 
189     const G4PTblDictionary* GetDictionary() co    194     const G4PTblDictionary* GetDictionary() const;
190                                                   195 
191     // Returns key value of the particle (i.e. << 
192     inline const G4String& GetKey(const G4Part    196     inline const G4String& GetKey(const G4ParticleDefinition* particle) const;
                                                   >> 197       // Returns key value of the particle (i.e. particle name)
193                                                   198 
194     // Returns the pointer to EncodingDictiona << 199     const G4PTblEncodingDictionary* GetEncodingDictionary() const; 
195     const G4PTblEncodingDictionary* GetEncodin << 200       // Returns the pointer to EncodingDictionary
196                                                   201 
197   private:                                        202   private:
198     // Provate default constructor             << 203 
199     G4ParticleTable();                            204     G4ParticleTable();
                                                   >> 205       // Provate default constructor
200                                                   206 
201     void CheckReadiness() const;                  207     void CheckReadiness() const;
202                                                   208 
203     // Private data --------------------------    209     // Private data ---------------------------------------------------
204                                                   210 
205     G4ParticleDefinition* genericIon = nullptr    211     G4ParticleDefinition* genericIon = nullptr;
206     G4ParticleDefinition* genericMuonicAtom =     212     G4ParticleDefinition* genericMuonicAtom = nullptr;
207     const G4ParticleDefinition* selectedPartic    213     const G4ParticleDefinition* selectedParticle = nullptr;
208                                                   214 
209     const G4String noName = " ";                  215     const G4String noName = " ";
210     G4String selectedName = "undefined";          216     G4String selectedName = "undefined";
211                                                   217 
                                                   >> 218     G4int verboseLevel = 1;
212     // Control flag for output message            219     // Control flag for output message
213     //  0: Silent                                 220     //  0: Silent
214     //  1: Warning message                        221     //  1: Warning message
215     //  2: More                                   222     //  2: More
216     G4int verboseLevel = 1;                    << 
217                                                   223 
218     G4bool readyToUse = false;                    224     G4bool readyToUse = false;
219 };                                                225 };
220                                                   226 
221 #include "G4ParticleTable.icc"                    227 #include "G4ParticleTable.icc"
222                                                   228 
223 #endif                                            229 #endif
224                                                   230