diff --git a/PWGLF/Tasks/Strangeness/CMakeLists.txt b/PWGLF/Tasks/Strangeness/CMakeLists.txt index 660c7ce8610..f63ab2693ff 100644 --- a/PWGLF/Tasks/Strangeness/CMakeLists.txt +++ b/PWGLF/Tasks/Strangeness/CMakeLists.txt @@ -123,3 +123,8 @@ o2physics_add_dpl_workflow(lambdak0sflattenicity SOURCES lambdak0sflattenicity.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore COMPONENT_NAME Analysis) + +o2physics_add_dpl_workflow(lambdajetpolarization + SOURCES lambdaJetpolarization.cxx + PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore + COMPONENT_NAME Analysis) diff --git a/PWGLF/Tasks/Strangeness/lambdaJetpolarization.cxx b/PWGLF/Tasks/Strangeness/lambdaJetpolarization.cxx new file mode 100644 index 00000000000..107b6b4a282 --- /dev/null +++ b/PWGLF/Tasks/Strangeness/lambdaJetpolarization.cxx @@ -0,0 +1,669 @@ +// 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. +/// + +/// \author Youpeng Su (yousu@cern.ch) +#include +#include +#include +#include +#include "Framework/runDataProcessing.h" +#include "Framework/AnalysisTask.h" +#include "Common/DataModel/EventSelection.h" +#include "PWGLF/DataModel/LFStrangenessTables.h" +#include "Common/DataModel/PIDResponse.h" +#include "Framework/O2DatabasePDGPlugin.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include +#include + +using std::cout; +using std::endl; +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace myTable +{ +DECLARE_SOA_COLUMN(EventIndex, eventindex, Int_t); +DECLARE_SOA_COLUMN(V0px, v0px, Float_t); +DECLARE_SOA_COLUMN(V0py, v0py, Float_t); +DECLARE_SOA_COLUMN(V0pz, v0pz, Float_t); +DECLARE_SOA_COLUMN(V0Lambdamass, v0Lambdamass, Float_t); +DECLARE_SOA_COLUMN(V0protonpx, v0protonpx, Float_t); +DECLARE_SOA_COLUMN(V0protonpy, v0protonpy, Float_t); +DECLARE_SOA_COLUMN(V0protonpz, v0protonpz, Float_t); +} // namespace myTable +DECLARE_SOA_TABLE(MyTable, "AOD", "MYTABLE", + myTable::EventIndex, myTable::V0px, myTable::V0py, myTable::V0pz, myTable::V0Lambdamass, + myTable::V0protonpx, myTable::V0protonpy, myTable::V0protonpz); +} // namespace o2::aod + +namespace o2::aod +{ +namespace myTableJet +{ + +DECLARE_SOA_COLUMN(EventIndex, eventindex, Int_t); +DECLARE_SOA_COLUMN(Jetpx, jetpx, float); +DECLARE_SOA_COLUMN(Jetpy, jetpy, float); +DECLARE_SOA_COLUMN(Jetpz, jetpz, float); +} // namespace myTableJet +DECLARE_SOA_TABLE(MyTableJet, "AOD", "MYTABLEJet", + myTableJet::EventIndex, myTableJet::Jetpx, myTableJet::Jetpy, myTableJet::Jetpz); +} // namespace o2::aod + +struct myAnalysis { + Produces myTable; + Produces myTableJet; + + HistogramRegistry registry{"registry"}; + Configurable v0cospa{"v0cospa", 0.995, "V0 CosPA"}; + Configurable dcanegtopv{"dcanegtopv", 0.05, "DCA Neg To PV"}; + Configurable dcapostopv{"dcapostopv", 0.05, "DCA Pos To PV"}; + SliceCache cache; + HistogramRegistry JEhistos{"JEhistos", {}, OutputObjHandlingPolicy::AnalysisObject}; + + Configurable cfgeventSelections{"cfgeventSelections", "sel8", "choose event selection"}; + Configurable cfgtrackSelections{"cfgtrackSelections", "globalTracks", "set track selections"}; + Configurable cfgDataHists{"cfgDataHists", true, "Enables DataHists"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + // Others configure + Configurable cDebugLevel{"cDebugLevel", 1, "Resolution of Debug"}; + Configurable cfgVtxCut{"cfgVtxCut", 10.0, "V_z cut selection"}; + Configurable cfgjetPtMin{"cfgjetPtMin", 15.0, "minimum jet pT cut"}; + Configurable cfgjetR{"cfgjetR", 0.4, "jet resolution parameter"}; + Configurable cfgtrkMinPt{"cfgtrkMinPt", 0.15, "set track min pT"}; + Configurable cfgtrkMaxEta{"cfgtrkMaxEta", 0.8, "set track max Eta"}; + Configurable cfgMaxDCArToPVcut{"cfgMaxDCArToPVcut", 0.5, "Track DCAr cut to PV Maximum"}; + Configurable cfgMaxDCAzToPVcut{"cfgMaxDCAzToPVcut", 2.0, "Track DCAz cut to PV Maximum"}; + Configurable cfgnFindableTPCClusters{"cfgnFindableTPCClusters", 50, "nFindable TPC Clusters"}; + Configurable cfgnTPCCrossedRows{"cfgnTPCCrossedRows", 70, "nCrossed TPC Rows"}; + Configurable cfgnRowsOverFindable{"cfgnRowsOverFindable", 1.2, "nRowsOverFindable TPC CLusters"}; + Configurable cfgnTPCChi2{"cfgnTPChi2", 4.0, "nTPC Chi2 per Cluster"}; + Configurable cfgnITSChi2{"cfgnITShi2", 36.0, "nITS Chi2 per Cluster"}; + Configurable cfgConnectedToPV{"cfgConnectedToPV", true, "PV contributor track selection"}; + Configurable cfgPrimaryTrack{"cfgPrimaryTrack", true, "Primary track selection"}; + Configurable cfgnTPCPID{"cfgnTPCPID", 4, "nTPC PID"}; + Configurable cfgnTOFPID{"cfgnTOFPID", 4, "nTOF PID"}; + + // V0 track selection//////////////////////////////////////////////////////////////// + Configurable requireITS{"requireITS", false, "require ITS hit"}; + Configurable requireTOF{"requireTOF", false, "require TOF hit"}; + Configurable requireTPC{"requireTPC", true, "require TPC hit"}; + Configurable requirepassedSingleTrackSelection{"requirepassedSingleTrackSelection", false, "requirepassedSingleTrackSelection"}; + Configurable minITSnCls{"minITSnCls", 4.0f, "min number of ITS clusters"}; + Configurable minTPCnClsFound{"minTPCnClsFound", 80.0f, "min number of found TPC clusters"}; + Configurable minNCrossedRowsTPC{"minNCrossedRowsTPC", 80.0f, "min number of TPC crossed rows"}; + Configurable maxChi2TPC{"maxChi2TPC", 4.0f, "max chi2 per cluster TPC"}; + Configurable maxChi2ITS{"maxChi2ITS", 36.0f, "max chi2 per cluster ITS"}; + Configurable etaMin{"etaMin", -0.8f, "eta min"}; + Configurable etaMax{"etaMax", +0.8f, "eta max"}; + Configurable ptMin_V0_proton{"ptMin_V0_proton", 0.3f, "pt min of proton from V0"}; + Configurable ptMax_V0_proton{"ptMax_V0_proton", 10.0f, "pt max of proton from V0"}; + Configurable ptMin_V0_pion{"ptMin_V0_pion", 0.1f, "pt min of pion from V0"}; + Configurable ptMax_V0_pion{"ptMax_V0_pion", 1.5f, "pt max of pion from V0"}; + Configurable ptMin_K0_pion{"ptMin_K0_pion", 0.3f, "pt min of pion from K0"}; + Configurable ptMax_K0_pion{"ptMax_K0_pion", 10.0f, "pt max of pion from K0"}; + Configurable dcaV0DaughtersMax{"dcaV0DaughtersMax", 0.5f, "Maximum DCA Daughters"}; + Configurable minimumV0Radius{"minimumV0Radius", 0.5f, "Minimum V0 Radius"}; + Configurable maximumV0Radius{"maximumV0Radius", 40.0f, "Maximum V0 Radius"}; + Configurable nsigmaTPCmin{"nsigmaTPCmin", -5.0f, "Minimum nsigma TPC"}; + Configurable nsigmaTPCmax{"nsigmaTPCmax", +5.0f, "Maximum nsigma TPC"}; + Configurable nsigmaTOFmin{"nsigmaTOFmin", -5.0f, "Minimum nsigma TOF"}; + Configurable nsigmaTOFmax{"nsigmaTOFmax", +5.0f, "Maximum nsigma TOF"}; + Configurable yMin{"yMin", -0.5f, "minimum y"}; + Configurable yMax{"yMax", +0.5f, "maximum y"}; + Configurable v0rejLambda{"v0rejLambda", 0.01, "V0 rej K0s"}; + Configurable CtauLambda{"ctauLambda", 30, "C tau Lambda (cm)"}; + // Event Selection///////////////////////////////// + Configurable cutzvertex{"cutzvertex", 10.0f, "Accepted z-vertex range (cm)"}; + Configurable sel8{"sel8", 0, "Apply sel8 event selection"}; + Configurable isTriggerTVX{"isTriggerTVX", 1, "TVX trigger"}; + Configurable iscutzvertex{"iscutzvertex", 1, "Accepted z-vertex range (cm)"}; + Configurable isNoTimeFrameBorder{"isNoTimeFrameBorder", 1, "TF border cut"}; + Configurable isNoITSROFrameBorder{"isNoITSROFrameBorder", 1, "ITS ROF border cut"}; + Configurable isVertexTOFmatched{"isVertexTOFmatched", 1, "Is Vertex TOF matched"}; + Configurable isGoodZvtxFT0vsPV{"isGoodZvtxFT0vsPV", 0, "isGoodZvtxFT0vsPV"}; + /////////////////////////V0 QA analysis/////////////////////////////// + Configurable dcav0dau{"dcav0dau", 1.0, "DCA V0 Daughters"}; + // CONFIG DONE + ///////////////////////////////////////// //INIT//////////////////////////////////////////////////////////////////// + int eventSelection = -1; + int trackSelection = -1; + + void init(o2::framework::InitContext&) + { + // HISTOGRAMS + const AxisSpec axisEta{30, -1.5, +1.5, "#eta"}; + const AxisSpec axisPhi{200, -1, +7, "#phi"}; + const AxisSpec axisPt{200, 0, +200, "#pt"}; + const AxisSpec MinvAxis = {500, 0.1, 1.25}; + const AxisSpec PtAxis = {200, 0, 20.0}; + const AxisSpec MultAxis = {100, 0, 100}; + const AxisSpec dRAxis = {100, 0, 100}; + + const AxisSpec axisPx{200, -10, 10, "#px"}; + const AxisSpec axisPy{200, -10, 10, "#py"}; + const AxisSpec axisPz{200, -10, 10, "#pz"}; + const AxisSpec massAxis{200, 0.9f, 1.2f, "mass"}; + const AxisSpec eventAxis{1000000, 0.5f, 1000000.5f, "event"}; + + if (cfgDataHists) { + + JEhistos.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", kTH1F, {{200, 0., 200.}}); + JEhistos.add("h_track_eta", "track #eta;#eta_{track};entries", kTH1F, {{100, -1.f, 1.f}}); + JEhistos.add("h_track_phi", "track #varphi;#varphi_{track};entries", kTH1F, {{80, -1.f, 7.f}}); + JEhistos.add("nJetsPerEvent", "nJetsPerEvent", kTH1F, {{10, 0.0, 10.0}}); + JEhistos.add("FJetaHistogram", "FJetaHistogram", kTH1F, {axisEta}); + JEhistos.add("FJphiHistogram", "FJphiHistogram", kTH1F, {axisPhi}); + JEhistos.add("FJptHistogram", "FJptHistogram", kTH1F, {axisPt}); + JEhistos.add("hDCArToPv", "DCArToPv", kTH1F, {{300, 0.0, 3.0}}); + JEhistos.add("hDCAzToPv", "DCAzToPv", kTH1F, {{300, 0.0, 3.0}}); + JEhistos.add("rawpT", "rawpT", kTH1F, {{1000, 0.0, 10.0}}); + JEhistos.add("rawDpT", "rawDpT", kTH2F, {{1000, 0.0, 10.0}, {300, -1.5, 1.5}}); + JEhistos.add("hIsPrim", "hIsPrim", kTH1F, {{2, -0.5, +1.5}}); + JEhistos.add("hIsGood", "hIsGood", kTH1F, {{2, -0.5, +1.5}}); + JEhistos.add("hIsPrimCont", "hIsPrimCont", kTH1F, {{2, -0.5, +1.5}}); + JEhistos.add("hFindableTPCClusters", "hFindableTPCClusters", kTH1F, {{200, 0, 200}}); + JEhistos.add("hFindableTPCRows", "hFindableTPCRows", kTH1F, {{200, 0, 200}}); + JEhistos.add("hClustersVsRows", "hClustersVsRows", kTH1F, {{200, 0, 2}}); + JEhistos.add("hTPCChi2", "hTPCChi2", kTH1F, {{200, 0, 100}}); + JEhistos.add("hITSChi2", "hITSChi2", kTH1F, {{200, 0, 100}}); + JEhistos.add("etaHistogram", "etaHistogram", kTH1F, {axisEta}); + JEhistos.add("phiHistogram", "phiHistogram", kTH1F, {axisPhi}); + JEhistos.add("ptHistogram", "ptHistogram", kTH1F, {axisPt}); + JEhistos.add("V0Counts", "V0Counts", kTH1F, {{10, 0, 10}}); + JEhistos.add("hUSS_1D", "hUSS_1D", kTH1F, {MinvAxis}); + JEhistos.add("hPt", "hPt", {HistType::kTH1F, {{100, 0.0f, 10.0f}}}); + JEhistos.add("hMassVsPtLambda", "hMassVsPtLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + JEhistos.add("hMassVsPtAntiLambda", "hMassVsPtAntiLambda", {HistType::kTH2F, {{100, 0.0f, 10.0f}, {200, 1.016f, 1.216f}}}); + JEhistos.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + JEhistos.add("hMassAntiLambda", "hMassAntiLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + JEhistos.add("V0Radius", "V0Radius", {HistType::kTH1D, {{100, 0.0f, 20.0f}}}); + JEhistos.add("CosPA", "CosPA", {HistType::kTH1F, {{100, 0.9f, 1.0f}}}); + JEhistos.add("V0DCANegToPV", "V0DCANegToPV", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + JEhistos.add("V0DCAPosToPV", "V0DCAPosToPV", {HistType::kTH1F, {{100, -1.0f, 1.0f}}}); + JEhistos.add("V0DCAV0Daughters", "V0DCAV0Daughters", {HistType::kTH1F, {{55, 0.0f, 2.20f}}}); + JEhistos.add("TPCNSigmaPosPi", "TPCNSigmaPosPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + JEhistos.add("TPCNSigmaNegPi", "TPCNSigmaNegPi", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + JEhistos.add("TPCNSigmaPosPr", "TPCNSigmaPosPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + JEhistos.add("TPCNSigmaNegPr", "TPCNSigmaNegPr", {HistType::kTH1F, {{100, -10.0f, 10.0f}}}); + JEhistos.add("hNEvents", "hNEvents", {HistType::kTH1I, {{10, 0.f, 10.f}}}); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(1, "all"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(2, "sel8"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(3, "TVX"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(4, "zvertex"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(5, "TFBorder"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(6, "ITSROFBorder"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(7, "isTOFVertexMatched"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(8, "isGoodZvtxFT0vsPV"); + JEhistos.get(HIST("hNEvents"))->GetXaxis()->SetBinLabel(9, "Applied selected"); + registry.add("hNEventsJet", "hNEventsJet", {HistType::kTH1I, {{4, 0.f, 4.f}}}); + registry.get(HIST("hNEventsJet"))->GetXaxis()->SetBinLabel(1, "all"); + registry.get(HIST("hNEventsJet"))->GetXaxis()->SetBinLabel(2, "zvertex"); + registry.get(HIST("hNEventsJet"))->GetXaxis()->SetBinLabel(3, "JCollisionSel::sel8"); + JEhistos.add("v0Lambdapx", "v0Lambdapx", kTH1F, {axisPx}); + JEhistos.add("v0Lambdapy", "v0Lambdapy", kTH1F, {axisPy}); + JEhistos.add("v0Lambdapz", "v0Lambdapz", kTH1F, {axisPz}); + JEhistos.add("v0AntiLambdapx", "v0AntiLambdapx", kTH1F, {axisPx}); + JEhistos.add("v0AntiLambdapy", "v0AntiLambdapy", kTH1F, {axisPy}); + JEhistos.add("v0AntiLambdapz", "v0AntiLambdapz", kTH1F, {axisPz}); + JEhistos.add("jetpx", "jetpx", kTH1F, {axisPx}); + JEhistos.add("jetpy", "jetpy", kTH1F, {axisPy}); + JEhistos.add("jetpz", "jetpz", kTH1F, {axisPz}); + JEhistos.add("hV0Lambda", "V0Lambda", + {HistType::kTHnSparseF, {eventAxis, axisPx, axisPy, axisPz, massAxis, axisPx, axisPy, axisPz}}); + } + eventSelection = jetderiveddatautilities::initialiseEventSelection(static_cast(cfgeventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + } // end of init + + double massPi = o2::constants::physics::MassPiMinus; + double massPr = o2::constants::physics::MassProton; + using DauTracks = soa::Join; + using EventCandidates = soa::Join; // , aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs + using TrackCandidates = soa::Join; + using JCollisions = soa::Join; + using V0Collisions = soa::Join; + Filter jetCuts = aod::jet::pt > cfgjetPtMin&& aod::jet::r == nround(cfgjetR.node() * 100.0f); + template + bool TrackSelection(const TrackType track) + { + // basic track cuts + if (track.pt() < cfgtrkMinPt) + return false; + + if (std::abs(track.eta()) > cfgtrkMaxEta) + return false; + + if (std::abs(track.dcaXY()) > cfgMaxDCArToPVcut) + return false; + + if (std::abs(track.dcaZ()) > cfgMaxDCAzToPVcut) + return false; + + if (cfgPrimaryTrack && !track.isPrimaryTrack()) + return false; + + if (track.tpcNClsFindable() < cfgnFindableTPCClusters) + return false; + + if (track.tpcNClsCrossedRows() < cfgnTPCCrossedRows) + return false; + + if (track.tpcCrossedRowsOverFindableCls() > cfgnRowsOverFindable) + return false; + + if (track.tpcChi2NCl() > cfgnTPCChi2) + return false; + + if (track.itsChi2NCl() > cfgnITSChi2) + return false; + + if (cfgConnectedToPV && !track.isPVContributor()) + return false; + + return true; + }; + + template + bool trackPIDPion(const T& candidate) + { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaPi()) < cfgnTPCPID) + tpcPIDPassed = true; + + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPi()) < cfgnTOFPID) { + tofPIDPassed = true; + } + } else { + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + return false; + } + + template + bool trackPIDProton(const T& candidate) + { + bool tpcPIDPassed{false}, tofPIDPassed{false}; + if (std::abs(candidate.tpcNSigmaPr()) < cfgnTPCPID) + tpcPIDPassed = true; + + if (candidate.hasTOF()) { + if (std::abs(candidate.tofNSigmaPr()) < cfgnTOFPID) { + tofPIDPassed = true; + } + } else { + tofPIDPassed = true; + } + if (tpcPIDPassed && tofPIDPassed) { + return true; + } + return false; + } + + // Single-Track Selection + template + bool passedSingleTrackSelection(const Track& track) + { + if (requireITS && (!track.hasITS())) + return false; + if (requireITS && track.itsNCls() < minITSnCls) + return false; + if (!track.hasTPC()) + return false; + if (track.tpcNClsFound() < minTPCnClsFound) + return false; + if (track.tpcNClsCrossedRows() < minNCrossedRowsTPC) + return false; + if (track.tpcChi2NCl() > maxChi2TPC) + return false; + if (track.eta() < etaMin || track.eta() > etaMax) + return false; + if (requireTOF && (!track.hasTOF())) + return false; + return true; + } + // Lambda Selections + template + bool passedLambdaSelection(const Lambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + + // Single-Track Selections + if (requirepassedSingleTrackSelection && !passedSingleTrackSelection(ptrack)) + return false; + if (requirepassedSingleTrackSelection && !passedSingleTrackSelection(ntrack)) + return false; + + if (v0.v0radius() < minimumV0Radius || v0.v0cosPA() < v0cospa || + TMath::Abs(ptrack.eta()) > etaMax || + TMath::Abs(ntrack.eta()) > etaMax) { + return false; + } + if (TMath::Abs(v0.dcanegtopv()) < dcanegtopv) + return false; + if (TMath::Abs(v0.dcapostopv()) < dcapostopv) + return false; + if (v0.dcaV0daughters() > dcav0dau) + return false; + + // PID Selections (TPC) + if (requireTPC) { + if (ptrack.tpcNSigmaPr() < nsigmaTPCmin || ptrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPi() < nsigmaTPCmin || ntrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + } + + if (requireTOF) { + if (ptrack.tofNSigmaPr() < nsigmaTOFmin || ptrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPi() < nsigmaTOFmin || ntrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + } + + TLorentzVector lorentzVect; + lorentzVect.SetXYZM(v0.px(), v0.py(), v0.pz(), 1.115683); + + if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) { + return false; + } + + if (TMath::Abs(v0.mK0Short() - o2::constants::physics::MassK0Short) < v0rejLambda) { + return false; + } + if (TMath::Abs(v0.mLambda() - o2::constants::physics::MassLambda0) > 0.075) { + return false; + } + + return true; + } + // AntiLambda Selections + template + bool passedAntiLambdaSelection(const AntiLambda& v0, const TrackPos& ptrack, const TrackNeg& ntrack) + { + // Single-Track Selections + if (requirepassedSingleTrackSelection && !passedSingleTrackSelection(ptrack)) + return false; + if (requirepassedSingleTrackSelection && !passedSingleTrackSelection(ntrack)) + return false; + + if (v0.v0radius() < minimumV0Radius || v0.v0cosPA() < v0cospa || + TMath::Abs(ptrack.eta()) > etaMax || + TMath::Abs(ntrack.eta()) > etaMax) { + return false; + } + + if (TMath::Abs(v0.dcanegtopv()) < dcanegtopv) // + return false; + if (TMath::Abs(v0.dcapostopv()) < dcapostopv) // + return false; + if (v0.dcaV0daughters() > dcav0dau) // + return false; + // PID Selections (TOF) + if (requireTOF) { + if (ptrack.tofNSigmaPi() < nsigmaTOFmin || ptrack.tofNSigmaPi() > nsigmaTOFmax) + return false; + if (ntrack.tofNSigmaPr() < nsigmaTOFmin || ntrack.tofNSigmaPr() > nsigmaTOFmax) + return false; + } + if (requireTPC) { + if (ptrack.tpcNSigmaPi() < nsigmaTPCmin || ptrack.tpcNSigmaPi() > nsigmaTPCmax) + return false; + if (ntrack.tpcNSigmaPr() < nsigmaTPCmin || ntrack.tpcNSigmaPr() > nsigmaTPCmax) + return false; + } + + TLorentzVector lorentzVect; + lorentzVect.SetXYZM(v0.px(), v0.py(), v0.pz(), 1.115683); + if (lorentzVect.Rapidity() < yMin || lorentzVect.Rapidity() > yMax) { + return false; + } + + if (TMath::Abs(v0.mK0Short() - o2::constants::physics::MassK0Short) < v0rejLambda) { + return false; + } + if (TMath::Abs(v0.mAntiLambda() - o2::constants::physics::MassLambda0) > 0.075) { + return false; + } + return true; + } + ///////Event selection + template + bool AcceptEvent(TCollision const& collision) + { + if (sel8 && !collision.sel8()) { + return false; + } + JEhistos.fill(HIST("hNEvents"), 1.5); + + if (isTriggerTVX && !collision.selection_bit(aod::evsel::kIsTriggerTVX)) { + return false; + } + JEhistos.fill(HIST("hNEvents"), 2.5); + + if (iscutzvertex && TMath::Abs(collision.posZ()) > cutzvertex) { + return false; + } + JEhistos.fill(HIST("hNEvents"), 3.5); + + if (isNoTimeFrameBorder && !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) { + return false; + } + + JEhistos.fill(HIST("hNEvents"), 4.5); + + if (isNoITSROFrameBorder && !collision.selection_bit(aod::evsel::kNoITSROFrameBorder)) { + return false; + } + JEhistos.fill(HIST("hNEvents"), 5.5); + if (isVertexTOFmatched && !collision.selection_bit(aod::evsel::kIsVertexTOFmatched)) { + return false; + } + JEhistos.fill(HIST("hNEvents"), 6.5); + if (isGoodZvtxFT0vsPV && !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { + return false; + } + JEhistos.fill(HIST("hNEvents"), 7.5); + + return true; + } + // Filter preFilterV0 = nabs(aod::v0data::dcapostopv) > dcapostopv&&nabs(aod::v0data::dcanegtopv) > dcanegtopv&& aod::v0data::dcaV0daughters < dcaV0DaughtersMax; + + int nEvents = 0; + void processJetTracks(JCollisions::iterator const& collision, soa::Filtered> const& chargedjets, soa::Join const& tracks, TrackCandidates const&) + { + if (cDebugLevel > 0) { + } + + registry.fill(HIST("hNEventsJet"), 0.5); + if (fabs(collision.posZ()) > cfgVtxCut) { + return; + } + registry.fill(HIST("hNEventsJet"), 1.5); + + if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::JCollisionSel::sel8)) { + return; + } + registry.fill(HIST("hNEventsJet"), 2.5); + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + + auto originalTrack = track.track_as>(); + JEhistos.fill(HIST("hDCArToPv"), originalTrack.dcaXY()); + JEhistos.fill(HIST("hDCAzToPv"), originalTrack.dcaZ()); + JEhistos.fill(HIST("rawpT"), originalTrack.pt()); + JEhistos.fill(HIST("rawDpT"), track.pt(), track.pt() - originalTrack.pt()); + JEhistos.fill(HIST("hIsPrim"), originalTrack.isPrimaryTrack()); + JEhistos.fill(HIST("hIsGood"), originalTrack.isGlobalTrackWoDCA()); + JEhistos.fill(HIST("hIsPrimCont"), originalTrack.isPVContributor()); + JEhistos.fill(HIST("hFindableTPCClusters"), originalTrack.tpcNClsFindable()); + JEhistos.fill(HIST("hFindableTPCRows"), originalTrack.tpcNClsCrossedRows()); + JEhistos.fill(HIST("hClustersVsRows"), originalTrack.tpcCrossedRowsOverFindableCls()); + JEhistos.fill(HIST("hTPCChi2"), originalTrack.tpcChi2NCl()); + JEhistos.fill(HIST("hITSChi2"), originalTrack.itsChi2NCl()); + JEhistos.fill(HIST("h_track_pt"), track.pt()); + JEhistos.fill(HIST("h_track_eta"), track.eta()); + JEhistos.fill(HIST("h_track_phi"), track.phi()); + + if (track.pt() < cfgtrkMinPt && std::abs(track.eta()) > cfgtrkMaxEta) { + continue; + } + JEhistos.fill(HIST("ptHistogram"), track.pt()); + JEhistos.fill(HIST("etaHistogram"), track.eta()); + JEhistos.fill(HIST("phiHistogram"), track.phi()); + } + int nJets = 0; + nEvents++; + for (auto chargedjet : chargedjets) { + JEhistos.fill(HIST("FJetaHistogram"), chargedjet.eta()); + JEhistos.fill(HIST("FJphiHistogram"), chargedjet.phi()); + JEhistos.fill(HIST("FJptHistogram"), chargedjet.pt()); + + JEhistos.fill(HIST("jetpx"), chargedjet.px()); + JEhistos.fill(HIST("jetpy"), chargedjet.py()); + JEhistos.fill(HIST("jetpz"), chargedjet.pz()); + + myTableJet(nEvents, chargedjet.px(), chargedjet.py(), chargedjet.pz()); + + nJets++; + } + + JEhistos.fill(HIST("nJetsPerEvent"), nJets); + } + PROCESS_SWITCH(myAnalysis, processJetTracks, "process JE Framework", true); + int nEventsV0 = 0; + + void processV0(V0Collisions::iterator const& collision, aod::V0Datas const& V0s, TrackCandidates const&) + { + + nEventsV0++; + JEhistos.fill(HIST("hNEvents"), 0.5); + if (!AcceptEvent(collision)) { + return; + } + JEhistos.fill(HIST("hNEvents"), 8.5); + int V0NumbersPerEvent = 0; + int V0LambdaNumbers = 0; + for (auto& v0 : V0s) { + float ctauLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0; + float ctauAntiLambda = v0.distovertotmom(collision.posX(), collision.posY(), collision.posZ()) * o2::constants::physics::MassLambda0Bar; + + const auto& pos = v0.posTrack_as(); + const auto& neg = v0.negTrack_as(); + V0NumbersPerEvent = V0NumbersPerEvent + 1; + if (passedLambdaSelection(v0, pos, neg) && ctauLambda < CtauLambda) { + JEhistos.fill(HIST("hPt"), v0.pt()); + JEhistos.fill(HIST("V0Radius"), v0.v0radius()); + JEhistos.fill(HIST("CosPA"), v0.v0cosPA()); + JEhistos.fill(HIST("V0DCANegToPV"), v0.dcanegtopv()); + JEhistos.fill(HIST("V0DCAPosToPV"), v0.dcapostopv()); + JEhistos.fill(HIST("V0DCAV0Daughters"), v0.dcaV0daughters()); + } + + if (passedLambdaSelection(v0, pos, neg) && ctauAntiLambda < CtauLambda) { + V0LambdaNumbers = V0LambdaNumbers + 1; + JEhistos.fill(HIST("hMassVsPtLambda"), v0.pt(), v0.mLambda()); + JEhistos.fill(HIST("hMassLambda"), v0.mLambda()); + JEhistos.fill(HIST("TPCNSigmaPosPr"), pos.tpcNSigmaPr()); + JEhistos.fill(HIST("TPCNSigmaNegPi"), neg.tpcNSigmaPi()); + + JEhistos.fill(HIST("v0Lambdapx"), v0.px()); + JEhistos.fill(HIST("v0Lambdapy"), v0.py()); + JEhistos.fill(HIST("v0Lambdapz"), v0.pz()); + myTable(nEventsV0, v0.px(), v0.py(), v0.pz(), v0.mLambda(), pos.px(), pos.py(), pos.pz()); + JEhistos.fill(HIST("hV0Lambda"), nEventsV0, v0.px(), v0.py(), v0.pz(), v0.mLambda(), pos.px(), pos.py(), pos.pz()); + } + if (passedAntiLambdaSelection(v0, pos, neg)) { + + JEhistos.fill(HIST("hMassVsPtAntiLambda"), v0.pt(), v0.mAntiLambda()); + JEhistos.fill(HIST("hMassAntiLambda"), v0.mAntiLambda()); + JEhistos.fill(HIST("TPCNSigmaPosPi"), pos.tpcNSigmaPi()); + JEhistos.fill(HIST("TPCNSigmaNegPr"), neg.tpcNSigmaPr()); + + JEhistos.fill(HIST("v0AntiLambdapx"), v0.px()); + JEhistos.fill(HIST("v0AntiLambdapy"), v0.py()); + JEhistos.fill(HIST("v0AntiLambdapz"), v0.pz()); + } + } + JEhistos.fill(HIST("V0Counts"), V0NumbersPerEvent); + } + PROCESS_SWITCH(myAnalysis, processV0, "processV0", true); +}; + +struct LfMyV0s { + HistogramRegistry registry{"registry"}; + + void init(InitContext const&) + { + const AxisSpec axisPx{200, -10, 10, "#px"}; + const AxisSpec axisPy{200, -10, 10, "#py"}; + const AxisSpec axisPz{200, -10, 10, "#pz"}; + registry.add("EventIndexV0", "EventIndexV0", {HistType::kTH1F, {{1000000, 0.5f, 1000000.5f}}}); + registry.add("V0px", "V0px", kTH1F, {axisPx}); + registry.add("V0py", "V0py", kTH1F, {axisPx}); + registry.add("V0pz", "V0pz", kTH1F, {axisPx}); + registry.add("hMassLambda", "hMassLambda", {HistType::kTH1F, {{200, 0.9f, 1.2f}}}); + registry.add("V0protonpx", "V0protonpx", kTH1F, {axisPx}); + registry.add("V0protonpy", "V0protonpy", kTH1F, {axisPx}); + registry.add("V0protonpz", "V0protonpz", kTH1F, {axisPx}); + registry.add("EventIndexJet", "EventIndexJet", {HistType::kTH1F, {{1000000, 0.5f, 1000000.5f}}}); + registry.add("Jetpx", "Jetpx", kTH1F, {axisPx}); + registry.add("Jetpy", "Jetpy", kTH1F, {axisPx}); + registry.add("Jetpz", "Jetpz", kTH1F, {axisPx}); + } + using V0Collisions = soa::Join; + + int N = 0; + void process(aod::MyTable const& myv0s, aod::MyTableJet const& myJets) + { + + for (auto& candidate : myv0s) { + registry.fill(HIST("EventIndexV0"), candidate.eventindex(), 0.5); + registry.fill(HIST("V0px"), candidate.v0px(), 0.5); + registry.fill(HIST("V0py"), candidate.v0py(), 0.5); + registry.fill(HIST("V0pz"), candidate.v0pz(), 0.5); + registry.fill(HIST("hMassLambda"), candidate.v0Lambdamass(), 0.5); + registry.fill(HIST("V0protonpx"), candidate.v0protonpx(), 0.5); + registry.fill(HIST("V0protonpy"), candidate.v0protonpy(), 0.5); + registry.fill(HIST("V0protonpz"), candidate.v0protonpz(), 0.5); + } + + for (auto& Jet : myJets) { + registry.fill(HIST("EventIndexJet"), Jet.eventindex(), 0.5); + registry.fill(HIST("Jetpx"), Jet.jetpx(), 0.5); + registry.fill(HIST("Jetpy"), Jet.jetpy(), 0.5); + registry.fill(HIST("Jetpz"), Jet.jetpz(), 0.5); + } + } + PROCESS_SWITCH(LfMyV0s, process, "process V0", true); +}; + +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + auto w = WorkflowSpec{adaptAnalysisTask(cfgc)}; + w.push_back(adaptAnalysisTask(cfgc)); + return w; +}