Skip to content

Commit

Permalink
PWGLF: add found tag in findable exercise (AliceO2Group#5991)
Browse files Browse the repository at this point in the history
* PWGLF: add found tag in findable exercise

* Fix default

* Many bugfixes

* Please consider the following formatting changes (#288)

* Changes in QA counting

* Please consider the following formatting changes (#289)

* Megalinter fix

* Please consider the following formatting changes (#290)

* Asymmetric V0MCCore build mode for duplicate handling

* Extra bookkeeping

* Please consider the following formatting changes (#291)

* Fix bugs

* Please consider the following formatting changes (#292)

* V0Cores vs V0MCCores: always interlink

* Please consider the following formatting changes (#293)

---------

Co-authored-by: ALICE Builder <[email protected]>
  • Loading branch information
ddobrigk and alibuild authored May 5, 2024
1 parent eac5efa commit a3737b7
Show file tree
Hide file tree
Showing 8 changed files with 531 additions and 161 deletions.
39 changes: 39 additions & 0 deletions PWGLF/DataModel/LFStrangenessTables.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,16 +693,40 @@ namespace v0data
DECLARE_SOA_INDEX_COLUMN(V0Data, v0Data); //! Index to V0Data entry
DECLARE_SOA_INDEX_COLUMN(V0fCData, v0fCData); //! Index to V0Data entry
DECLARE_SOA_INDEX_COLUMN_FULL(V0MC, v0MC, int, V0MCCores, "_MC"); //!
DECLARE_SOA_INDEX_COLUMN(V0MCCore, v0MCCore);
} // namespace v0data

DECLARE_SOA_TABLE(V0DataLink, "AOD", "V0DATALINK", //! Joinable table with V0s which links to V0Data which is not produced for all entries
o2::soa::Index<>, v0data::V0DataId, v0data::V0fCDataId);
DECLARE_SOA_TABLE(V0MCRefs, "AOD", "V0MCREF", //! index table when using AO2Ds
o2::soa::Index<>, v0data::V0MCId);
DECLARE_SOA_TABLE(V0CoreMCLabels, "AOD", "V0COREMCLABEL", //! optional table to refer to V0MCCores if not joinable
o2::soa::Index<>, v0data::V0MCCoreId);

using V0sLinked = soa::Join<V0s, V0DataLink>;
using V0Linked = V0sLinked::iterator;

namespace v0data
{
DECLARE_SOA_COLUMN(IsFound, isFound, bool); //! is this FindableV0 actually in the V0s table?
}

// Major bypass for simultaneous found vs findable study
DECLARE_SOA_TABLE(FindableV0s, "AOD", "FindableV0", //! Will store findable
o2::soa::Index<>, v0::CollisionId,
v0::PosTrackId, v0::NegTrackId,
v0::V0Type,
v0::IsStandardV0<v0::V0Type>,
v0::IsPhotonV0<v0::V0Type>,
v0::IsCollinearV0<v0::V0Type>,
o2::soa::Marker<1>);

DECLARE_SOA_TABLE(V0FoundTags, "AOD", "V0FoundTag", //! found or not?
v0data::IsFound);

using FindableV0sLinked = soa::Join<FindableV0s, V0DataLink>;
using FindableV0Linked = FindableV0sLinked::iterator;

// helper for building
namespace v0tag
{
Expand Down Expand Up @@ -1239,6 +1263,21 @@ using CascadeLinked = CascadesLinked::iterator;
using KFCascadesLinked = soa::Join<Cascades, KFCascDataLink>;
using KFCascadeLinked = KFCascadesLinked::iterator;

namespace cascdata
{
DECLARE_SOA_INDEX_COLUMN(FindableV0, findableV0); //! V0 index
DECLARE_SOA_COLUMN(IsFound, isFound, bool); //! is this FindableCascade actually in the Cascades table?
} // namespace cascdata

DECLARE_SOA_TABLE(FindableCascades, "AOD", "FINDABLECASCS", //! Run 3 cascade table
o2::soa::Index<>, cascade::CollisionId, cascdata::FindableV0Id, cascade::BachelorId, o2::soa::Marker<1>);

DECLARE_SOA_TABLE(CascFoundTags, "AOD", "CascFoundTag", //! found or not?
cascdata::IsFound);

using FindableCascadesLinked = soa::Join<FindableCascades, CascDataLink>;
using FindableCascadeLinked = FindableCascadesLinked::iterator;

namespace casctag
{
DECLARE_SOA_COLUMN(IsInteresting, isInteresting, bool); //! will this be built or not?
Expand Down
224 changes: 150 additions & 74 deletions PWGLF/TableProducer/Strangeness/cascadebuilder.cxx

Large diffs are not rendered by default.

96 changes: 56 additions & 40 deletions PWGLF/TableProducer/Strangeness/cascademcbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ struct cascademcbuilder {

void init(InitContext const&) {}

//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
// build cascade labels
void processCascades(aod::CascDatas const& casctable, aod::V0sLinked const&, aod::V0Datas const& /*v0table*/, aod::McTrackLabels const&, aod::McParticles const&)
template <typename TCascadeTable>
void generateCascadeMCinfo(TCascadeTable cascTable)
{
for (auto& casc : casctable) {
for (auto& casc : cascTable) {
int pdgCode = -1, pdgCodeMother = -1;
int pdgCodePositive = -1, pdgCodeNegative = -1, pdgCodeBachelor = -1, pdgCodeV0 = -1;
bool isPhysicalPrimary = false;
Expand All @@ -72,16 +71,16 @@ struct cascademcbuilder {
int lLabel = -1, lMotherLabel = -1;

// Acquire all three daughter tracks, please
auto lBachTrack = casc.bachelor_as<aod::McTrackLabels>();
auto lNegTrack = casc.negTrack_as<aod::McTrackLabels>();
auto lPosTrack = casc.posTrack_as<aod::McTrackLabels>();
auto lBachTrack = casc.template bachelor_as<aod::McTrackLabels>();
auto lNegTrack = casc.template negTrack_as<aod::McTrackLabels>();
auto lPosTrack = casc.template posTrack_as<aod::McTrackLabels>();

// Association check
// There might be smarter ways of doing this in the future
if (lNegTrack.has_mcParticle() && lPosTrack.has_mcParticle() && lBachTrack.has_mcParticle()) {
auto lMCBachTrack = lBachTrack.mcParticle_as<aod::McParticles>();
auto lMCNegTrack = lNegTrack.mcParticle_as<aod::McParticles>();
auto lMCPosTrack = lPosTrack.mcParticle_as<aod::McParticles>();
auto lMCBachTrack = lBachTrack.template mcParticle_as<aod::McParticles>();
auto lMCNegTrack = lNegTrack.template mcParticle_as<aod::McParticles>();
auto lMCPosTrack = lPosTrack.template mcParticle_as<aod::McParticles>();

pdgCodePositive = lMCPosTrack.pdgCode();
pdgCodeNegative = lMCNegTrack.pdgCode();
Expand All @@ -98,8 +97,8 @@ struct cascademcbuilder {

// Step 1: check if the mother is the same, go up a level
if (lMCNegTrack.has_mothers() && lMCPosTrack.has_mothers()) {
for (auto& lNegMother : lMCNegTrack.mothers_as<aod::McParticles>()) {
for (auto& lPosMother : lMCPosTrack.mothers_as<aod::McParticles>()) {
for (auto& lNegMother : lMCNegTrack.template mothers_as<aod::McParticles>()) {
for (auto& lPosMother : lMCPosTrack.template mothers_as<aod::McParticles>()) {
if (lNegMother == lPosMother) {
// acquire information
xlmc = lMCPosTrack.vx();
Expand All @@ -109,27 +108,29 @@ struct cascademcbuilder {

// if we got to this level, it means the mother particle exists and is the same
// now we have to go one level up and compare to the bachelor mother too
for (auto& lV0Mother : lNegMother.mothers_as<aod::McParticles>()) {
for (auto& lBachMother : lMCBachTrack.mothers_as<aod::McParticles>()) {
if (lV0Mother == lBachMother) {
lLabel = lV0Mother.globalIndex();
pdgCode = lV0Mother.pdgCode();
isPhysicalPrimary = lV0Mother.isPhysicalPrimary();
xmc = lMCBachTrack.vx();
ymc = lMCBachTrack.vy();
zmc = lMCBachTrack.vz();
px = lV0Mother.px();
py = lV0Mother.py();
pz = lV0Mother.pz();
if (lV0Mother.has_mothers()) {
for (auto& lV0GrandMother : lV0Mother.mothers_as<aod::McParticles>()) {
pdgCodeMother = lV0GrandMother.pdgCode();
lMotherLabel = lV0GrandMother.globalIndex();
if (lNegMother.has_mothers() && lMCBachTrack.has_mothers()) {
for (auto& lV0Mother : lNegMother.template mothers_as<aod::McParticles>()) {
for (auto& lBachMother : lMCBachTrack.template mothers_as<aod::McParticles>()) {
if (lV0Mother == lBachMother) {
lLabel = lV0Mother.globalIndex();
pdgCode = lV0Mother.pdgCode();
isPhysicalPrimary = lV0Mother.isPhysicalPrimary();
xmc = lMCBachTrack.vx();
ymc = lMCBachTrack.vy();
zmc = lMCBachTrack.vz();
px = lV0Mother.px();
py = lV0Mother.py();
pz = lV0Mother.pz();
if (lV0Mother.has_mothers()) {
for (auto& lV0GrandMother : lV0Mother.template mothers_as<aod::McParticles>()) {
pdgCodeMother = lV0GrandMother.pdgCode();
lMotherLabel = lV0GrandMother.globalIndex();
}
}
}
}
}
} // end conditional V0-bach pair
} // end conditional V0-bach pair
} // end has mothers
} // end neg = pos mother conditional
}
} // end loop neg/pos mothers
Expand All @@ -151,6 +152,20 @@ struct cascademcbuilder {
} // end casctable loop
}

//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
// build cascade labels
void processCascades(aod::CascDatas const& casctable, aod::V0sLinked const&, aod::V0Datas const& /*v0table*/, aod::McTrackLabels const&, aod::McParticles const&)
{
generateCascadeMCinfo(casctable);
}

//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
// build findable cascade labels
void processFindableCascades(aod::CascDatas const& casctable, aod::FindableV0sLinked const&, aod::V0Datas const& /*v0table*/, aod::McTrackLabels const&, aod::McParticles const&)
{
generateCascadeMCinfo(casctable);
}

//*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*+-+*
// build kf cascade labels
void processKFCascades(aod::KFCascDatas const& casctable, aod::V0s const&, aod::McTrackLabels const&, aod::McParticles const&)
Expand All @@ -159,25 +174,25 @@ struct cascademcbuilder {
int lLabel = -1;

// Acquire all three daughter tracks, please
auto lBachTrack = casc.bachelor_as<aod::McTrackLabels>();
auto lNegTrack = casc.negTrack_as<aod::McTrackLabels>();
auto lPosTrack = casc.posTrack_as<aod::McTrackLabels>();
auto lBachTrack = casc.template bachelor_as<aod::McTrackLabels>();
auto lNegTrack = casc.template negTrack_as<aod::McTrackLabels>();
auto lPosTrack = casc.template posTrack_as<aod::McTrackLabels>();

// Association check
// There might be smarter ways of doing this in the future
if (lNegTrack.has_mcParticle() && lPosTrack.has_mcParticle() && lBachTrack.has_mcParticle()) {
auto lMCBachTrack = lBachTrack.mcParticle_as<aod::McParticles>();
auto lMCNegTrack = lNegTrack.mcParticle_as<aod::McParticles>();
auto lMCPosTrack = lPosTrack.mcParticle_as<aod::McParticles>();
auto lMCBachTrack = lBachTrack.template mcParticle_as<aod::McParticles>();
auto lMCNegTrack = lNegTrack.template mcParticle_as<aod::McParticles>();
auto lMCPosTrack = lPosTrack.template mcParticle_as<aod::McParticles>();
// Step 1: check if the mother is the same, go up a level
if (lMCNegTrack.has_mothers() && lMCPosTrack.has_mothers()) {
for (auto& lNegMother : lMCNegTrack.mothers_as<aod::McParticles>()) {
for (auto& lPosMother : lMCPosTrack.mothers_as<aod::McParticles>()) {
for (auto& lNegMother : lMCNegTrack.template mothers_as<aod::McParticles>()) {
for (auto& lPosMother : lMCPosTrack.template mothers_as<aod::McParticles>()) {
if (lNegMother == lPosMother) {
// if we got to this level, it means the mother particle exists and is the same
// now we have to go one level up and compare to the bachelor mother too
for (auto& lV0Mother : lNegMother.mothers_as<aod::McParticles>()) {
for (auto& lBachMother : lMCBachTrack.mothers_as<aod::McParticles>()) {
for (auto& lV0Mother : lNegMother.template mothers_as<aod::McParticles>()) {
for (auto& lBachMother : lMCBachTrack.template mothers_as<aod::McParticles>()) {
if (lV0Mother == lBachMother) {
lLabel = lV0Mother.globalIndex();
}
Expand Down Expand Up @@ -289,6 +304,7 @@ struct cascademcbuilder {
}

PROCESS_SWITCH(cascademcbuilder, processCascades, "Produce regular cascade label tables", true);
PROCESS_SWITCH(cascademcbuilder, processFindableCascades, "Produce findable cascade label tables", false);
PROCESS_SWITCH(cascademcbuilder, processKFCascades, "Produce KF cascade label tables", false);
PROCESS_SWITCH(cascademcbuilder, processTrackedCascades, "Produce tracked cascade label tables", false);
PROCESS_SWITCH(cascademcbuilder, processBBTags, "Produce cascade bach-baryon correlation tags", true);
Expand Down
19 changes: 10 additions & 9 deletions PWGLF/TableProducer/Strangeness/cascademcfinder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
// [email protected]
//

#include <Math/Vector4D.h>
#include <cmath>
#include <array>
#include <cstdlib>

#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
Expand All @@ -40,7 +45,6 @@
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Centrality.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsParameters/GRPMagField.h"
#include "CCDB/BasicCCDBManager.h"

Expand All @@ -49,24 +53,21 @@
#include <TH1F.h>
#include <TH2F.h>
#include <TProfile.h>
#include <Math/Vector4D.h>
#include <TPDGCode.h>
#include <TDatabasePDG.h>
#include <cmath>
#include <array>
#include <cstdlib>

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using std::array;
using namespace ROOT::Math;

// WARNING: the cascade findable uses findable V0s as well
using LabeledTracks = soa::Join<aod::TracksIU, aod::TracksExtra, aod::McTrackLabels>;
using LabeledFullV0s = soa::Join<aod::V0s, aod::McFullV0Labels>;
using LabeledFullV0s = soa::Join<aod::FindableV0s, aod::McFullV0Labels>;

struct cascademcfinder {
Produces<aod::Cascades> cascades;
Produces<aod::FindableCascades> cascades;

HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};

Expand All @@ -89,8 +90,8 @@ struct cascademcfinder {
void init(InitContext&)
{
// initialize histograms
const AxisSpec axisNTimesCollRecoed{(int)10, -0.5f, +9.5f, ""};
const AxisSpec axisPt{(int)100, +0.0f, +10.0f, "p_{T} (GeV/c)"};
const AxisSpec axisNTimesCollRecoed{static_cast<int>(10), -0.5f, +9.5f, ""};
const AxisSpec axisPt{static_cast<int>(100), +0.0f, +10.0f, "p_{T} (GeV/c)"};

histos.add("hNTimesCollRecoed", "hNTimesCollRecoed", kTH1F, {axisNTimesCollRecoed});

Expand Down
Loading

0 comments on commit a3737b7

Please sign in to comment.