Skip to content

Commit

Permalink
[PWGLF] Add Resonance Tutorials (#7969)
Browse files Browse the repository at this point in the history
* Add files via upload

* Update CMakeLists.txt

Remove the trailing spaces at the end of the line

* Update CMakeLists.txt

Remove the trailing spaces at the end of the line

* Update CMakeLists.txt

Remove the trailing spaces at the end of the line

* Update CMakeLists.txt

Remove the trailing spaces at the end of the line
  • Loading branch information
hkoley authored Oct 12, 2024
1 parent eb2efc9 commit 1a6d4bd
Show file tree
Hide file tree
Showing 6 changed files with 537 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Tutorials/PWGLF/Resonance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,23 @@ o2physics_add_dpl_workflow(resonances-step2
SOURCES resonances_step2.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME AnalysisTutorial)

o2physics_add_dpl_workflow(resonances-step3
SOURCES resonances_step3.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME AnalysisTutorial)

o2physics_add_dpl_workflow(resonances-step4
SOURCES resonances_step4.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME AnalysisTutorial)

o2physics_add_dpl_workflow(resonances-step5
SOURCES resonances_step5.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME AnalysisTutorial)

o2physics_add_dpl_workflow(resonances-step6
SOURCES resonances_step6.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME AnalysisTutorial)
8 changes: 7 additions & 1 deletion Tutorials/PWGLF/Resonance/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# This is the base for the PWGLF tutorials for the O2AT

The tutorial (6-10 Nov 2023) can be still used and is a reference for the LF analyses.
The tutorial can be still used and is a reference for the LF Resonance analyses.
It is built as a set of steps. Each step adds a level of complexity and is built in a separate executable.
The executables are defined in the `CMakeLists.txt`.

## Files
* `README.md` this readme
* `CMakeLists.txt` here are defined the source files to compile
* `resonance_step0.cxx` Read the resonance table and run basic track loop
* `resonance_step1.cxx` Producing same event invariant mass distribution
* `resonance_step2.cxx` Producing Mixed event invariant mass distribution
* `resonance_step3.cxx` Starting point for MC: loop over all Generated MC particles
* `resonance_step4.cxx` Producing histograms (pt distributions etc.) for Generated MCs
* `resonance_step5.cxx` Loop over all MC Tracks and produce basic QA histograms
* `resonance_step6.cxx` Resonance reconstruction
77 changes: 77 additions & 0 deletions Tutorials/PWGLF/Resonance/resonances_step3.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \brief this is a starting point for the Resonances tutorial for MC part
/// \author Hirak Kumar Koley <[email protected]>
/// \since 11/10/2024

#include "CommonConstants/PhysicsConstants.h"
#include "Framework/AnalysisTask.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/runDataProcessing.h"
#include "PWGLF/DataModel/LFResonanceTables.h"

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;

// STEP 3
// Starting point for MC: loop over all Generated MC particles
struct resonances_tutorial {
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};

// Configurable for number of bins
Configurable<int> nBins{"nBins", 100, "N bins in all histos"};
// Configurable for min pT cut
Configurable<double> cMinPtcut{"cMinPtcut", 0.15, "Track minimum pt cut"};

// Initialize the ananlysis task
void init(o2::framework::InitContext&)
{
// register histograms
histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}});
histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}});
}

// MC particle selection
template <typename ParticleType>
bool ptCut(const ParticleType resoParents)
{
// basic pt cuts
if (std::abs(resoParents.pt()) < cMinPtcut)
return false;

return true;
}

// Fill histograms (main function)
template <typename CollisionType, typename ParticleType>
void fillHistograms(const CollisionType& /*collision*/, const ParticleType& resoParents)
{
for (auto part : resoParents) { // loop over all resoParents
if (!ptCut(part))
continue; // pt selection

// QA plots
histos.fill(HIST("hEta"), part.eta());
}
}

// Process the MC
void process(aod::ResoCollision& collision, aod::ResoMCParents& resoParents)
{
// Fill the event counter
histos.fill(HIST("hVertexZ"), collision.posZ());
fillHistograms(collision, resoParents); // Fill histograms, MC
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<resonances_tutorial>(cfgc)}; }
109 changes: 109 additions & 0 deletions Tutorials/PWGLF/Resonance/resonances_step4.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \brief this is a starting point for the Resonances tutorial for MC
/// \author Hirak Kumar Koley <[email protected]>
/// \since 11/10/2024

