Skip to content

Commit 4a5c898

Browse files
victor-gonzalezVictor
andauthored
[PWGCF] DptDpt - Splitting the PID QC information (AliceO2Group#8754)
Co-authored-by: Victor <[email protected]>
1 parent 62bc61e commit 4a5c898

File tree

4 files changed

+228
-113
lines changed

4 files changed

+228
-113
lines changed

PWGCF/TableProducer/dptdptfilter.cxx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "PWGCF/DataModel/DptDptFiltered.h"
3333
#include "Common/DataModel/TrackSelectionTables.h"
3434
#include "Common/DataModel/CollisionAssociationTables.h"
35+
#include "Framework/O2DatabasePDGPlugin.h"
3536
#include "Framework/runDataProcessing.h"
3637
#include "Framework/RunningWorkflowInfo.h"
3738
#include <TROOT.h>
@@ -778,6 +779,7 @@ struct DptDptFilterTracks {
778779
"PID criteria for muons"};
779780

780781
OutputObj<TList> fOutput{"DptDptFilterTracksInfo", OutputObjHandlingPolicy::AnalysisObject};
782+
Service<o2::framework::O2DatabasePDG> fPDG;
781783
PIDSpeciesSelection pidselector;
782784
bool checkAmbiguousTracks = false;
783785

@@ -821,7 +823,6 @@ struct DptDptFilterTracks {
821823
fSystem = getSystemType(tmpstr);
822824
getTaskOptionValue(initContext, "dpt-dpt-filter", "datatype", tmpstr, false);
823825
fDataType = getDataType(tmpstr);
824-
fPDG = TDatabasePDG::Instance();
825826

826827
/* required ambiguous tracks checks? */
827828
if (dofilterDetectorLevelWithoutPIDAmbiguous || dofilterDetectorLevelWithPIDAmbiguous || dofilterDetectorLevelWithFullPIDAmbiguous ||
@@ -1181,9 +1182,10 @@ struct DptDptFilterTracks {
11811182
}
11821183

11831184
for (auto const& particle : particles) {
1184-
float charge = getCharge(particle);
1185-
11861185
int8_t pid = -1;
1186+
auto pdgpart = fPDG->GetParticle(particle.pdgCode());
1187+
float charge = pdgpart != nullptr ? getCharge(pdgpart->Charge()) : 0;
1188+
11871189
if (charge != 0) {
11881190
if (particle.has_mcCollision() && (particle.template mcCollision_as<soa::Join<aod::McCollisions, aod::DptDptCFGenCollisionsInfo>>()).collisionaccepted()) {
11891191
auto mccollision = particle.template mcCollision_as<soa::Join<aod::McCollisions, aod::DptDptCFGenCollisionsInfo>>();
@@ -1505,8 +1507,9 @@ inline int8_t DptDptFilterTracks::identifySecFromMaterialParticle(ParticleObject
15051507
template <typename ParticleObject, typename MCCollisionObject>
15061508
inline int8_t DptDptFilterTracks::selectParticle(ParticleObject const& particle, MCCollisionObject const& mccollision)
15071509
{
1508-
float charge = getCharge(particle);
15091510
int8_t sp = -127;
1511+
auto pdgpart = fPDG->GetParticle(particle.pdgCode());
1512+
float charge = pdgpart != nullptr ? getCharge(pdgpart->Charge()) : 0;
15101513
if (charge != 0) {
15111514
/* before particle selection */
15121515
fillParticleHistosBeforeSelection(particle, mccollision, charge);

PWGCF/TableProducer/dptdptfilter.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,6 @@ float particleMaxDCAxy = 999.9f;
352352
float particleMaxDCAZ = 999.9f;
353353
bool traceCollId0 = false;
354354

355-
TDatabasePDG* fPDG = nullptr;
356-
357355
inline TriggerSelectionType getTriggerSelection(std::string const& triggstr)
358356
{
359357
if (triggstr.empty() || triggstr == "MB") {
@@ -1107,14 +1105,9 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision)
11071105
}
11081106
}
11091107

1110-
template <typename ParticleObject>
1111-
inline float getCharge(ParticleObject& particle)
1108+
inline float getCharge(float pdgCharge)
11121109
{
1113-
float charge = 0.0;
1114-
TParticlePDG* pdgparticle = fPDG->GetParticle(particle.pdgCode());
1115-
if (pdgparticle != nullptr) {
1116-
charge = (pdgparticle->Charge() / 3 >= 1) ? 1.0 : ((pdgparticle->Charge() / 3 <= -1) ? -1.0 : 0);
1117-
}
1110+
float charge = (pdgCharge / 3 >= 1) ? 1.0 : ((pdgCharge / 3 <= -1) ? -1.0 : 0);
11181111
return charge;
11191112
}
11201113

@@ -1129,15 +1122,13 @@ inline bool acceptParticle(ParticleObject& particle, MCCollisionObject const&)
11291122
return false;
11301123
}
11311124

1132-
float charge = getCharge(particle);
1133-
11341125
if (particle.isPhysicalPrimary()) {
11351126
if ((particle.mcCollisionId() == 0) && traceCollId0) {
11361127
LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex());
11371128
}
11381129

11391130
if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) {
1140-
return (charge != 0) ? true : false;
1131+
return true;
11411132
}
11421133
} else {
11431134
if ((particle.mcCollisionId() == 0) && traceCollId0) {

PWGCF/Tasks/match-reco-gen.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
#include "Framework/ASoAHelpers.h"
2323
#include "Framework/AnalysisDataModel.h"
2424
#include "Framework/AnalysisTask.h"
25+
#include "Framework/O2DatabasePDGPlugin.h"
2526
#include "Framework/runDataProcessing.h"
2627
#include "PWGCF/Core/AnalysisConfigurableCuts.h"
2728
#include "PWGCF/DataModel/DptDptFiltered.h"
2829
#include "PWGCF/TableProducer/dptdptfilter.h"
29-
#include <TDatabasePDG.h>
3030
#include <TDirectory.h>
3131
#include <TFolder.h>
3232
#include <TH1.h>
@@ -71,6 +71,7 @@ struct CheckGeneratorLevelVsDetectorLevel {
7171
Configurable<bool> cfgTrackCollAssoc{"trackcollassoc", false, "Track collision id association, track-mcparticle-mccollision vs. track-collision-mccollision: true, false. Default false"};
7272

7373
HistogramRegistry histos{"RecoGenHistograms", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
74+
Service<o2::framework::O2DatabasePDG> fPDG;
7475
typedef enum { kBEFORE = 0,
7576
kAFTER } beforeafterselection;
7677
typedef enum { kPOSITIVE = 0,
@@ -110,7 +111,6 @@ struct CheckGeneratorLevelVsDetectorLevel {
110111
/* if the system type is not known at this time, we have to put the initialization somewhere else */
111112
fSystem = getSystemType(cfgSystem);
112113
fDataType = getDataType(cfgDataType);
113-
fPDG = TDatabasePDG::Instance();
114114

115115
AxisSpec deltaEta = {100, -2, 2, "#Delta#eta"};
116116
AxisSpec deltaPhi = {100, 0, constants::math::TwoPI, "#Delta#varphi (rad)"};
@@ -337,10 +337,10 @@ struct CheckGeneratorLevelVsDetectorLevel {
337337
size_t nreco = tracks.size();
338338
size_t ngen = 0;
339339

340-
for (auto& part : mcParticles) {
340+
for (auto const& part : mcParticles) {
341341
auto pdgpart = fPDG->GetParticle(part.pdgCode());
342342
if (pdgpart != nullptr) {
343-
float charge = (pdgpart->Charge() >= 3) ? 1.0 : ((pdgpart->Charge() <= -3) ? -1.0 : 0.0);
343+
float charge = getCharge(pdgpart->Charge());
344344
if (charge != 0.0) {
345345
ngen++;
346346
}
@@ -394,7 +394,7 @@ struct CheckGeneratorLevelVsDetectorLevel {
394394
for (auto& part : mcParticles) {
395395
auto pdgpart = fPDG->GetParticle(part.pdgCode());
396396
if (pdgpart != nullptr) {
397-
float charge = (pdgpart->Charge() >= 3) ? 1.0 : ((pdgpart->Charge() <= -3) ? -1.0 : 0.0);
397+
float charge = getCharge(pdgpart->Charge());
398398
if (charge != 0.0) {
399399
ngen++;
400400
}

0 commit comments

Comments
 (0)