Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 56 additions & 53 deletions PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/workflow-file]

Name of a workflow file must match the name of the main struct in it (without the PWG prefix). (Class implementation files should be in "Core" directories.)
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand Down Expand Up @@ -75,7 +75,7 @@
using namespace o2::framework;
using namespace o2::framework::expressions;

o2::common::core::MetadataHelper metadataInfo;
o2::common::core::MetadataHelper metadataInfo{};

static constexpr int nParameters = 1;
static const std::vector<std::string> tableNames{
Expand Down Expand Up @@ -143,7 +143,7 @@
// CCDB options
struct : ConfigurableGroup {
std::string prefix = "ccdb";
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};

Check failure on line 146 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/configurable]

Use lowerCamelCase for names of configurables and use the same name for the struct member as for the JSON string. (Declare the type and names on the same line.)
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
Expand Down Expand Up @@ -198,8 +198,8 @@
std::string prefix = "mixingOpts";
Configurable<int> n3bodyMixing{"n3bodyMixing", 0, "Number of decay3bodys to mix: 0 - value set to maximum bin entry in hDecay3BodyRadiusPhi, > 0 - manual setting"};
Configurable<int> mixingType{"mixingType", 0, "0: mix V0 from one event with bachelor from another, 1: mix pion and bachelor from one event with proton from another, 1: mix proton and bachelor from one event with pion from another "};
ConfigurableAxis bins3BodyRadius{"mixingOpts.bins3BodyRadius", {VARIABLE_WIDTH, 0.0f, 2.0f, 4.0f, 7.0f, 10.0f, 14.0f, 18.0f, 22.0f, 30.0f, 40.0f}, "Mixing bins - 3body radius"};

Check failure on line 201 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/configurable]

Use lowerCamelCase for names of configurables and use the same name for the struct member as for the JSON string. (Declare the type and names on the same line.)
ConfigurableAxis bins3BodyPhi{"mixingOpts.bins3BodyPhi", {VARIABLE_WIDTH, -180 * o2::constants::math::Deg2Rad, -120 * o2::constants::math::Deg2Rad, -60 * o2::constants::math::Deg2Rad, 0, 60 * o2::constants::math::Deg2Rad, 120 * o2::constants::math::Deg2Rad, 180 * o2::constants::math::Deg2Rad}, "Mixing bins - 3body phi (rad)"};

Check failure on line 202 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/configurable]

Use lowerCamelCase for names of configurables and use the same name for the struct member as for the JSON string. (Declare the type and names on the same line.)
ConfigurableAxis bins3BodyPhiDegree{"mixingOpts.bins3BodyPhiDegree", {VARIABLE_WIDTH, -180, -120, -60, 0, 60, 120, 180}, "Mixing bins - 3body phi (degree)"};
ConfigurableAxis bins3BodyPosZ{"mixingOpts.bins3BodyPosZ", {VARIABLE_WIDTH, -500.0f, -200.0f, -100.0f, -70.0f, -60.0f, -50.0f, -40.0f, -35.0f, -30.0f, -25.0f, -20.0f, -15.0f, -13.0f, -10.0f, -8.0f, -6.0f, -4.0f, -2.0f, 0.0f, 2.0f, 4.0f, 6.0f, 8.0f, 10.0f, 13.0f, 15.0f, 20.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f, 60.0f, 70.0f, 100.0f, 200.0f, 500.0f}, "3body SV z position"};
Configurable<bool> selectPVPosZ3bodyMixing{"selectPVPosZ3bodyMixing", true, "Select same pvPosZ events in case of 3body mixing"};
Expand All @@ -220,31 +220,31 @@

// Helper struct to contain MC information prior to filling
struct mc3Bodyinfo {
int label;
std::array<float, 3> genDecVtx{0.f};
std::array<float, 3> genMomentum{0.f};
float genCt;
float genPhi;
float genEta;
float genRapidity;
std::array<float, 3> genMomProton{0.f};
std::array<float, 3> genMomPion{0.f};
std::array<float, 3> genMomDeuteron{0.f};
bool isReco;
int motherLabel;
int motherPdgCode;
int daughterPrPdgCode;
int daughterPiPdgCode;
int daughterDePdgCode;
bool isDeuteronPrimary;
bool survivedEventSel;
int label = -1;
std::array<float, 3> genDecVtx{-1.f, -1.f, -1.f};
std::array<float, 3> genMomentum{-1.f, -1.f, -1.f};
float genCt = -1.f;
float genPhi = -1.f;
float genEta = -1.f;
float genRapidity = -1.f;
std::array<float, 3> genMomProton{-1.f, -1.f, -1.f};
std::array<float, 3> genMomPion{-1.f, -1.f, -1.f};
std::array<float, 3> genMomDeuteron{-1.f, -1.f, -1.f};
bool isReco = false;
int motherLabel = -1;
int motherPdgCode = -1;
int daughterPrPdgCode = -1;
int daughterPiPdgCode = -1;
int daughterDePdgCode = -1;
bool isDeuteronPrimary = false;
bool survivedEventSel = false;
};
mc3Bodyinfo this3BodyMCInfo;

