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
2 changes: 1 addition & 1 deletion PWGLF/Tasks/Resonances/phitutorial.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGLF/Tasks/Resonances/phitutorial.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 @@ -27,7 +27,7 @@
#include <Framework/runDataProcessing.h>

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

Check failure on line 30 in PWGLF/Tasks/Resonances/phitutorial.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/lorentz-vector]

Do not use the TLorentzVector legacy class. Use std::array with RecoDecay methods or the ROOT::Math::LorentzVector template instead.

// C++ includes
#include <string>
Expand Down Expand Up @@ -57,7 +57,7 @@
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
Expand All @@ -77,7 +77,7 @@
{
if (!event.sel8())
return false;
if (std::abs(event.posZ()) > 10)

Check failure on line 80 in PWGLF/Tasks/Resonances/phitutorial.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.
return false;
if (!event.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))
return false;
Expand All @@ -94,7 +94,7 @@
{
if (!track.isGlobalTrack())
return false;
if (track.pt() < 0.15)

Check failure on line 97 in PWGLF/Tasks/Resonances/phitutorial.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.
return false;
if (std::abs(track.eta()) > 1.0)
return false;
Expand All @@ -107,11 +107,11 @@
{
bool tpcPIDPassed{false}, tofPIDPassed{false};
// TPC
if (std::abs(candidate.tpcNSigmaKa()) < 3)

Check failure on line 110 in PWGLF/Tasks/Resonances/phitutorial.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.
tpcPIDPassed = true;
// TOF
if (candidate.hasTOF()) {
if (std::abs(candidate.tofNSigmaKa()) < 3) {

Check failure on line 114 in PWGLF/Tasks/Resonances/phitutorial.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.
tofPIDPassed = true;
}
} else {
Expand All @@ -133,8 +133,8 @@
void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks)
{
nEvents++;
if ((nEvents + 1) % 10000 == 0) {

Check failure on line 136 in PWGLF/Tasks/Resonances/phitutorial.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.
std::cout << "Processed Data Events: " << nEvents << std::endl;

Check failure on line 137 in PWGLF/Tasks/Resonances/phitutorial.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}

if (!eventSelection(collision))
Expand Down
36 changes: 17 additions & 19 deletions PWGLF/Tasks/Resonances/phitutorial_step0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <Framework/runDataProcessing.h>

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

Check failure on line 30 in PWGLF/Tasks/Resonances/phitutorial_step0.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/lorentz-vector]

Do not use the TLorentzVector legacy class. Use std::array with RecoDecay methods or the ROOT::Math::LorentzVector template instead.

// C++ includes
#include <string>
Expand Down Expand Up @@ -71,25 +71,25 @@
template <typename EventType>
bool eventSelection(const EventType event)
{
if (!event.sel8()) //This is required to extract good events
if (!event.sel8()) // This is required to extract good events
return false;

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

// 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){
void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks)
{
nEvents++;
if ((nEvents + 1) % 10000 == 0) {
std::cout << "Processed Data Events: " << nEvents << std::endl;

Check failure on line 92 in PWGLF/Tasks/Resonances/phitutorial_step0.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}

if (!eventSelection(collision))
Expand All @@ -99,16 +99,16 @@
// 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)

// 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
Expand All @@ -120,14 +120,12 @@
//..
}


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

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

//***************************************//
// TASK COMPLETE!
//**************************************//
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
Expand Down
18 changes: 8 additions & 10 deletions PWGLF/Tasks/Resonances/phitutorial_step1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ struct phitutorial_step1 {
template <typename EventType>
bool eventSelection(const EventType event)
{
if (!event.sel8()) //This is required to extract good events
if (!event.sel8()) // This is required to extract good events
return false;

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

// Space for more helper functions!

//********************************************//
// HELPER FCNS COMPLETE, NOW WE DO PROCESS FCNS
Expand All @@ -102,14 +101,14 @@ struct phitutorial_step1 {
// track.isGlobalTrack() <.... this menas that it is a good track
// track.pt() >0.15 <.... we want to remove really low momentum tracks
// -0.8<track.eta()<0.8 <.... the TPC efficiency drops really hard at the edges

// We can either create a template function (see eventSelection above for reference) that accepts tracks instead of collisions.
// We can also directly implement the track cuts on the track iterators (track, trk1, trk2) themselves.
// We can also set a filter around the subscribed table. Then before the process function, you would have to modify:
// Filter pT Filter = track::pt > 0.15f;
// then you have to modify the subscription
// soa::Filtered<TrackCandidates> const& tracks

for (const auto& track : tracks) {
histos.fill(HIST("Nch_pT"), track.pt());
}
Expand All @@ -130,10 +129,9 @@ struct phitutorial_step1 {
} // proccessSameEvent
PROCESS_SWITCH(phitutorial_step1, processDataSameEvent, "process Data Same Event", false);

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

//***************************************//
// TASK COMPLETE!
//**************************************//
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
Expand Down
32 changes: 15 additions & 17 deletions PWGLF/Tasks/Resonances/phitutorial_step2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ struct phitutorial_step2 {
template <typename EventType>
bool eventSelection(const EventType event)
{
if (!event.sel8()) //This is required to extract good events
if (!event.sel8()) // This is required to extract good events
return false;

return true;
};
//********************************************//
Expand All @@ -89,9 +89,9 @@ struct phitutorial_step2 {
return false;

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

//********************************************//
// HELPER FCNS COMPLETE, NOW WE DO PROCESS FCNS
Expand All @@ -112,20 +112,19 @@ struct phitutorial_step2 {
// Now, we want to add some PID to ensure that we are with a higher likelhood pairing Kaons.
// Three ways to do this:
// 1.) Directly cut on the tracks in the looping functions (not recommended)

// 2.) Create a helper function above similar to trackSelection

// 3.) Partition your tracks with a preselection by adding this outside of your process function:
// Partition<TrackCandidates> kaon (nabs(aod::pidtpc::tpcNSigmaKa) <= X); // X is a cfg value or a hardcoded integer.
// Then inside the function: auto tracks1 = kaon->sliceByCached(aod::track::collisionId, collision1.globalIndex(), cache); Do the same for tracks2.

// Getters for PID:
// tracks.tpcNSigmaKa()
// tracks.tofNSigmaKa()
// Good starting value for the selected nsigma value is "3".
// You might not want to have a STRICT TOF cut, a lot of tracks with good TPC PID does not have TOF information. You can make a conditional cut on TOF by only implementing the TOF cut if track.hasTOF() returns TRUE.

//Getters for PID:
// tracks.tpcNSigmaKa()
// tracks.tofNSigmaKa()
// Good starting value for the selected nsigma value is "3".
// You might not want to have a STRICT TOF cut, a lot of tracks with good TPC PID does not have TOF information. You can make a conditional cut on TOF by only implementing the TOF cut if track.hasTOF() returns TRUE.

for (const auto& track : tracks) {
if (!trackSelection(track)) {
continue;
Expand All @@ -151,10 +150,9 @@ struct phitutorial_step2 {
} // proccessSameEvent
PROCESS_SWITCH(phitutorial_step2, processDataSameEvent, "process Data Same Event", false);

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

//***************************************//
// TASK COMPLETE!
//**************************************//
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
Expand Down
34 changes: 16 additions & 18 deletions PWGLF/Tasks/Resonances/phitutorial_step3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ struct phitutorial_step3 {
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});

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

}; // end of init

Expand All @@ -77,9 +76,9 @@ struct phitutorial_step3 {
template <typename EventType>
bool eventSelection(const EventType event)
{
if (!event.sel8()) //This is required to extract good events
if (!event.sel8()) // This is required to extract good events
return false;

return true;
};
//********************************************//
Expand All @@ -96,7 +95,7 @@ struct phitutorial_step3 {
return true;
};

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

template <typename TrackPID>
bool trackPIDKaon(const TrackPID& candidate)
Expand Down Expand Up @@ -136,11 +135,11 @@ struct phitutorial_step3 {
if (!eventSelection(collision))
return;

//Last step, we want to remove the cominbatorial background to get a clean peak. We want to fill our new two booked historams, Nch_LSS_Minv and Nch_ME_Minv
// Last step, we want to remove the cominbatorial background to get a clean peak. We want to fill our new two booked historams, Nch_LSS_Minv and Nch_ME_Minv

// LSS is easy, you simply need to fill the histogram if the conjugate argument below is NOT true.
// For event mixing, we have to now copy our logic into a new process function below, and iterate over track pairs between different events!

//LSS is easy, you simply need to fill the histogram if the conjugate argument below is NOT true.
// For event mixing, we have to now copy our logic into a new process function below, and iterate over track pairs between different events!

for (const auto& track : tracks) {
if (!trackSelection(track)) {
continue;
Expand Down Expand Up @@ -178,32 +177,31 @@ struct phitutorial_step3 {
// DEFINITION OF SLICE CACHE, BINNING AND MIXING STRUCTURE
//*********************************************************//
Preslice<aod::Tracks> perCollision = aod::track::collisionId;
//We ensure here that we mix events that have relatively similar characteristics.
// We ensure here that we mix events that have relatively similar characteristics.
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)//notice the collisions subscrition, it is not an iterator here!
void processDataMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks) // notice the collisions subscrition, it is not an iterator here!
{

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

if (!eventSelection(c1) || !eventSelection(c2))
continue;
//Fill your event mixing logic here.
// Fill your event mixing logic here.
//..
//..
//..
} //pairs
} // pairs
} // processMixedEvent
PROCESS_SWITCH(phitutorial_step3, processDataMixedEvent, "process Data Mixed Event", false);

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

//***************************************//
// TASK COMPLETE!
//**************************************//
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
Expand Down
Loading