#include "CommonConstants/PhysicsConstants.h"
#include "Framework/AnalysisTask.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/runDataProcessing.h"
#include "PWGLF/DataModel/LFResonanceTables.h"

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;

// STEP 4
// Producing histograms for Generated MCs
struct resonances_tutorial {
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};

// Configurable for number of bins
Configurable<int> nBins{"nBins", 100, "N bins in all histos"};
// Configurable for min pT cut
Configurable<double> cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"};

/// Histograms
ConfigurableAxis binsPt{"binsPt", {VARIABLE_WIDTH, 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7.0, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9, 9.0, 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 11.0, 11.1, 11.2, 11.3, 11.4, 11.5, 11.6, 11.7, 11.8, 11.9, 12.0, 12.1, 12.2, 12.3, 12.4, 12.5, 12.6, 12.7, 12.8, 12.9, 13.0, 13.1, 13.2, 13.3, 13.4, 13.5, 13.6, 13.7, 13.8, 13.9, 14.0, 14.1, 14.2, 14.3, 14.4, 14.5, 14.6, 14.7, 14.8, 14.9, 15.0}, "Binning of the pT axis"};
ConfigurableAxis binsCent{"binsCent", {VARIABLE_WIDTH, 0., 1., 5., 10., 30., 50., 70., 100., 110.}, "Binning of the centrality axis"};

// Initialize the ananlysis task
void init(o2::framework::InitContext&)
{
AxisSpec centAxis = {binsCent, "V0M (%)"};
AxisSpec ptAxis = {binsPt, "#it{p}_{T} (GeV/#it{c})"};

// register histograms
histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}});
histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}});
histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}});

// MC QA
histos.add("hphipt", "pT distribution of True MC phi", kTH1F, {ptAxis});
histos.add("phiGen", "pT distribution of True MC phi", kTH2F, {ptAxis, centAxis});

// Print output histograms statistics
LOG(info) << "Size of the histograms in resonance tutorial step1:";
histos.print();
}

// MC particle selection
template <typename ParticleType>
bool ptCut(const ParticleType resoParents)
{
// basic pt cuts
if (std::abs(resoParents.pt()) < cMinPtcut)
return false;

return true;
}

// Fill histograms (main function)
template <typename CollisionType, typename ParticleType>
void fillHistograms(const CollisionType& collision, const ParticleType& resoParents)
{
auto multiplicity = collision.cent();
for (auto& part : resoParents) { // loop over all pre-filtered MC particles
if (!ptCut(part))
continue; // pt selection

// QA plots
histos.fill(HIST("hEta"), part.eta());

if (abs(part.pdgCode()) != 333) // phi(0)
continue;
if (abs(part.y()) > 0.5) { // rapidity cut
continue;
}
if (abs(part.daughterPDG1()) != 321 || abs(part.daughterPDG2()) != 321) { // At least one decay to Kaon
continue;
}
histos.fill(HIST("phiGen"), part.pt(), multiplicity);
histos.fill(HIST("hphipt"), part.pt());
}
}

// Process the MC
void process(aod::ResoCollision& collision, aod::ResoMCParents& resoParents)
{
auto multiplicity = collision.cent();

// Fill the event counter
histos.fill(HIST("hVertexZ"), collision.posZ());
histos.fill(HIST("hMultiplicityPercent"), multiplicity);

fillHistograms(collision, resoParents); // Fill histograms, MC
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<resonances_tutorial>(cfgc)}; }
136 changes: 136 additions & 0 deletions Tutorials/PWGLF/Resonance/resonances_step5.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \brief this is a starting point for the Resonances tutorial
/// \author Hirak Kumar Koley
/// \since 11/10/2024

#include "CommonConstants/PhysicsConstants.h"
#include "Framework/AnalysisTask.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/runDataProcessing.h"
#include "PWGLF/DataModel/LFResonanceTables.h"

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;

