|
| 1 | +// Copyright 2019-2020 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 | +// |
| 12 | +// \Single Gap Event Analyzer |
| 13 | +// \author Sasha Bylinkin, alexander.bylinkin@gmail.com |
| 14 | +// \since April 2023 |
| 15 | + |
| 16 | +#include "Framework/runDataProcessing.h" |
| 17 | +#include "Framework/AnalysisTask.h" |
| 18 | + |
| 19 | +#include "TVector3.h" |
| 20 | +#include "TTree.h" |
| 21 | +#include "TFile.h" |
| 22 | +#include <TH1F.h> |
| 23 | +#include <TH2F.h> |
| 24 | +#include "Common/DataModel/PIDResponse.h" |
| 25 | +#include "PWGUD/DataModel/SGTables.h" |
| 26 | +#include "PWGUD/Core/UDHelpers.h" |
| 27 | +#include "PWGUD/Core/SGSelector.h" |
| 28 | +#include "PWGUD/Core/SGTrackSelector.h" |
| 29 | + |
| 30 | +using namespace o2; |
| 31 | +using namespace o2::framework; |
| 32 | +using namespace o2::framework::expressions; |
| 33 | + |
| 34 | +struct sgPIDAnalyzer { |
| 35 | + HistogramRegistry histos{"Histos", {}}; |
| 36 | + |
| 37 | + ConfigurableAxis ptAxis{ |
| 38 | + "ptAxis", |
| 39 | + {198, 0.1, 10.0}, |
| 40 | + "Pt binning"}; |
| 41 | + |
| 42 | + ConfigurableAxis sigmaAxis{"sigmaAxis", {100, -50, 50}, "nSigma TPC binning"}; |
| 43 | + |
| 44 | + void init(InitContext&) |
| 45 | + { |
| 46 | + |
| 47 | + const AxisSpec ptBins{ptAxis, "p_{T} axis"}; |
| 48 | + const AxisSpec nSigmaBins{sigmaAxis, "pseudo rapidity axis"}; |
| 49 | + histos.add("TPC/pTPC_Pi", "Positive TPC Pi Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 50 | + histos.add("TPC/nTPC_Pi", "Negative TPC Pi Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 51 | + histos.add("TPC/pTPC_Ka", "Positive TPC Ka Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 52 | + histos.add("TPC/nTPC_Ka", "Negative TPC Ka Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 53 | + histos.add("TPC/pTPC_Pr", "Positive TPC Pr Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 54 | + histos.add("TPC/nTPC_Pr", "Negative TPC Pr Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 55 | + histos.add("TPC/pTPC_El", "Positive TPC El Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 56 | + histos.add("TPC/nTPC_El", "Negative TPC El Tracks", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 57 | + |
| 58 | + histos.add("TPC/pTPC_Pi_Ka", "Positive TPC Pi vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 59 | + histos.add("TPC/pTPC_Pi_Pr", "Positive TPC Pi vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 60 | + histos.add("TPC/pTPC_Pi_El", "Positive TPC Pi vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 61 | + histos.add("TPC/pTPC_Ka_Pi", "Positive TPC Ka vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 62 | + histos.add("TPC/pTPC_Ka_Pr", "Positive TPC Ka vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 63 | + histos.add("TPC/pTPC_Ka_El", "Positive TPC Ka vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 64 | + histos.add("TPC/pTPC_Pr_Pi", "Positive TPC Pr vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 65 | + histos.add("TPC/pTPC_Pr_Ka", "Positive TPC Pr vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 66 | + histos.add("TPC/pTPC_Pr_El", "Positive TPC Pr vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 67 | + |
| 68 | + histos.add("TPC/nTPC_Pi_Ka", "Positive TPC Pi vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 69 | + histos.add("TPC/nTPC_Pi_Pr", "Positive TPC Pi vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 70 | + histos.add("TPC/nTPC_Pi_El", "Positive TPC Pi vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 71 | + histos.add("TPC/nTPC_Ka_Pi", "Positive TPC Ka vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 72 | + histos.add("TPC/nTPC_Ka_Pr", "Positive TPC Ka vs Pr", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 73 | + histos.add("TPC/nTPC_Ka_El", "Positive TPC Ka vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 74 | + histos.add("TPC/nTPC_Pr_Pi", "Positive TPC Pr vs Pi", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 75 | + histos.add("TPC/nTPC_Pr_Ka", "Positive TPC Pr vs Ka", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 76 | + histos.add("TPC/nTPC_Pr_El", "Positive TPC Pr vs El", {HistType::kTH2F, {ptBins, nSigmaBins}}); |
| 77 | + |
| 78 | + histos.add("TOF/pPi", "Positive TPC Pi vs TOF Pi vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 79 | + histos.add("TOF/nPi", "Negative TPC Pi vs TOF Pi vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 80 | + histos.add("TOF/pKa", "Positive TPC Ka vs TOF Ka vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 81 | + histos.add("TOF/nKa", "Negative TPC Ka vs TOF Ka vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 82 | + histos.add("TOF/pPr", "Positive TPC Pr vs TOF Pr vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 83 | + histos.add("TOF/nPr", "Negative TPC Pr vs TOF Pr vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 84 | + histos.add("TOF/pEl", "Positive TPC El vs TOF El vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 85 | + histos.add("TOF/nEl", "Negative TPC El vs TOF El vs pt", {HistType::kTH3F, {ptBins, nSigmaBins, nSigmaBins}}); |
| 86 | + } |
| 87 | + |
| 88 | + void process(aod::SGEvents const& events, aod::SGTracks const& tracks) |
| 89 | + { |
| 90 | + int eventIndex = 0; // Sequential index for SGEvents |
| 91 | + for (auto event : events) { |
| 92 | + for (auto track : tracks) { |
| 93 | + if (track.sgEventId() != eventIndex) |
| 94 | + continue; // Match track to the current event index |
| 95 | + bool isPositive = (track.sign() > 0); |
| 96 | + if (track.tofpi() == -999) { |
| 97 | + // Directly fill histograms without a local variable for histName |
| 98 | + if (isPositive) { |
| 99 | + histos.fill(HIST("TPC/pTPC_Pi"), track.pt(), track.tpcpi()); |
| 100 | + histos.fill(HIST("TPC/pTPC_Ka"), track.pt(), track.tpcka()); |
| 101 | + histos.fill(HIST("TPC/pTPC_Pr"), track.pt(), track.tpcpr()); |
| 102 | + histos.fill(HIST("TPC/pTPC_El"), track.pt(), track.tpcel()); |
| 103 | + if (abs(track.tpcpi()) < 1) { |
| 104 | + histos.fill(HIST("TPC/pTPC_Pi_Ka"), track.pt(), track.tpcka()); |
| 105 | + histos.fill(HIST("TPC/pTPC_Pi_Pr"), track.pt(), track.tpcpr()); |
| 106 | + histos.fill(HIST("TPC/pTPC_Pi_El"), track.pt(), track.tpcel()); |
| 107 | + } |
| 108 | + if (abs(track.tpcka()) < 1) { |
| 109 | + histos.fill(HIST("TPC/pTPC_Ka_Pi"), track.pt(), track.tpcpi()); |
| 110 | + histos.fill(HIST("TPC/pTPC_Ka_Pr"), track.pt(), track.tpcpr()); |
| 111 | + histos.fill(HIST("TPC/pTPC_Ka_El"), track.pt(), track.tpcel()); |
| 112 | + } |
| 113 | + if (abs(track.tpcpr()) < 1) { |
| 114 | + histos.fill(HIST("TPC/pTPC_Pr_Pi"), track.pt(), track.tpcpi()); |
| 115 | + histos.fill(HIST("TPC/pTPC_Pr_Ka"), track.pt(), track.tpcka()); |
| 116 | + histos.fill(HIST("TPC/pTPC_Pr_El"), track.pt(), track.tpcel()); |
| 117 | + } |
| 118 | + } else { |
| 119 | + histos.fill(HIST("TPC/nTPC_Pi"), track.pt(), track.tpcpi()); |
| 120 | + histos.fill(HIST("TPC/nTPC_Ka"), track.pt(), track.tpcka()); |
| 121 | + histos.fill(HIST("TPC/nTPC_Pr"), track.pt(), track.tpcpr()); |
| 122 | + histos.fill(HIST("TPC/nTPC_El"), track.pt(), track.tpcel()); |
| 123 | + if (abs(track.tpcpi()) < 1) { |
| 124 | + histos.fill(HIST("TPC/nTPC_Pi_Ka"), track.pt(), track.tpcka()); |
| 125 | + histos.fill(HIST("TPC/nTPC_Pi_Pr"), track.pt(), track.tpcpr()); |
| 126 | + histos.fill(HIST("TPC/nTPC_Pi_El"), track.pt(), track.tpcel()); |
| 127 | + } |
| 128 | + if (abs(track.tpcka()) < 1) { |
| 129 | + histos.fill(HIST("TPC/nTPC_Ka_Pi"), track.pt(), track.tpcpi()); |
| 130 | + histos.fill(HIST("TPC/nTPC_Ka_Pr"), track.pt(), track.tpcpr()); |
| 131 | + histos.fill(HIST("TPC/nTPC_Ka_El"), track.pt(), track.tpcel()); |
| 132 | + } |
| 133 | + if (abs(track.tpcpr()) < 1) { |
| 134 | + histos.fill(HIST("TPC/nTPC_Pr_Pi"), track.pt(), track.tpcpi()); |
| 135 | + histos.fill(HIST("TPC/nTPC_Pr_Ka"), track.pt(), track.tpcka()); |
| 136 | + histos.fill(HIST("TPC/nTPC_Pr_El"), track.pt(), track.tpcel()); |
| 137 | + } |
| 138 | + } |
| 139 | + } else { |
| 140 | + if (isPositive) { |
| 141 | + histos.fill(HIST("TOF/pPi"), track.pt(), track.tpcpi(), track.tofpi()); |
| 142 | + histos.fill(HIST("TOF/pKa"), track.pt(), track.tpcka(), track.tofka()); |
| 143 | + histos.fill(HIST("TOF/pPr"), track.pt(), track.tpcpr(), track.tofpr()); |
| 144 | + histos.fill(HIST("TOF/pEl"), track.pt(), track.tpcel(), track.tofel()); |
| 145 | + } else { |
| 146 | + histos.fill(HIST("TOF/nPi"), track.pt(), track.tpcpi(), track.tofpi()); |
| 147 | + histos.fill(HIST("TOF/nKa"), track.pt(), track.tpcka(), track.tofka()); |
| 148 | + histos.fill(HIST("TOF/nPr"), track.pt(), track.tpcpr(), track.tofpr()); |
| 149 | + histos.fill(HIST("TOF/nEl"), track.pt(), track.tpcel(), track.tofel()); |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + eventIndex++; |
| 154 | + } |
| 155 | + } |
| 156 | +}; |
| 157 | + |
| 158 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 159 | +{ |
| 160 | + return WorkflowSpec{ |
| 161 | + adaptAnalysisTask<sgPIDAnalyzer>(cfgc, TaskName{"sgpidanalyzer"})}; |
| 162 | +} |
0 commit comments