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