// CCDB and magnetic field
int mRunNumber;
float d_bz;
Service<o2::ccdb::BasicCCDBManager> ccdb;
int mRunNumber = 0;
float d_bz = 0.f;
Service<o2::ccdb::BasicCCDBManager> ccdb{};
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
std::unordered_map<int, float> ccdbCache; // Maps runNumber -> d_bz
o2::base::MatLayerCylSet* lut = nullptr;
Expand Down Expand Up @@ -305,7 +305,7 @@
}
matCorr = o2::base::Propagator::MatCorrType::USEMatCorrTGeo;
}
if (useMatCorrType == 2) {

Check failure on line 308 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGF(info, "LUT correction requested, loading LUT");
lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(ccdbConfigurations.lutPath));
matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
Expand Down Expand Up @@ -379,7 +379,7 @@

// list enabled tables
for (int i = 0; i < nTables; i++) {
if (mEnabledTables[i]) {
if (mEnabledTables[i] != 0) {
LOGF(info, " -~> Table enabled: %s", tableNames[i]);
}
}
Expand Down Expand Up @@ -433,26 +433,26 @@
}
}

if (mEnabledTables[kVtx3BodyDatas] && mEnabledTables[kMcVtx3BodyDatas]) {
if (mEnabledTables[kVtx3BodyDatas] != 0 && mEnabledTables[kMcVtx3BodyDatas] != 0) {
LOG(fatal) << "Tables Vtx3BodyDatas and McVtx3BodyDatas cannot both be enabled at the same time. Choose one!";
}

// Add histograms separately for different process functions
if (doprocessRealData == true || doprocessMonteCarlo == true) {
if (doprocessRealData || doprocessMonteCarlo) {
auto hEventCounter = registry.add<TH1>("Counters/hEventCounter", "hEventCounter", HistType::kTH1D, {{2, 0.0f, 2.0f}});
hEventCounter->GetXaxis()->SetBinLabel(1, "all");
hEventCounter->GetXaxis()->SetBinLabel(2, "selected");
hEventCounter->LabelsOption("v");
}

if (doprocessMonteCarlo == true) {
if (doprocessMonteCarlo) {
auto hMcEventCounter = registry.add<TH1>("Counters/hMcEventCounter", "hMcEventCounter", HistType::kTH1D, {{2, 0.0f, 2.0f}});
hMcEventCounter->GetXaxis()->SetBinLabel(1, "all");
hMcEventCounter->GetXaxis()->SetBinLabel(2, "reconstructed");
hMcEventCounter->LabelsOption("v");
}

if (doprocessRealData == true || doprocessRealDataReduced == true || doprocessMonteCarlo == true) {
if (doprocessRealData || doprocessRealDataReduced || doprocessMonteCarlo) {
if (doTrackQA) { // histograms for all daughter tracks of (selected) 3body candidates
registry.add("QA/Tracks/hTrackProtonTPCNcls", "hTrackProtonTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}});
registry.add("QA/Tracks/hTrackPionTPCNcls", "hTrackPionTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}});
Expand Down Expand Up @@ -482,7 +482,7 @@
}
}

if (doprocessRealDataReduced3bodyMixing == true) {
if (doprocessRealDataReduced3bodyMixing) {
auto h3bodyCombinationCounter = registry.add<TH1>("Mixing/h3bodyCombinationCounter", "h3bodyCombinationCounter", HistType::kTH1D, {{4, 0.0f, 4.0f}});
h3bodyCombinationCounter->GetXaxis()->SetBinLabel(1, "total");
h3bodyCombinationCounter->GetXaxis()->SetBinLabel(2, "not same collision");
Expand Down Expand Up @@ -513,15 +513,15 @@
}

auto timestamp = bc.timestamp();
o2::parameters::GRPMagField* grpmag = 0x0;
o2::parameters::GRPMagField* grpmag = nullptr;
ccdb->clearCache(ccdbConfigurations.grpmagPath);
grpmag = ccdb->getSpecific<o2::parameters::GRPMagField>(ccdbConfigurations.grpmagPath, timestamp);
if (!grpmag) {
LOG(fatal) << "Got nullptr from CCDB for path " << ccdbConfigurations.grpmagPath << " of object GRPMagField for timestamp " << timestamp;
}
o2::base::Propagator::initFieldFromGRP(grpmag);
// Fetch magnetic field from ccdb for current collision
auto d_bz = o2::base::Propagator::Instance()->getNominalBz();
d_bz = o2::base::Propagator::Instance()->getNominalBz();
LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG";

// set magnetic field value for DCA fitter
Expand All @@ -532,7 +532,7 @@
KFParticle::SetField(d_bz);
#endif

if (useMatCorrType == 2) {

Check failure on line 535 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
// setMatLUT only after magfield has been initalized
// (setMatLUT has implicit and problematic init field call if not)
LOG(info) << "Loading material look-up table for timestamp: " << timestamp;
Expand All @@ -550,9 +550,9 @@

float getMagFieldFromRunNumber(int runNumber)
{
float magField;
float magField{};
// Check if the CCDB data for this run is already cached
if (ccdbCache.find(runNumber) != ccdbCache.end()) {
if (ccdbCache.contains(runNumber)) {
LOG(debug) << "CCDB data already cached for run " << runNumber;
magField = ccdbCache[runNumber];
// if not, retrieve it from CCDB
Expand Down Expand Up @@ -592,7 +592,7 @@
helper.fitterV0.setBz(magField);
helper.fitter3body.setBz(magField);

if (useMatCorrType == 2) {

Check failure on line 595 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
// setMatLUT only after magfield has been initalized (setMatLUT has implicit and problematic init field call if not)
o2::base::Propagator::Instance()->setMatLUT(lut);
}
Expand Down Expand Up @@ -649,7 +649,7 @@
}

// event selection
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || (collision.posZ() >= 10.0f || collision.posZ() <= -10.0f)) {

Check failure on line 652 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
continue;
}

Expand Down Expand Up @@ -702,7 +702,7 @@
if (!collision.selection_bit(aod::evsel::kNoITSROFrameBorder) && !disableITSROFCut) { // ITS ROF boarder cut if not disabled
continue;
}
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || (collision.posZ() >= 10.0f || collision.posZ() <= -10.0f)) {

Check failure on line 705 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
continue;
}
// Zorro
Expand All @@ -729,10 +729,10 @@
auto trackPion = protonSign > 0 ? trackNeg : trackPos;

// get deuteron TOF PID
float tofNSigmaDeuteron;
float tofNSigmaDeuteron{};
if constexpr (!soa::is_table<TBCs>) { // running over derived data
tofNSigmaDeuteron = trackDeuteron.tofNSigmaDe();
} else if constexpr (soa::is_table<TBCs>) { // running over AO2Ds
} else { // running over AO2Ds
if constexpr (soa::is_table<TMCParticles>) { // running over MC (track table with labels)
tofNSigmaDeuteron = getTOFnSigma<true /*isMC*/, TCollisions>(mRespParamsV3, collision, trackDeuteron);
} else { // running over real data
Expand Down Expand Up @@ -803,11 +803,10 @@
if (!trackProton.has_mcParticle() || !trackPion.has_mcParticle() || !trackDeuteron.has_mcParticle()) {
if (!doStoreMcBkg) {
continue; // if not storing MC background, skip candidates where at least one daughter is not matched to MC particle
} else {
this3BodyMCInfo.motherLabel = -5; // at least one of the daughters not matched to MC particle
// fill analysis table (only McVtx3BodyDatas is filled here)
fillAnalysisTables();
}
this3BodyMCInfo.motherLabel = -5; // at least one of the daughters not matched to MC particle
// fill analysis table (only McVtx3BodyDatas is filled here)
fillAnalysisTables();
} else { // all daughters are matched to MC particles, get their MC info
// get MC daughter particles
auto mcTrackProton = trackProton.template mcParticle_as<aod::McParticles>();
Expand Down Expand Up @@ -880,18 +879,24 @@
bool haveProton = false, havePion = false, haveDeuteron = false;
bool haveAntiProton = false, haveAntiPion = false, haveAntiDeuteron = false;
for (const auto& mcparticleDaughter : mcparticle.template daughters_as<TMCParticles>()) {
if (mcparticleDaughter.pdgCode() == PDG_t::kProton)
if (mcparticleDaughter.pdgCode() == PDG_t::kProton) {
haveProton = true;
if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar)
}
if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar) {
haveAntiProton = true;
if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus)
}
if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus) {
havePion = true;
if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus)
}
if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus) {
haveAntiPion = true;
if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron)
}
if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) {
haveDeuteron = true;
if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron)
}
if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) {
haveAntiDeuteron = true;
}
}

// check if hypertriton decayed via 3-body decay and is particle or anti-particle
Expand Down Expand Up @@ -1048,7 +1053,7 @@
doMixing(collision1, trackProton0, trackPion1, trackDeuteron1, magFieldCol1);
}
// mix pion
if (mixingOpts.mixingType == 2) {

Check failure on line 1056 in PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
doMixing(collision0, trackProton0, trackPion1, trackDeuteron0, magFieldCol0);
doMixing(collision1, trackProton1, trackPion0, trackDeuteron1, magFieldCol1);
}
Expand Down Expand Up @@ -1077,13 +1082,13 @@
void fillAnalysisTables()
{
// generate analysis tables
if (mEnabledTables[kDecay3BodyIndices]) {
if (mEnabledTables[kDecay3BodyIndices] != 0) {
products.decay3bodyindices(helper.decay3body.decay3bodyID,
helper.decay3body.protonID, helper.decay3body.pionID, helper.decay3body.deuteronID,
helper.decay3body.collisionID);
registry.fill(HIST("Counters/hTableBuildingStatistics"), kDecay3BodyIndices);
}
if (mEnabledTables[kVtx3BodyDatas]) {
if (mEnabledTables[kVtx3BodyDatas] != 0) {
products.vtx3bodydatas(helper.decay3body.sign,
helper.decay3body.mass, helper.decay3body.massV0,
helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2],
Expand All @@ -1109,14 +1114,14 @@
helper.decay3body.pidForTrackingDeuteron);
registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyDatas);
}
if (mEnabledTables[kVtx3BodyCovs]) {
if (mEnabledTables[kVtx3BodyCovs] != 0) {
products.vtx3bodycovs(helper.decay3body.covProton.data(),
helper.decay3body.covPion.data(),
helper.decay3body.covDeuteron.data(),
helper.decay3body.covariance.data());
registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyCovs);
}
if (mEnabledTables[kMcVtx3BodyDatas]) {
if (mEnabledTables[kMcVtx3BodyDatas] != 0) {
products.mcvtx3bodydatas(helper.decay3body.sign,
helper.decay3body.mass, helper.decay3body.massV0,
helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2],
Expand Down Expand Up @@ -1182,9 +1187,8 @@
// fill analysis tables with built candidate
fillAnalysisTables();
return;
} else {
return;
}
return;
}

// ______________________________________________________________
Expand Down Expand Up @@ -1259,9 +1263,8 @@
// check if the common mother is a hypertriton
if (std::abs(momPdgCode) == o2::constants::physics::Pdg::kHyperTriton) {
return momID;
} else {
return -1; // common mother found but not a hypertriton
}
return -1; // common mother found but not a hypertriton
}

