Skip to content

Commit fc11d42

Browse files
committed
O2DatabasePDG service
This commit concerns the PDG database. It modifies/restructures existing code (from Generator/PDG) and wraps it into a new service "O2DatabasePDG". The new service returns a modified TDatabasePDG instance, in which ALICE particles have been added. Existing code can simply transform from the use of "TDatabasePDG::Instance" to "O2DatabasePDG::Instance". This transition is made easy via this commit. Also touching the DPL service that returns TDatabasePDG, so that O2Physics, Analysis automatically get the correctly augmended object. MCTrack has been modified to use the new service, fixing issues with wrong masses.
1 parent 04f7383 commit fc11d42

14 files changed

Lines changed: 618 additions & 355 deletions

File tree

DataFormats/simulation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ o2_add_library(SimulationDataFormat
1919
src/MCEventHeader.cxx
2020
src/CustomStreamers.cxx
2121
src/MCUtils.cxx
22+
src/O2DatabasePDG.cxx
2223
PUBLIC_LINK_LIBRARIES Microsoft.GSL::GSL
2324
O2::DetectorsCommonDataFormats
2425
O2::GPUCommon O2::DetectorsBase
@@ -42,6 +43,7 @@ o2_target_root_dictionary(
4243
include/SimulationDataFormat/MCEventStats.h
4344
include/SimulationDataFormat/IOMCTruthContainerView.h
4445
include/SimulationDataFormat/MCUtils.h
46+
include/SimulationDataFormat/O2DatabasePDG.h
4547
LINKDEF src/SimulationDataLinkDef.h)
4648
# note the explicit LINKDEF as the linkdef in src is
4749
#

DataFormats/simulation/include/SimulationDataFormat/MCTrack.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "SimulationDataFormat/ParticleStatus.h"
2020
#include "DetectorsCommonDataFormats/DetID.h"
2121
#include "Rtypes.h"
22-
#include "TDatabasePDG.h"
22+
#include "SimulationDataFormat/O2DatabasePDG.h"
2323
#include "TLorentzVector.h"
2424
#include "TMCProcess.h"
2525
#include "TMath.h"
@@ -29,6 +29,12 @@
2929

3030
namespace o2
3131
{
32+
33+
namespace MCTrackHelper
34+
{
35+
void printMassError(int pdg);
36+
};
37+
3238
/// Data class for storing Monte Carlo tracks processed by the Stack.
3339
/// An MCTrack can be a primary track put into the simulation or a
3440
/// secondary one produced by the transport through decay or interaction.
@@ -73,6 +79,8 @@ class MCTrackT
7379
Double_t GetStartVertexCoordinatesY() const { return mStartVertexCoordinatesY; }
7480
Double_t GetStartVertexCoordinatesZ() const { return mStartVertexCoordinatesZ; }
7581
Double_t GetStartVertexCoordinatesT() const { return mStartVertexCoordinatesT; }
82+
83+
/// return mass from PDG Database if known (print message in case cannot look up)
7684
Double_t GetMass() const;
7785

7886
Double_t GetEnergy() const;
@@ -363,15 +371,15 @@ inline void MCTrackT<T>::Print(Int_t trackId) const
363371
template <typename T>
364372
inline Double_t MCTrackT<T>::GetMass() const
365373
{
366-
if (TDatabasePDG::Instance()) {
367-
TParticlePDG* particle = TDatabasePDG::Instance()->GetParticle(mPdgCode);
374+
TDatabasePDG* pdgdb = O2DatabasePDG::Instance();
375+
if (pdgdb) {
376+
auto particle = pdgdb->GetParticle(mPdgCode);
368377
if (particle) {
369378
return particle->Mass();
370-
} else {
371-
return 0.;
372379
}
373380
}
374-
return 0.;
381+
MCTrackHelper::printMassError(mPdgCode);
382+
return 0; // coming here is a mistake which should not happen
375383
}
376384

377385
template <typename T>

0 commit comments

Comments
 (0)