|
| 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 | +}; |
0 commit comments