laura is hosted by Hepforge, IPPP Durham
Laura++  v1r0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauDatabasePDG.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2008 - 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
15 #include <iostream>
16 using std::cout;
17 using std::cerr;
18 using std::endl;
19 
20 #include "TDatabasePDG.h"
21 
22 #include "LauDatabasePDG.hh"
23 #include "LauParticlePDG.hh"
24 
26 
27 ClassImp(LauDatabasePDG)
28 
29 // Constructor
30 
32  theDatabase_( new TDatabasePDG() ),
33  particles_(),
34  debug_(kFALSE)
35 {
36 }
37 
38 // Destructor
39 
41 {
42  delete theDatabase_; theDatabase_ = 0;
43  for (LauPDGList::iterator iter = particles_.begin(); iter != particles_.end(); ++iter) {
44  delete iter->second; iter->second = 0;
45  }
46 }
47 
48 // Private static method to access the instance
49 // Will create it and add the missing particles if it doesn't already exist
50 
52 {
53  if (theInstance_ == 0) {
56  }
57  return *theInstance_;
58 }
59 
60 // All static methods grab the instance and call the private non-static
61 // methods - this ensures that the database exists and that the missing
62 // particles are added to it.
63 
65 {
66  return LauDatabasePDG::get().createParticle( theCode );
67 }
68 
69 const LauParticlePDG* LauDatabasePDG::particle(const TString& theString)
70 {
71  return LauDatabasePDG::get().createParticle( theString );
72 }
73 
74 Int_t LauDatabasePDG::code(const TString& theString)
75 {
76  return LauDatabasePDG::get().pdgCode( theString );
77 }
78 
79 TString LauDatabasePDG::string(Int_t theCode)
80 {
81  return LauDatabasePDG::get().pdgName( theCode );
82 }
83 
84 // The following method adds particles to the ROOT database that are
85 // missing from it's default setup. This should only be called once,
86 // immediately after the creation of the instance.
87 
89 {
90  TParticlePDG* part(0);
91  TParticlePDG* antipart(0);
92 
93  // format is:
94  // name, title, mass, stable?, width, 3*Q, category, PDG code
95 
96  part = theDatabase_->AddParticle("deuteron", "deuteron", 1.8756134, kTRUE, 0.0, 3, "Nucleus", 1011);
97  antipart = theDatabase_->AddAntiParticle("anti-deuteron", -1011);
98  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
99 
100  part = theDatabase_->AddParticle("tritium", "tritium", 2.80925, kTRUE, 0.0, 3, "Nucleus", 1021);
101  antipart = theDatabase_->AddAntiParticle("anti-tritium", -1021);
102  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
103 
104  part = theDatabase_->AddParticle("He3", "He3", 2.80923, kTRUE, 0.0, 6, "Nucleus", 1012);
105  antipart = theDatabase_->AddAntiParticle("anti-He3", -1012);
106  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
107 
108  part = theDatabase_->AddParticle("alpha", "alpha", 3.727417, kTRUE, 0.0, 3, "Nucleus", 1022);
109  antipart = theDatabase_->AddAntiParticle("anti-alpha", -1022);
110  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
111 
112  part = theDatabase_->AddParticle("eta_c(2S)", "eta_c(2S)", 3.628, kTRUE, 0.0195, 0, "Meson", 20441);
113 
114  part = theDatabase_->AddParticle("psi(3770)", "psi(3770)", 3.7699, kTRUE, 0.0236, 0, "Meson", 40443);
115 
116  part = theDatabase_->AddParticle("rho(2S)0", "rho(2S)0", 1.46, kTRUE, 0.31, 0, "Meson", 30113);
117  part = theDatabase_->AddParticle("rho(2S)+", "rho(2S)+", 1.46, kTRUE, 0.31, 3, "Meson", 30213);
118  antipart = theDatabase_->AddAntiParticle("rho(2S)-", -30213);
119  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
120 
121  part = theDatabase_->AddParticle("rho(3S)0", "rho(3S)0", 1.46, kTRUE, 0.31, 0, "Meson", 40113);
122  part = theDatabase_->AddParticle("rho(3S)+", "rho(3S)+", 1.46, kTRUE, 0.31, 3, "Meson", 40213);
123  antipart = theDatabase_->AddAntiParticle("rho(3S)-", -40213);
124  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
125 
126  part = theDatabase_->AddParticle("Xsu", "Xsu", 1.6, kTRUE, 0.5, 3, "Meson", 30353);
127  antipart = theDatabase_->AddAntiParticle("anti-Xsu", -30353);
128  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
129 
130  part = theDatabase_->AddParticle("Xu0", "Xu0", 1., kTRUE, 0., 0, "Special", 41);
131  part = theDatabase_->AddParticle("Xu+", "Xu+", 1., kTRUE, 0., 3, "Special", 42);
132  antipart = theDatabase_->AddAntiParticle("Xu-", -42);
133  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
134 
135  part = theDatabase_->AddParticle("Xsd", "Xsd", 1.6, kTRUE, 0.5, 0, "Meson", 30343);
136  antipart = theDatabase_->AddAntiParticle("anti-Xsd", -30343);
137  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
138 
139  part = theDatabase_->AddParticle("K'*0", "K'*0", 1.414, kTRUE, 0.232, 0, "Meson", 100313);
140  antipart = theDatabase_->AddAntiParticle("anti-K'*0", -100313);
141  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
142 
143  part = theDatabase_->AddParticle("K'*+", "K'*+", 1.414, kTRUE, 0.232, 3, "Meson", 100323);
144  antipart = theDatabase_->AddAntiParticle("K'*-", -100323);
145  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
146 
147  part = theDatabase_->AddParticle("K''*0", "K''*0", 1.717, kTRUE, 0.322, 0, "Meson", 30313);
148  antipart = theDatabase_->AddAntiParticle("anti-K''*0", -30313);
149  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
150 
151  part = theDatabase_->AddParticle("K''*+", "K''*+", 1.717, kTRUE, 0.322, 3, "Meson", 30323);
152  antipart = theDatabase_->AddAntiParticle("K''*-", -30323);
153  part->SetAntiParticle(antipart); antipart->SetAntiParticle(part);
154 }
155 
156 // These next two methods are the ones that actually build-up our database.
157 
159 {
160  // if we've already created this one simply return it
161  LauPDGList::iterator iter = particles_.find(theCode);
162  if ( iter != particles_.end() ) {
163  return iter->second;
164  }
165 
166  // otherwise we'll have to make it...
167 
168  // first get the particle from the database
169  TParticlePDG* theTParticle = theDatabase_->GetParticle( theCode );
170  if (theTParticle == 0) {
171  cerr<<"ERROR in LauDatabasePDG::createParticle : Invalid PDG code: "<<theCode<<endl;
172  return 0;
173  }
174 
175  // then create a new particle from it and store it in the map
176  LauParticlePDG * theParticle = new LauParticlePDG( theTParticle );
177  std::pair< LauPDGList::iterator, bool > insertResult = particles_.insert( std::make_pair( theCode, theParticle ) );
178  if ( ! insertResult.second ) {
179  cerr<<"ERROR in LauDatabasePDG::createParticle : Something went wrong inserting particle "<<theCode<<" into the map."<<endl;
180  delete theParticle;
181  return 0;
182  }
183 
184  // then get the anti-particle from the database
185  TParticlePDG* theTAntiParticle = theTParticle->AntiParticle();
186 
187  // check if we have a self-conjugate particle
188  if ( theTAntiParticle == 0 || theTAntiParticle == theTParticle ) {
189  // if so then set it to be it's own anti-particle and return
190  theParticle->setAntiParticle( theParticle );
191  if ( debug_ ) {
192  cout<<"INFO in LauDatabasePDG::createParticle : Created self-conjugate particle "<<theTParticle->GetName()<<endl;
193  }
194  return theParticle;
195  }
196 
197  // otherwise make the particle's antiparticle and store it in the map
198  LauParticlePDG * antiParticle = new LauParticlePDG( theTAntiParticle );
199  Int_t conjCode = antiParticle->code();
200  insertResult = particles_.insert( std::make_pair( conjCode, antiParticle ) );
201  if ( ! insertResult.second ) {
202  cerr<<"ERROR in LauDatabasePDG::createParticle : Something went wrong inserting anti-particle "<<conjCode<<" into the map."<<endl;
203  particles_.erase( theCode );
204  delete theParticle;
205  delete antiParticle;
206  return 0;
207  }
208 
209  // set the particle and anti-particle to be each others conjugate
210  theParticle->setAntiParticle( antiParticle );
211  antiParticle->setAntiParticle( theParticle );
212 
213  // and finally return the particle we've created
214  if ( debug_ ) {
215  cout<<"INFO in LauDatabasePDG::createParticle : Created particle "<<theTParticle->GetName()<<" and its conjugate "<<theTAntiParticle->GetName()<<endl;
216  }
217  return theParticle;
218 }
219 
220 const LauParticlePDG* LauDatabasePDG::createParticle(const TString& theString)
221 {
222  // turn the string into a PDG code
223  Int_t theCode = this->pdgCode(theString);
224  if ( theCode == 0 ) {
225  cerr<<"ERROR in LauDatabasePDG::createParticle : Invalid particle string: "<<theString<<endl;
226  return 0;
227  }
228  // self-message to get the particle
229  return this->createParticle(theCode);
230 }
231 
232 // These last two methods have to be independent of our own database since
233 // they are used by the methods that create the particles and so we'd end
234 // up with an infinite loop.
235 
236 Int_t LauDatabasePDG::pdgCode(const TString& theString)
237 {
238  TParticlePDG* theParticle = theDatabase_->GetParticle(theString);
239  if (theParticle == 0) {
240  cerr<<"ERROR in LauDatabasePDG::pdgCode : Invalid particle string: "<<theString<<endl;
241  return 0;
242  }
243  return theParticle->PdgCode();
244 }
245 
246 TString LauDatabasePDG::pdgName(Int_t theCode)
247 {
248  TParticlePDG* theParticle = theDatabase_->GetParticle(theCode);
249  if (theParticle == 0) {
250  cerr<<"ERROR in LauDatabasePDG::pdgName : Invalid particle code: "<<theCode<<endl;
251  return "";
252  }
253  return theParticle->GetName();
254 }
255 
TDatabasePDG * theDatabase_
The ROOT database.
Class for storing particle properties.
~LauDatabasePDG()
Destructor.
TString pdgName(Int_t theCode)
Get the associated name string for a given pdgCode.
const Bool_t debug_
Debug flag - set in constructor.
LauDatabasePDG()
Constructor.
void addMissingParticles()
Add particles to the ROOT database that are missing from the default setup.
Singleton class that provides access to particle property records.
File containing declaration of LauDatabasePDG class.
static LauDatabasePDG & get()
Get the database instance.
File containing declaration of LauParticlePDG class.
static const LauParticlePDG * particle(Int_t code)
Get particle object based on the PDG code.
static LauDatabasePDG * theInstance_
The singleton instance.
const LauParticlePDG * createParticle(Int_t theCode)
Create particle in the database for a given PDG code and return the new particle. ...
LauPDGList particles_
The list of particle objects.
void setAntiParticle(const LauParticlePDG *antiPart)
Set the antiparticle.
Int_t pdgCode(const TString &theString)
Get the associated pdgCode for a given particle name string.
static Int_t code(const TString &string)
Method to convert from a particle name string into a PDG code.
Int_t code() const
The particle PDG code.
static TString string(Int_t code)
Method to convert from a PDG code to a particle name string.