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