Skip to content

Commit

Permalink
[PWGCF] DptDpt - Splitting the PID QC information (AliceO2Group#8754)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor <[email protected]>
  • Loading branch information
victor-gonzalez and Victor authored Dec 1, 2024
1 parent 62bc61e commit 4a5c898
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 113 deletions.
11 changes: 7 additions & 4 deletions PWGCF/TableProducer/dptdptfilter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "PWGCF/DataModel/DptDptFiltered.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "Common/DataModel/CollisionAssociationTables.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Framework/runDataProcessing.h"
#include "Framework/RunningWorkflowInfo.h"
#include <TROOT.h>
Expand Down Expand Up @@ -778,6 +779,7 @@ struct DptDptFilterTracks {
"PID criteria for muons"};

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

Expand Down Expand Up @@ -821,7 +823,6 @@ struct DptDptFilterTracks {
fSystem = getSystemType(tmpstr);
getTaskOptionValue(initContext, "dpt-dpt-filter", "datatype", tmpstr, false);
fDataType = getDataType(tmpstr);
fPDG = TDatabasePDG::Instance();

/* required ambiguous tracks checks? */
if (dofilterDetectorLevelWithoutPIDAmbiguous || dofilterDetectorLevelWithPIDAmbiguous || dofilterDetectorLevelWithFullPIDAmbiguous ||
Expand Down Expand Up @@ -1181,9 +1182,10 @@ struct DptDptFilterTracks {
}

for (auto const& particle : particles) {
float charge = getCharge(particle);

int8_t pid = -1;
auto pdgpart = fPDG->GetParticle(particle.pdgCode());
float charge = pdgpart != nullptr ? getCharge(pdgpart->Charge()) : 0;

if (charge != 0) {
if (particle.has_mcCollision() && (particle.template mcCollision_as<soa::Join<aod::McCollisions, aod::DptDptCFGenCollisionsInfo>>()).collisionaccepted()) {
auto mccollision = particle.template mcCollision_as<soa::Join<aod::McCollisions, aod::DptDptCFGenCollisionsInfo>>();
Expand Down Expand Up @@ -1505,8 +1507,9 @@ inline int8_t DptDptFilterTracks::identifySecFromMaterialParticle(ParticleObject
template <typename ParticleObject, typename MCCollisionObject>
inline int8_t DptDptFilterTracks::selectParticle(ParticleObject const& particle, MCCollisionObject const& mccollision)
{
float charge = getCharge(particle);
int8_t sp = -127;
auto pdgpart = fPDG->GetParticle(particle.pdgCode());
float charge = pdgpart != nullptr ? getCharge(pdgpart->Charge()) : 0;
if (charge != 0) {
/* before particle selection */
fillParticleHistosBeforeSelection(particle, mccollision, charge);
Expand Down
15 changes: 3 additions & 12 deletions PWGCF/TableProducer/dptdptfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ float particleMaxDCAxy = 999.9f;
float particleMaxDCAZ = 999.9f;
bool traceCollId0 = false;

TDatabasePDG* fPDG = nullptr;

inline TriggerSelectionType getTriggerSelection(std::string const& triggstr)
{
if (triggstr.empty() || triggstr == "MB") {
Expand Down Expand Up @@ -1107,14 +1105,9 @@ void exploreMothers(ParticleObject& particle, MCCollisionObject& collision)
}
}

template <typename ParticleObject>
inline float getCharge(ParticleObject& particle)
inline float getCharge(float pdgCharge)
{
float charge = 0.0;
TParticlePDG* pdgparticle = fPDG->GetParticle(particle.pdgCode());
if (pdgparticle != nullptr) {
charge = (pdgparticle->Charge() / 3 >= 1) ? 1.0 : ((pdgparticle->Charge() / 3 <= -1) ? -1.0 : 0);
}
float charge = (pdgCharge / 3 >= 1) ? 1.0 : ((pdgCharge / 3 <= -1) ? -1.0 : 0);
return charge;
}

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

float charge = getCharge(particle);

if (particle.isPhysicalPrimary()) {
if ((particle.mcCollisionId() == 0) && traceCollId0) {
LOGF(info, "Particle %d passed isPhysicalPrimary", particle.globalIndex());
}

if (ptlow < particle.pt() && particle.pt() < ptup && etalow < particle.eta() && particle.eta() < etaup) {
return (charge != 0) ? true : false;
return true;
}
} else {
if ((particle.mcCollisionId() == 0) && traceCollId0) {
Expand Down
10 changes: 5 additions & 5 deletions PWGCF/Tasks/match-reco-gen.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Framework/runDataProcessing.h"
#include "PWGCF/Core/AnalysisConfigurableCuts.h"
#include "PWGCF/DataModel/DptDptFiltered.h"
#include "PWGCF/TableProducer/dptdptfilter.h"
#include <TDatabasePDG.h>
#include <TDirectory.h>
#include <TFolder.h>
#include <TH1.h>
Expand Down Expand Up @@ -71,6 +71,7 @@ struct CheckGeneratorLevelVsDetectorLevel {
Configurable<bool> cfgTrackCollAssoc{"trackcollassoc", false, "Track collision id association, track-mcparticle-mccollision vs. track-collision-mccollision: true, false. Default false"};

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

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

for (auto& part : mcParticles) {
for (auto const& part : mcParticles) {
auto pdgpart = fPDG->GetParticle(part.pdgCode());
if (pdgpart != nullptr) {
float charge = (pdgpart->Charge() >= 3) ? 1.0 : ((pdgpart->Charge() <= -3) ? -1.0 : 0.0);
float charge = getCharge(pdgpart->Charge());
if (charge != 0.0) {
ngen++;
}
Expand Down Expand Up @@ -394,7 +394,7 @@ struct CheckGeneratorLevelVsDetectorLevel {
for (auto& part : mcParticles) {
auto pdgpart = fPDG->GetParticle(part.pdgCode());
if (pdgpart != nullptr) {
float charge = (pdgpart->Charge() >= 3) ? 1.0 : ((pdgpart->Charge() <= -3) ? -1.0 : 0.0);
float charge = getCharge(pdgpart->Charge());
if (charge != 0.0) {
ngen++;
}
Expand Down
Loading

0 comments on commit 4a5c898

Please sign in to comment.