// @(#)root/eg:$Id$
// Author: Pasha Murat   12/02/99

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TDatabasePDG
#define ROOT_TDatabasePDG

#ifndef ROOT_TParticlePDG
#include "TParticlePDG.h"
#endif
#ifndef ROOT_TParticleClassPDG
#include "TParticleClassPDG.h"
#endif

class THashList;
class TExMap;

class TDatabasePDG: public TNamed {

protected:
   static TDatabasePDG *fgInstance;        // protect against multiple instances
   THashList           *fParticleList;     // list of PDG particles
   TObjArray           *fListOfClasses;    // list of classes (leptons etc.)
   mutable TExMap      *fPdgMap;           //!hash-map from pdg-code to particle

   // make copy-constructor and assigment protected since class cannot be copied
   TDatabasePDG(const TDatabasePDG& db)
     : TNamed(db), fParticleList(db.fParticleList),
     fListOfClasses(db.fListOfClasses), fPdgMap(0) { }

   TDatabasePDG& operator=(const TDatabasePDG& db)
   {if(this!=&db) {TNamed::operator=(db); fParticleList=db.fParticleList;
         fListOfClasses=db.fListOfClasses; fPdgMap=db.fPdgMap;} 
      return *this;}

   void BuildPdgMap() const;

public:

   TDatabasePDG();
   virtual ~TDatabasePDG();

   static TDatabasePDG*  Instance();

   virtual TParticlePDG*   AddParticle(const char*  Name,
                                       const char*  Title,
                                       Double_t     Mass,
                                       Bool_t       Stable,
                                       Double_t     DecayWidth,
                                       Double_t     Charge,
                                       const char*  ParticleClass,
                                       Int_t        PdgCode,
                                       Int_t        Anti=-1,
                                       Int_t        TrackingCode=0);

   virtual Int_t  ConvertGeant3ToPdg(Int_t Geant3Number) const;
   virtual Int_t  ConvertPdgToGeant3(Int_t pdgNumber) const;
   virtual Int_t  ConvertIsajetToPdg(Int_t isaNumber) const;

   virtual TParticlePDG* AddAntiParticle(const char* Name, Int_t PdgCode);

   TParticlePDG  *GetParticle(Int_t pdgCode) const;
   TParticlePDG  *GetParticle(const char *name) const;

   TParticleClassPDG* GetParticleClass(const char* name) {
      if (fParticleList == 0)  ((TDatabasePDG*)this)->ReadPDGTable();
      return (TParticleClassPDG*) fListOfClasses->FindObject(name);
   }

   const THashList *ParticleList() const { return fParticleList; }

   virtual void   Print(Option_t *opt = "") const;

   Bool_t IsFolder() const { return kTRUE; }
   virtual void   Browse(TBrowser* b);

   virtual void   ReadPDGTable (const char *filename = "");
   virtual Int_t  WritePDGTable(const char *filename);

   ClassDef(TDatabasePDG,2)  // PDG particle database

};

#endif
 TDatabasePDG.h:1
 TDatabasePDG.h:2
 TDatabasePDG.h:3
 TDatabasePDG.h:4
 TDatabasePDG.h:5
 TDatabasePDG.h:6
 TDatabasePDG.h:7
 TDatabasePDG.h:8
 TDatabasePDG.h:9
 TDatabasePDG.h:10
 TDatabasePDG.h:11
 TDatabasePDG.h:12
 TDatabasePDG.h:13
 TDatabasePDG.h:14
 TDatabasePDG.h:15
 TDatabasePDG.h:16
 TDatabasePDG.h:17
 TDatabasePDG.h:18
 TDatabasePDG.h:19
 TDatabasePDG.h:20
 TDatabasePDG.h:21
 TDatabasePDG.h:22
 TDatabasePDG.h:23
 TDatabasePDG.h:24
 TDatabasePDG.h:25
 TDatabasePDG.h:26
 TDatabasePDG.h:27
 TDatabasePDG.h:28
 TDatabasePDG.h:29
 TDatabasePDG.h:30
 TDatabasePDG.h:31
 TDatabasePDG.h:32
 TDatabasePDG.h:33
 TDatabasePDG.h:34
 TDatabasePDG.h:35
 TDatabasePDG.h:36
 TDatabasePDG.h:37
 TDatabasePDG.h:38
 TDatabasePDG.h:39
 TDatabasePDG.h:40
 TDatabasePDG.h:41
 TDatabasePDG.h:42
 TDatabasePDG.h:43
 TDatabasePDG.h:44
 TDatabasePDG.h:45
 TDatabasePDG.h:46
 TDatabasePDG.h:47
 TDatabasePDG.h:48
 TDatabasePDG.h:49
 TDatabasePDG.h:50
 TDatabasePDG.h:51
 TDatabasePDG.h:52
 TDatabasePDG.h:53
 TDatabasePDG.h:54
 TDatabasePDG.h:55
 TDatabasePDG.h:56
 TDatabasePDG.h:57
 TDatabasePDG.h:58
 TDatabasePDG.h:59
 TDatabasePDG.h:60
 TDatabasePDG.h:61
 TDatabasePDG.h:62
 TDatabasePDG.h:63
 TDatabasePDG.h:64
 TDatabasePDG.h:65
 TDatabasePDG.h:66
 TDatabasePDG.h:67
 TDatabasePDG.h:68
 TDatabasePDG.h:69
 TDatabasePDG.h:70
 TDatabasePDG.h:71
 TDatabasePDG.h:72
 TDatabasePDG.h:73
 TDatabasePDG.h:74
 TDatabasePDG.h:75
 TDatabasePDG.h:76
 TDatabasePDG.h:77
 TDatabasePDG.h:78
 TDatabasePDG.h:79
 TDatabasePDG.h:80
 TDatabasePDG.h:81
 TDatabasePDG.h:82
 TDatabasePDG.h:83
 TDatabasePDG.h:84
 TDatabasePDG.h:85
 TDatabasePDG.h:86
 TDatabasePDG.h:87
 TDatabasePDG.h:88
 TDatabasePDG.h:89
 TDatabasePDG.h:90
 TDatabasePDG.h:91