Skip to content

Commit db4d927

Browse files
committed
Add the O2DatabasePDG::Mass function in the PDG tutorial
1 parent a4f00b5 commit db4d927

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

Tutorials/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ o2physics_add_dpl_workflow(event-mixing-validation
109109

110110
o2physics_add_dpl_workflow(mc-histograms
111111
SOURCES src/mcHistograms.cxx
112-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::FrameworkPhysicsSupport
112+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
113113
COMPONENT_NAME AnalysisTutorial)
114114

115115
o2physics_add_dpl_workflow(ccdbaccess
@@ -196,7 +196,7 @@ o2physics_add_dpl_workflow(conditional-expressions
196196

197197
o2physics_add_dpl_workflow(using-pdg
198198
SOURCES src/usingPDGService.cxx
199-
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore
199+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
200200
COMPONENT_NAME AnalysisTutorial)
201201

202202
o2physics_add_dpl_workflow(propagated-tracks
@@ -228,4 +228,3 @@ o2physics_add_dpl_workflow(consume
228228
SOURCES src/consume.cxx
229229
PUBLIC_LINK_LIBRARIES O2::Framework
230230
COMPONENT_NAME AnalysisTutorial)
231-

Tutorials/src/mcHistograms.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "Framework/AnalysisTask.h"
1818
#include "CommonConstants/MathConstants.h"
1919
#include "Framework/O2DatabasePDGPlugin.h"
20-
#include "TDatabasePDG.h"
2120

2221
using namespace o2;
2322
using namespace o2::framework;
@@ -42,15 +41,15 @@ struct VertexDistribution {
4241
// Simple analysis of PhysicalPrimary particles
4342
struct PhysicalPrimaryCharge {
4443
OutputObj<TH1F> charge{TH1F("charge_prim", "charge_prim", 100, -5, 5)};
45-
Service<O2DatabasePDG> pdgDB;
44+
Service<o2::framework::O2DatabasePDG> pdg;
4645

4746
void process(aod::McParticles const& mcParticles)
4847
{
4948
for (auto& particle : mcParticles) {
5049
if (!particle.isPhysicalPrimary()) {
5150
continue;
5251
}
53-
auto pdgParticle = pdgDB->GetParticle(particle.pdgCode());
52+
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
5453
if (!pdgParticle) {
5554
continue;
5655
}

Tutorials/src/usingPDGService.cxx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,31 @@
1111

1212
#include "Framework/AnalysisTask.h"
1313
#include "Framework/O2DatabasePDGPlugin.h"
14-
#include "TDatabasePDG.h"
1514
#include "Framework/runDataProcessing.h"
1615

1716
using namespace o2;
1817
using namespace o2::framework;
1918

2019
struct UsePdgDatabase {
21-
Service<O2DatabasePDG> pdg;
20+
Service<o2::framework::O2DatabasePDG> pdg;
2221
OutputObj<TH1F> particleCharges{TH1F("charges", ";charge;entries", 201, -10.1, 10.1)};
22+
OutputObj<TH1F> particleMasses{TH1F("masses", ";mass (GeV/#it{c}^{2});entries", 1000, 0., 10.)};
2323

2424
void process(aod::McCollision const&, aod::McParticles const& particles)
2525
{
26-
for (auto& particle : particles) {
27-
auto pdgInfo = pdg->GetParticle(particle.pdgCode());
26+
for (auto const& particle : particles) {
27+
auto pdgCode = particle.pdgCode();
28+
auto mass = pdg->Mass(pdgCode);
29+
if (mass < 0.) {
30+
continue;
31+
}
32+
particleMasses->Fill(mass);
33+
// LOGF(info, "PDG: %d %g", pdgCode, mass);
34+
auto pdgInfo = pdg->GetParticle(pdgCode);
2835
if (pdgInfo != nullptr) {
2936
particleCharges->Fill(pdgInfo->Charge());
3037
} else {
31-
LOGF(warn, "[%d] unknown particle with PDG code %d", particle.globalIndex(), particle.pdgCode());
38+
LOGF(warn, "[%d] unknown particle with PDG code %d", particle.globalIndex(), pdgCode);
3239
}
3340
}
3441
}

0 commit comments

Comments
 (0)