diff --git a/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysis.cxx b/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysis.cxx new file mode 100644 index 0000000000000..8839b6bd88b11 --- /dev/null +++ b/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysis.cxx @@ -0,0 +1,153 @@ +// Copyright CERN and copyright holders of ALICE O2. This software is +// distributed under the terms of the GNU General Public License v3 (GPL +// Version 3), copied verbatim in the file "COPYING". +// +// See http://alice-o2.web.cern.ch/license for full licensing information. +// +// 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. +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include +#include + +#include + +using namespace o2; +using namespace o2::framework; + +struct SimpleHistogramTaskWithRuntimeDefinition { + HistogramRegistry registry{"registry", {}}; + + void init(InitContext&) + { + std::vector ptBinning = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, + 1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 5.0, 10.0, 20.0, 50.0}; + AxisSpec ptAxis = {ptBinning, "#it{p}_{T} (GeV/c)"}; + registry.add("pt", "pt", kTH1F, {ptAxis}); + } + + // aod::Track is an iterator over tracks table + // HIST() is a macro to parse the string and find appropriate histogram at compile time + void process(aod::Track const& track) + { + registry.get(HIST("pt"))->Fill(track.pt()); + } +}; + +struct SimpleHistogramTask { + HistogramRegistry registry{ + "registry", + { + // name, title, hist type, vector of axes + // here each axis is defined as: {nBins, min, max, optional title, optional name} + // alternatively, for variable binning: {{binEdge1, binEdge2, ...}, optional title, optional name} + {"eta", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, // + {"phi", "#varphi", {HistType::kTH1F, {{100, 0., 2. * M_PI}}}}, // + {"pt", "pt", {HistType::kTH1F, {{100, -0.01, 10.01, "#it{p}_{T} (GeV/c)"}}}}, // + {"ptVariableBinning", "pt", {HistType::kTH1F, {{ // + {0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, // + 1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 5.0, 10.0, 20.0, 50.0}, + "#it{p}_{T} (GeV/c)"}}}} // + } // + }; + + // aod::Track is an iterator over tracks table + void process(aod::Track const& track) + { + + registry.get(HIST("eta"))->Fill(track.eta()); + registry.get(HIST("phi"))->Fill(track.phi()); + registry.get(HIST("pt"))->Fill(track.pt()); + registry.get(HIST("ptVariableBinning"))->Fill(track.pt()); + } +}; + +struct HistogramsWithFilters { + HistogramRegistry registry{ + "registry", + { + {"eta", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, // + {"ptToPt", "ptToPt", {HistType::kTH2F, {{100, -0.01, 10.01}, {100, -0.01, 10.01}}}} // + } // + }; + + // If we fill histograms with filters, we need to provide full tables + // aod::Tracks instead of aod::Track + void process(aod::Tracks const& tracks) + { + registry.fill(HIST("eta"), tracks, aod::track::eta > 0.0f); + registry.fill(HIST("ptToPt"), tracks, aod::track::pt < 5.0f); + } +}; +//start TPCvsPT ZCH +struct HistogramsWithTPC { + HistogramRegistry registry{ + "registry", + { + // {"eta", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, // + //{"ptToPt", "ptToPt", {HistType::kTH2F, {{100, -0.01, 10.01}, {100, -0.01, 10.01}}}}, // + {"TPCSignal", "TPC signal", {HistType::kTH2F, {{100, 0, 10, "pt"}, {100, 0, 600, "tpc"}}}}// + } // + }; + + // If we fill histograms with filters, we need to provide full tables + // aod::Tracks instead of aod::Track + void process(aod::FullTrack const& track) + { + // registry.fill(HIST("eta"), tracks, aod::track::eta > 0.0f); + //registry.fill(HIST("ptToPt"), tracks, aod::track::pt < 5.0f); + registry.fill(HIST("TPCSignal"), track.pt(), track.tpcSignal()); + } +}; +//end TPCvsPT ZCH + +//start TOFvsPT ZCH +struct HistogramsWithTof { + HistogramRegistry registry{ + "registry", + { + {"TOFSignal", "TOF signal", {HistType::kTH2F, {{100, 0, 10, "pt"}, {10000, 0, 50000, "tof"}}}}// + } // + }; + + // If we fill histograms with filters, we need to provide full tables + // aod::Tracks instead of aod::Track + void process(aod::FullTrack const& track) + { + registry.fill(HIST("TOFSignal"), track.pt(), track.tofSignal()); + } +}; +//end TOFvsPT ZCH + +//start ETAvsPHI +struct HistogramEtaVsPhi{ + HistogramRegistry registry{ + "registry", + { + {"EtaVsPhi", "EtaVsPhi", {HistType::kTH2F, {{100, 0, 2*TMath::Pi(), "phi"}, {100, -1.2, 1.2, "eta"}}}}// + } // + }; + + // If we fill histograms with filters, we need to provide full tables + // aod::Tracks instead of aod::Track + void process(aod::FullTrack const& track) + { + registry.fill(HIST("EtaVsPhi"), track.phi(), track.eta()); + } +}; +//end EtavsPhi ZCH + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc)}; +} diff --git a/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysisPID.cxx b/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysisPID.cxx new file mode 100644 index 0000000000000..f00f7542c0661 --- /dev/null +++ b/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysisPID.cxx @@ -0,0 +1,465 @@ +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/PID/PIDTOF.h" +#include "AnalysisDataModel/TrackSelectionTables.h" + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct TPCvsMomentum { + static constexpr std::string_view sigvsp[6] = {"TpcVsMomentumPr", "TpcVsMomentumKa", "TpcVsMomentumPi", "TofVsMomentumPr", "TofVsMomentumKa", "TofVsMomentumPi"}; + + HistogramRegistry registry { + "registry", + { + {"TpcVsMomentumPr", "TpcVsMomentumPr;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 6000}}}}, + {"TpcVsMomentumKa", "TpcVsMomentumKa;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 4000}}}}, + {"TpcVsMomentumPi", "TpcVsMomentumPi;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 1000}}}}, + {"TofVsMomentumPr", "TofVsMomentumPr;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}}, + {"TofVsMomentumKa", "TofVsMomentumKa;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}}, + {"TofVsMomentumPi", "TofVsMomentumPi;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}} + } + }; + + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + + // i - 0 for proton, 1 for kaon, 2 for pion + // j - 0 for TPC, 1 for TOF + template + void fillParticleHistos(const T& track, const float nsigma[]) + { + + if (track.pt() < 0.5) + { + if (abs(nsigma[i]) < nsigmacut.value) + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); // i+3 to fill TofVsMomentum hists + } + } else if ((track.pt() >= 0.5) && ((i == 1) || (i == 2))) + { + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); + } + } else if ((track.pt() >= 0.8) || (i == 0)) + { + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); + } + } + + } + + // i - 0 for proton, 1 for kaon, 2 for pion + template + void fillParticleHistos2(const T& track) + { + + //pions + if(i==0){ + if (track.pt() < 0.5) //Pt < 0.5 - only TPC + { + if (abs(track.tpcNSigmaPi()) < nsigmacut.value) + registry.fill(HIST(sigvsp[2]), track.p(), track.tpcSignal()); + } + else if (track.pt() >= 0.5) //Pt>= 0.5 - TPC + TOF + { + if (sqrt(pow(track.tpcNSigmaPi(), 2) + pow(track.tofNSigmaPi())) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(sigvsp[2]), track.p(), track.tpcSignal()); + registry.fill(HIST(sigvsp[5]), track.p(), track.tofSignal()); + } + } + } + + //kaons + if(i==1){ + if (track.pt() < 0.5) //Pt < 0.5 - only TPC + { + if (abs(track.tpcNSigmaKa()) < nsigmacut.value) + registry.fill(HIST(sigvsp[1]), track.p(), track.tpcSignal()); + } + else if (track.pt() >= 0.5) //Pt>= 0.5 - TPC + TOF + { + if (sqrt(pow(track.tpcNSigmaPi(), 2) + pow(track.tofNSigmaPi())) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(sigvsp[1]), track.p(), track.tpcSignal()); + registry.fill(HIST(sigvsp[4]), track.p(), track.tofSignal()); + } + } + } + + //protons + if(i==2){ + if (track.pt() < 0.5) //Pt < 0.5 - only TPC + { + if (abs(track.tpcNSigmaKa()) < nsigmacut.value) + registry.fill(HIST(sigvsp[0]), track.p(), track.tpcSignal()); + } + else if (track.pt() >= 0.5) //Pt>= 0.5 - TPC + TOF + { + if (sqrt(pow(track.tpcNSigmaPi(), 2) + pow(track.tofNSigmaPi())) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(sigvsp[0]), track.p(), track.tpcSignal()); + registry.fill(HIST(sigvsp[3]), track.p(), track.tofSignal()); + } + } + } + + } + + using myTracks = soa::Join::iterator; + void process(myTracks const& track) + { + const float nsigma[6] = {track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), + track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()}; + + // first number in < > - 0 for + // second - 0 for TPC, 1 for TOF + /* + fillParticleHistos<0, 0>(track, nsigma); + fillParticleHistos<1, 0>(track, nsigma); + fillParticleHistos<2, 0>(track, nsigma); + fillParticleHistos<0, 1>(track, nsigma); + fillParticleHistos<1, 1>(track, nsigma); + fillParticleHistos<2, 1>(track, nsigma);*/ + + fillParticleHistos2<0>(track); + fillParticleHistos2<1>(track); + fillParticleHistos2<2>(track); + } +}; + +struct PHist{ + static constexpr std::string_view hname[3] = {"PrPt", "PiPt", "KaPt"}; + + HistogramRegistry registry{ + "registry", + {{"PrPt", "ProtonPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}, + {"PiPt", "PionPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}, + {"KaPt", "KaonPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}} + }; + + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + + template + void fillParticleHistos(const T& track, const float nsigma[]) + { + if (track.pt() < 0.5) + { + if (abs(nsigma[i]) < nsigmacut.value) + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.5) && ((i == 1) || (i == 2))) + { // for pions and kaons + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.5) && (i == 0)) + { // for protons with pt 0.5 <= 0.8 + if (abs(nsigma[i]) < nsigmacut.value) + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.8) && (i == 0)) + { // only for protons + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(hname[i]), track.pt()); + } + } + } + + using myTracks = soa::Join::iterator; + void process(myTracks const& track) + { + const float nsigma[6] = {track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), + track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()}; + + // i == 0 for Protons, 1 for Kaons, 2 for Pions + fillParticleHistos<0>(track, nsigma); + fillParticleHistos<1>(track, nsigma); + fillParticleHistos<2>(track, nsigma); + } + +}; + +struct showNSigma { + //Filter trackFilter = aod::track::isGlobalTrack == true; + //soa::Filtered>; + using myTracks = soa::Join; + void process(myTracks const& tracks) + { + std::ofstream f; + f.open("nSigma.txt"); + + for (auto& track : tracks) { + f << track.tpcNSigmaPi() << "\t" << track.tpcNSigmaKa() << "\t" << track.tpcNSigmaPr() << "\t" << track.tofNSigmaPi() << "\t" << track.tofNSigmaKa() << "\t" <; + + void process(myTracks const& tracks) + { + for (auto& track : tracks) + { + std::cout << track.pdgCode() << std::endl; + } + } +}; + +struct showPDGHist { + using myTracks = soa::Join; + + HistogramRegistry registry{ + "registry", + {{"PDG", "PDG; pT", {HistType::kTH1F, {{5000, -4000, 4000}}}}} + }; + + void process(myTracks const& tracks) + { + for (auto& track : tracks) + { + std::cout << track.pdgCode() << std::endl; + registry.get(HIST("PDG"))-> Fill(track.pdgCode()); + + } + } +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + }; +} + + + + + +/*#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/PID/PIDTOF.h" +#include "AnalysisDataModel/TrackSelectionTables.h" + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct TPCvsMomentum { + static constexpr std::string_view sigvsp[6] = {"TpcVsMomentumPr", "TpcVsMomentumKa", "TpcVsMomentumPi", "TofVsMomentumPr", "TofVsMomentumKa", "TofVsMomentumPi"}; + HistogramRegistry registry { + "registry", + { + {"TpcVsMomentumPr", "TpcVsMomentumPr;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 6000}}}}, + {"TpcVsMomentumKa", "TpcVsMomentumKa;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 4000}}}}, + {"TpcVsMomentumPi", "TpcVsMomentumPi;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 1000}}}}, + {"TofVsMomentumPr", "TofVsMomentumPr;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}}, + {"TofVsMomentumKa", "TofVsMomentumKa;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}}, + {"TofVsMomentumPi", "TofVsMomentumPi;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}} + } + }; + + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + + // i - 0 for proton, 1 for kaon, 2 for pion + // j - 0 for TPC, 1 for TOF + template + void fillParticleHistos(const T& track, const float nsigma[]) + { + if (track.pt() < 0.5) + { + if (abs(nsigma[i]) < nsigmacut.value) + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); // i+3 to fill TofVsMomentum hists + } + } else if ((track.pt() >= 0.5) && ((i == 1) || (i == 2))) + { + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); + } + } else if ((track.pt() >= 0.8) || (i == 0)) + { + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); + } + } + } + + using myTracks = soa::Join::iterator; + void process(myTracks const& track) + { + const float nsigma[6] = {track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), + track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()}; + + // first number in < > - 0 for + // second - 0 for TPC, 1 for TOF + fillParticleHistos<0, 0>(track, nsigma); + fillParticleHistos<1, 0>(track, nsigma); + fillParticleHistos<2, 0>(track, nsigma); + fillParticleHistos<0, 1>(track, nsigma); + fillParticleHistos<1, 1>(track, nsigma); + fillParticleHistos<2, 1>(track, nsigma); + } +}; + +struct PHist{ + static constexpr std::string_view hname[3] = {"PrPt", "PiPt", "KaPt"}; + + HistogramRegistry registry{ + "registry", + {{"PrPt", "ProtonPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}, + {"PiPt", "PionPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}, + {"KaPt", "KaonPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}} + }; + + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + + template + void fillParticleHistos(const T& track, const float nsigma[]) + { + if (track.pt() < 0.5) + { + if (abs(nsigma[i]) < nsigmacut.value) + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.5) && ((i == 1) || (i == 2))) + { // for pions and kaons + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.5) && (i == 0)) + { // for protons with pt 0.5 <= 0.8 + if (abs(nsigma[i]) < nsigmacut.value) + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.8) && (i == 0)) + { // only for protons + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(hname[i]), track.pt()); + } + } + } + + using myTracks = soa::Join::iterator; + void process(myTracks const& track) + { + const float nsigma[6] = {track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), + track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()}; + + // i == 0 for Protons, 1 for Kaons, 2 for Pions + fillParticleHistos<0>(track, nsigma); + fillParticleHistos<1>(track, nsigma); + fillParticleHistos<2>(track, nsigma); + } + +}; + +struct showNSigma { + using myTracks = soa::Join; + void process(myTracks const& tracks) + { + std::ofstream f; + f.open("nSigma.txt"); + + for (auto& track : tracks) { + f << track.tpcNSigmaPi() << "\t" << track.tpcNSigmaKa() << "\t" << track.tpcNSigmaPr() << "\t" << track.tofNSigmaPi() << "\t" << track.tofNSigmaKa() << "\t" <; + + void process(myTracks const& tracks) + { + for (auto& track : tracks) + { + std::cout << track.pdgCode() << std::endl; + } + } +}; + +struct showPDGHist { + using myTracks = soa::Join; + + HistogramRegistry registry{ + "registry", + {{"PDG", "PDG; pT", {HistType::kTH1F, {{5000, -4000, 4000}}}}} + }; + + void process(myTracks const& tracks) + { + for (auto& track : tracks) + { + std::cout << track.pdgCode() << std::endl; + registry.get(HIST("PDG"))-> Fill(track.pdgCode()); + + } + } +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + }; +} + +*/ diff --git a/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysisPID2.cxx b/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysisPID2.cxx new file mode 100644 index 0000000000000..16b839e225b41 --- /dev/null +++ b/Analysis/Tasks/PWGCF/AliFemto/AliFemtoSimpleAnalysisPID2.cxx @@ -0,0 +1,263 @@ +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include +#include "AnalysisDataModel/PID/PIDResponse.h" +#include "AnalysisDataModel/PID/PIDTOF.h" +#include "AnalysisDataModel/TrackSelectionTables.h" + +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +struct TPCvsMomentum { + static constexpr std::string_view sigvsp[6] = {"TpcVsMomentumPr", "TpcVsMomentumKa", "TpcVsMomentumPi", "TofVsMomentumPr", "TofVsMomentumKa", "TofVsMomentumPi"}; + + HistogramRegistry registry { + "registry", + { + {"TpcVsMomentumPr", "TpcVsMomentumPr;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 6000}}}}, + {"TpcVsMomentumKa", "TpcVsMomentumKa;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 4000}}}}, + {"TpcVsMomentumPi", "TpcVsMomentumPi;p GeV/c^2; TPC signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 1000}}}}, + {"TofVsMomentumPr", "TofVsMomentumPr;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}}, + {"TofVsMomentumKa", "TofVsMomentumKa;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}}, + {"TofVsMomentumPi", "TofVsMomentumPi;p GeV/c^2; TOF signal", {HistType::kTH2F, {{500, 0, 10}, {500, 0, 100000}}}} + } + }; + + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + + // i - 0 for proton, 1 for kaon, 2 for pion + // j - 0 for TPC, 1 for TOF + template + void fillParticleHistos(const T& track, const float nsigma[]) + { + + if (track.pt() < 0.5) + { + if (abs(nsigma[i]) < nsigmacut.value) + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); // i+3 to fill TofVsMomentum hists + } + } else if ((track.pt() >= 0.5) && ((i == 1) || (i == 2))) + { + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); + } + } else if ((track.pt() >= 0.8) || (i == 0)) + { + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + if (j == 0) + registry.fill(HIST(sigvsp[i]), track.p(), track.tpcSignal()); + else if (j == 1) + registry.fill(HIST(sigvsp[i+3]), track.p(), track.tofSignal()); + } + } + + } + + // i - 0 for proton, 1 for kaon, 2 for pion + template + void fillParticleHistos2(const T& track) + { + + //pions + if(i==0){ + if (track.pt() < 0.5) //Pt < 0.5 - only TPC + { + if (abs(track.tpcNSigmaPi()) < nsigmacut.value) + registry.fill(HIST(sigvsp[2]), track.p(), track.tpcSignal()); + } + else if (track.pt() >= 0.5) //Pt>= 0.5 - TPC + TOF + { + if (sqrt(pow(track.tpcNSigmaPi(), 2) + pow(track.tofNSigmaPi())) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(sigvsp[2]), track.p(), track.tpcSignal()); + registry.fill(HIST(sigvsp[5]), track.p(), track.tofSignal()); + } + } + } + + //kaons + if(i==1){ + if (track.pt() < 0.5) //Pt < 0.5 - only TPC + { + if (abs(track.tpcNSigmaKa()) < nsigmacut.value) + registry.fill(HIST(sigvsp[1]), track.p(), track.tpcSignal()); + } + else if (track.pt() >= 0.5) //Pt>= 0.5 - TPC + TOF + { + if (sqrt(pow(track.tpcNSigmaPi(), 2) + pow(track.tofNSigmaPi())) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(sigvsp[1]), track.p(), track.tpcSignal()); + registry.fill(HIST(sigvsp[4]), track.p(), track.tofSignal()); + } + } + } + + //protons + if(i==2){ + if (track.pt() < 0.5) //Pt < 0.5 - only TPC + { + if (abs(track.tpcNSigmaKa()) < nsigmacut.value) + registry.fill(HIST(sigvsp[0]), track.p(), track.tpcSignal()); + } + else if (track.pt() >= 0.5) //Pt>= 0.5 - TPC + TOF + { + if (sqrt(pow(track.tpcNSigmaPi(), 2) + pow(track.tofNSigmaPi())) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(sigvsp[0]), track.p(), track.tpcSignal()); + registry.fill(HIST(sigvsp[3]), track.p(), track.tofSignal()); + } + } + } + + } + + using myTracks = soa::Join::iterator; + void process(myTracks const& track) + { + const float nsigma[6] = {track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), + track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()}; + + // first number in < > - 0 for + // second - 0 for TPC, 1 for TOF + /* + fillParticleHistos<0, 0>(track, nsigma); + fillParticleHistos<1, 0>(track, nsigma); + fillParticleHistos<2, 0>(track, nsigma); + fillParticleHistos<0, 1>(track, nsigma); + fillParticleHistos<1, 1>(track, nsigma); + fillParticleHistos<2, 1>(track, nsigma);*/ + + fillParticleHistos2<0>(track); + fillParticleHistos2<1>(track); + fillParticleHistos2<2>(track); + } +}; + +struct PHist{ + static constexpr std::string_view hname[3] = {"PrPt", "PiPt", "KaPt"}; + + HistogramRegistry registry{ + "registry", + {{"PrPt", "ProtonPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}, + {"PiPt", "PionPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}, + {"KaPt", "KaonPt; pT GeV/c", {HistType::kTH1F, {{500, 0, 5}}}}} + }; + + Configurable nsigmacut{"nsigmacut", 3, "Value of the Nsigma cut"}; + + template + void fillParticleHistos(const T& track, const float nsigma[]) + { + if (track.pt() < 0.5) + { + if (abs(nsigma[i]) < nsigmacut.value) + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.5) && ((i == 1) || (i == 2))) + { // for pions and kaons + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.5) && (i == 0)) + { // for protons with pt 0.5 <= 0.8 + if (abs(nsigma[i]) < nsigmacut.value) + { + registry.fill(HIST(hname[i]), track.pt()); + } + } else if ((track.pt() >= 0.8) && (i == 0)) + { // only for protons + if (sqrt(pow(nsigma[i], 2) + pow(nsigma[i+3],2)) < nsigmacut.value) // square root of tpcSignal^2 + tofSignal^2 + { + registry.fill(HIST(hname[i]), track.pt()); + } + } + } + + using myTracks = soa::Join::iterator; + void process(myTracks const& track) + { + const float nsigma[6] = {track.tpcNSigmaPr(), track.tpcNSigmaKa(), track.tpcNSigmaPi(), + track.tofNSigmaPr(), track.tofNSigmaKa(), track.tofNSigmaPi()}; + + // i == 0 for Protons, 1 for Kaons, 2 for Pions + fillParticleHistos<0>(track, nsigma); + fillParticleHistos<1>(track, nsigma); + fillParticleHistos<2>(track, nsigma); + } + +}; + +struct showNSigma { + //Filter trackFilter = aod::track::isGlobalTrack == true; + //soa::Filtered>; + using myTracks = soa::Join; + void process(myTracks const& tracks) + { + std::ofstream f; + f.open("nSigma.txt"); + + for (auto& track : tracks) { + f << track.tpcNSigmaPi() << "\t" << track.tpcNSigmaKa() << "\t" << track.tpcNSigmaPr() << "\t" << track.tofNSigmaPi() << "\t" << track.tofNSigmaKa() << "\t" <; + + void process(myTracks const& tracks) + { + for (auto& track : tracks) + { + std::cout << track.pdgCode() << std::endl; + } + } +}; + +struct showPDGHist { + using myTracks = soa::Join; + + HistogramRegistry registry{ + "registry", + {{"PDG", "PDG; pT", {HistType::kTH1F, {{5000, -4000, 4000}}}}} + }; + + void process(myTracks const& tracks) + { + for (auto& track : tracks) + { + std::cout << track.pdgCode() << std::endl; + registry.get(HIST("PDG"))-> Fill(track.pdgCode()); + + } + } +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{ + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + // adaptAnalysisTask(cfgc), + }; +} diff --git a/Analysis/Tasks/PWGCF/AliFemto/CMakeLists.txt b/Analysis/Tasks/PWGCF/AliFemto/CMakeLists.txt new file mode 100644 index 0000000000000..c3549cd468203 --- /dev/null +++ b/Analysis/Tasks/PWGCF/AliFemto/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright 2019-2020 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. + + +o2_add_dpl_workflow(alifemto-simple-example + SOURCES AliFemtoSimpleAnalysis.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisCore O2::AnalysisDataModel + COMPONENT_NAME Analysis) + +o2_add_dpl_workflow(alifemto-simple-example-pid + SOURCES AliFemtoSimpleAnalysisPID.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisCore O2::AnalysisDataModel + COMPONENT_NAME Analysis) + +o2_add_dpl_workflow(alifemto-simple-example-pid-2 + SOURCES AliFemtoSimpleAnalysisPID2.cxx + PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisCore O2::AnalysisDataModel + COMPONENT_NAME Analysis) + + diff --git a/Analysis/Tasks/PWGCF/CMakeLists.txt b/Analysis/Tasks/PWGCF/CMakeLists.txt index 28ab35144fd01..3de5d995ebab7 100644 --- a/Analysis/Tasks/PWGCF/CMakeLists.txt +++ b/Analysis/Tasks/PWGCF/CMakeLists.txt @@ -10,6 +10,7 @@ # or submit itself to any jurisdiction. add_subdirectory(FemtoDream) +add_subdirectory(AliFemto) o2_add_library(PWGCFCore SOURCES AnalysisConfigurableCuts.cxx