// ______________________________________________________________
Expand Down Expand Up @@ -1339,7 +1342,7 @@
auto yAxis = registry.get<TH2>(HIST("Mixing/hDecay3BodyRadiusPhi"))->GetYaxis();

for (const auto& decay3body : decay3bodys) {
int bin_Radius, bin_Phi;
int bin_Radius{}, bin_Phi{};
if (decay3bodyBuilderOpts.useKFParticle) {
bin_Radius = xAxis->FindBin(decay3body.radiusKF());
bin_Phi = yAxis->FindBin(decay3body.phiKF());
Expand Down
4 changes: 2 additions & 2 deletions PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ struct TrackedHypertritonRecoTask {
bool isSignal = false;
bool isRecoMCCollision = false;
bool survivedEventSelection = false;
uint8_t fakeHeITSLayerMap = 0;
uint8_t fakeHeITSLayerMap{};
int motherLabel = -1;
int statusCode = 0;
};
Expand Down Expand Up @@ -779,7 +779,7 @@ struct TrackedHypertritonRecoTask {
}

template <class TTracksTo, typename TTracked3body>
std::array<float, 2> getItsTrackDCAToSV(TTracked3body tracked3Body)
std::array<float, 2> getItsTrackDCAToSV(TTracked3body const& tracked3Body)
{
const auto itsTrack = tracked3Body.template itsTrack_as<TTracksTo>();
auto itsTrackParCov = getTrackParCov(itsTrack);
Expand Down
Loading