Skip to content

Commit ee35ebc

Browse files
smaff92alibuild
andauthored
[PWGLF] temporary location for tutorial files, will restage them to t… (#13744)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 31c77bd commit ee35ebc

File tree

6 files changed

+893
-0
lines changed

6 files changed

+893
-0
lines changed

PWGLF/Tasks/Resonances/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,23 @@ o2physics_add_dpl_workflow(phi-1020-spherocity-analysis
267267
SOURCES phi1020SpherocityAnalysis.cxx
268268
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
269269
COMPONENT_NAME Analysis)
270+
o2physics_add_dpl_workflow(phitutorial
271+
SOURCES phitutorial.cxx
272+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
273+
COMPONENT_NAME Analysis)
274+
o2physics_add_dpl_workflow(phitutorial-step0
275+
SOURCES phitutorial_step0.cxx
276+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
277+
COMPONENT_NAME Analysis)
278+
o2physics_add_dpl_workflow(phitutorial-step1
279+
SOURCES phitutorial_step1.cxx
280+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
281+
COMPONENT_NAME Analysis)
282+
o2physics_add_dpl_workflow(phitutorial-step2
283+
SOURCES phitutorial_step2.cxx
284+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
285+
COMPONENT_NAME Analysis)
286+
o2physics_add_dpl_workflow(phitutorial-step3
287+
SOURCES phitutorial_step3.cxx
288+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
289+
COMPONENT_NAME Analysis)
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
/// \file phitutorial.cxx
12+
/// \brief Phi meson analysis tutorial
13+
/// \author Adrian Fereydon Nassirpour <adrian.fereydon.nassirpour@cern.ch>
14+
15+
// IMPORTANT INCLUDES
16+
#include "Common/DataModel/Centrality.h"
17+
#include "Common/DataModel/EventSelection.h"
18+
#include "Common/DataModel/Multiplicity.h"
19+
#include "Common/DataModel/PIDResponse.h"
20+
#include "Common/DataModel/TrackSelectionTables.h"
21+
22+
#include "Framework/ASoA.h"
23+
#include "Framework/AnalysisDataModel.h"
24+
#include "Framework/AnalysisTask.h"
25+
#include "ReconstructionDataFormats/Track.h"
26+
#include <Framework/ASoAHelpers.h>
27+
#include <Framework/runDataProcessing.h>
28+
29+
// ROOT Includes (optional)
30+
#include <TLorentzVector.h>
31+
32+
// C++ includes
33+
#include <iostream>
34+
#include <string>
35+
#include <vector>
36+
37+
using namespace o2;
38+
using namespace o2::framework;
39+
using namespace o2::framework::expressions;
40+
41+
// MAIN STRUCT
42+
struct phitutorial {
43+
44+
//*************************************//
45+
// SLICECACHE AND REGISTRY DEFS
46+
//*************************************//
47+
SliceCache cache;
48+
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
49+
50+
//*************************************//
51+
// INIT FUNCTION AND HISTOGRAM BOOKING
52+
//*************************************//
53+
void init(o2::framework::InitContext&)
54+
{
55+
const AxisSpec ptAxis = {200, 0, 20.0};
56+
const AxisSpec MinvAxis = {200, 0.85, 1.25};
57+
58+
histos.add("Nch_pT", "Nch_pT", kTH1F, {ptAxis});
59+
histos.add("Nch_USS_Minv", "Nch_USS_Minv", kTH1F, {MinvAxis});
60+
histos.add("Nch_LSS_Minv", "Nch_LSS_Minv", kTH1F, {MinvAxis});
61+
62+
histos.add("Nch_ME_Minv", "Nch_ME_Minv", kTH1F, {MinvAxis});
63+
64+
}; // end of init
65+
66+
//*************************************//
67+
// TIME TO BUILD TRACK AND EVENT CANDIDATES
68+
//*************************************//
69+
using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::CentFT0Ms>;
70+
using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::pidTPCFullKa, aod::pidTOFFullKa>;
71+
double massKa = o2::constants::physics::MassKPlus;
72+
73+
//***************************************//
74+
// PREAMBLE COMPLETE, NOW WE DO HELPER FCNS
75+
//**************************************//
76+
template <typename EventType>
77+
bool eventSelection(const EventType event)
78+
{
79+
if (!event.sel8())
80+
return false;
81+
if (std::abs(event.posZ()) > 10)
82+
return false;
83+
if (!event.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV))
84+
return false;
85+
if (!event.selection_bit(aod::evsel::kNoSameBunchPileup))
86+
return false;
87+
if (!event.selection_bit(aod::evsel::kNoCollInTimeRangeStandard))
88+
return false;
89+
90+
return true;
91+
};
92+
//********************************************//
93+
template <typename TracksType>
94+
bool trackSelection(const TracksType track)
95+
{
96+
if (!track.isGlobalTrack())
97+
return false;
98+
if (track.pt() < 0.15)
99+
return false;
100+
if (std::abs(track.eta()) > 1.0)
101+
return false;
102+
103+
return true;
104+
};
105+
//********************************************//
106+
template <typename TrackPID>
107+
bool trackPIDKaon(const TrackPID& candidate)
108+
{
109+
bool tpcPIDPassed{false}, tofPIDPassed{false};
110+
// TPC
111+
if (std::abs(candidate.tpcNSigmaKa()) < 3)
112+
tpcPIDPassed = true;
113+
// TOF
114+
if (candidate.hasTOF()) {
115+
if (std::abs(candidate.tofNSigmaKa()) < 3) {
116+
tofPIDPassed = true;
117+
}
118+
} else {
119+
tofPIDPassed = true;
120+
}
121+
// TPC & TOF
122+
if (tpcPIDPassed && tofPIDPassed) {
123+
return true;
124+
}
125+
return false;
126+
}
127+
128+
//********************************************//
129+
// HELPER FCNS COMPLETE, NOW WE DO PROCESS FCNS
130+
//********************************************//
131+
132+
// SAME EVENT
133+
int nEvents = 0;
134+
void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks)
135+
{
136+
nEvents++;
137+
if ((nEvents + 1) % 10000 == 0) {
138+
std::cout << "Processed Data Events: " << nEvents << std::endl;
139+
}
140+
141+
if (!eventSelection(collision))
142+
return;
143+
144+
for (const auto& track : tracks) {
145+
histos.fill(HIST("Nch_pT"), track.pt());
146+
}
147+
148+
for (const auto& [trk1, trk2] : combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy(tracks, tracks))) {
149+
if (!trackSelection(trk1) || !trackSelection(trk2)) {
150+
continue;
151+
}
152+
if (!trackPIDKaon(trk1) || !trackPIDKaon(trk2)) {
153+
continue;
154+
}
155+
156+
ROOT::Math::PxPyPzMVector lDecayDaughter1, lDecayDaughter2, lResonance;
157+
lDecayDaughter1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massKa);
158+
lDecayDaughter2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massKa);
159+
160+
lResonance = lDecayDaughter1 + lDecayDaughter2;
161+
double conjugate = trk1.sign() * trk2.sign();
162+
if (conjugate < 0) {
163+
histos.fill(HIST("Nch_USS_Minv"), lResonance.M());
164+
} else {
165+
histos.fill(HIST("Nch_LSS_Minv"), lResonance.M());
166+
}
167+
} // Invariant mass combinations
168+
169+
} // proccessSameEvent
170+
PROCESS_SWITCH(phitutorial, processDataSameEvent, "process Data Same Event", false);
171+
172+
//**************************************************************************************************************************//
173+
174+
// MIXED EVENT
175+
176+
//*********************************************************//
177+
// DEFINITION OF SLICE CACHE, BINNING AND MIXING STRUCTURE
178+
//*********************************************************//
179+
Preslice<aod::Tracks> perCollision = aod::track::collisionId;
180+
std::vector<double> zBins{10, -10, 10};
181+
std::vector<double> multBins{VARIABLE_WIDTH, 0, 5, 10, 20, 30, 40, 50, 100.1};
182+
using BinningType = ColumnBinningPolicy<aod::collision::PosZ, aod::cent::CentFT0M>;
183+
BinningType binning{{zBins, multBins}, true};
184+
SameKindPair<EventCandidates, TrackCandidates, BinningType> pair{binning, 5, -1, &cache};
185+
186+
void processDataMixedEvent(EventCandidates const& collisions, TrackCandidates const& tracks)
187+
{
188+
LOGF(info, "Input data Collisions %d, Tracks %d ", collisions.size(), tracks.size());
189+
190+
for (const auto& [c1, tracks1, c2, tracks2] : pair) {
191+
192+
if (!eventSelection(c1) || !eventSelection(c2))
193+
continue;
194+
195+
for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks1, tracks2))) {
196+
197+
if (track1.sign() * track2.sign() > 0)
198+
continue;
199+
200+
if (!trackSelection(track1) || !trackSelection(track2)) {
201+
continue;
202+
}
203+
if (!trackPIDKaon(track1) || !trackPIDKaon(track2)) {
204+
continue;
205+
}
206+
207+
ROOT::Math::PxPyPzMVector lDecayDaughter1, lDecayDaughter2, mother;
208+
lDecayDaughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa);
209+
lDecayDaughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massKa);
210+
211+
mother = lDecayDaughter1 + lDecayDaughter2;
212+
213+
histos.fill(HIST("Nch_ME_Minv"), mother.M());
214+
}
215+
}
216+
} // processMixedEvent
217+
PROCESS_SWITCH(phitutorial, processDataMixedEvent, "process Data Mixed Event", false);
218+
};
219+
220+
//***************************************//
221+
// TASK COMPLETE!
222+
//**************************************//
223+
224+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
225+
{
226+
return WorkflowSpec{adaptAnalysisTask<phitutorial>(cfgc)};
227+
};
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
/// \file phitutorial.cxx
12+
/// \brief Phi meson analysis tutorial
13+
/// \author Adrian Fereydon Nassirpour <adrian.fereydon.nassirpour@cern.ch>
14+
15+
// IMPORTANT INCLUDES
16+
#include "Common/DataModel/Centrality.h"
17+
#include "Common/DataModel/EventSelection.h"
18+
#include "Common/DataModel/Multiplicity.h"
19+
#include "Common/DataModel/PIDResponse.h"
20+
#include "Common/DataModel/TrackSelectionTables.h"
21+
22+
#include "Framework/ASoA.h"
23+
#include "Framework/AnalysisDataModel.h"
24+
#include "Framework/AnalysisTask.h"
25+
#include "ReconstructionDataFormats/Track.h"
26+
#include <Framework/ASoAHelpers.h>
27+
#include <Framework/runDataProcessing.h>
28+
29+
// ROOT Includes (optional)
30+
#include <TLorentzVector.h>
31+
32+
// C++ includes
33+
#include <iostream>
34+
#include <string>
35+
#include <vector>
36+
37+
using namespace o2;
38+
using namespace o2::framework;
39+
using namespace o2::framework::expressions;
40+
41+
// MAIN STRUCT
42+
struct phitutorial_step0 {
43+
44+
//*************************************//
45+
// SLICECACHE AND REGISTRY DEFS
46+
//*************************************//
47+
SliceCache cache;
48+
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
49+
50+
//*************************************//
51+
// INIT FUNCTION AND HISTOGRAM BOOKING
52+
//*************************************//
53+
void init(o2::framework::InitContext&)
54+
{
55+
const AxisSpec ptAxis = {200, 0, 20.0};
56+
const AxisSpec MinvAxis = {200, 0.85, 1.25};
57+
58+
histos.add("Nch_pT", "Nch_pT", kTH1F, {ptAxis});
59+
60+
}; // end of init
61+
62+
//*************************************//
63+
// TIME TO BUILD TRACK AND EVENT CANDIDATES
64+
//*************************************//
65+
using EventCandidates = soa::Join<aod::Collisions, aod::EvSels, aod::FT0Mults, aod::CentFT0Ms>;
66+
using TrackCandidates = soa::Join<aod::Tracks, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection, aod::pidTPCFullKa, aod::pidTOFFullKa>;
67+
double massKa = o2::constants::physics::MassKPlus;
68+
69+
//***************************************//
70+
// PREAMBLE COMPLETE, NOW WE DO HELPER FCNS
71+
//**************************************//
72+
template <typename EventType>
73+
bool eventSelection(const EventType event)
74+
{
75+
if (!event.sel8()) // This is required to extract good events
76+
return false;
77+
78+
return true;
79+
};
80+
//********************************************//
81+
// Space for more helper functions!
82+
83+
//********************************************//
84+
// HELPER FCNS COMPLETE, NOW WE DO PROCESS FCNS
85+
//********************************************//
86+
87+
// SAME EVENT
88+
int nEvents = 0;
89+
void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks)
90+
{
91+
nEvents++;
92+
if ((nEvents + 1) % 10000 == 0) {
93+
std::cout << "Processed Data Events: " << nEvents << std::endl;
94+
}
95+
96+
if (!eventSelection(collision))
97+
return;
98+
99+
// Now, time to start coding the task!
100+
// Keep in mind that:
101+
// M_inv = sqrt( (E1+E2)^2 - |P1 + P2|^2 )
102+
// Where you use the energies and momenta of the individual Kaons.
103+
104+
// You should fill: histos.fill(HIST("Minv"), M_inv), calculated as above.
105+
106+
// Usefull tips:
107+
// E = sqrt(p^2 + m^2). The Kaon mass is found above in the constant massKa
108+
// pz = pT*sinh(eta)
109+
// track.pt()
110+
// track.eta();
111+
// std::sinh(x)
112+
113+
// For more concise techinques, check out:
114+
// ROOT::Math::PxPyPzMVector //Check google
115+
// combinations(o2::soa::CombinationsStrictlyUpperIndexPolicy.... //check ALICE O2 documentation
116+
117+
for (const auto& track : tracks) {
118+
histos.fill(HIST("Nch_pT"), track.pt());
119+
//..
120+
//..
121+
//..
122+
}
123+
124+
} // proccessSameEvent
125+
PROCESS_SWITCH(phitutorial_step0, processDataSameEvent, "process Data Same Event", false);
126+
127+
//***************************************//
128+
// TASK COMPLETE!
129+
//**************************************//
130+
};
131+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
132+
{
133+
return WorkflowSpec{adaptAnalysisTask<phitutorial_step0>(cfgc)};
134+
};

0 commit comments

Comments
 (0)