From 1daa6e2334d359c41a1553ae764437713fad23ba Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Wed, 25 Oct 2023 21:26:18 +0200 Subject: [PATCH] derived data example fixes --- .../Skimming/DataModel/DerivedExampleTable.h | 6 ++--- Tutorials/Skimming/derivedBasicConsumer.cxx | 25 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Tutorials/Skimming/DataModel/DerivedExampleTable.h b/Tutorials/Skimming/DataModel/DerivedExampleTable.h index 3bfc67697a0..3d3918b3ccb 100644 --- a/Tutorials/Skimming/DataModel/DerivedExampleTable.h +++ b/Tutorials/Skimming/DataModel/DerivedExampleTable.h @@ -18,7 +18,7 @@ namespace o2::aod { -DECLARE_SOA_TABLE(DerivedCollisions, "AOD", "DERCOLTA", o2::soa::Index<>, +DECLARE_SOA_TABLE(DerivedCollisions, "AOD", "DERCOLLS", o2::soa::Index<>, o2::aod::collision::PosZ); using DerivedCollision = DerivedCollisions::iterator; @@ -29,9 +29,9 @@ DECLARE_SOA_COLUMN(Pt, pt, float); DECLARE_SOA_COLUMN(Eta, eta, float); DECLARE_SOA_COLUMN(Phi, phi, float); } // namespace exampleTrackSpace -DECLARE_SOA_TABLE(DerivedTracks, "AOD", "DERTRATA", +DECLARE_SOA_TABLE(DerivedTracks, "AOD", "DERTRACKS", o2::soa::Index<>, exampleTrackSpace::DerivedCollisionId, exampleTrackSpace::Pt, exampleTrackSpace::Eta, exampleTrackSpace::Phi); -using DerivedTracks = DerivedTracks::iterator; +using DerivedTrack = DerivedTracks::iterator; } // namespace o2::aod #endif // O2_ANALYSIS_DERIVEDEXAMPLETABLES_H diff --git a/Tutorials/Skimming/derivedBasicConsumer.cxx b/Tutorials/Skimming/derivedBasicConsumer.cxx index bc468924bd9..27734ecd9e9 100644 --- a/Tutorials/Skimming/derivedBasicConsumer.cxx +++ b/Tutorials/Skimming/derivedBasicConsumer.cxx @@ -26,6 +26,8 @@ using namespace o2::framework::expressions; #include "Framework/runDataProcessing.h" struct DerivedBasicConsumer { + SliceCache cache; + /// Function to aid in calculating delta-phi /// \param phi1 first phi value /// \param phi2 second phi value @@ -45,15 +47,15 @@ struct DerivedBasicConsumer { Configurable maxPtAssoc{"maxPtAssoc", 4.0, "max pT associated"}; Configurable minPtTrig{"minPtTrig", 4.0, "min pT trigger"}; - ConfigurableAxis axisPhi{"axisPhi", {72, 0, 2 * M_PI}, "#phi"}; + ConfigurableAxis axisPhi{"axisPhi", {72, 0, 2 * TMath::Pi()}, "#phi"}; ConfigurableAxis axisEta{"axisEta", {80, -0.8, +0.8}, "#eta"}; - ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {36, -PIHalf, PIHalf * 3}, "delta #varphi axis for histograms"}; + ConfigurableAxis axisDeltaPhi{"axisDeltaPhi", {36, -o2::constants::math::PIHalf, o2::constants::math::PIHalf * 3}, "delta #varphi axis for histograms"}; // Histogram registry: an object to hold your histograms HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; - Partition triggerTracks = aod::track::pt > minPtTrig; - Partition assocTracks = aod::track::pt > minPtAssoc && aod::track::pt < maxPtAssoc; + Partition triggerTracks = aod::track::pt > minPtTrig; + Partition assocTracks = aod::track::pt > minPtAssoc && aod::track::pt < maxPtAssoc; Preslice perCollision = aod::track::collisionId; @@ -61,7 +63,6 @@ struct DerivedBasicConsumer { { // define axes you want to use const AxisSpec axisCounter{1, 0, +1, ""}; - const AxisSpec axisPt{nBinsPt, 0, 10, "p_{T}"}; histos.add("eventCounter", "eventCounter", kTH1F, {axisCounter}); // for correlation study @@ -77,22 +78,22 @@ struct DerivedBasicConsumer { histos.fill(HIST("eventCounter"), 0.5); //partitions are not grouped by default - auto triggerTracksGrouped = triggerTracks->sliceByCached(aod::track::collisionId, collision.globalIndex()); - auto assocTracksGrouped = assocTracks->sliceByCached(aod::track::collisionId, collision.globalIndex()); + auto triggerTracksGrouped = triggerTracks->sliceByCached(aod::exampleTrackSpace::derivedCollisionId, collision.globalIndex(), cache); + auto assocTracksGrouped = assocTracks->sliceByCached(aod::exampleTrackSpace::derivedCollisionId, collision.globalIndex(), cache); //Inspect the trigger and associated populations for (auto& track : triggerTracksGrouped) { //<- only for a subset - registry.get(HIST("etaHistogramTrigger"))->Fill(track.eta()); //<- this should show the selection - registry.get(HIST("ptHistogramTrigger"))->Fill(track.pt()); + histos.get(HIST("etaHistogramTrigger"))->Fill(track.eta()); //<- this should show the selection + histos.get(HIST("ptHistogramTrigger"))->Fill(track.pt()); } for (auto& track : assocTracksGrouped) { //<- only for a subset - registry.get(HIST("etaHistogramAssoc"))->Fill(track.eta()); //<- this should show the selection - registry.get(HIST("ptHistogramAssoc"))->Fill(track.pt()); + histos.get(HIST("etaHistogramAssoc"))->Fill(track.eta()); //<- this should show the selection + histos.get(HIST("ptHistogramAssoc"))->Fill(track.pt()); } //Now we do two-particle correlations, using "combinations" for (auto& [trackTrigger, trackAssoc] : combinations(o2::soa::CombinationsFullIndexPolicy(triggerTracksGrouped, assocTracksGrouped))) { - registry.get(HIST("correlationFunction"))->Fill( ComputeDeltaPhi(trackTrigger.phi(), trackAssoc.phi() )); + histos.get(HIST("correlationFunction"))->Fill( ComputeDeltaPhi(trackTrigger.phi(), trackAssoc.phi() )); } } };