// STEP 5
// loop over all MC Tracks and produce basic QA histograms
struct resonances_tutorial {
// Define slice per Resocollision
SliceCache cache;
Preslice<aod::ResoTracks> perResoCollision = aod::resodaughter::resoCollisionId;
Preslice<aod::Tracks> perCollision = aod::track::collisionId;

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

// Configurable for number of bins
Configurable<int> nBins{"nBins", 100, "N bins in all histos"};
// Configurable for min pT cut
Configurable<double> cMinPtcut{"cMinPtcut", 0.15, "Track minium pt cut"};

// Track selection
// primary track condition
Configurable<bool> cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; // kGoldenChi2 | kDCAxy | kDCAz
Configurable<bool> cfgGlobalWoDCATrack{"cfgGlobalWoDCATrack", true, "Global track selection without DCA"}; // kQualityTracks (kTrackType | kTPCNCls | kTPCCrossedRows | kTPCCrossedRowsOverNCls | kTPCChi2NDF | kTPCRefit | kITSNCls | kITSChi2NDF | kITSRefit | kITSHits) | kInAcceptanceTracks (kPtRange | kEtaRange)
Configurable<bool> cfgPVContributor{"cfgPVContributor", true, "PV contributor track selection"}; // PV Contriuibutor

// DCA Selections
// DCAr to PV
Configurable<double> cMaxDCArToPVcut{"cMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"};
// DCAz to PV
Configurable<double> cMaxDCAzToPVcut{"cMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"};

// PID selection
Configurable<float> nsigmaCutTPC{"nsigmacutTPC", 3.0, "Value of the TPC Nsigma cut"};
Configurable<float> nsigmacutTOF{"nsigmacutTOF", 3.0, "Value /home/hirak/Desktop/LstarTaskTest/run/dpl-config.jsonof the TOF Nsigma cut"};

// Initialize the ananlysis task
void init(o2::framework::InitContext&)
{
// register histograms
histos.add("hVertexZ", "hVertexZ", HistType::kTH1F, {{nBins, -15., 15.}});
histos.add("hEta", "Eta distribution", kTH1F, {{200, -1.0f, 1.0f}});
histos.add("hMultiplicityPercent", "Multiplicity Percentile", kTH1F, {{120, 0.0f, 120.0f}});
histos.add("hDcaxy", "Dcaxy distribution", kTH1F, {{100, -0.5f, 0.5f}});
histos.add("hDcaz", "Dcaz distribution", kTH1F, {{100, -0.5f, 0.5f}});
histos.add("hNsigmaKaonTPC", "NsigmaKaon TPC distribution", kTH1F, {{100, -10.0f, 10.0f}});
histos.add("hNsigmaKaonTOF", "NsigmaKaon TOF distribution", kTH1F, {{100, -10.0f, 10.0f}});

// Print output histograms statistics
LOG(info) << "Size of the histograms in resonance tutorial step2:";
histos.print();
}

// Track selection
template <typename TrackType>
bool trackCut(const TrackType track)
{
// basic track cuts
if (std::abs(track.pt()) < cMinPtcut)
return false;
if (std::abs(track.dcaXY()) > cMaxDCArToPVcut)
return false;
if (std::abs(track.dcaZ()) > cMaxDCAzToPVcut)
return false;
if (cfgPrimaryTrack && !track.isPrimaryTrack())
return false;
if (cfgGlobalWoDCATrack && !track.isGlobalTrackWoDCA())
return false;
if (cfgPVContributor && !track.isPVContributor())
return false;
return true;
}

// PID selection TPC +TOF Veto
template <typename T>
bool selectionPID(const T& candidate)
{
bool tpcPass = std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPC;
bool tofPass = (candidate.hasTOF()) ? std::abs(candidate.tofNSigmaKa()) < nsigmacutTOF : true;
if (tpcPass && tofPass) {
return true;
}
return false;
}

template <typename CollisionType, typename TracksType>
void fillHistograms(const CollisionType& /* collision */, const TracksType& dTracks)
{
for (auto track : dTracks) { // loop over all dTracks
if (!trackCut(track) || !selectionPID(track)) {
continue; // track selection and PID selection
}
// QA plots
histos.fill(HIST("hEta"), track.eta());
histos.fill(HIST("hDcaxy"), track.dcaXY());
histos.fill(HIST("hDcaz"), track.dcaZ());
histos.fill(HIST("hNsigmaKaonTPC"), track.tpcNSigmaKa());
if (track.hasTOF()) {
histos.fill(HIST("hNsigmaKaonTOF"), track.tofNSigmaKa());
}
}
}

// Process the data
void process(aod::ResoCollision& collision,
soa::Join<aod::ResoTracks, aod::ResoMCTracks> const& resotracks)
{
// Fill the event counter
histos.fill(HIST("hVertexZ"), collision.posZ());
histos.fill(HIST("hMultiplicityPercent"), collision.cent());

fillHistograms(collision, resotracks);
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<resonances_tutorial>(cfgc)}; }
Loading

0 comments on commit 1a6d4bd

Please sign in to comment.