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
20 changes: 20 additions & 0 deletions PWGLF/Tasks/Resonances/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(lambda1520analysisinoo

Check failure on line 62 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name lambda1520analysisinoo does not match its file name lambda1520analysisinOO.cxx. (Matches lambda1520analysisinoo.cxx.)
SOURCES lambda1520analysisinOO.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -69,7 +69,7 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(k1analysismicro

Check failure on line 72 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name k1analysismicro does not match its file name k1AnalysisMicro.cxx. (Matches k1analysismicro.cxx.)
SOURCES k1AnalysisMicro.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -89,12 +89,12 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(lambda1520spherocityanalysis

Check failure on line 92 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name lambda1520spherocityanalysis does not match its file name lambda1520SpherocityAnalysis.cxx. (Matches lambda1520spherocityanalysis.cxx.)
SOURCES lambda1520SpherocityAnalysis.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(delta-analysis

Check failure on line 97 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name delta-analysis does not match its file name deltaanalysis.cxx. (Matches deltaAnalysis.cxx.)
SOURCES deltaanalysis.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -104,7 +104,7 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(phi-analysis-thnsparse

Check failure on line 107 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name phi-analysis-thnsparse does not match its file name phianalysisTHnSparse.cxx. (Matches phiAnalysisThnsparse.cxx.)
SOURCES phianalysisTHnSparse.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -119,12 +119,12 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(lambda1520-pbpb

Check failure on line 122 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name lambda1520-pbpb does not match its file name lambda1520_PbPb.cxx. (Matches lambda1520Pbpb.cxx.)
SOURCES lambda1520_PbPb.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(kshortkshort

Check failure on line 127 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name kshortkshort does not match its file name higherMassResonances.cxx. (Matches kshortkshort.cxx.)
SOURCES higherMassResonances.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -134,7 +134,7 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(phianalysisrun3pbpb

Check failure on line 137 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name phianalysisrun3pbpb does not match its file name phianalysisrun3_PbPb.cxx. (Matches phianalysisrun3pbpb.cxx.)
SOURCES phianalysisrun3_PbPb.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -144,7 +144,7 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(k892spherocityanalysis

Check failure on line 147 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name k892spherocityanalysis does not match its file name k892SpherocityAnalysis.cxx. (Matches k892spherocityanalysis.cxx.)
SOURCES k892SpherocityAnalysis.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand All @@ -164,7 +164,7 @@
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)

o2physics_add_dpl_workflow(xi1530analysis

Check failure on line 167 in PWGLF/Tasks/Resonances/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / O2 linter

[name/o2-workflow]

Workflow name xi1530analysis does not match its file name xi1530Analysis.cxx. (Matches xi1530analysis.cxx.)
SOURCES xi1530Analysis.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
Expand Down Expand Up @@ -267,3 +267,23 @@
SOURCES phi1020SpherocityAnalysis.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
o2physics_add_dpl_workflow(phitutorial
SOURCES phitutorial.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
o2physics_add_dpl_workflow(phitutorial-step0
SOURCES phitutorial_step0.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
o2physics_add_dpl_workflow(phitutorial-step1
SOURCES phitutorial_step1.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
o2physics_add_dpl_workflow(phitutorial-step2
SOURCES phitutorial_step2.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
o2physics_add_dpl_workflow(phitutorial-step3
SOURCES phitutorial_step3.cxx
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
COMPONENT_NAME Analysis)
227 changes: 227 additions & 0 deletions PWGLF/Tasks/Resonances/phitutorial.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
// Copyright 2019-2025 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.
/// \file phitutorial.cxx
/// \brief Phi meson analysis tutorial
/// \author Adrian Fereydon Nassirpour <adrian.fereydon.nassirpour@cern.ch>

// IMPORTANT INCLUDES
#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "Framework/ASoA.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "ReconstructionDataFormats/Track.h"
#include <Framework/ASoAHelpers.h>
#include <Framework/runDataProcessing.h>

// ROOT Includes (optional)
#include <TLorentzVector.h>

// C++ includes
#include <iostream>
#include <string>
#include <vector>

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

// MAIN STRUCT
struct phitutorial {

//*************************************//
// SLICECACHE AND REGISTRY DEFS
//*************************************//
SliceCache cache;
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};

//*************************************//
// INIT FUNCTION AND HISTOGRAM BOOKING
//*************************************//
void init(o2::framework::InitContext&)
{
const AxisSpec ptAxis = {200, 0, 20.0};
const AxisSpec MinvAxis = {200, 0.85, 1.25};

histos.add("Nch_pT", "Nch_pT", kTH1F, {ptAxis});
histos.add("Nch_USS_Minv", "Nch_USS_Minv", kTH1F, {MinvAxis});
histos.add("Nch_LSS_Minv", "Nch_LSS_Minv", kTH1F, {MinvAxis});

histos.add("Nch_ME_Minv", "Nch_ME_Minv", kTH1F, {MinvAxis});

}; // end of init

//*************************************//
// TIME TO BUILD TRACK AND EVENT CANDIDATES
//*************************************//
using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::CentFT0Ms>;
using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::pidTPCFullKa, aod::pidTOFFullKa>;
double massKa = o2::constants::physics::MassKPlus;

//***************************************//
// PREAMBLE COMPLETE, NOW WE DO HELPER FCNS
//**************************************//
template <typename EventType>
bool eventSelection(const EventType event)
{
if (!event.sel8())
return false;
if (std::abs(event.posZ()) > 10)
return false;
if (!event.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))
return false;
if (!event.selection_bit(aod::evsel::kNoSameBunchPileup))
return false;
if (!event.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))
return false;

return true;
};
//********************************************//
template <typename TracksType>
bool trackSelection(const TracksType track)
{
if (!track.isGlobalTrack())
return false;
if (track.pt() < 0.15)
return false;
if (std::abs(track.eta()) > 1.0)
return false;

return true;
};
//********************************************//
template <typename TrackPID>
bool trackPIDKaon(const TrackPID& candidate)
{
bool tpcPIDPassed{false}, tofPIDPassed{false};
// TPC
if (std::abs(candidate.tpcNSigmaKa()) < 3)
tpcPIDPassed = true;
// TOF
if (candidate.hasTOF()) {
if (std::abs(candidate.tofNSigmaKa()) < 3) {
tofPIDPassed = true;
}
} else {
tofPIDPassed = true;
}
// TPC & TOF
if (tpcPIDPassed && tofPIDPassed) {
return true;
}
return false;
}

//********************************************//
// HELPER FCNS COMPLETE, NOW WE DO PROCESS FCNS
//********************************************//

// SAME EVENT
int nEvents = 0;
void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks)
{
nEvents++;
if ((nEvents + 1) % 10000 == 0) {
std::cout << "Processed Data Events: " << nEvents << std::endl;
}

if (!eventSelection(collision))
return;

for (const auto& track : tracks) {
histos.fill(HIST("Nch_pT"), track.pt());
}

for (const auto& [trk1, trk2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(tracks, tracks))) {
if (!trackSelection(trk1) || !trackSelection(trk2)) {
continue;
}
if (!trackPIDKaon(trk1) || !trackPIDKaon(trk2)) {
continue;
}

ROOT::Math::PxPyPzMVector lDecayDaughter1, lDecayDaughter2, lResonance;
lDecayDaughter1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massKa);
lDecayDaughter2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massKa);

lResonance = lDecayDaughter1 + lDecayDaughter2;
double conjugate = trk1.sign() * trk2.sign();
if (conjugate < 0) {
histos.fill(HIST("Nch_USS_Minv"), lResonance.M());
} else {
histos.fill(HIST("Nch_LSS_Minv"), lResonance.M());
}
} // Invariant mass combinations

} // proccessSameEvent
PROCESS_SWITCH(phitutorial, processDataSameEvent, "process Data Same Event", false);

//**************************************************************************************************************************//

// MIXED EVENT

//*********************************************************//
// DEFINITION OF SLICE CACHE, BINNING AND MIXING STRUCTURE
//*********************************************************//
Preslice<aod::Tracks> perCollision = aod::track::collisionId;
std::vector<double> zBins{10, -10, 10};
std::vector<double> multBins{VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1};
using BinningType = ColumnBinningPolicy<aod::collision::PosZ, aod::cent::CentFT0M>;
BinningType binning{{zBins, multBins}, true};
SameKindPair<EventCandidates, TrackCandidates, BinningType> pair{binning, 5, -1, &cache};

void processDataMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks)
{
LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size());

for (const auto& [c1, tracks1, c2, tracks2] : pair) {

if (!eventSelection(c1) || !eventSelection(c2))
continue;

for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) {

if (track1.sign() * track2.sign() > 0)
continue;

if (!trackSelection(track1) || !trackSelection(track2)) {
continue;
}
if (!trackPIDKaon(track1) || !trackPIDKaon(track2)) {
continue;
}

ROOT::Math::PxPyPzMVector lDecayDaughter1, lDecayDaughter2, mother;
lDecayDaughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa);
lDecayDaughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa);

mother = lDecayDaughter1 + lDecayDaughter2;

histos.fill(HIST("Nch_ME_Minv"), mother.M());
}
}
} // processMixedEvent
PROCESS_SWITCH(phitutorial, processDataMixedEvent, "process Data Mixed Event", false);
};

//***************************************//
// TASK COMPLETE!
//**************************************//

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{adaptAnalysisTask<phitutorial>(cfgc)};
};
134 changes: 134 additions & 0 deletions PWGLF/Tasks/Resonances/phitutorial_step0.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// Copyright 2019-2025 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.
/// \file phitutorial.cxx
/// \brief Phi meson analysis tutorial
/// \author Adrian Fereydon Nassirpour <adrian.fereydon.nassirpour@cern.ch>

// IMPORTANT INCLUDES
#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/EventSelection.h"
#include "Common/DataModel/Multiplicity.h"
#include "Common/DataModel/PIDResponse.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include "Framework/ASoA.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "ReconstructionDataFormats/Track.h"
#include <Framework/ASoAHelpers.h>
#include <Framework/runDataProcessing.h>

// ROOT Includes (optional)
#include <TLorentzVector.h>

// C++ includes
#include <iostream>
#include <string>
#include <vector>

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

// MAIN STRUCT
struct phitutorial_step0 {

//*************************************//
// SLICECACHE AND REGISTRY DEFS
//*************************************//
SliceCache cache;
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};

//*************************************//
// INIT FUNCTION AND HISTOGRAM BOOKING
//*************************************//
void init(o2::framework::InitContext&)
{
const AxisSpec ptAxis = {200, 0, 20.0};
const AxisSpec MinvAxis = {200, 0.85, 1.25};

histos.add("Nch_pT", "Nch_pT", kTH1F, {ptAxis});

}; // end of init

//*************************************//
// TIME TO BUILD TRACK AND EVENT CANDIDATES
//*************************************//
using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::CentFT0Ms>;
using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::pidTPCFullKa, aod::pidTOFFullKa>;
double massKa = o2::constants::physics::MassKPlus;

//***************************************//
// PREAMBLE COMPLETE, NOW WE DO HELPER FCNS
//**************************************//
template <typename EventType>
bool eventSelection(const EventType event)
{
if (!event.sel8()) // This is required to extract good events
return false;

return true;
};
//********************************************//
// Space for more helper functions!

//********************************************//
// HELPER FCNS COMPLETE, NOW WE DO PROCESS FCNS
//********************************************//

// SAME EVENT
int nEvents = 0;
void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks)
{
nEvents++;
if ((nEvents + 1) % 10000 == 0) {
std::cout << "Processed Data Events: " << nEvents << std::endl;
}

if (!eventSelection(collision))
return;

// Now, time to start coding the task!
// Keep in mind that:
// M_inv = sqrt( (E1+E2)^2 - |P1 + P2|^2 )
// Where you use the energies and momenta of the individual Kaons.

// You should fill: histos.fill(HIST("Minv"), M_inv), calculated as above.

// Usefull tips:
// E = sqrt(p^2 + m^2). The Kaon mass is found above in the constant massKa
// pz = pT*sinh(eta)
// track.pt()
// track.eta();
// std::sinh(x)

// For more concise techinques, check out:
// ROOT::Math::PxPyPzMVector //Check google
// combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy.... //check ALICE O2 documentation

for (const auto& track : tracks) {
histos.fill(HIST("Nch_pT"), track.pt());
//..
//..
//..
}

} // proccessSameEvent
PROCESS_SWITCH(phitutorial_step0, processDataSameEvent, "process Data Same Event", false);

//***************************************//
// TASK COMPLETE!
//**************************************//
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{adaptAnalysisTask<phitutorial_step0>(cfgc)};
};
Loading
Loading