diff --git a/doc/mainpage.dox.in b/doc/mainpage.dox.in index 3099fbc..2e61cd1 100644 --- a/doc/mainpage.dox.in +++ b/doc/mainpage.dox.in @@ -1,33 +1,33 @@ /*! \copyright Copyright 2004-2019 University of Warwick
Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License. */ /*! \authors Laura++ package authors:
John Back, Paul Harrison, Thomas Latham */ /*! \mainpage Welcome to the Laura++ documentation, please use the links at the top of the page to navigate to particular classes or namespaces. The Laura++ project webpages can be found at @PROJECT_HOMEPAGE_URL@ -See also the [README](@PROJECT_SOURCE_DIR@/README.md) and [release notes](@PROJECT_SOURCE_DIR@/doc/ReleaseNotes.md) for more information. +See also the [README](@PROJECT_SOURCE_DIR@/README.md) and [release notes](@PROJECT_SOURCE_DIR@/ReleaseNotes.md) for more information. */ diff --git a/src/LauDatabasePDG.cc.in b/src/LauDatabasePDG.cc.in index 01e4392..204773f 100644 --- a/src/LauDatabasePDG.cc.in +++ b/src/LauDatabasePDG.cc.in @@ -1,326 +1,326 @@ /* Copyright 2008 University of Warwick Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* Laura++ package authors: John Back Paul Harrison Thomas Latham */ /*! \file LauDatabasePDG.cc \brief File containing implementation of LauDatabasePDG class. */ #include "LauDatabasePDG.hh" #include "LauJsonTools.hh" #include "LauParticlePDG.hh" #include "TDatabasePDG.h" #include #include -ClassImp(LauDatabasePDG) - TString LauDatabasePDG::ppJsonFile_{"@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/@CMAKE_PROJECT_NAME@/ParticleProperties.json"}; +ClassImp(LauDatabasePDG) + // Constructor LauDatabasePDG::LauDatabasePDG() { addMissingParticles(); readParticleProperties(); } // Private static method to access the instance // Will create it and add the missing particles if it doesn't already exist LauDatabasePDG& LauDatabasePDG::get() { static LauDatabasePDG theInstance; return theInstance; } // All static methods grab the instance and call the private non-static // methods - this ensures that the database exists and that the missing // particles are added to it. const LauParticlePDG* LauDatabasePDG::particle(const Int_t theCode) { return LauDatabasePDG::get().createParticle( theCode ); } const LauParticlePDG* LauDatabasePDG::particle(const TString& theString) { return LauDatabasePDG::get().createParticle( theString ); } TString LauDatabasePDG::string(const Int_t theCode) { return LauDatabasePDG::get().pdgName( theCode ); } Int_t LauDatabasePDG::code(const TString& theString) { return LauDatabasePDG::get().pdgCode( theString ); } Double_t LauDatabasePDG::particleMass(const Int_t theCode) { return LauDatabasePDG::get().mass( theCode ); } Double_t LauDatabasePDG::particleMass(const TString& theString) { return LauDatabasePDG::get().mass( theString ); } // The following method adds particles to the ROOT database that are // missing from its default setup. This should only be called once, // in the constuctor of the single instance. void LauDatabasePDG::addMissingParticles() { TParticlePDG* part{nullptr}; TParticlePDG* antipart{nullptr}; // format is: // name, title, mass, stable?, width, 3*Q, category, PDG code part = theDatabase_.AddParticle("deuteron", "deuteron", 1.8756134, kTRUE, 0.0, 3, "Nucleus", 1011); antipart = theDatabase_.AddAntiParticle("anti-deuteron", -1011); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("tritium", "tritium", 2.80925, kTRUE, 0.0, 3, "Nucleus", 1021); antipart = theDatabase_.AddAntiParticle("anti-tritium", -1021); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("He3", "He3", 2.80923, kTRUE, 0.0, 6, "Nucleus", 1012); antipart = theDatabase_.AddAntiParticle("anti-He3", -1012); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("alpha", "alpha", 3.727417, kTRUE, 0.0, 3, "Nucleus", 1022); antipart = theDatabase_.AddAntiParticle("anti-alpha", -1022); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("eta_c(2S)", "eta_c(2S)", 3.628, kTRUE, 0.0195, 0, "Meson", 20441); part = theDatabase_.AddParticle("psi(3770)", "psi(3770)", 3.7699, kTRUE, 0.0236, 0, "Meson", 40443); part = theDatabase_.AddParticle("rho(2S)0", "rho(2S)0", 1.46, kTRUE, 0.31, 0, "Meson", 30113); part = theDatabase_.AddParticle("rho(2S)+", "rho(2S)+", 1.46, kTRUE, 0.31, 3, "Meson", 30213); antipart = theDatabase_.AddAntiParticle("rho(2S)-", -30213); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("rho(3S)0", "rho(3S)0", 1.46, kTRUE, 0.31, 0, "Meson", 40113); part = theDatabase_.AddParticle("rho(3S)+", "rho(3S)+", 1.46, kTRUE, 0.31, 3, "Meson", 40213); antipart = theDatabase_.AddAntiParticle("rho(3S)-", -40213); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("Xsu", "Xsu", 1.6, kTRUE, 0.5, 3, "Meson", 30353); antipart = theDatabase_.AddAntiParticle("anti-Xsu", -30353); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("Xu0", "Xu0", 1., kTRUE, 0., 0, "Special", 41); part = theDatabase_.AddParticle("Xu+", "Xu+", 1., kTRUE, 0., 3, "Special", 42); antipart = theDatabase_.AddAntiParticle("Xu-", -42); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("Xsd", "Xsd", 1.6, kTRUE, 0.5, 0, "Meson", 30343); antipart = theDatabase_.AddAntiParticle("anti-Xsd", -30343); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("K'*0", "K'*0", 1.414, kTRUE, 0.232, 0, "Meson", 100313); antipart = theDatabase_.AddAntiParticle("anti-K'*0", -100313); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("K'*+", "K'*+", 1.414, kTRUE, 0.232, 3, "Meson", 100323); antipart = theDatabase_.AddAntiParticle("K'*-", -100323); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("K''*0", "K''*0", 1.717, kTRUE, 0.322, 0, "Meson", 30313); antipart = theDatabase_.AddAntiParticle("anti-K''*0", -30313); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); part = theDatabase_.AddParticle("K''*+", "K''*+", 1.717, kTRUE, 0.322, 3, "Meson", 30323); antipart = theDatabase_.AddAntiParticle("K''*-", -30323); part->SetAntiParticle(antipart); antipart->SetAntiParticle(part); } void LauDatabasePDG::readParticleProperties() { // NB deliberately not using uniform initialisation here because of this issue: // https://json.nlohmann.me/home/faq/#brace-initialization-yields-arrays const nlohmann::json j = LauJsonTools::readJsonFile( ppJsonFile_.Data(), "", LauJsonTools::JsonType::Array ); if ( j.is_null() ) { std::cerr << "ERROR in LauDatabasePDG::readParticleProperties : unable to retrieve JSON array from root element of file \"" << ppJsonFile_ << "\"" << std::endl; return; } particleMasses_.clear(); const std::vector mandatoryElements { std::make_pair("code", LauJsonTools::JsonType::Number_Unsigned), std::make_pair("mass", LauJsonTools::JsonType::Number_Float) }; for ( const auto& massRecord : j ) { if ( ! LauJsonTools::checkObjectElements( massRecord, mandatoryElements ) ) { std::cerr << "WARNING in LauDatabasePDG::readParticleProperties : aborting processing due to mis-formatted elements" << std::endl; return; } } for ( const auto& massRecord : j ) { const auto code { LauJsonTools::getValue( massRecord, "code" ) }; const auto mass { LauJsonTools::getValue( massRecord, "mass" ) }; particleMasses_.insert( std::make_pair( code, mass ) ); } } // These next two methods are the ones that actually build-up our database. const LauParticlePDG* LauDatabasePDG::createParticle(const Int_t theCode) { // if we've already created this one simply return it auto particleIter { particles_.find(theCode) }; if ( particleIter != particles_.end() ) { return particleIter->second.get(); } // otherwise we'll have to make it... // first see if we have a mass stored Int_t massCode { theCode }; if ( theCode == 130 || theCode == 310 ) { // special case for KS and KS, which should use K0 code for mass look-up massCode = 311; } auto massIter { particleMasses_.find(TMath::Abs(theCode)) }; const Double_t mass { ( massIter != particleMasses_.end() ) ? massIter->second : 0.0 }; // next get the particle from the database TParticlePDG* theTParticle { theDatabase_.GetParticle( theCode ) }; if (theTParticle == nullptr) { std::cerr <<"ERROR in LauDatabasePDG::createParticle : Invalid PDG code: "< theParticleOwned { new LauParticlePDG{ theTParticle, mass } }; auto theParticle { theParticleOwned.get() }; auto [ _, ok ] = particles_.emplace( std::make_pair( theCode, std::move(theParticleOwned) ) ); if ( ! ok ) { std::cerr <<"ERROR in LauDatabasePDG::createParticle : Something went wrong inserting particle "<AntiParticle(); // check if we have a self-conjugate particle if ( theTAntiParticle == nullptr || theTAntiParticle == theTParticle ) { // if so then set it to be it's own anti-particle and return theParticle->setAntiParticle( theParticle ); if ( debug_ ) { std::cout <<"INFO in LauDatabasePDG::createParticle : Created self-conjugate particle "<GetName()<< std::endl; } return theParticle; } // otherwise make the particle's antiparticle and store it in the map std::unique_ptr antiParticleOwned { new LauParticlePDG{ theTAntiParticle, mass } }; auto antiParticle { antiParticleOwned.get() }; const Int_t conjCode { antiParticle->code() }; auto [ __, antiOK ] = particles_.emplace( std::make_pair( conjCode, std::move(antiParticleOwned) ) ); if ( ! antiOK ) { std::cerr <<"ERROR in LauDatabasePDG::createParticle : Something went wrong inserting anti-particle "<setAntiParticle( antiParticle ); antiParticle->setAntiParticle( theParticle ); if ( debug_ ) { std::cout <<"INFO in LauDatabasePDG::createParticle : Created particle "<GetName()<<" and its conjugate "<GetName()<< std::endl; } // and finally return the particle we've created return theParticle; } const LauParticlePDG* LauDatabasePDG::createParticle(const TString& theString) { // turn the string into a PDG code const Int_t theCode { this->pdgCode(theString) }; if ( theCode == 0 ) { std::cerr <<"ERROR in LauDatabasePDG::createParticle : Invalid particle string: "<createParticle(theCode); } Double_t LauDatabasePDG::mass(const Int_t theCode) { const LauParticlePDG* theParticle { this->createParticle(theCode) }; if ( theParticle == nullptr ) { return -1.0; } return theParticle->mass(); } Double_t LauDatabasePDG::mass(const TString& theString) { // turn the string into a PDG code const Int_t theCode { this->pdgCode(theString) }; if ( theCode == 0 ) { std::cerr <<"ERROR in LauDatabasePDG::mass : Invalid particle string: "<mass(theCode); } // These last two methods have to be independent of our own database since // they are used by the methods that create the particles and so we'd end // up with an infinite loop. Int_t LauDatabasePDG::pdgCode(const TString& theString) { TParticlePDG* theParticle = theDatabase_.GetParticle(theString); if (theParticle == nullptr) { std::cerr <<"ERROR in LauDatabasePDG::pdgCode : Invalid particle string: "<PdgCode(); } TString LauDatabasePDG::pdgName(const Int_t theCode) { TParticlePDG* theParticle = theDatabase_.GetParticle(theCode); if (theParticle == nullptr) { std::cerr <<"ERROR in LauDatabasePDG::pdgName : Invalid particle code: "<GetName(); }